// Range v3 library // // Copyright Casey Carter 2018 // // Use, modification and distribution is subject to the // Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // Project home: https://github.com/ericniebler/range-v3 #ifndef RANGES_V3_DETAIL_ADL_GET_HPP #define RANGES_V3_DETAIL_ADL_GET_HPP #include #include #include namespace ranges { /// \cond namespace detail { namespace _adl_get_ { template void get(); template constexpr auto adl_get(TupleLike && t) noexcept -> decltype(get(static_cast(t))) { return get(static_cast(t)); } template constexpr auto adl_get(TupleLike && t) noexcept -> decltype(get(static_cast(t))) { return get(static_cast(t)); } } // namespace _adl_get_ using _adl_get_::adl_get; } // namespace detail namespace _tuple_wrapper_ { template struct forward_tuple_interface : TupleLike { forward_tuple_interface() = default; using TupleLike::TupleLike; #if !defined(__clang__) || __clang_major__ > 3 CPP_member constexpr CPP_ctor(forward_tuple_interface)(TupleLike && base)( // noexcept(std::is_nothrow_move_constructible::value) // requires move_constructible) : TupleLike(static_cast(base)) {} CPP_member constexpr CPP_ctor(forward_tuple_interface)(TupleLike const & base)( // noexcept(std::is_nothrow_copy_constructible::value) // requires copy_constructible) : TupleLike(base) {} #else // Clang 3.x have a problem with inheriting constructors // that causes the declarations in the preceeding PP block to get // instantiated too early. CPP_template(typename B = TupleLike)( // requires move_constructible) // constexpr forward_tuple_interface(TupleLike && base) noexcept( std::is_nothrow_move_constructible::value) : TupleLike(static_cast(base)) {} CPP_template(typename B = TupleLike)( // requires copy_constructible) // constexpr forward_tuple_interface(TupleLike const & base) noexcept( std::is_nothrow_copy_constructible::value) : TupleLike(base) {} #endif // clang-format off template friend constexpr auto CPP_auto_fun(get)( forward_tuple_interface &wb) ( return detail::adl_get(static_cast(wb)) ) template friend constexpr auto CPP_auto_fun(get)( forward_tuple_interface const &wb) ( return detail::adl_get(static_cast(wb)) ) template friend constexpr auto CPP_auto_fun(get)( forward_tuple_interface &&wb) ( return detail::adl_get(static_cast(wb)) ) template friend constexpr auto CPP_auto_fun(get)( forward_tuple_interface const &&wb) ( return detail::adl_get(static_cast(wb)) ) template friend constexpr auto CPP_auto_fun(get)( forward_tuple_interface &wb) ( return detail::adl_get(static_cast(wb)) ) template friend constexpr auto CPP_auto_fun(get)( forward_tuple_interface const &wb) ( return detail::adl_get(static_cast(wb)) ) template friend constexpr auto CPP_auto_fun(get)( forward_tuple_interface &&wb) ( return detail::adl_get(static_cast(wb)) ) template friend constexpr auto CPP_auto_fun(get)( forward_tuple_interface const &&wb) ( return detail::adl_get(static_cast(wb)) ) // clang-format on }; } // namespace _tuple_wrapper_ /// \endcond } // namespace ranges #endif // RANGES_V3_DETAIL_ADL_GET_HPP