// // Copyright (c) 2005, 2006 João Abecasis // // 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) // #if !BOOST_PP_IS_ITERATING # if !defined(BOOST_FUSION_SEQUENCE_UTILITY_UNPACK_ARGS_HPP_INCLUDED) # define BOOST_FUSION_SEQUENCE_UTILITY_UNPACK_ARGS_HPP_INCLUDED # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include namespace boost { namespace fusion { namespace detail { template struct unpack_args_impl_helper { typedef typename remove_cv::type f_nocv; typedef typename mpl::eval_if< is_pointer, mpl::identity, mpl::eval_if< is_function, add_pointer, mpl::identity > >::type type; }; template < class F, class Sequence, class F_ = typename unpack_args_impl_helper::type, class Size = mpl::int_::value> > struct unpack_args_impl; template struct unpack_args_impl > { typedef typename boost::result_of::type type; static type call(F & f, Sequence &) { return f(); } }; # define BOOST_FUSION_next_iterator(z, n, data) \ typedef typename fusion::result_of::next::type \ BOOST_PP_CAT(I, BOOST_PP_INC(n)); # define BOOST_FUSION_deref_iterator(z, n, data) \ typedef typename fusion::result_of::deref::type BOOST_PP_CAT(T, BOOST_PP_INC(n)); # define BOOST_FUSION_next_call_iterator(z, n, data) \ BOOST_PP_CAT(I, BOOST_PP_INC(n)) BOOST_PP_CAT(i, BOOST_PP_INC(n)) \ = fusion::next(BOOST_PP_CAT(i, n)); # define BOOST_FUSION_n BOOST_PP_ITERATION() # define BOOST_PP_ITERATION_PARAMS_1 (3, (1, FUSION_MAX_UNPACK_ARG_SIZE, \ )) # include BOOST_PP_ITERATE() # undef BOOST_FUSION_next_iterator # undef BOOST_FUSION_deref_iterator # undef BOOST_FUSION_next_call_iterator # undef BOOST_FUSION_n # undef BOOST_PP_ITERATION_PARAMS_1 } // namespace detail namespace result_of { template struct unpack_args : detail::unpack_args_impl { }; } // namespace result_of template inline typename result_of::unpack_args::type unpack_args(F & f, Sequence & seq) { return result_of::unpack_args::call(f, seq); } template inline typename result_of::unpack_args::type unpack_args(F const & f, Sequence & seq) { return result_of::unpack_args::call(f, seq); } template inline typename result_of::unpack_args::type unpack_args(F & f, Sequence const & seq) { return result_of::unpack_args::call(f, seq); } template inline typename result_of::unpack_args::type unpack_args(F const & f, Sequence const & seq) { return result_of::unpack_args::call(f, seq); } }} // namespace boost::fusion # endif // include guard #else // BOOST_PP_IS_ITERATING template struct unpack_args_impl > { typedef typename fusion::result_of::begin::type I0; typedef typename fusion::result_of::deref::type T0; BOOST_PP_REPEAT(BOOST_FUSION_n, BOOST_FUSION_next_iterator, ~) BOOST_PP_REPEAT(BOOST_FUSION_n, BOOST_FUSION_deref_iterator, ~) typedef typename boost::result_of< F_( BOOST_PP_ENUM_PARAMS(BOOST_FUSION_n, T) ) >::type type; static type call(F & f, Sequence & seq) { I0 i0 = fusion::begin(seq); BOOST_PP_REPEAT(BOOST_PP_DEC(BOOST_FUSION_n), BOOST_FUSION_next_call_iterator, ~) return f( BOOST_PP_ENUM_PARAMS(BOOST_FUSION_n, *i) ); } }; #endif // BOOST_PP_IS_ITERATING