Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /*==============================================================================
0002     Copyright (c) 2005-2008 Hartmut Kaiser
0003     Copyright (c) 2005-2010 Joel de Guzman
0004     Copyright (c) 2010 Thomas Heller
0005     Copyright (c) 2021 Beojan Stanislaus
0006 
0007     Distributed under the Boost Software License, Version 1.0. (See accompanying
0008     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0009 ==============================================================================*/
0010 
0011 #ifndef BOOST_PHOENIX_STL_TUPLE_H_
0012 #define BOOST_PHOENIX_STL_TUPLE_H_
0013 
0014 #if __cplusplus >= 201402L                                                     \
0015   || (defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 190024210)
0016 
0017 #include <tuple>
0018 #include <boost/phoenix/core/argument.hpp>
0019 #include <boost/phoenix/core/call.hpp>
0020 #include <boost/phoenix/core/expression.hpp>
0021 #include <boost/phoenix/core/limits.hpp>
0022 #include <boost/phoenix/core/meta_grammar.hpp>
0023 
0024 // Lazy functions for std::tuple (and similar)
0025 // get will work wherever it is accessible through ADL
0026 // Cribbing from functions in object
0027 
0028 namespace boost { namespace phoenix { namespace tuple_detail
0029 {
0030     // Wrappers to pass a type or an index
0031     template<typename T>
0032     struct type_wrap
0033     {
0034         typedef T type;
0035     };
0036     template<int N>
0037     struct idx_wrap
0038     {
0039         static constexpr int idx = N;
0040     };
0041 }}} // namespace boost::phoenix::tuple_detail
0042 
0043 BOOST_PHOENIX_DEFINE_EXPRESSION(
0044   (boost)(phoenix)(get_with_type),
0045   (proto::terminal<tuple_detail::type_wrap<proto::_> >)(meta_grammar))
0046 
0047 BOOST_PHOENIX_DEFINE_EXPRESSION(
0048   (boost)(phoenix)(get_with_idx),
0049   (proto::terminal<proto::_>)(meta_grammar))
0050 
0051 namespace boost { namespace phoenix {
0052     namespace impl {
0053         struct get_with_type
0054         {
0055             // Don't need to use result_of protocol since this only works with C++11+
0056             // anyway
0057             template<typename T, typename Expr, typename Context>
0058             auto& operator()(T, const Expr& t, const Context& ctx) const
0059             {
0060                 using std::get; // Prevents the next line from being a syntax error <
0061                                 // C++20
0062                 using T_ = typename proto::result_of::value<T>::type;
0063                 return get<typename T_::type>(boost::phoenix::eval(t, ctx));
0064             }
0065         };
0066 
0067         struct get_with_idx
0068         {
0069             // Don't need to use result_of protocol since this only works with C++11+
0070             // anyway
0071             template<typename T, typename Expr, typename Context>
0072             auto& operator()(T, const Expr& t, const Context& ctx) const
0073             {
0074                 using std::get; // Prevents the next line from being a syntax error <
0075                                 // C++20
0076                 using T_ = typename proto::result_of::value<T>::type;
0077                 return get<T_::idx>(boost::phoenix::eval(t, ctx));
0078             }
0079         };
0080     }
0081 
0082     template<typename Dummy>
0083     struct default_actions::when<rule::get_with_type, Dummy>
0084         : call<impl::get_with_type, Dummy>
0085     {};
0086     template<typename Dummy>
0087     struct default_actions::when<rule::get_with_idx, Dummy>
0088         : call<impl::get_with_idx, Dummy>
0089     {};
0090 
0091     template<typename T, typename Tuple>
0092     inline typename expression::get_with_type<tuple_detail::type_wrap<T>, Tuple>::
0093     type const
0094     get_(const Tuple& t)
0095     {
0096         return expression::get_with_type<tuple_detail::type_wrap<T>, Tuple>::make(
0097         tuple_detail::type_wrap<T>(), t);
0098     }
0099 
0100     template<int N, typename Tuple>
0101     inline typename expression::get_with_idx<tuple_detail::idx_wrap<N>, Tuple>::
0102     type const
0103     get_(const Tuple& t)
0104     {
0105         return expression::get_with_idx<tuple_detail::idx_wrap<N>, Tuple>::make(
0106         tuple_detail::idx_wrap<N>(), t);
0107     }
0108 
0109 #if 0 // Disabled this for now due to ODR viaolations $$$ Fix Me $$$
0110     // Make unpacked argument placeholders
0111     namespace placeholders {
0112         #define BOOST_PP_LOCAL_LIMITS (1, BOOST_PHOENIX_ARG_LIMIT)
0113         #define BOOST_PP_LOCAL_MACRO(N)                                                 \
0114             const auto uarg##N =                                                        \
0115             boost::phoenix::get_<(N)-1>(boost::phoenix::placeholders::arg1);
0116         #include BOOST_PP_LOCAL_ITERATE()
0117     }
0118 #endif
0119 
0120 }} // namespace boost::phoenix
0121 
0122 #endif // C++ 14
0123 #endif // BOOST_PHOENIX_STL_TUPLE_H_