blob: 28e6374b75c1498cb4915b6941016a0557dcba14 [file] [log] [blame]
Jeff Thompsona28eed82013-08-22 16:21:10 -07001
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 Thompson3d613fd2013-10-15 15:39:04 -070035# define AUX778076_COUNT_ARGS_REPEAT NDNBOOST_MPL_PP_REPEAT
Jeff Thompsona28eed82013-08-22 16:21:10 -070036# define AUX778076_COUNT_ARGS_PARAMS(param) \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070037 NDNBOOST_MPL_PP_PARAMS( \
Jeff Thompsona28eed82013-08-22 16:21:10 -070038 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 Thompson3d613fd2013-10-15 15:39:04 -070049# define AUX778076_COUNT_ARGS_REPEAT NDNBOOST_PP_REPEAT
Jeff Thompsona28eed82013-08-22 16:21:10 -070050# define AUX778076_COUNT_ARGS_PARAMS(param) \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070051 NDNBOOST_PP_ENUM_SHIFTED_PARAMS( \
52 NDNBOOST_PP_INC(AUX778076_COUNT_ARGS_ARITY) \
Jeff Thompsona28eed82013-08-22 16:21:10 -070053 , param \
54 ) \
55 /**/
56
57#endif // AUX778076_COUNT_ARGS_USE_STANDARD_PP_PRIMITIVES
58
59
60#define AUX778076_IS_ARG_TEMPLATE_NAME \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070061 NDNBOOST_PP_CAT(is_,NDNBOOST_PP_CAT(AUX778076_COUNT_ARGS_PREFIX,_arg)) \
Jeff Thompsona28eed82013-08-22 16:21:10 -070062/**/
63
64#define AUX778076_COUNT_ARGS_FUNC(unused, i, param) \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070065 NDNBOOST_PP_EXPR_IF(i, +) \
66 AUX778076_IS_ARG_TEMPLATE_NAME<NDNBOOST_PP_CAT(param,NDNBOOST_PP_INC(i))>::value \
Jeff Thompsona28eed82013-08-22 16:21:10 -070067/**/
68
69// is_<xxx>_arg
70template< AUX778076_COUNT_ARGS_TEMPLATE_PARAM >
71struct AUX778076_IS_ARG_TEMPLATE_NAME
72{
Jeff Thompson3d613fd2013-10-15 15:39:04 -070073 NDNBOOST_STATIC_CONSTANT(bool, value = true);
Jeff Thompsona28eed82013-08-22 16:21:10 -070074};
75
76template<>
77struct AUX778076_IS_ARG_TEMPLATE_NAME<AUX778076_COUNT_ARGS_DEFAULT>
78{
Jeff Thompson3d613fd2013-10-15 15:39:04 -070079 NDNBOOST_STATIC_CONSTANT(bool, value = false);
Jeff Thompsona28eed82013-08-22 16:21:10 -070080};
81
82// <xxx>_count_args
83template<
84 AUX778076_COUNT_ARGS_PARAMS(AUX778076_COUNT_ARGS_TEMPLATE_PARAM)
85 >
Jeff Thompson3d613fd2013-10-15 15:39:04 -070086struct NDNBOOST_PP_CAT(AUX778076_COUNT_ARGS_PREFIX,_count_args)
Jeff Thompsona28eed82013-08-22 16:21:10 -070087{
Jeff Thompson3d613fd2013-10-15 15:39:04 -070088 NDNBOOST_STATIC_CONSTANT(int, value = AUX778076_COUNT_ARGS_REPEAT(
Jeff Thompsona28eed82013-08-22 16:21:10 -070089 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