sl@0: sl@0: #if !defined(BOOST_PP_IS_ITERATING) sl@0: sl@0: ///// header body sl@0: sl@0: #ifndef BOOST_MPL_BIND_HPP_INCLUDED sl@0: #define BOOST_MPL_BIND_HPP_INCLUDED sl@0: sl@0: // Copyright Peter Dimov 2001 sl@0: // Copyright Aleksey Gurtovoy 2001-2004 sl@0: // sl@0: // Distributed under the Boost Software License, Version 1.0. sl@0: // (See accompanying file LICENSE_1_0.txt or copy at sl@0: // http://www.boost.org/LICENSE_1_0.txt) sl@0: // sl@0: // See http://www.boost.org/libs/mpl for documentation. sl@0: sl@0: // $Source: /cvsroot/boost/boost/boost/mpl/bind.hpp,v $ sl@0: // $Date: 2004/10/26 14:51:04 $ sl@0: // $Revision: 1.13 $ sl@0: sl@0: #if !defined(BOOST_MPL_PREPROCESSING_MODE) sl@0: # include sl@0: # include sl@0: # include sl@0: # include sl@0: # include sl@0: # include sl@0: # include sl@0: # include sl@0: # include sl@0: # include sl@0: # if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) sl@0: # include sl@0: # endif sl@0: #endif sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \ sl@0: && !defined(BOOST_MPL_PREPROCESSING_MODE) sl@0: sl@0: # if defined(BOOST_MPL_CFG_NO_UNNAMED_PLACEHOLDER_SUPPORT) sl@0: # define BOOST_MPL_PREPROCESSED_HEADER basic_bind.hpp sl@0: # else sl@0: # define BOOST_MPL_PREPROCESSED_HEADER bind.hpp sl@0: # endif sl@0: # include sl@0: sl@0: #else sl@0: sl@0: # include sl@0: # include sl@0: # include sl@0: # include sl@0: # include sl@0: # include sl@0: # include sl@0: # include sl@0: # include sl@0: # include sl@0: # include sl@0: # include sl@0: # include sl@0: sl@0: # include sl@0: # include sl@0: # include sl@0: # include sl@0: sl@0: namespace boost { namespace mpl { sl@0: sl@0: // local macros, #undef-ined at the end of the header sl@0: # define AUX778076_APPLY \ sl@0: BOOST_PP_CAT(apply_wrap,BOOST_MPL_LIMIT_METAFUNCTION_ARITY) \ sl@0: /**/ sl@0: sl@0: # if defined(BOOST_MPL_CFG_DMC_AMBIGUOUS_CTPS) sl@0: # define AUX778076_DMC_PARAM() , int dummy_ sl@0: # else sl@0: # define AUX778076_DMC_PARAM() sl@0: # endif sl@0: sl@0: # define AUX778076_BIND_PARAMS(param) \ sl@0: BOOST_MPL_PP_PARAMS( \ sl@0: BOOST_MPL_LIMIT_METAFUNCTION_ARITY \ sl@0: , param \ sl@0: ) \ sl@0: /**/ sl@0: sl@0: # define AUX778076_BIND_DEFAULT_PARAMS(param, value) \ sl@0: BOOST_MPL_PP_DEFAULT_PARAMS( \ sl@0: BOOST_MPL_LIMIT_METAFUNCTION_ARITY \ sl@0: , param \ sl@0: , value \ sl@0: ) \ sl@0: /**/ sl@0: sl@0: # define AUX778076_BIND_N_PARAMS(n, param) \ sl@0: BOOST_PP_COMMA_IF(n) BOOST_MPL_PP_PARAMS(n, param) \ sl@0: /**/ sl@0: sl@0: # define AUX778076_BIND_N_SPEC_PARAMS(n, param, def) \ sl@0: BOOST_PP_COMMA_IF(n) \ sl@0: BOOST_MPL_PP_PARTIAL_SPEC_PARAMS(n, param, def) \ sl@0: /**/ sl@0: sl@0: #if !defined(BOOST_MPL_CFG_NO_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES) sl@0: # define AUX778076_BIND_NESTED_DEFAULT_PARAMS(param, value) \ sl@0: AUX778076_BIND_DEFAULT_PARAMS(param, value) \ sl@0: /**/ sl@0: #else sl@0: # define AUX778076_BIND_NESTED_DEFAULT_PARAMS(param, value) \ sl@0: AUX778076_BIND_PARAMS(param) \ sl@0: /**/ sl@0: #endif sl@0: sl@0: namespace aux { sl@0: sl@0: #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) sl@0: sl@0: template< sl@0: typename T, AUX778076_BIND_PARAMS(typename U) sl@0: > sl@0: struct resolve_bind_arg sl@0: { sl@0: typedef T type; sl@0: }; sl@0: sl@0: # if !defined(BOOST_MPL_CFG_NO_UNNAMED_PLACEHOLDER_SUPPORT) sl@0: sl@0: template< sl@0: typename T sl@0: , typename Arg sl@0: > sl@0: struct replace_unnamed_arg sl@0: { sl@0: typedef Arg next; sl@0: typedef T type; sl@0: }; sl@0: sl@0: template< sl@0: typename Arg sl@0: > sl@0: struct replace_unnamed_arg< arg<-1>,Arg > sl@0: { sl@0: typedef typename Arg::next next; sl@0: typedef Arg type; sl@0: }; sl@0: sl@0: # endif // BOOST_MPL_CFG_NO_UNNAMED_PLACEHOLDER_SUPPORT sl@0: sl@0: template< sl@0: BOOST_MPL_AUX_NTTP_DECL(int, N), AUX778076_BIND_PARAMS(typename U) sl@0: > sl@0: struct resolve_bind_arg< arg,AUX778076_BIND_PARAMS(U) > sl@0: { sl@0: typedef typename AUX778076_APPLY, AUX778076_BIND_PARAMS(U)>::type type; sl@0: }; sl@0: sl@0: #if !defined(BOOST_MPL_CFG_NO_BIND_TEMPLATE) sl@0: template< sl@0: typename F, AUX778076_BIND_PARAMS(typename T), AUX778076_BIND_PARAMS(typename U) sl@0: > sl@0: struct resolve_bind_arg< bind,AUX778076_BIND_PARAMS(U) > sl@0: { sl@0: typedef bind f_; sl@0: typedef typename AUX778076_APPLY::type type; sl@0: }; sl@0: #endif sl@0: sl@0: #else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION sl@0: sl@0: // agurt, 15/jan/02: it's not a intended to be used as a function class, and sl@0: // MSVC6.5 has problems with 'apply' name here (the code compiles, but doesn't sl@0: // work), so I went with the 'result_' here, and in all other similar cases sl@0: template< bool > sl@0: struct resolve_arg_impl sl@0: { sl@0: template< typename T, AUX778076_BIND_PARAMS(typename U) > struct result_ sl@0: { sl@0: typedef T type; sl@0: }; sl@0: }; sl@0: sl@0: template<> sl@0: struct resolve_arg_impl sl@0: { sl@0: template< typename T, AUX778076_BIND_PARAMS(typename U) > struct result_ sl@0: { sl@0: typedef typename AUX778076_APPLY< sl@0: T sl@0: , AUX778076_BIND_PARAMS(U) sl@0: >::type type; sl@0: }; sl@0: }; sl@0: sl@0: // for 'resolve_bind_arg' sl@0: template< typename T > struct is_bind_template; sl@0: sl@0: template< sl@0: typename T, AUX778076_BIND_PARAMS(typename U) sl@0: > sl@0: struct resolve_bind_arg sl@0: : resolve_arg_impl< is_bind_template::value > sl@0: ::template result_< T,AUX778076_BIND_PARAMS(U) > sl@0: { sl@0: }; sl@0: sl@0: # if !defined(BOOST_MPL_CFG_NO_UNNAMED_PLACEHOLDER_SUPPORT) sl@0: sl@0: template< typename T > sl@0: struct replace_unnamed_arg_impl sl@0: { sl@0: template< typename Arg > struct result_ sl@0: { sl@0: typedef Arg next; sl@0: typedef T type; sl@0: }; sl@0: }; sl@0: sl@0: template<> sl@0: struct replace_unnamed_arg_impl< arg<-1> > sl@0: { sl@0: template< typename Arg > struct result_ sl@0: { sl@0: typedef typename next::type next; sl@0: typedef Arg type; sl@0: }; sl@0: }; sl@0: sl@0: template< typename T, typename Arg > sl@0: struct replace_unnamed_arg sl@0: : replace_unnamed_arg_impl::template result_ sl@0: { sl@0: }; sl@0: sl@0: # endif // BOOST_MPL_CFG_NO_UNNAMED_PLACEHOLDER_SUPPORT sl@0: sl@0: // agurt, 10/mar/02: the forward declaration has to appear before any of sl@0: // 'is_bind_helper' overloads, otherwise MSVC6.5 issues an ICE on it sl@0: template< BOOST_MPL_AUX_NTTP_DECL(int, arity_) > struct bind_chooser; sl@0: sl@0: aux::no_tag is_bind_helper(...); sl@0: template< typename T > aux::no_tag is_bind_helper(protect*); sl@0: sl@0: // overload for "main" form sl@0: // agurt, 15/mar/02: MSVC 6.5 fails to properly resolve the overload sl@0: // in case if we use 'aux::type_wrapper< bind<...> >' here, and all sl@0: // 'bind' instantiations form a complete type anyway sl@0: #if !defined(BOOST_MPL_CFG_NO_BIND_TEMPLATE) sl@0: template< sl@0: typename F, AUX778076_BIND_PARAMS(typename T) sl@0: > sl@0: aux::yes_tag is_bind_helper(bind*); sl@0: #endif sl@0: sl@0: template< BOOST_MPL_AUX_NTTP_DECL(int, N) > sl@0: aux::yes_tag is_bind_helper(arg*); sl@0: sl@0: template< bool is_ref_ = true > sl@0: struct is_bind_template_impl sl@0: { sl@0: template< typename T > struct result_ sl@0: { sl@0: BOOST_STATIC_CONSTANT(bool, value = false); sl@0: }; sl@0: }; sl@0: sl@0: template<> sl@0: struct is_bind_template_impl sl@0: { sl@0: template< typename T > struct result_ sl@0: { sl@0: BOOST_STATIC_CONSTANT(bool, value = sl@0: sizeof(aux::is_bind_helper(static_cast(0))) sl@0: == sizeof(aux::yes_tag) sl@0: ); sl@0: }; sl@0: }; sl@0: sl@0: template< typename T > struct is_bind_template sl@0: : is_bind_template_impl< ::boost::detail::is_reference_impl::value > sl@0: ::template result_ sl@0: { sl@0: }; sl@0: sl@0: #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION sl@0: sl@0: } // namespace aux sl@0: sl@0: sl@0: #define BOOST_PP_ITERATION_PARAMS_1 \ sl@0: (3,(0, BOOST_MPL_LIMIT_METAFUNCTION_ARITY, )) sl@0: #include BOOST_PP_ITERATE() sl@0: sl@0: #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ sl@0: && !defined(BOOST_MPL_CFG_NO_TEMPLATE_TEMPLATE_PARAMETERS) sl@0: /// if_/eval_if specializations sl@0: # define AUX778076_SPEC_NAME if_ sl@0: # define BOOST_PP_ITERATION_PARAMS_1 (3,(3, 3, )) sl@0: # include BOOST_PP_ITERATE() sl@0: sl@0: #if !defined(BOOST_MPL_CFG_DMC_AMBIGUOUS_CTPS) sl@0: # define AUX778076_SPEC_NAME eval_if sl@0: # define BOOST_PP_ITERATION_PARAMS_1 (3,(3, 3, )) sl@0: # include BOOST_PP_ITERATE() sl@0: #endif sl@0: #endif sl@0: sl@0: // real C++ version is already taken care of sl@0: #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ sl@0: && !defined(BOOST_MPL_CFG_NO_BIND_TEMPLATE) sl@0: sl@0: namespace aux { sl@0: // apply_count_args sl@0: #define AUX778076_COUNT_ARGS_PREFIX bind sl@0: #define AUX778076_COUNT_ARGS_DEFAULT na sl@0: #define AUX778076_COUNT_ARGS_ARITY BOOST_MPL_LIMIT_METAFUNCTION_ARITY sl@0: #include sl@0: } sl@0: sl@0: // bind sl@0: template< sl@0: typename F, AUX778076_BIND_PARAMS(typename T) AUX778076_DMC_PARAM() sl@0: > sl@0: struct bind sl@0: : aux::bind_chooser< sl@0: aux::bind_count_args::value sl@0: >::template result_< F,AUX778076_BIND_PARAMS(T) >::type sl@0: { sl@0: }; sl@0: sl@0: BOOST_MPL_AUX_ARITY_SPEC( sl@0: BOOST_PP_INC(BOOST_MPL_LIMIT_METAFUNCTION_ARITY) sl@0: , bind sl@0: ) sl@0: sl@0: BOOST_MPL_AUX_TEMPLATE_ARITY_SPEC( sl@0: BOOST_PP_INC(BOOST_MPL_LIMIT_METAFUNCTION_ARITY) sl@0: , bind sl@0: ) sl@0: sl@0: sl@0: #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION sl@0: sl@0: # undef AUX778076_BIND_NESTED_DEFAULT_PARAMS sl@0: # undef AUX778076_BIND_N_SPEC_PARAMS sl@0: # undef AUX778076_BIND_N_PARAMS sl@0: # undef AUX778076_BIND_DEFAULT_PARAMS sl@0: # undef AUX778076_BIND_PARAMS sl@0: # undef AUX778076_DMC_PARAM sl@0: # undef AUX778076_APPLY sl@0: sl@0: }} sl@0: sl@0: #endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS sl@0: #endif // BOOST_MPL_BIND_HPP_INCLUDED sl@0: sl@0: ///// iteration, depth == 1 sl@0: sl@0: #elif BOOST_PP_ITERATION_DEPTH() == 1 sl@0: sl@0: # define i_ BOOST_PP_FRAME_ITERATION(1) sl@0: sl@0: #if defined(AUX778076_SPEC_NAME) sl@0: sl@0: // lazy metafunction specialization sl@0: template< template< BOOST_MPL_PP_PARAMS(i_, typename T) > class F, typename Tag > sl@0: struct BOOST_PP_CAT(quote,i_); sl@0: sl@0: template< BOOST_MPL_PP_PARAMS(i_, typename T) > struct AUX778076_SPEC_NAME; sl@0: sl@0: template< sl@0: typename Tag AUX778076_BIND_N_PARAMS(i_, typename T) sl@0: > sl@0: struct BOOST_PP_CAT(bind,i_)< sl@0: BOOST_PP_CAT(quote,i_) sl@0: AUX778076_BIND_N_PARAMS(i_,T) sl@0: > sl@0: { sl@0: template< sl@0: AUX778076_BIND_NESTED_DEFAULT_PARAMS(typename U, na) sl@0: > sl@0: struct apply sl@0: { sl@0: private: sl@0: typedef mpl::arg<1> n1; sl@0: # define BOOST_PP_ITERATION_PARAMS_2 (3,(1, i_, )) sl@0: # include BOOST_PP_ITERATE() sl@0: sl@0: typedef typename AUX778076_SPEC_NAME< sl@0: typename t1::type sl@0: , BOOST_MPL_PP_EXT_PARAMS(2, BOOST_PP_INC(i_), t) sl@0: >::type f_; sl@0: sl@0: public: sl@0: typedef typename f_::type type; sl@0: }; sl@0: }; sl@0: sl@0: #undef AUX778076_SPEC_NAME sl@0: sl@0: #else // AUX778076_SPEC_NAME sl@0: sl@0: template< sl@0: typename F AUX778076_BIND_N_PARAMS(i_, typename T) AUX778076_DMC_PARAM() sl@0: > sl@0: struct BOOST_PP_CAT(bind,i_) sl@0: { sl@0: template< sl@0: AUX778076_BIND_NESTED_DEFAULT_PARAMS(typename U, na) sl@0: > sl@0: struct apply sl@0: { sl@0: private: sl@0: # if !defined(BOOST_MPL_CFG_NO_UNNAMED_PLACEHOLDER_SUPPORT) sl@0: sl@0: typedef aux::replace_unnamed_arg< F,mpl::arg<1> > r0; sl@0: typedef typename r0::type a0; sl@0: typedef typename r0::next n1; sl@0: typedef typename aux::resolve_bind_arg::type f_; sl@0: /// sl@0: # else sl@0: typedef typename aux::resolve_bind_arg::type f_; sl@0: sl@0: # endif // BOOST_MPL_CFG_NO_UNNAMED_PLACEHOLDER_SUPPORT sl@0: sl@0: # if i_ > 0 sl@0: # define BOOST_PP_ITERATION_PARAMS_2 (3,(1, i_, )) sl@0: # include BOOST_PP_ITERATE() sl@0: # endif sl@0: sl@0: public: sl@0: sl@0: # define AUX778076_ARG(unused, i_, t) \ sl@0: BOOST_PP_COMMA_IF(i_) \ sl@0: typename BOOST_PP_CAT(t,BOOST_PP_INC(i_))::type \ sl@0: /**/ sl@0: sl@0: typedef typename BOOST_PP_CAT(apply_wrap,i_)< sl@0: f_ sl@0: BOOST_PP_COMMA_IF(i_) BOOST_MPL_PP_REPEAT(i_, AUX778076_ARG, t) sl@0: >::type type; sl@0: sl@0: # undef AUX778076_ARG sl@0: }; sl@0: }; sl@0: sl@0: namespace aux { sl@0: sl@0: #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) sl@0: sl@0: template< sl@0: typename F AUX778076_BIND_N_PARAMS(i_, typename T), AUX778076_BIND_PARAMS(typename U) sl@0: > sl@0: struct resolve_bind_arg< sl@0: BOOST_PP_CAT(bind,i_),AUX778076_BIND_PARAMS(U) sl@0: > sl@0: { sl@0: typedef BOOST_PP_CAT(bind,i_) f_; sl@0: typedef typename AUX778076_APPLY::type type; sl@0: }; sl@0: sl@0: #else sl@0: sl@0: template< sl@0: typename F AUX778076_BIND_N_PARAMS(i_, typename T) sl@0: > sl@0: aux::yes_tag sl@0: is_bind_helper(BOOST_PP_CAT(bind,i_)*); sl@0: sl@0: #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION sl@0: sl@0: } // namespace aux sl@0: sl@0: BOOST_MPL_AUX_ARITY_SPEC(BOOST_PP_INC(i_), BOOST_PP_CAT(bind,i_)) sl@0: BOOST_MPL_AUX_TEMPLATE_ARITY_SPEC(BOOST_PP_INC(i_), BOOST_PP_CAT(bind,i_)) sl@0: sl@0: # if !defined(BOOST_MPL_CFG_NO_BIND_TEMPLATE) sl@0: # if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) sl@0: sl@0: #if i_ == BOOST_MPL_LIMIT_METAFUNCTION_ARITY sl@0: /// primary template (not a specialization!) sl@0: template< sl@0: typename F AUX778076_BIND_N_PARAMS(i_, typename T) AUX778076_DMC_PARAM() sl@0: > sl@0: struct bind sl@0: : BOOST_PP_CAT(bind,i_) sl@0: { sl@0: }; sl@0: #else sl@0: template< sl@0: typename F AUX778076_BIND_N_PARAMS(i_, typename T) AUX778076_DMC_PARAM() sl@0: > sl@0: struct bind< F AUX778076_BIND_N_SPEC_PARAMS(i_, T, na) > sl@0: : BOOST_PP_CAT(bind,i_) sl@0: { sl@0: }; sl@0: #endif sl@0: sl@0: # else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION sl@0: sl@0: namespace aux { sl@0: sl@0: template<> sl@0: struct bind_chooser sl@0: { sl@0: template< sl@0: typename F, AUX778076_BIND_PARAMS(typename T) sl@0: > sl@0: struct result_ sl@0: { sl@0: typedef BOOST_PP_CAT(bind,i_)< F AUX778076_BIND_N_PARAMS(i_,T) > type; sl@0: }; sl@0: }; sl@0: sl@0: } // namespace aux sl@0: sl@0: # endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION sl@0: # endif // BOOST_MPL_CFG_NO_BIND_TEMPLATE sl@0: sl@0: #endif // AUX778076_SPEC_NAME sl@0: sl@0: # undef i_ sl@0: sl@0: ///// iteration, depth == 2 sl@0: sl@0: #elif BOOST_PP_ITERATION_DEPTH() == 2 sl@0: sl@0: # define j_ BOOST_PP_FRAME_ITERATION(2) sl@0: # if !defined(BOOST_MPL_CFG_NO_UNNAMED_PLACEHOLDER_SUPPORT) sl@0: sl@0: typedef aux::replace_unnamed_arg< BOOST_PP_CAT(T,j_),BOOST_PP_CAT(n,j_) > BOOST_PP_CAT(r,j_); sl@0: typedef typename BOOST_PP_CAT(r,j_)::type BOOST_PP_CAT(a,j_); sl@0: typedef typename BOOST_PP_CAT(r,j_)::next BOOST_PP_CAT(n,BOOST_PP_INC(j_)); sl@0: typedef aux::resolve_bind_arg BOOST_PP_CAT(t,j_); sl@0: /// sl@0: # else sl@0: typedef aux::resolve_bind_arg< BOOST_PP_CAT(T,j_),AUX778076_BIND_PARAMS(U)> BOOST_PP_CAT(t,j_); sl@0: sl@0: # endif sl@0: # undef j_ sl@0: sl@0: #endif // BOOST_PP_IS_ITERATING