Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:09:47

0001 // Range v3 library
0002 //
0003 //  Copyright Casey Carter 2018
0004 //
0005 //  Use, modification and distribution is subject to the
0006 //  Boost Software License, Version 1.0. (See accompanying
0007 //  file LICENSE_1_0.txt or copy at
0008 //  http://www.boost.org/LICENSE_1_0.txt)
0009 //
0010 // Project home: https://github.com/ericniebler/range-v3
0011 
0012 #ifndef RANGES_V3_DETAIL_ADL_GET_HPP
0013 #define RANGES_V3_DETAIL_ADL_GET_HPP
0014 
0015 #include <cstddef>
0016 
0017 #include <concepts/concepts.hpp>
0018 
0019 #include <range/v3/range_fwd.hpp>
0020 
0021 #include <range/v3/detail/prologue.hpp>
0022 
0023 namespace ranges
0024 {
0025     /// \cond
0026     namespace detail
0027     {
0028         namespace _adl_get_
0029         {
0030             template<typename>
0031             void get();
0032 
0033             template<std::size_t I, typename TupleLike>
0034             constexpr auto adl_get(TupleLike && t) noexcept
0035                 -> decltype(get<I>(static_cast<TupleLike &&>(t)))
0036             {
0037                 return get<I>(static_cast<TupleLike &&>(t));
0038             }
0039             template<typename T, typename TupleLike>
0040             constexpr auto adl_get(TupleLike && t) noexcept
0041                 -> decltype(get<T>(static_cast<TupleLike &&>(t)))
0042             {
0043                 return get<T>(static_cast<TupleLike &&>(t));
0044             }
0045         } // namespace _adl_get_
0046         using _adl_get_::adl_get;
0047     } // namespace detail
0048 
0049     namespace _tuple_wrapper_
0050     {
0051         template<typename TupleLike>
0052         struct forward_tuple_interface : TupleLike
0053         {
0054             forward_tuple_interface() = default;
0055             using TupleLike::TupleLike;
0056 #if !defined(__clang__) || __clang_major__ > 3
0057             CPP_member
0058             constexpr CPP_ctor(forward_tuple_interface)(TupleLike && base)(    //
0059                 noexcept(std::is_nothrow_move_constructible<TupleLike>::value) //
0060                 requires move_constructible<TupleLike>)
0061               : TupleLike(static_cast<TupleLike &&>(base))
0062             {}
0063             CPP_member
0064             constexpr CPP_ctor(forward_tuple_interface)(TupleLike const & base)( //
0065                 noexcept(std::is_nothrow_copy_constructible<TupleLike>::value)   //
0066                 requires copy_constructible<TupleLike>)
0067               : TupleLike(base)
0068             {}
0069 #else
0070             // Clang 3.x have a problem with inheriting constructors
0071             // that causes the declarations in the preceeding PP block to get
0072             // instantiated too early.
0073             template(typename B = TupleLike)(
0074                 requires move_constructible<B>)
0075                 constexpr forward_tuple_interface(TupleLike && base) noexcept(
0076                     std::is_nothrow_move_constructible<TupleLike>::value)
0077               : TupleLike(static_cast<TupleLike &&>(base))
0078             {}
0079             template(typename B = TupleLike)(
0080                 requires copy_constructible<B>)
0081                 constexpr forward_tuple_interface(TupleLike const & base) noexcept(
0082                     std::is_nothrow_copy_constructible<TupleLike>::value)
0083               : TupleLike(base)
0084             {}
0085 #endif
0086 
0087             // clang-format off
0088             template<std::size_t I, typename U = TupleLike>
0089             friend constexpr auto CPP_auto_fun(get)(
0090                 forward_tuple_interface<TupleLike> &wb)
0091             (
0092                 return detail::adl_get<I>(static_cast<U &>(wb))
0093             )
0094             template<std::size_t I, typename U = TupleLike>
0095             friend constexpr auto CPP_auto_fun(get)(
0096                 forward_tuple_interface<TupleLike> const &wb)
0097             (
0098                 return detail::adl_get<I>(static_cast<U const &>(wb))
0099             )
0100             template<std::size_t I, typename U = TupleLike>
0101             friend constexpr auto CPP_auto_fun(get)(
0102                 forward_tuple_interface<TupleLike> &&wb)
0103             (
0104                 return detail::adl_get<I>(static_cast<U &&>(wb))
0105             )
0106             template<std::size_t I, typename U = TupleLike>
0107             friend constexpr auto CPP_auto_fun(get)(
0108                 forward_tuple_interface<TupleLike> const &&wb)
0109             (
0110                 return detail::adl_get<I>(static_cast<U const &&>(wb))
0111             )
0112             template<typename T, typename U = TupleLike>
0113             friend constexpr auto CPP_auto_fun(get)(
0114                 forward_tuple_interface<TupleLike> &wb)
0115             (
0116                 return detail::adl_get<T>(static_cast<U &>(wb))
0117             )
0118             template<typename T, typename U = TupleLike>
0119             friend constexpr auto CPP_auto_fun(get)(
0120                 forward_tuple_interface<TupleLike> const &wb)
0121             (
0122                 return detail::adl_get<T>(static_cast<U const &>(wb))
0123             )
0124             template<typename T, typename U = TupleLike>
0125             friend constexpr auto CPP_auto_fun(get)(
0126                 forward_tuple_interface<TupleLike> &&wb)
0127             (
0128                 return detail::adl_get<T>(static_cast<U &&>(wb))
0129             )
0130             template<typename T, typename U = TupleLike>
0131             friend constexpr auto CPP_auto_fun(get)(
0132                 forward_tuple_interface<TupleLike> const &&wb)
0133             (
0134                 return detail::adl_get<T>(static_cast<U const &&>(wb))
0135             )
0136             // clang-format on
0137         };
0138     } // namespace _tuple_wrapper_
0139     /// \endcond
0140 } // namespace ranges
0141 
0142 #include <range/v3/detail/epilogue.hpp>
0143 
0144 #endif // RANGES_V3_DETAIL_ADL_GET_HPP