Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 1 | |
| 2 | // NO INCLUDE GUARDS, THE HEADER IS INTENDED FOR MULTIPLE INCLUSION |
| 3 | |
| 4 | // Copyright Aleksey Gurtovoy 2000-2004 |
| 5 | // |
| 6 | // Distributed under the Boost Software License, Version 1.0. |
| 7 | // (See accompanying file LICENSE_1_0.txt or copy at |
| 8 | // http://www.boost.org/LICENSE_1_0.txt) |
| 9 | // |
| 10 | // See http://www.boost.org/libs/mpl for documentation. |
| 11 | |
| 12 | // $Id: count_args.hpp 49267 2008-10-11 06:19:02Z agurtovoy $ |
| 13 | // $Date: 2008-10-10 23:19:02 -0700 (Fri, 10 Oct 2008) $ |
| 14 | // $Revision: 49267 $ |
| 15 | |
| 16 | #include <ndnboost/preprocessor/expr_if.hpp> |
| 17 | #include <ndnboost/preprocessor/inc.hpp> |
| 18 | #include <ndnboost/preprocessor/cat.hpp> |
| 19 | |
| 20 | #if !defined(AUX778076_COUNT_ARGS_PARAM_NAME) |
| 21 | # define AUX778076_COUNT_ARGS_PARAM_NAME T |
| 22 | #endif |
| 23 | |
| 24 | #if !defined(AUX778076_COUNT_ARGS_TEMPLATE_PARAM) |
| 25 | # define AUX778076_COUNT_ARGS_TEMPLATE_PARAM typename AUX778076_COUNT_ARGS_PARAM_NAME |
| 26 | #endif |
| 27 | |
| 28 | // local macros, #undef-ined at the end of the header |
| 29 | |
| 30 | #if !defined(AUX778076_COUNT_ARGS_USE_STANDARD_PP_PRIMITIVES) |
| 31 | |
| 32 | # include <ndnboost/mpl/aux_/preprocessor/repeat.hpp> |
| 33 | # include <ndnboost/mpl/aux_/preprocessor/params.hpp> |
| 34 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 35 | # define AUX778076_COUNT_ARGS_REPEAT NDNBOOST_MPL_PP_REPEAT |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 36 | # define AUX778076_COUNT_ARGS_PARAMS(param) \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 37 | NDNBOOST_MPL_PP_PARAMS( \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 38 | AUX778076_COUNT_ARGS_ARITY \ |
| 39 | , param \ |
| 40 | ) \ |
| 41 | /**/ |
| 42 | |
| 43 | #else |
| 44 | |
| 45 | # include <ndnboost/preprocessor/enum_shifted_params.hpp> |
| 46 | # include <ndnboost/preprocessor/repeat.hpp> |
| 47 | # include <ndnboost/preprocessor/inc.hpp> |
| 48 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 49 | # define AUX778076_COUNT_ARGS_REPEAT NDNBOOST_PP_REPEAT |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 50 | # define AUX778076_COUNT_ARGS_PARAMS(param) \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 51 | NDNBOOST_PP_ENUM_SHIFTED_PARAMS( \ |
| 52 | NDNBOOST_PP_INC(AUX778076_COUNT_ARGS_ARITY) \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 53 | , param \ |
| 54 | ) \ |
| 55 | /**/ |
| 56 | |
| 57 | #endif // AUX778076_COUNT_ARGS_USE_STANDARD_PP_PRIMITIVES |
| 58 | |
| 59 | |
| 60 | #define AUX778076_IS_ARG_TEMPLATE_NAME \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 61 | NDNBOOST_PP_CAT(is_,NDNBOOST_PP_CAT(AUX778076_COUNT_ARGS_PREFIX,_arg)) \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 62 | /**/ |
| 63 | |
| 64 | #define AUX778076_COUNT_ARGS_FUNC(unused, i, param) \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 65 | NDNBOOST_PP_EXPR_IF(i, +) \ |
| 66 | AUX778076_IS_ARG_TEMPLATE_NAME<NDNBOOST_PP_CAT(param,NDNBOOST_PP_INC(i))>::value \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 67 | /**/ |
| 68 | |
| 69 | // is_<xxx>_arg |
| 70 | template< AUX778076_COUNT_ARGS_TEMPLATE_PARAM > |
| 71 | struct AUX778076_IS_ARG_TEMPLATE_NAME |
| 72 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 73 | NDNBOOST_STATIC_CONSTANT(bool, value = true); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 74 | }; |
| 75 | |
| 76 | template<> |
| 77 | struct AUX778076_IS_ARG_TEMPLATE_NAME<AUX778076_COUNT_ARGS_DEFAULT> |
| 78 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 79 | NDNBOOST_STATIC_CONSTANT(bool, value = false); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 80 | }; |
| 81 | |
| 82 | // <xxx>_count_args |
| 83 | template< |
| 84 | AUX778076_COUNT_ARGS_PARAMS(AUX778076_COUNT_ARGS_TEMPLATE_PARAM) |
| 85 | > |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 86 | struct NDNBOOST_PP_CAT(AUX778076_COUNT_ARGS_PREFIX,_count_args) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 87 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 88 | NDNBOOST_STATIC_CONSTANT(int, value = AUX778076_COUNT_ARGS_REPEAT( |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 89 | AUX778076_COUNT_ARGS_ARITY |
| 90 | , AUX778076_COUNT_ARGS_FUNC |
| 91 | , AUX778076_COUNT_ARGS_PARAM_NAME |
| 92 | )); |
| 93 | }; |
| 94 | |
| 95 | #undef AUX778076_COUNT_ARGS_FUNC |
| 96 | #undef AUX778076_IS_ARG_TEMPLATE_NAME |
| 97 | #undef AUX778076_COUNT_ARGS_PARAMS |
| 98 | #undef AUX778076_COUNT_ARGS_REPEAT |
| 99 | |
| 100 | #undef AUX778076_COUNT_ARGS_ARITY |
| 101 | #undef AUX778076_COUNT_ARGS_DEFAULT |
| 102 | #undef AUX778076_COUNT_ARGS_PREFIX |
| 103 | #undef AUX778076_COUNT_ARGS_USE_STANDARD_PP_PRIMITIVES |
| 104 | #undef AUX778076_COUNT_ARGS_TEMPLATE_PARAM |
| 105 | #undef AUX778076_COUNT_ARGS_PARAM_NAME |