#if !defined(BOOST_PP_IS_ITERATING) ///// header body #ifndef BOOST_TUPLE_APPLY_HPP_INCLUDED #define BOOST_TUPLE_APPLY_HPP_INCLUDED // file: boost/tuple/apply.hpp // last modified: 15/feb/03 // Copyright (c) 2003 // Aleksey Gurtovoy // // Permission to use, copy, modify, distribute and sell this software // and its documentation for any purpose is hereby granted without fee, // provided that the above copyright notice appears in all copies and // that both the copyright notice and this permission notice appear in // supporting documentation. No representations are made about the // suitability of this software for any purpose. It is provided "as is" // without express or implied warranty. #include "boost/ref.hpp" #include "boost/mpl/if.hpp" #include "boost/mpl/identity.hpp" #include "boost/mpl/int_c.hpp" #include "boost/mpl/aux_/has_xxx.hpp" #include "boost/preprocessor/enum.hpp" #include "boost/preprocessor/iterate.hpp" #include "boost/config.hpp" #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) # include "boost/tuple/detail/tuple_basic_no_partial_spec.hpp" #else # include "boost/tuple/detail/tuple_basic.hpp" #endif #if defined(BOOST_NO_VOID_RETURNS) # include "boost/type_traits/is_void.hpp" # include "boost/mpl/apply_if.hpp" # include "boost/mpl/void.hpp" #endif #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 # include "boost/type_traits/is_class.hpp" # include "boost/mpl/bool_c.hpp" #endif namespace boost { namespace tuples { namespace aux { #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_result_type_impl, result_type, false) template< typename T > struct has_result_type : mpl::if_c< ::boost::is_class::value , has_result_type_impl , mpl::bool_c >::type { }; #else BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type) #endif template< typename T > struct result_type_accessor { typedef typename T::result_type type; }; // recognizes only 'F::result_type' for now; ideally, should // support LL and/or Phoenix-style function objects #if !defined(BOOST_NO_VOID_RETURNS) template< typename F, typename Tuple > struct apply_result_type : mpl::if_c< ::boost::tuples::aux::has_result_type::value , result_type_accessor , mpl::identity >::type { }; #else template< typename F, typename Tuple > struct apply_result_type { typedef typename mpl::apply_if_c< has_result_type::value , result_type_accessor , mpl::identity >::type r_; typedef typename mpl::if_< boost::is_void , mpl::void_ , r_ >::type type; }; #endif #define AUX_APPLY_TUPLE_ARG(unused, n, args) get(args) #define AUX_APPLY_TUPLE_RETURN_TYPE R #define AUX_APPLY_TUPLE_RETURN(expr) expr template< typename R > struct apply_helper { #define BOOST_PP_ITERATION_LIMITS (0, 9) #define BOOST_PP_FILENAME_1 "boost/tuple/apply.hpp" #include BOOST_PP_ITERATE() }; #undef AUX_APPLY_TUPLE_RETURN #undef AUX_APPLY_TUPLE_RETURN_TYPE # if defined(BOOST_NO_VOID_RETURNS) #define AUX_APPLY_TUPLE_RETURN_TYPE mpl::void_ #define AUX_APPLY_TUPLE_RETURN(expr) expr, mpl::void_() template<> struct apply_helper { #define BOOST_PP_ITERATION_LIMITS (0, 9) #define BOOST_PP_FILENAME_1 "boost/tuple/apply.hpp" #include BOOST_PP_ITERATE() }; #undef AUX_APPLY_TUPLE_RETURN #undef AUX_APPLY_TUPLE_RETURN_TYPE # endif // BOOST_NO_VOID_RETURNS #undef AUX_APPLY_TUPLE_ARG } // namespace aux template< typename F, typename Tuple > typename aux::apply_result_type::type apply(F f, Tuple const& args) { typedef typename aux::apply_result_type::type r_; typedef mpl::int_c< length::value > arity; return aux::apply_helper::apply(f, args, arity()); } } // namespace tuples } // namespace boost #endif // BOOST_TUPLE_APPLY_HPP_INCLUDED ///// iteration, depth == 1 #else #define n BOOST_PP_FRAME_ITERATION(1) template< typename F, typename Tuple > static AUX_APPLY_TUPLE_RETURN_TYPE apply(F f, Tuple const& args, mpl::int_c) { typename unwrap_reference::type f_ = f; return AUX_APPLY_TUPLE_RETURN(f_( BOOST_PP_ENUM(n, AUX_APPLY_TUPLE_ARG, args) )); } #undef n #endif // BOOST_PP_IS_ITERATING