Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 1 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 2 | #if !defined(NDNBOOST_PP_IS_ITERATING) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 3 | |
| 4 | ///// header body |
| 5 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 6 | #ifndef NDNBOOST_MPL_BIND_HPP_INCLUDED |
| 7 | #define NDNBOOST_MPL_BIND_HPP_INCLUDED |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 8 | |
| 9 | // Copyright Peter Dimov 2001 |
| 10 | // Copyright Aleksey Gurtovoy 2001-2004 |
| 11 | // |
| 12 | // Distributed under the Boost Software License, Version 1.0. |
| 13 | // (See accompanying file LICENSE_1_0.txt or copy at |
| 14 | // http://www.boost.org/LICENSE_1_0.txt) |
| 15 | // |
| 16 | // See http://www.boost.org/libs/mpl for documentation. |
| 17 | |
| 18 | // $Id: bind.hpp 49267 2008-10-11 06:19:02Z agurtovoy $ |
| 19 | // $Date: 2008-10-10 23:19:02 -0700 (Fri, 10 Oct 2008) $ |
| 20 | // $Revision: 49267 $ |
| 21 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 22 | #if !defined(NDNBOOST_MPL_PREPROCESSING_MODE) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 23 | # include <ndnboost/mpl/bind_fwd.hpp> |
| 24 | # include <ndnboost/mpl/placeholders.hpp> |
| 25 | # include <ndnboost/mpl/next.hpp> |
| 26 | # include <ndnboost/mpl/protect.hpp> |
| 27 | # include <ndnboost/mpl/apply_wrap.hpp> |
| 28 | # include <ndnboost/mpl/limits/arity.hpp> |
| 29 | # include <ndnboost/mpl/aux_/na.hpp> |
| 30 | # include <ndnboost/mpl/aux_/arity_spec.hpp> |
| 31 | # include <ndnboost/mpl/aux_/type_wrapper.hpp> |
| 32 | # include <ndnboost/mpl/aux_/yes_no.hpp> |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 33 | # if defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 34 | # include <ndnboost/type_traits/is_reference.hpp> |
| 35 | # endif |
| 36 | #endif |
| 37 | |
| 38 | #include <ndnboost/mpl/aux_/config/bind.hpp> |
| 39 | #include <ndnboost/mpl/aux_/config/static_constant.hpp> |
| 40 | #include <ndnboost/mpl/aux_/config/use_preprocessed.hpp> |
| 41 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 42 | #if !defined(NDNBOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \ |
| 43 | && !defined(NDNBOOST_MPL_PREPROCESSING_MODE) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 44 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 45 | # if defined(NDNBOOST_MPL_CFG_NO_UNNAMED_PLACEHOLDER_SUPPORT) |
| 46 | # define NDNBOOST_MPL_PREPROCESSED_HEADER basic_bind.hpp |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 47 | # else |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 48 | # define NDNBOOST_MPL_PREPROCESSED_HEADER bind.hpp |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 49 | # endif |
| 50 | # include <ndnboost/mpl/aux_/include_preprocessed.hpp> |
| 51 | |
| 52 | #else |
| 53 | |
| 54 | # include <ndnboost/mpl/aux_/preprocessor/params.hpp> |
| 55 | # include <ndnboost/mpl/aux_/preprocessor/default_params.hpp> |
| 56 | # include <ndnboost/mpl/aux_/preprocessor/def_params_tail.hpp> |
| 57 | # include <ndnboost/mpl/aux_/preprocessor/partial_spec_params.hpp> |
| 58 | # include <ndnboost/mpl/aux_/preprocessor/ext_params.hpp> |
| 59 | # include <ndnboost/mpl/aux_/preprocessor/repeat.hpp> |
| 60 | # include <ndnboost/mpl/aux_/preprocessor/enum.hpp> |
| 61 | # include <ndnboost/mpl/aux_/preprocessor/add.hpp> |
| 62 | # include <ndnboost/mpl/aux_/config/dmc_ambiguous_ctps.hpp> |
| 63 | # include <ndnboost/mpl/aux_/config/ctps.hpp> |
| 64 | # include <ndnboost/mpl/aux_/config/ttp.hpp> |
| 65 | # include <ndnboost/mpl/aux_/config/dtp.hpp> |
| 66 | # include <ndnboost/mpl/aux_/nttp_decl.hpp> |
| 67 | |
| 68 | # include <ndnboost/preprocessor/iterate.hpp> |
| 69 | # include <ndnboost/preprocessor/comma_if.hpp> |
| 70 | # include <ndnboost/preprocessor/cat.hpp> |
| 71 | # include <ndnboost/preprocessor/inc.hpp> |
| 72 | |
| 73 | namespace ndnboost { namespace mpl { |
| 74 | |
| 75 | // local macros, #undef-ined at the end of the header |
| 76 | # define AUX778076_APPLY \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 77 | NDNBOOST_PP_CAT(apply_wrap,NDNBOOST_MPL_LIMIT_METAFUNCTION_ARITY) \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 78 | /**/ |
| 79 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 80 | # if defined(NDNBOOST_MPL_CFG_DMC_AMBIGUOUS_CTPS) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 81 | # define AUX778076_DMC_PARAM() , int dummy_ |
| 82 | # else |
| 83 | # define AUX778076_DMC_PARAM() |
| 84 | # endif |
| 85 | |
| 86 | # define AUX778076_BIND_PARAMS(param) \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 87 | NDNBOOST_MPL_PP_PARAMS( \ |
| 88 | NDNBOOST_MPL_LIMIT_METAFUNCTION_ARITY \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 89 | , param \ |
| 90 | ) \ |
| 91 | /**/ |
| 92 | |
| 93 | # define AUX778076_BIND_DEFAULT_PARAMS(param, value) \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 94 | NDNBOOST_MPL_PP_DEFAULT_PARAMS( \ |
| 95 | NDNBOOST_MPL_LIMIT_METAFUNCTION_ARITY \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 96 | , param \ |
| 97 | , value \ |
| 98 | ) \ |
| 99 | /**/ |
| 100 | |
| 101 | # define AUX778076_BIND_N_PARAMS(n, param) \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 102 | NDNBOOST_PP_COMMA_IF(n) NDNBOOST_MPL_PP_PARAMS(n, param) \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 103 | /**/ |
| 104 | |
| 105 | # define AUX778076_BIND_N_SPEC_PARAMS(n, param, def) \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 106 | NDNBOOST_PP_COMMA_IF(n) \ |
| 107 | NDNBOOST_MPL_PP_PARTIAL_SPEC_PARAMS(n, param, def) \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 108 | /**/ |
| 109 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 110 | #if !defined(NDNBOOST_MPL_CFG_NO_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 111 | # define AUX778076_BIND_NESTED_DEFAULT_PARAMS(param, value) \ |
| 112 | AUX778076_BIND_DEFAULT_PARAMS(param, value) \ |
| 113 | /**/ |
| 114 | #else |
| 115 | # define AUX778076_BIND_NESTED_DEFAULT_PARAMS(param, value) \ |
| 116 | AUX778076_BIND_PARAMS(param) \ |
| 117 | /**/ |
| 118 | #endif |
| 119 | |
| 120 | namespace aux { |
| 121 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 122 | #if !defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 123 | |
| 124 | template< |
| 125 | typename T, AUX778076_BIND_PARAMS(typename U) |
| 126 | > |
| 127 | struct resolve_bind_arg |
| 128 | { |
| 129 | typedef T type; |
| 130 | }; |
| 131 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 132 | # if !defined(NDNBOOST_MPL_CFG_NO_UNNAMED_PLACEHOLDER_SUPPORT) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 133 | |
| 134 | template< |
| 135 | typename T |
| 136 | , typename Arg |
| 137 | > |
| 138 | struct replace_unnamed_arg |
| 139 | { |
| 140 | typedef Arg next; |
| 141 | typedef T type; |
| 142 | }; |
| 143 | |
| 144 | template< |
| 145 | typename Arg |
| 146 | > |
| 147 | struct replace_unnamed_arg< arg<-1>,Arg > |
| 148 | { |
| 149 | typedef typename Arg::next next; |
| 150 | typedef Arg type; |
| 151 | }; |
| 152 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 153 | # endif // NDNBOOST_MPL_CFG_NO_UNNAMED_PLACEHOLDER_SUPPORT |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 154 | |
| 155 | template< |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 156 | NDNBOOST_MPL_AUX_NTTP_DECL(int, N), AUX778076_BIND_PARAMS(typename U) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 157 | > |
| 158 | struct resolve_bind_arg< arg<N>,AUX778076_BIND_PARAMS(U) > |
| 159 | { |
| 160 | typedef typename AUX778076_APPLY<mpl::arg<N>, AUX778076_BIND_PARAMS(U)>::type type; |
| 161 | }; |
| 162 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 163 | #if !defined(NDNBOOST_MPL_CFG_NO_BIND_TEMPLATE) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 164 | template< |
| 165 | typename F, AUX778076_BIND_PARAMS(typename T), AUX778076_BIND_PARAMS(typename U) |
| 166 | > |
| 167 | struct resolve_bind_arg< bind<F,AUX778076_BIND_PARAMS(T)>,AUX778076_BIND_PARAMS(U) > |
| 168 | { |
| 169 | typedef bind<F,AUX778076_BIND_PARAMS(T)> f_; |
| 170 | typedef typename AUX778076_APPLY<f_, AUX778076_BIND_PARAMS(U)>::type type; |
| 171 | }; |
| 172 | #endif |
| 173 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 174 | #else // NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 175 | |
| 176 | // agurt, 15/jan/02: it's not a intended to be used as a function class, and |
| 177 | // MSVC6.5 has problems with 'apply' name here (the code compiles, but doesn't |
| 178 | // work), so I went with the 'result_' here, and in all other similar cases |
| 179 | template< bool > |
| 180 | struct resolve_arg_impl |
| 181 | { |
| 182 | template< typename T, AUX778076_BIND_PARAMS(typename U) > struct result_ |
| 183 | { |
| 184 | typedef T type; |
| 185 | }; |
| 186 | }; |
| 187 | |
| 188 | template<> |
| 189 | struct resolve_arg_impl<true> |
| 190 | { |
| 191 | template< typename T, AUX778076_BIND_PARAMS(typename U) > struct result_ |
| 192 | { |
| 193 | typedef typename AUX778076_APPLY< |
| 194 | T |
| 195 | , AUX778076_BIND_PARAMS(U) |
| 196 | >::type type; |
| 197 | }; |
| 198 | }; |
| 199 | |
| 200 | // for 'resolve_bind_arg' |
| 201 | template< typename T > struct is_bind_template; |
| 202 | |
| 203 | template< |
| 204 | typename T, AUX778076_BIND_PARAMS(typename U) |
| 205 | > |
| 206 | struct resolve_bind_arg |
| 207 | : resolve_arg_impl< is_bind_template<T>::value > |
| 208 | ::template result_< T,AUX778076_BIND_PARAMS(U) > |
| 209 | { |
| 210 | }; |
| 211 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 212 | # if !defined(NDNBOOST_MPL_CFG_NO_UNNAMED_PLACEHOLDER_SUPPORT) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 213 | |
| 214 | template< typename T > |
| 215 | struct replace_unnamed_arg_impl |
| 216 | { |
| 217 | template< typename Arg > struct result_ |
| 218 | { |
| 219 | typedef Arg next; |
| 220 | typedef T type; |
| 221 | }; |
| 222 | }; |
| 223 | |
| 224 | template<> |
| 225 | struct replace_unnamed_arg_impl< arg<-1> > |
| 226 | { |
| 227 | template< typename Arg > struct result_ |
| 228 | { |
| 229 | typedef typename next<Arg>::type next; |
| 230 | typedef Arg type; |
| 231 | }; |
| 232 | }; |
| 233 | |
| 234 | template< typename T, typename Arg > |
| 235 | struct replace_unnamed_arg |
| 236 | : replace_unnamed_arg_impl<T>::template result_<Arg> |
| 237 | { |
| 238 | }; |
| 239 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 240 | # endif // NDNBOOST_MPL_CFG_NO_UNNAMED_PLACEHOLDER_SUPPORT |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 241 | |
| 242 | // agurt, 10/mar/02: the forward declaration has to appear before any of |
| 243 | // 'is_bind_helper' overloads, otherwise MSVC6.5 issues an ICE on it |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 244 | template< NDNBOOST_MPL_AUX_NTTP_DECL(int, arity_) > struct bind_chooser; |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 245 | |
| 246 | aux::no_tag is_bind_helper(...); |
| 247 | template< typename T > aux::no_tag is_bind_helper(protect<T>*); |
| 248 | |
| 249 | // overload for "main" form |
| 250 | // agurt, 15/mar/02: MSVC 6.5 fails to properly resolve the overload |
| 251 | // in case if we use 'aux::type_wrapper< bind<...> >' here, and all |
| 252 | // 'bind' instantiations form a complete type anyway |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 253 | #if !defined(NDNBOOST_MPL_CFG_NO_BIND_TEMPLATE) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 254 | template< |
| 255 | typename F, AUX778076_BIND_PARAMS(typename T) |
| 256 | > |
| 257 | aux::yes_tag is_bind_helper(bind<F,AUX778076_BIND_PARAMS(T)>*); |
| 258 | #endif |
| 259 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 260 | template< NDNBOOST_MPL_AUX_NTTP_DECL(int, N) > |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 261 | aux::yes_tag is_bind_helper(arg<N>*); |
| 262 | |
| 263 | template< bool is_ref_ = true > |
| 264 | struct is_bind_template_impl |
| 265 | { |
| 266 | template< typename T > struct result_ |
| 267 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 268 | NDNBOOST_STATIC_CONSTANT(bool, value = false); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 269 | }; |
| 270 | }; |
| 271 | |
| 272 | template<> |
| 273 | struct is_bind_template_impl<false> |
| 274 | { |
| 275 | template< typename T > struct result_ |
| 276 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 277 | NDNBOOST_STATIC_CONSTANT(bool, value = |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 278 | sizeof(aux::is_bind_helper(static_cast<T*>(0))) |
| 279 | == sizeof(aux::yes_tag) |
| 280 | ); |
| 281 | }; |
| 282 | }; |
| 283 | |
| 284 | template< typename T > struct is_bind_template |
| 285 | : is_bind_template_impl< ::ndnboost::detail::is_reference_impl<T>::value > |
| 286 | ::template result_<T> |
| 287 | { |
| 288 | }; |
| 289 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 290 | #endif // NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 291 | |
| 292 | } // namespace aux |
| 293 | |
| 294 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 295 | #define NDNBOOST_PP_ITERATION_PARAMS_1 \ |
| 296 | (3,(0, NDNBOOST_MPL_LIMIT_METAFUNCTION_ARITY, <ndnboost/mpl/bind.hpp>)) |
| 297 | #include NDNBOOST_PP_ITERATE() |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 298 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 299 | #if !defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ |
| 300 | && !defined(NDNBOOST_MPL_CFG_NO_TEMPLATE_TEMPLATE_PARAMETERS) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 301 | /// if_/eval_if specializations |
| 302 | # define AUX778076_SPEC_NAME if_ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 303 | # define NDNBOOST_PP_ITERATION_PARAMS_1 (3,(3, 3, <ndnboost/mpl/bind.hpp>)) |
| 304 | # include NDNBOOST_PP_ITERATE() |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 305 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 306 | #if !defined(NDNBOOST_MPL_CFG_DMC_AMBIGUOUS_CTPS) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 307 | # define AUX778076_SPEC_NAME eval_if |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 308 | # define NDNBOOST_PP_ITERATION_PARAMS_1 (3,(3, 3, <ndnboost/mpl/bind.hpp>)) |
| 309 | # include NDNBOOST_PP_ITERATE() |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 310 | #endif |
| 311 | #endif |
| 312 | |
| 313 | // real C++ version is already taken care of |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 314 | #if defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ |
| 315 | && !defined(NDNBOOST_MPL_CFG_NO_BIND_TEMPLATE) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 316 | |
| 317 | namespace aux { |
| 318 | // apply_count_args |
| 319 | #define AUX778076_COUNT_ARGS_PREFIX bind |
| 320 | #define AUX778076_COUNT_ARGS_DEFAULT na |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 321 | #define AUX778076_COUNT_ARGS_ARITY NDNBOOST_MPL_LIMIT_METAFUNCTION_ARITY |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 322 | #include <ndnboost/mpl/aux_/count_args.hpp> |
| 323 | } |
| 324 | |
| 325 | // bind |
| 326 | template< |
| 327 | typename F, AUX778076_BIND_PARAMS(typename T) AUX778076_DMC_PARAM() |
| 328 | > |
| 329 | struct bind |
| 330 | : aux::bind_chooser< |
| 331 | aux::bind_count_args<AUX778076_BIND_PARAMS(T)>::value |
| 332 | >::template result_< F,AUX778076_BIND_PARAMS(T) >::type |
| 333 | { |
| 334 | }; |
| 335 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 336 | NDNBOOST_MPL_AUX_ARITY_SPEC( |
| 337 | NDNBOOST_PP_INC(NDNBOOST_MPL_LIMIT_METAFUNCTION_ARITY) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 338 | , bind |
| 339 | ) |
| 340 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 341 | NDNBOOST_MPL_AUX_TEMPLATE_ARITY_SPEC( |
| 342 | NDNBOOST_PP_INC(NDNBOOST_MPL_LIMIT_METAFUNCTION_ARITY) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 343 | , bind |
| 344 | ) |
| 345 | |
| 346 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 347 | #endif // NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 348 | |
| 349 | # undef AUX778076_BIND_NESTED_DEFAULT_PARAMS |
| 350 | # undef AUX778076_BIND_N_SPEC_PARAMS |
| 351 | # undef AUX778076_BIND_N_PARAMS |
| 352 | # undef AUX778076_BIND_DEFAULT_PARAMS |
| 353 | # undef AUX778076_BIND_PARAMS |
| 354 | # undef AUX778076_DMC_PARAM |
| 355 | # undef AUX778076_APPLY |
| 356 | |
| 357 | }} |
| 358 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 359 | #endif // NDNBOOST_MPL_CFG_NO_PREPROCESSED_HEADERS |
| 360 | #endif // NDNBOOST_MPL_BIND_HPP_INCLUDED |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 361 | |
| 362 | ///// iteration, depth == 1 |
| 363 | |
| 364 | // For gcc 4.4 compatability, we must include the |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 365 | // NDNBOOST_PP_ITERATION_DEPTH test inside an #else clause. |
| 366 | #else // NDNBOOST_PP_IS_ITERATING |
| 367 | #if NDNBOOST_PP_ITERATION_DEPTH() == 1 |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 368 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 369 | # define i_ NDNBOOST_PP_FRAME_ITERATION(1) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 370 | |
| 371 | #if defined(AUX778076_SPEC_NAME) |
| 372 | |
| 373 | // lazy metafunction specialization |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 374 | template< template< NDNBOOST_MPL_PP_PARAMS(i_, typename T) > class F, typename Tag > |
| 375 | struct NDNBOOST_PP_CAT(quote,i_); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 376 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 377 | template< NDNBOOST_MPL_PP_PARAMS(i_, typename T) > struct AUX778076_SPEC_NAME; |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 378 | |
| 379 | template< |
| 380 | typename Tag AUX778076_BIND_N_PARAMS(i_, typename T) |
| 381 | > |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 382 | struct NDNBOOST_PP_CAT(bind,i_)< |
| 383 | NDNBOOST_PP_CAT(quote,i_)<AUX778076_SPEC_NAME,Tag> |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 384 | AUX778076_BIND_N_PARAMS(i_,T) |
| 385 | > |
| 386 | { |
| 387 | template< |
| 388 | AUX778076_BIND_NESTED_DEFAULT_PARAMS(typename U, na) |
| 389 | > |
| 390 | struct apply |
| 391 | { |
| 392 | private: |
| 393 | typedef mpl::arg<1> n1; |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 394 | # define NDNBOOST_PP_ITERATION_PARAMS_2 (3,(1, i_, <ndnboost/mpl/bind.hpp>)) |
| 395 | # include NDNBOOST_PP_ITERATE() |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 396 | |
| 397 | typedef typename AUX778076_SPEC_NAME< |
| 398 | typename t1::type |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 399 | , NDNBOOST_MPL_PP_EXT_PARAMS(2, NDNBOOST_PP_INC(i_), t) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 400 | >::type f_; |
| 401 | |
| 402 | public: |
| 403 | typedef typename f_::type type; |
| 404 | }; |
| 405 | }; |
| 406 | |
| 407 | #undef AUX778076_SPEC_NAME |
| 408 | |
| 409 | #else // AUX778076_SPEC_NAME |
| 410 | |
| 411 | template< |
| 412 | typename F AUX778076_BIND_N_PARAMS(i_, typename T) AUX778076_DMC_PARAM() |
| 413 | > |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 414 | struct NDNBOOST_PP_CAT(bind,i_) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 415 | { |
| 416 | template< |
| 417 | AUX778076_BIND_NESTED_DEFAULT_PARAMS(typename U, na) |
| 418 | > |
| 419 | struct apply |
| 420 | { |
| 421 | private: |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 422 | # if !defined(NDNBOOST_MPL_CFG_NO_UNNAMED_PLACEHOLDER_SUPPORT) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 423 | |
| 424 | typedef aux::replace_unnamed_arg< F,mpl::arg<1> > r0; |
| 425 | typedef typename r0::type a0; |
| 426 | typedef typename r0::next n1; |
| 427 | typedef typename aux::resolve_bind_arg<a0,AUX778076_BIND_PARAMS(U)>::type f_; |
| 428 | /// |
| 429 | # else |
| 430 | typedef typename aux::resolve_bind_arg<F,AUX778076_BIND_PARAMS(U)>::type f_; |
| 431 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 432 | # endif // NDNBOOST_MPL_CFG_NO_UNNAMED_PLACEHOLDER_SUPPORT |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 433 | |
| 434 | # if i_ > 0 |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 435 | # define NDNBOOST_PP_ITERATION_PARAMS_2 (3,(1, i_, <ndnboost/mpl/bind.hpp>)) |
| 436 | # include NDNBOOST_PP_ITERATE() |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 437 | # endif |
| 438 | |
| 439 | public: |
| 440 | |
| 441 | # define AUX778076_ARG(unused, i_, t) \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 442 | NDNBOOST_PP_COMMA_IF(i_) \ |
| 443 | typename NDNBOOST_PP_CAT(t,NDNBOOST_PP_INC(i_))::type \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 444 | /**/ |
| 445 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 446 | typedef typename NDNBOOST_PP_CAT(apply_wrap,i_)< |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 447 | f_ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 448 | NDNBOOST_PP_COMMA_IF(i_) NDNBOOST_MPL_PP_REPEAT(i_, AUX778076_ARG, t) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 449 | >::type type; |
| 450 | |
| 451 | # undef AUX778076_ARG |
| 452 | }; |
| 453 | }; |
| 454 | |
| 455 | namespace aux { |
| 456 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 457 | #if !defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 458 | |
| 459 | template< |
| 460 | typename F AUX778076_BIND_N_PARAMS(i_, typename T), AUX778076_BIND_PARAMS(typename U) |
| 461 | > |
| 462 | struct resolve_bind_arg< |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 463 | NDNBOOST_PP_CAT(bind,i_)<F AUX778076_BIND_N_PARAMS(i_,T)>,AUX778076_BIND_PARAMS(U) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 464 | > |
| 465 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 466 | typedef NDNBOOST_PP_CAT(bind,i_)<F AUX778076_BIND_N_PARAMS(i_,T)> f_; |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 467 | typedef typename AUX778076_APPLY<f_, AUX778076_BIND_PARAMS(U)>::type type; |
| 468 | }; |
| 469 | |
| 470 | #else |
| 471 | |
| 472 | template< |
| 473 | typename F AUX778076_BIND_N_PARAMS(i_, typename T) |
| 474 | > |
| 475 | aux::yes_tag |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 476 | is_bind_helper(NDNBOOST_PP_CAT(bind,i_)<F AUX778076_BIND_N_PARAMS(i_,T)>*); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 477 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 478 | #endif // NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 479 | |
| 480 | } // namespace aux |
| 481 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 482 | NDNBOOST_MPL_AUX_ARITY_SPEC(NDNBOOST_PP_INC(i_), NDNBOOST_PP_CAT(bind,i_)) |
| 483 | NDNBOOST_MPL_AUX_TEMPLATE_ARITY_SPEC(NDNBOOST_PP_INC(i_), NDNBOOST_PP_CAT(bind,i_)) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 484 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 485 | # if !defined(NDNBOOST_MPL_CFG_NO_BIND_TEMPLATE) |
| 486 | # if !defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 487 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 488 | #if i_ == NDNBOOST_MPL_LIMIT_METAFUNCTION_ARITY |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 489 | /// primary template (not a specialization!) |
| 490 | template< |
| 491 | typename F AUX778076_BIND_N_PARAMS(i_, typename T) AUX778076_DMC_PARAM() |
| 492 | > |
| 493 | struct bind |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 494 | : NDNBOOST_PP_CAT(bind,i_)<F AUX778076_BIND_N_PARAMS(i_,T) > |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 495 | { |
| 496 | }; |
| 497 | #else |
| 498 | template< |
| 499 | typename F AUX778076_BIND_N_PARAMS(i_, typename T) AUX778076_DMC_PARAM() |
| 500 | > |
| 501 | struct bind< F AUX778076_BIND_N_SPEC_PARAMS(i_, T, na) > |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 502 | : NDNBOOST_PP_CAT(bind,i_)<F AUX778076_BIND_N_PARAMS(i_,T) > |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 503 | { |
| 504 | }; |
| 505 | #endif |
| 506 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 507 | # else // NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 508 | |
| 509 | namespace aux { |
| 510 | |
| 511 | template<> |
| 512 | struct bind_chooser<i_> |
| 513 | { |
| 514 | template< |
| 515 | typename F, AUX778076_BIND_PARAMS(typename T) |
| 516 | > |
| 517 | struct result_ |
| 518 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 519 | typedef NDNBOOST_PP_CAT(bind,i_)< F AUX778076_BIND_N_PARAMS(i_,T) > type; |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 520 | }; |
| 521 | }; |
| 522 | |
| 523 | } // namespace aux |
| 524 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 525 | # endif // NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION |
| 526 | # endif // NDNBOOST_MPL_CFG_NO_BIND_TEMPLATE |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 527 | |
| 528 | #endif // AUX778076_SPEC_NAME |
| 529 | |
| 530 | # undef i_ |
| 531 | |
| 532 | ///// iteration, depth == 2 |
| 533 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 534 | #elif NDNBOOST_PP_ITERATION_DEPTH() == 2 |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 535 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 536 | # define j_ NDNBOOST_PP_FRAME_ITERATION(2) |
| 537 | # if !defined(NDNBOOST_MPL_CFG_NO_UNNAMED_PLACEHOLDER_SUPPORT) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 538 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 539 | typedef aux::replace_unnamed_arg< NDNBOOST_PP_CAT(T,j_),NDNBOOST_PP_CAT(n,j_) > NDNBOOST_PP_CAT(r,j_); |
| 540 | typedef typename NDNBOOST_PP_CAT(r,j_)::type NDNBOOST_PP_CAT(a,j_); |
| 541 | typedef typename NDNBOOST_PP_CAT(r,j_)::next NDNBOOST_PP_CAT(n,NDNBOOST_PP_INC(j_)); |
| 542 | typedef aux::resolve_bind_arg<NDNBOOST_PP_CAT(a,j_), AUX778076_BIND_PARAMS(U)> NDNBOOST_PP_CAT(t,j_); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 543 | /// |
| 544 | # else |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 545 | typedef aux::resolve_bind_arg< NDNBOOST_PP_CAT(T,j_),AUX778076_BIND_PARAMS(U)> NDNBOOST_PP_CAT(t,j_); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 546 | |
| 547 | # endif |
| 548 | # undef j_ |
| 549 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 550 | #endif // NDNBOOST_PP_ITERATION_DEPTH() |
| 551 | #endif // NDNBOOST_PP_IS_ITERATING |