/*============================================================================== Copyright (c) 2005-2008 Hartmut Kaiser Copyright (c) 2005-2010 Joel de Guzman Copyright (c) 2010 Thomas Heller Copyright (c) 2021 Beojan Stanislaus Distributed under 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) ==============================================================================*/ #ifndef BOOST_PHOENIX_STL_TUPLE_H_ #define BOOST_PHOENIX_STL_TUPLE_H_ #if __cplusplus >= 201402L \ || (defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 190024210) #include #include #include #include #include #include // Lazy functions for std::tuple (and similar) // get will work wherever it is accessible through ADL // Cribbing from functions in object namespace boost { namespace phoenix { namespace tuple_detail { // Wrappers to pass a type or an index template struct type_wrap { typedef T type; }; template struct idx_wrap { static constexpr int idx = N; }; }}} // namespace boost::phoenix::tuple_detail BOOST_PHOENIX_DEFINE_EXPRESSION( (boost)(phoenix)(get_with_type), (proto::terminal >)(meta_grammar)) BOOST_PHOENIX_DEFINE_EXPRESSION( (boost)(phoenix)(get_with_idx), (proto::terminal)(meta_grammar)) namespace boost { namespace phoenix { namespace impl { struct get_with_type { // Don't need to use result_of protocol since this only works with C++11+ // anyway template auto& operator()(T, const Expr& t, const Context& ctx) const { using std::get; // Prevents the next line from being a syntax error < // C++20 using T_ = typename proto::result_of::value::type; return get(boost::phoenix::eval(t, ctx)); } }; struct get_with_idx { // Don't need to use result_of protocol since this only works with C++11+ // anyway template auto& operator()(T, const Expr& t, const Context& ctx) const { using std::get; // Prevents the next line from being a syntax error < // C++20 using T_ = typename proto::result_of::value::type; return get(boost::phoenix::eval(t, ctx)); } }; } template struct default_actions::when : call {}; template struct default_actions::when : call {}; template inline typename expression::get_with_type, Tuple>:: type const get_(const Tuple& t) { return expression::get_with_type, Tuple>::make( tuple_detail::type_wrap(), t); } template inline typename expression::get_with_idx, Tuple>:: type const get_(const Tuple& t) { return expression::get_with_idx, Tuple>::make( tuple_detail::idx_wrap(), t); } #if 0 // Disabled this for now due to ODR viaolations $$$ Fix Me $$$ // Make unpacked argument placeholders namespace placeholders { #define BOOST_PP_LOCAL_LIMITS (1, BOOST_PHOENIX_ARG_LIMIT) #define BOOST_PP_LOCAL_MACRO(N) \ const auto uarg##N = \ boost::phoenix::get_<(N)-1>(boost::phoenix::placeholders::arg1); #include BOOST_PP_LOCAL_ITERATE() } #endif }} // namespace boost::phoenix #endif // C++ 14 #endif // BOOST_PHOENIX_STL_TUPLE_H_