Chris@16: Chris@16: #if !defined(BOOST_PP_IS_ITERATING) Chris@16: Chris@16: ///// header body Chris@16: Chris@16: #ifndef BOOST_MPL_APPLY_HPP_INCLUDED Chris@16: #define BOOST_MPL_APPLY_HPP_INCLUDED Chris@16: Chris@16: // Copyright Aleksey Gurtovoy 2000-2004 Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. Chris@16: // (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: // See http://www.boost.org/libs/mpl for documentation. Chris@16: Chris@101: // $Id$ Chris@101: // $Date$ Chris@101: // $Revision$ Chris@16: Chris@16: #if !defined(BOOST_MPL_PREPROCESSING_MODE) Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: #endif Chris@16: Chris@16: #include Chris@16: Chris@16: #if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \ Chris@16: && !defined(BOOST_MPL_PREPROCESSING_MODE) Chris@16: Chris@16: # define BOOST_MPL_PREPROCESSED_HEADER apply.hpp Chris@16: # include Chris@16: Chris@16: #else Chris@16: Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: Chris@16: namespace boost { namespace mpl { Chris@16: Chris@16: // local macros, #undef-ined at the end of the header Chris@16: # define AUX778076_APPLY_PARAMS(param) \ Chris@16: BOOST_MPL_PP_PARAMS( \ Chris@16: BOOST_MPL_LIMIT_METAFUNCTION_ARITY \ Chris@16: , param \ Chris@16: ) \ Chris@16: /**/ Chris@16: Chris@16: # define AUX778076_APPLY_DEF_PARAMS(param, value) \ Chris@16: BOOST_MPL_PP_DEFAULT_PARAMS( \ Chris@16: BOOST_MPL_LIMIT_METAFUNCTION_ARITY \ Chris@16: , param \ Chris@16: , value \ Chris@16: ) \ Chris@16: /**/ Chris@16: Chris@16: # define AUX778076_APPLY_N_PARAMS(n, param) \ Chris@16: BOOST_MPL_PP_PARAMS(n, param) \ Chris@16: /**/ Chris@16: Chris@16: # define AUX778076_APPLY_N_COMMA_PARAMS(n, param) \ Chris@16: BOOST_PP_COMMA_IF(n) \ Chris@16: BOOST_MPL_PP_PARAMS(n, param) \ Chris@16: /**/ Chris@16: Chris@16: # define AUX778076_APPLY_N_PARTIAL_SPEC_PARAMS(n, param, def) \ Chris@16: BOOST_PP_COMMA_IF(n) \ Chris@16: BOOST_MPL_PP_PARTIAL_SPEC_PARAMS(n, param, def) \ Chris@16: /**/ Chris@16: Chris@16: # define AUX778076_APPLY_N_SPEC_PARAMS(n, param) \ Chris@16: BOOST_MPL_PP_ENUM(BOOST_PP_INC(n), param) \ Chris@16: /**/ Chris@16: Chris@16: Chris@16: #define BOOST_PP_ITERATION_PARAMS_1 \ Chris@16: (3,(0, BOOST_MPL_LIMIT_METAFUNCTION_ARITY, )) Chris@16: #include BOOST_PP_ITERATE() Chris@16: Chris@16: # if !defined(BOOST_MPL_CFG_NO_APPLY_TEMPLATE) Chris@16: // real C++ version is already taken care of Chris@16: # if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) Chris@16: Chris@16: namespace aux { Chris@16: // apply_count_args Chris@16: #define AUX778076_COUNT_ARGS_PREFIX apply Chris@16: #define AUX778076_COUNT_ARGS_DEFAULT na Chris@16: #define AUX778076_COUNT_ARGS_ARITY BOOST_MPL_LIMIT_METAFUNCTION_ARITY Chris@16: #include Chris@16: } Chris@16: Chris@16: Chris@16: template< Chris@16: typename F, AUX778076_APPLY_DEF_PARAMS(typename T, na) Chris@16: > Chris@16: struct apply Chris@16: : aux::apply_chooser< Chris@16: aux::apply_count_args< AUX778076_APPLY_PARAMS(T) >::value Chris@16: >::template result_< F, AUX778076_APPLY_PARAMS(T) >::type Chris@16: { Chris@16: }; Chris@16: Chris@16: # endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION Chris@16: # endif // BOOST_MPL_CFG_NO_APPLY_TEMPLATE Chris@16: Chris@16: # undef AUX778076_APPLY_N_SPEC_PARAMS Chris@16: # undef AUX778076_APPLY_N_PARTIAL_SPEC_PARAMS Chris@16: # undef AUX778076_APPLY_N_COMMA_PARAMS Chris@16: # undef AUX778076_APPLY_N_PARAMS Chris@16: # undef AUX778076_APPLY_DEF_PARAMS Chris@16: # undef AUX778076_APPLY_PARAMS Chris@16: Chris@16: }} Chris@16: Chris@16: #endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS Chris@16: #endif // BOOST_MPL_APPLY_HPP_INCLUDED Chris@16: Chris@16: ///// iteration, depth == 1 Chris@16: Chris@16: // For gcc 4.4 compatability, we must include the Chris@16: // BOOST_PP_ITERATION_DEPTH test inside an #else clause. Chris@16: #else // BOOST_PP_IS_ITERATING Chris@16: #if BOOST_PP_ITERATION_DEPTH() == 1 Chris@16: Chris@16: # define i_ BOOST_PP_FRAME_ITERATION(1) Chris@16: Chris@16: template< Chris@16: typename F AUX778076_APPLY_N_COMMA_PARAMS(i_, typename T) Chris@16: > Chris@16: struct BOOST_PP_CAT(apply,i_) Chris@16: #if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) Chris@16: : BOOST_PP_CAT(apply_wrap,i_)< Chris@16: typename lambda::type Chris@16: AUX778076_APPLY_N_COMMA_PARAMS(i_, T) Chris@16: > Chris@16: { Chris@16: #else Chris@16: { Chris@16: typedef typename BOOST_PP_CAT(apply_wrap,i_)< Chris@16: typename lambda::type Chris@16: AUX778076_APPLY_N_COMMA_PARAMS(i_, T) Chris@16: >::type type; Chris@16: #endif Chris@16: BOOST_MPL_AUX_LAMBDA_SUPPORT( Chris@16: BOOST_PP_INC(i_) Chris@16: , BOOST_PP_CAT(apply,i_) Chris@16: , (F AUX778076_APPLY_N_COMMA_PARAMS(i_,T)) Chris@16: ) Chris@16: }; Chris@16: Chris@16: Chris@16: #if defined(BOOST_MPL_CFG_MSVC_ETI_BUG) Chris@16: /// workaround for ETI bug Chris@16: template<> Chris@16: struct BOOST_PP_CAT(apply,i_) Chris@16: { Chris@16: typedef int type; Chris@16: }; Chris@16: #endif Chris@16: Chris@16: # if !defined(BOOST_MPL_CFG_NO_APPLY_TEMPLATE) Chris@16: # if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) Chris@16: Chris@16: #if i_ == BOOST_MPL_LIMIT_METAFUNCTION_ARITY Chris@16: /// primary template (not a specialization!) Chris@16: template< Chris@16: typename F AUX778076_APPLY_N_COMMA_PARAMS(i_, typename T) Chris@16: > Chris@16: struct apply Chris@16: : BOOST_PP_CAT(apply,i_)< F AUX778076_APPLY_N_COMMA_PARAMS(i_, T) > Chris@16: { Chris@16: }; Chris@16: #else Chris@16: template< Chris@16: typename F AUX778076_APPLY_N_COMMA_PARAMS(i_, typename T) Chris@16: > Chris@16: struct apply< F AUX778076_APPLY_N_PARTIAL_SPEC_PARAMS(i_, T, na) > Chris@16: : BOOST_PP_CAT(apply,i_)< F AUX778076_APPLY_N_COMMA_PARAMS(i_, T) > Chris@16: { Chris@16: }; Chris@16: #endif Chris@16: Chris@16: # else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION Chris@16: Chris@16: #if !defined(BOOST_MPL_CFG_NO_APPLY_TEMPLATE) Chris@16: namespace aux { Chris@16: Chris@16: template<> Chris@16: struct apply_chooser Chris@16: { Chris@16: template< Chris@16: typename F, AUX778076_APPLY_PARAMS(typename T) Chris@16: > Chris@16: struct result_ Chris@16: { Chris@16: typedef BOOST_PP_CAT(apply,i_)< Chris@16: F AUX778076_APPLY_N_COMMA_PARAMS(i_, T) Chris@16: > type; Chris@16: }; Chris@16: }; Chris@16: Chris@16: } // namespace aux Chris@16: #endif Chris@16: Chris@16: # endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION Chris@16: # endif // BOOST_MPL_CFG_NO_APPLY_TEMPLATE Chris@16: Chris@16: # undef i_ Chris@16: Chris@16: #endif // BOOST_PP_ITERATION_DEPTH() Chris@16: #endif // BOOST_PP_IS_ITERATING