Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:48:02

0001 
0002 #if !defined(BOOST_PP_IS_ITERATING)
0003 
0004 ///// header body
0005 
0006 #ifndef BOOST_MPL_BIND_HPP_INCLUDED
0007 #define BOOST_MPL_BIND_HPP_INCLUDED
0008 
0009 // Copyright Peter Dimov 2001
0010 // Copyright Aleksey Gurtovoy 2001-2004
0011 //
0012 // Distributed under the Boost Software License, Version 1.0. 
0013 // (See accompanying file LICENSE_1_0.txt or copy at 
0014 // http://www.boost.org/LICENSE_1_0.txt)
0015 //
0016 // See http://www.boost.org/libs/mpl for documentation.
0017 
0018 // $Id$
0019 // $Date$
0020 // $Revision$
0021 
0022 #if !defined(BOOST_MPL_PREPROCESSING_MODE)
0023 #   include <boost/mpl/bind_fwd.hpp>
0024 #   include <boost/mpl/placeholders.hpp>
0025 #   include <boost/mpl/next.hpp>
0026 #   include <boost/mpl/protect.hpp>
0027 #   include <boost/mpl/apply_wrap.hpp>
0028 #   include <boost/mpl/limits/arity.hpp>
0029 #   include <boost/mpl/aux_/na.hpp>
0030 #   include <boost/mpl/aux_/arity_spec.hpp>
0031 #   include <boost/mpl/aux_/type_wrapper.hpp>
0032 #   include <boost/mpl/aux_/yes_no.hpp>
0033 #   if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
0034 #       include <boost/type_traits/is_reference.hpp>
0035 #   endif 
0036 #endif
0037 
0038 #include <boost/mpl/aux_/config/bind.hpp>
0039 #include <boost/mpl/aux_/config/static_constant.hpp>
0040 #include <boost/mpl/aux_/config/use_preprocessed.hpp>
0041 
0042 #if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
0043     && !defined(BOOST_MPL_PREPROCESSING_MODE)
0044 
0045 #   if defined(BOOST_MPL_CFG_NO_UNNAMED_PLACEHOLDER_SUPPORT)
0046 #       define BOOST_MPL_PREPROCESSED_HEADER basic_bind.hpp
0047 #   else
0048 #       define BOOST_MPL_PREPROCESSED_HEADER bind.hpp
0049 #   endif
0050 #   include <boost/mpl/aux_/include_preprocessed.hpp>
0051 
0052 #else
0053 
0054 #   include <boost/mpl/aux_/preprocessor/params.hpp>
0055 #   include <boost/mpl/aux_/preprocessor/default_params.hpp>
0056 #   include <boost/mpl/aux_/preprocessor/def_params_tail.hpp>
0057 #   include <boost/mpl/aux_/preprocessor/partial_spec_params.hpp>
0058 #   include <boost/mpl/aux_/preprocessor/ext_params.hpp>
0059 #   include <boost/mpl/aux_/preprocessor/repeat.hpp>
0060 #   include <boost/mpl/aux_/preprocessor/enum.hpp>
0061 #   include <boost/mpl/aux_/preprocessor/add.hpp>
0062 #   include <boost/mpl/aux_/config/dmc_ambiguous_ctps.hpp>
0063 #   include <boost/mpl/aux_/config/ctps.hpp>
0064 #   include <boost/mpl/aux_/config/ttp.hpp>
0065 #   include <boost/mpl/aux_/config/dtp.hpp>
0066 #   include <boost/mpl/aux_/nttp_decl.hpp>
0067 
0068 #   include <boost/preprocessor/iterate.hpp>
0069 #   include <boost/preprocessor/comma_if.hpp>
0070 #   include <boost/preprocessor/cat.hpp>
0071 #   include <boost/preprocessor/inc.hpp>
0072 
0073 namespace boost { namespace mpl {
0074 
0075 // local macros, #undef-ined at the end of the header
0076 #   define AUX778076_APPLY \
0077     BOOST_PP_CAT(apply_wrap,BOOST_MPL_LIMIT_METAFUNCTION_ARITY) \
0078     /**/
0079 
0080 #   if defined(BOOST_MPL_CFG_DMC_AMBIGUOUS_CTPS)
0081 #       define AUX778076_DMC_PARAM() , int dummy_
0082 #   else
0083 #       define AUX778076_DMC_PARAM()
0084 #   endif
0085 
0086 #   define AUX778076_BIND_PARAMS(param) \
0087     BOOST_MPL_PP_PARAMS( \
0088           BOOST_MPL_LIMIT_METAFUNCTION_ARITY \
0089         , param \
0090         ) \
0091     /**/
0092 
0093 #   define AUX778076_BIND_DEFAULT_PARAMS(param, value) \
0094     BOOST_MPL_PP_DEFAULT_PARAMS( \
0095           BOOST_MPL_LIMIT_METAFUNCTION_ARITY \
0096         , param \
0097         , value \
0098         ) \
0099     /**/
0100 
0101 #   define AUX778076_BIND_N_PARAMS(n, param) \
0102     BOOST_PP_COMMA_IF(n) BOOST_MPL_PP_PARAMS(n, param) \
0103     /**/
0104 
0105 #   define AUX778076_BIND_N_SPEC_PARAMS(n, param, def) \
0106     BOOST_PP_COMMA_IF(n) \
0107     BOOST_MPL_PP_PARTIAL_SPEC_PARAMS(n, param, def) \
0108     /**/
0109 
0110 #if !defined(BOOST_MPL_CFG_NO_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES)
0111 #   define AUX778076_BIND_NESTED_DEFAULT_PARAMS(param, value) \
0112     AUX778076_BIND_DEFAULT_PARAMS(param, value) \
0113     /**/
0114 #else
0115 #   define AUX778076_BIND_NESTED_DEFAULT_PARAMS(param, value) \
0116     AUX778076_BIND_PARAMS(param) \
0117     /**/
0118 #endif
0119 
0120 namespace aux {
0121 
0122 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
0123 
0124 template<
0125       typename T, AUX778076_BIND_PARAMS(typename U)
0126     >
0127 struct resolve_bind_arg
0128 {
0129     typedef T type;
0130 };
0131 
0132 #   if !defined(BOOST_MPL_CFG_NO_UNNAMED_PLACEHOLDER_SUPPORT)
0133 
0134 template<
0135       typename T
0136     , typename Arg
0137     >
0138 struct replace_unnamed_arg
0139 {
0140     typedef Arg next;
0141     typedef T type;
0142 };
0143 
0144 template<
0145       typename Arg
0146     >
0147 struct replace_unnamed_arg< arg<-1>,Arg >
0148 {
0149     typedef typename Arg::next next;
0150     typedef Arg type;
0151 };
0152 
0153 #   endif // BOOST_MPL_CFG_NO_UNNAMED_PLACEHOLDER_SUPPORT
0154 
0155 template<
0156       BOOST_MPL_AUX_NTTP_DECL(int, N), AUX778076_BIND_PARAMS(typename U)
0157     >
0158 struct resolve_bind_arg< arg<N>,AUX778076_BIND_PARAMS(U) >
0159 {
0160     typedef typename AUX778076_APPLY<mpl::arg<N>, AUX778076_BIND_PARAMS(U)>::type type;
0161 };
0162 
0163 #if !defined(BOOST_MPL_CFG_NO_BIND_TEMPLATE)
0164 template<
0165       typename F, AUX778076_BIND_PARAMS(typename T), AUX778076_BIND_PARAMS(typename U)
0166     >
0167 struct resolve_bind_arg< bind<F,AUX778076_BIND_PARAMS(T)>,AUX778076_BIND_PARAMS(U) >
0168 {
0169     typedef bind<F,AUX778076_BIND_PARAMS(T)> f_;
0170     typedef typename AUX778076_APPLY<f_, AUX778076_BIND_PARAMS(U)>::type type;
0171 };
0172 #endif
0173 
0174 #else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
0175 
0176 // agurt, 15/jan/02: it's not a intended to be used as a function class, and 
0177 // MSVC6.5 has problems with 'apply' name here (the code compiles, but doesn't
0178 // work), so I went with the 'result_' here, and in all other similar cases
0179 template< bool >
0180 struct resolve_arg_impl
0181 {
0182     template< typename T, AUX778076_BIND_PARAMS(typename U) > struct result_
0183     {
0184         typedef T type;
0185     };
0186 };
0187 
0188 template<> 
0189 struct resolve_arg_impl<true>
0190 {
0191     template< typename T, AUX778076_BIND_PARAMS(typename U) > struct result_
0192     {
0193         typedef typename AUX778076_APPLY<
0194               T
0195             , AUX778076_BIND_PARAMS(U)
0196             >::type type;
0197     };
0198 };
0199 
0200 // for 'resolve_bind_arg'
0201 template< typename T > struct is_bind_template;
0202 
0203 template< 
0204       typename T, AUX778076_BIND_PARAMS(typename U)
0205     >
0206 struct resolve_bind_arg
0207     : resolve_arg_impl< is_bind_template<T>::value >
0208             ::template result_< T,AUX778076_BIND_PARAMS(U) >
0209 {
0210 };
0211 
0212 #   if !defined(BOOST_MPL_CFG_NO_UNNAMED_PLACEHOLDER_SUPPORT)
0213 
0214 template< typename T > 
0215 struct replace_unnamed_arg_impl
0216 {
0217     template< typename Arg > struct result_
0218     {
0219         typedef Arg next;
0220         typedef T type;
0221     };
0222 };
0223 
0224 template<> 
0225 struct replace_unnamed_arg_impl< arg<-1> >
0226 {
0227     template< typename Arg > struct result_
0228     {
0229         typedef typename next<Arg>::type next;
0230         typedef Arg type;
0231     };
0232 };
0233 
0234 template< typename T, typename Arg > 
0235 struct replace_unnamed_arg
0236     : replace_unnamed_arg_impl<T>::template result_<Arg>
0237 {
0238 };
0239 
0240 #   endif // BOOST_MPL_CFG_NO_UNNAMED_PLACEHOLDER_SUPPORT
0241 
0242 // agurt, 10/mar/02: the forward declaration has to appear before any of
0243 // 'is_bind_helper' overloads, otherwise MSVC6.5 issues an ICE on it
0244 template< BOOST_MPL_AUX_NTTP_DECL(int, arity_) > struct bind_chooser;
0245 
0246 aux::no_tag is_bind_helper(...);
0247 template< typename T > aux::no_tag is_bind_helper(protect<T>*);
0248 
0249 // overload for "main" form
0250 // agurt, 15/mar/02: MSVC 6.5 fails to properly resolve the overload 
0251 // in case if we use 'aux::type_wrapper< bind<...> >' here, and all 
0252 // 'bind' instantiations form a complete type anyway
0253 #if !defined(BOOST_MPL_CFG_NO_BIND_TEMPLATE)
0254 template<
0255       typename F, AUX778076_BIND_PARAMS(typename T)
0256     >
0257 aux::yes_tag is_bind_helper(bind<F,AUX778076_BIND_PARAMS(T)>*);
0258 #endif
0259 
0260 template< BOOST_MPL_AUX_NTTP_DECL(int, N) >
0261 aux::yes_tag is_bind_helper(arg<N>*);
0262 
0263 template< bool is_ref_ = true >
0264 struct is_bind_template_impl
0265 {
0266     template< typename T > struct result_
0267     {
0268         BOOST_STATIC_CONSTANT(bool, value = false);
0269     };
0270 };
0271 
0272 template<>
0273 struct is_bind_template_impl<false>
0274 {
0275     template< typename T > struct result_
0276     {
0277         BOOST_STATIC_CONSTANT(bool, value = 
0278               sizeof(aux::is_bind_helper(static_cast<T*>(0))) 
0279                 == sizeof(aux::yes_tag)
0280             );
0281     };
0282 };
0283 
0284 template< typename T > struct is_bind_template
0285     : is_bind_template_impl< ::boost::detail::is_reference_impl<T>::value >
0286         ::template result_<T>
0287 {
0288 };
0289 
0290 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
0291 
0292 } // namespace aux
0293 
0294 
0295 #define BOOST_PP_ITERATION_PARAMS_1 \
0296     (3,(0, BOOST_MPL_LIMIT_METAFUNCTION_ARITY, <boost/mpl/bind.hpp>))
0297 #include BOOST_PP_ITERATE()
0298 
0299 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
0300     && !defined(BOOST_MPL_CFG_NO_TEMPLATE_TEMPLATE_PARAMETERS)
0301 /// if_/eval_if specializations
0302 #   define AUX778076_SPEC_NAME if_
0303 #   define BOOST_PP_ITERATION_PARAMS_1 (3,(3, 3, <boost/mpl/bind.hpp>))
0304 #   include BOOST_PP_ITERATE()
0305 
0306 #if !defined(BOOST_MPL_CFG_DMC_AMBIGUOUS_CTPS)
0307 #   define AUX778076_SPEC_NAME eval_if
0308 #   define BOOST_PP_ITERATION_PARAMS_1 (3,(3, 3, <boost/mpl/bind.hpp>))
0309 #   include BOOST_PP_ITERATE()
0310 #endif
0311 #endif
0312 
0313 // real C++ version is already taken care of
0314 #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
0315     && !defined(BOOST_MPL_CFG_NO_BIND_TEMPLATE)
0316 
0317 namespace aux {
0318 // apply_count_args
0319 #define AUX778076_COUNT_ARGS_PREFIX bind
0320 #define AUX778076_COUNT_ARGS_DEFAULT na
0321 #define AUX778076_COUNT_ARGS_ARITY BOOST_MPL_LIMIT_METAFUNCTION_ARITY
0322 #include <boost/mpl/aux_/count_args.hpp>
0323 }
0324 
0325 // bind
0326 template<
0327       typename F, AUX778076_BIND_PARAMS(typename T) AUX778076_DMC_PARAM()
0328     >
0329 struct bind
0330     : aux::bind_chooser<
0331           aux::bind_count_args<AUX778076_BIND_PARAMS(T)>::value
0332         >::template result_< F,AUX778076_BIND_PARAMS(T) >::type
0333 {
0334 };
0335 
0336 BOOST_MPL_AUX_ARITY_SPEC(
0337       BOOST_PP_INC(BOOST_MPL_LIMIT_METAFUNCTION_ARITY)
0338     , bind
0339     )
0340 
0341 BOOST_MPL_AUX_TEMPLATE_ARITY_SPEC(
0342       BOOST_PP_INC(BOOST_MPL_LIMIT_METAFUNCTION_ARITY)
0343     , bind
0344     )
0345 
0346 
0347 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
0348 
0349 #   undef AUX778076_BIND_NESTED_DEFAULT_PARAMS
0350 #   undef AUX778076_BIND_N_SPEC_PARAMS
0351 #   undef AUX778076_BIND_N_PARAMS
0352 #   undef AUX778076_BIND_DEFAULT_PARAMS
0353 #   undef AUX778076_BIND_PARAMS
0354 #   undef AUX778076_DMC_PARAM
0355 #   undef AUX778076_APPLY
0356 
0357 }}
0358 
0359 #endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
0360 #endif // BOOST_MPL_BIND_HPP_INCLUDED
0361 
0362 ///// iteration, depth == 1
0363 
0364 // For gcc 4.4 compatability, we must include the
0365 // BOOST_PP_ITERATION_DEPTH test inside an #else clause.
0366 #else // BOOST_PP_IS_ITERATING
0367 #if BOOST_PP_ITERATION_DEPTH() == 1
0368 
0369 #   define i_ BOOST_PP_FRAME_ITERATION(1)
0370 
0371 #if defined(AUX778076_SPEC_NAME)
0372 
0373 // lazy metafunction specialization
0374 template< template< BOOST_MPL_PP_PARAMS(i_, typename T) > class F, typename Tag >
0375 struct BOOST_PP_CAT(quote,i_);
0376 
0377 template< BOOST_MPL_PP_PARAMS(i_, typename T) > struct AUX778076_SPEC_NAME;
0378 
0379 template<
0380       typename Tag AUX778076_BIND_N_PARAMS(i_, typename T)
0381     >
0382 struct BOOST_PP_CAT(bind,i_)< 
0383       BOOST_PP_CAT(quote,i_)<AUX778076_SPEC_NAME,Tag>
0384     AUX778076_BIND_N_PARAMS(i_,T)
0385     >
0386 {
0387     template<
0388           AUX778076_BIND_NESTED_DEFAULT_PARAMS(typename U, na)
0389         >
0390     struct apply
0391     {
0392      private:
0393         typedef mpl::arg<1> n1;
0394 #       define BOOST_PP_ITERATION_PARAMS_2 (3,(1, i_, <boost/mpl/bind.hpp>))
0395 #       include BOOST_PP_ITERATE()
0396 
0397         typedef typename AUX778076_SPEC_NAME<
0398               typename t1::type
0399             , BOOST_MPL_PP_EXT_PARAMS(2, BOOST_PP_INC(i_), t)
0400             >::type f_;
0401 
0402      public:
0403         typedef typename f_::type type;
0404     };
0405 };
0406 
0407 #undef AUX778076_SPEC_NAME
0408 
0409 #else // AUX778076_SPEC_NAME
0410 
0411 template<
0412       typename F AUX778076_BIND_N_PARAMS(i_, typename T) AUX778076_DMC_PARAM()
0413     >
0414 struct BOOST_PP_CAT(bind,i_)
0415 {
0416     template<
0417           AUX778076_BIND_NESTED_DEFAULT_PARAMS(typename U, na)
0418         >
0419     struct apply
0420     {
0421      private:
0422 #   if !defined(BOOST_MPL_CFG_NO_UNNAMED_PLACEHOLDER_SUPPORT)
0423 
0424         typedef aux::replace_unnamed_arg< F,mpl::arg<1> > r0;
0425         typedef typename r0::type a0;
0426         typedef typename r0::next n1;
0427         typedef typename aux::resolve_bind_arg<a0,AUX778076_BIND_PARAMS(U)>::type f_;
0428         ///
0429 #   else
0430         typedef typename aux::resolve_bind_arg<F,AUX778076_BIND_PARAMS(U)>::type f_;
0431 
0432 #   endif // BOOST_MPL_CFG_NO_UNNAMED_PLACEHOLDER_SUPPORT
0433 
0434 #   if i_ > 0
0435 #       define BOOST_PP_ITERATION_PARAMS_2 (3,(1, i_, <boost/mpl/bind.hpp>))
0436 #       include BOOST_PP_ITERATE()
0437 #   endif
0438 
0439      public:
0440 
0441 #   define AUX778076_ARG(unused, i_, t) \
0442     BOOST_PP_COMMA_IF(i_) \
0443     typename BOOST_PP_CAT(t,BOOST_PP_INC(i_))::type \
0444 /**/
0445 
0446         typedef typename BOOST_PP_CAT(apply_wrap,i_)<
0447               f_ 
0448             BOOST_PP_COMMA_IF(i_) BOOST_MPL_PP_REPEAT(i_, AUX778076_ARG, t)
0449             >::type type;
0450 
0451 #   undef AUX778076_ARG
0452     };
0453 };
0454 
0455 namespace aux {
0456 
0457 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
0458 
0459 template<
0460       typename F AUX778076_BIND_N_PARAMS(i_, typename T), AUX778076_BIND_PARAMS(typename U)
0461     >
0462 struct resolve_bind_arg<
0463       BOOST_PP_CAT(bind,i_)<F AUX778076_BIND_N_PARAMS(i_,T)>,AUX778076_BIND_PARAMS(U)
0464     >
0465 {
0466     typedef BOOST_PP_CAT(bind,i_)<F AUX778076_BIND_N_PARAMS(i_,T)> f_;
0467     typedef typename AUX778076_APPLY<f_, AUX778076_BIND_PARAMS(U)>::type type;
0468 };
0469 
0470 #else
0471 
0472 template<
0473       typename F AUX778076_BIND_N_PARAMS(i_, typename T)
0474     >
0475 aux::yes_tag
0476 is_bind_helper(BOOST_PP_CAT(bind,i_)<F AUX778076_BIND_N_PARAMS(i_,T)>*);
0477 
0478 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
0479 
0480 } // namespace aux
0481 
0482 BOOST_MPL_AUX_ARITY_SPEC(BOOST_PP_INC(i_), BOOST_PP_CAT(bind,i_))
0483 BOOST_MPL_AUX_TEMPLATE_ARITY_SPEC(BOOST_PP_INC(i_), BOOST_PP_CAT(bind,i_))
0484 
0485 #   if !defined(BOOST_MPL_CFG_NO_BIND_TEMPLATE)
0486 #   if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
0487     
0488 #if i_ == BOOST_MPL_LIMIT_METAFUNCTION_ARITY
0489 /// primary template (not a specialization!)
0490 template<
0491       typename F AUX778076_BIND_N_PARAMS(i_, typename T) AUX778076_DMC_PARAM()
0492     >
0493 struct bind
0494     : BOOST_PP_CAT(bind,i_)<F AUX778076_BIND_N_PARAMS(i_,T) >
0495 {
0496 };
0497 #else
0498 template<
0499       typename F AUX778076_BIND_N_PARAMS(i_, typename T) AUX778076_DMC_PARAM()
0500     >
0501 struct bind< F AUX778076_BIND_N_SPEC_PARAMS(i_, T, na) >
0502     : BOOST_PP_CAT(bind,i_)<F AUX778076_BIND_N_PARAMS(i_,T) >
0503 {
0504 };
0505 #endif
0506 
0507 #   else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
0508 
0509 namespace aux {
0510 
0511 template<>
0512 struct bind_chooser<i_>
0513 {
0514     template<
0515           typename F, AUX778076_BIND_PARAMS(typename T)
0516         >
0517     struct result_
0518     {
0519         typedef BOOST_PP_CAT(bind,i_)< F AUX778076_BIND_N_PARAMS(i_,T) > type;
0520     };
0521 };
0522 
0523 } // namespace aux
0524 
0525 #   endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
0526 #   endif // BOOST_MPL_CFG_NO_BIND_TEMPLATE
0527 
0528 #endif // AUX778076_SPEC_NAME
0529 
0530 #   undef i_
0531 
0532 ///// iteration, depth == 2
0533 
0534 #elif BOOST_PP_ITERATION_DEPTH() == 2
0535 
0536 #   define j_ BOOST_PP_FRAME_ITERATION(2)
0537 #   if !defined(BOOST_MPL_CFG_NO_UNNAMED_PLACEHOLDER_SUPPORT)
0538 
0539         typedef aux::replace_unnamed_arg< BOOST_PP_CAT(T,j_),BOOST_PP_CAT(n,j_) > BOOST_PP_CAT(r,j_);
0540         typedef typename BOOST_PP_CAT(r,j_)::type BOOST_PP_CAT(a,j_);
0541         typedef typename BOOST_PP_CAT(r,j_)::next BOOST_PP_CAT(n,BOOST_PP_INC(j_));
0542         typedef aux::resolve_bind_arg<BOOST_PP_CAT(a,j_), AUX778076_BIND_PARAMS(U)> BOOST_PP_CAT(t,j_);
0543         ///
0544 #   else
0545         typedef aux::resolve_bind_arg< BOOST_PP_CAT(T,j_),AUX778076_BIND_PARAMS(U)> BOOST_PP_CAT(t,j_);
0546 
0547 #   endif
0548 #   undef j_
0549 
0550 #endif // BOOST_PP_ITERATION_DEPTH()
0551 #endif // BOOST_PP_IS_ITERATING