Chris@16
|
1
|
Chris@16
|
2 #if !defined(BOOST_PP_IS_ITERATING)
|
Chris@16
|
3
|
Chris@16
|
4 ///// header body
|
Chris@16
|
5
|
Chris@16
|
6 #ifndef BOOST_MPL_AUX_TEMPLATE_ARITY_HPP_INCLUDED
|
Chris@16
|
7 #define BOOST_MPL_AUX_TEMPLATE_ARITY_HPP_INCLUDED
|
Chris@16
|
8
|
Chris@16
|
9 // Copyright Aleksey Gurtovoy 2001-2004
|
Chris@16
|
10 //
|
Chris@16
|
11 // Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
12 // (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
13 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
14 //
|
Chris@16
|
15 // See http://www.boost.org/libs/mpl for documentation.
|
Chris@16
|
16
|
Chris@101
|
17 // $Id$
|
Chris@101
|
18 // $Date$
|
Chris@101
|
19 // $Revision$
|
Chris@16
|
20
|
Chris@16
|
21 #include <boost/mpl/aux_/config/ttp.hpp>
|
Chris@16
|
22 #include <boost/mpl/aux_/config/lambda.hpp>
|
Chris@16
|
23
|
Chris@16
|
24 #if !defined(BOOST_MPL_PREPROCESSING_MODE)
|
Chris@16
|
25 # include <boost/mpl/aux_/template_arity_fwd.hpp>
|
Chris@16
|
26 # include <boost/mpl/int.hpp>
|
Chris@16
|
27 # if !defined(BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT)
|
Chris@16
|
28 # if defined(BOOST_MPL_CFG_EXTENDED_TEMPLATE_PARAMETERS_MATCHING)
|
Chris@16
|
29 # include <boost/mpl/aux_/type_wrapper.hpp>
|
Chris@16
|
30 # endif
|
Chris@16
|
31 # else
|
Chris@16
|
32 # include <boost/mpl/aux_/has_rebind.hpp>
|
Chris@16
|
33 # endif
|
Chris@16
|
34 #endif
|
Chris@16
|
35
|
Chris@16
|
36 #include <boost/mpl/aux_/config/static_constant.hpp>
|
Chris@16
|
37 #include <boost/mpl/aux_/config/use_preprocessed.hpp>
|
Chris@16
|
38
|
Chris@16
|
39 #if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
|
Chris@16
|
40 && !defined(BOOST_MPL_PREPROCESSING_MODE)
|
Chris@16
|
41
|
Chris@16
|
42 # define BOOST_MPL_PREPROCESSED_HEADER template_arity.hpp
|
Chris@16
|
43 # include <boost/mpl/aux_/include_preprocessed.hpp>
|
Chris@16
|
44
|
Chris@16
|
45 #else
|
Chris@16
|
46
|
Chris@16
|
47 # if !defined(BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT)
|
Chris@16
|
48 # if defined(BOOST_MPL_CFG_EXTENDED_TEMPLATE_PARAMETERS_MATCHING)
|
Chris@16
|
49
|
Chris@16
|
50 # include <boost/mpl/limits/arity.hpp>
|
Chris@16
|
51 # include <boost/mpl/aux_/preprocessor/range.hpp>
|
Chris@16
|
52 # include <boost/mpl/aux_/preprocessor/repeat.hpp>
|
Chris@16
|
53 # include <boost/mpl/aux_/preprocessor/params.hpp>
|
Chris@16
|
54 # include <boost/mpl/aux_/nttp_decl.hpp>
|
Chris@16
|
55
|
Chris@16
|
56 # include <boost/preprocessor/seq/fold_left.hpp>
|
Chris@16
|
57 # include <boost/preprocessor/comma_if.hpp>
|
Chris@16
|
58 # include <boost/preprocessor/iterate.hpp>
|
Chris@16
|
59 # include <boost/preprocessor/inc.hpp>
|
Chris@16
|
60 # include <boost/preprocessor/cat.hpp>
|
Chris@16
|
61
|
Chris@16
|
62 # define AUX778076_ARITY BOOST_PP_INC(BOOST_MPL_LIMIT_METAFUNCTION_ARITY)
|
Chris@16
|
63
|
Chris@16
|
64 namespace boost { namespace mpl { namespace aux {
|
Chris@16
|
65
|
Chris@16
|
66 template< BOOST_MPL_AUX_NTTP_DECL(int, N) > struct arity_tag
|
Chris@16
|
67 {
|
Chris@16
|
68 typedef char (&type)[N + 1];
|
Chris@16
|
69 };
|
Chris@16
|
70
|
Chris@16
|
71 # define AUX778076_MAX_ARITY_OP(unused, state, i_) \
|
Chris@16
|
72 ( BOOST_PP_CAT(C,i_) > 0 ? BOOST_PP_CAT(C,i_) : state ) \
|
Chris@16
|
73 /**/
|
Chris@16
|
74
|
Chris@16
|
75 template<
|
Chris@16
|
76 BOOST_MPL_PP_PARAMS(AUX778076_ARITY, BOOST_MPL_AUX_NTTP_DECL(int, C))
|
Chris@16
|
77 >
|
Chris@16
|
78 struct max_arity
|
Chris@16
|
79 {
|
Chris@16
|
80 BOOST_STATIC_CONSTANT(int, value =
|
Chris@16
|
81 BOOST_PP_SEQ_FOLD_LEFT(
|
Chris@16
|
82 AUX778076_MAX_ARITY_OP
|
Chris@16
|
83 , -1
|
Chris@16
|
84 , BOOST_MPL_PP_RANGE(1, AUX778076_ARITY)
|
Chris@16
|
85 )
|
Chris@16
|
86 );
|
Chris@16
|
87 };
|
Chris@16
|
88
|
Chris@16
|
89 # undef AUX778076_MAX_ARITY_OP
|
Chris@16
|
90
|
Chris@16
|
91 arity_tag<0>::type arity_helper(...);
|
Chris@16
|
92
|
Chris@16
|
93 # define BOOST_PP_ITERATION_LIMITS (1, AUX778076_ARITY)
|
Chris@16
|
94 # define BOOST_PP_FILENAME_1 <boost/mpl/aux_/template_arity.hpp>
|
Chris@16
|
95 # include BOOST_PP_ITERATE()
|
Chris@16
|
96
|
Chris@16
|
97 template< typename F, BOOST_MPL_AUX_NTTP_DECL(int, N) >
|
Chris@16
|
98 struct template_arity_impl
|
Chris@16
|
99 {
|
Chris@16
|
100 BOOST_STATIC_CONSTANT(int, value =
|
Chris@16
|
101 sizeof(::boost::mpl::aux::arity_helper(type_wrapper<F>(),arity_tag<N>())) - 1
|
Chris@16
|
102 );
|
Chris@16
|
103 };
|
Chris@16
|
104
|
Chris@16
|
105 # define AUX778076_TEMPLATE_ARITY_IMPL_INVOCATION(unused, i_, F) \
|
Chris@16
|
106 BOOST_PP_COMMA_IF(i_) template_arity_impl<F,BOOST_PP_INC(i_)>::value \
|
Chris@16
|
107 /**/
|
Chris@16
|
108
|
Chris@16
|
109 template< typename F >
|
Chris@16
|
110 struct template_arity
|
Chris@16
|
111 {
|
Chris@16
|
112 BOOST_STATIC_CONSTANT(int, value = (
|
Chris@16
|
113 max_arity< BOOST_MPL_PP_REPEAT(
|
Chris@16
|
114 AUX778076_ARITY
|
Chris@16
|
115 , AUX778076_TEMPLATE_ARITY_IMPL_INVOCATION
|
Chris@16
|
116 , F
|
Chris@16
|
117 ) >::value
|
Chris@16
|
118 ));
|
Chris@16
|
119
|
Chris@16
|
120 typedef mpl::int_<value> type;
|
Chris@16
|
121 };
|
Chris@16
|
122
|
Chris@16
|
123 # undef AUX778076_TEMPLATE_ARITY_IMPL_INVOCATION
|
Chris@16
|
124
|
Chris@16
|
125 # undef AUX778076_ARITY
|
Chris@16
|
126
|
Chris@16
|
127 }}}
|
Chris@16
|
128
|
Chris@16
|
129 # endif // BOOST_MPL_CFG_EXTENDED_TEMPLATE_PARAMETERS_MATCHING
|
Chris@16
|
130 # else // BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT
|
Chris@16
|
131
|
Chris@16
|
132 # include <boost/mpl/aux_/config/eti.hpp>
|
Chris@16
|
133
|
Chris@16
|
134 namespace boost { namespace mpl { namespace aux {
|
Chris@16
|
135
|
Chris@16
|
136 template< bool >
|
Chris@16
|
137 struct template_arity_impl
|
Chris@16
|
138 {
|
Chris@16
|
139 template< typename F > struct result_
|
Chris@16
|
140 : mpl::int_<-1>
|
Chris@16
|
141 {
|
Chris@16
|
142 };
|
Chris@16
|
143 };
|
Chris@16
|
144
|
Chris@16
|
145 template<>
|
Chris@16
|
146 struct template_arity_impl<true>
|
Chris@16
|
147 {
|
Chris@16
|
148 template< typename F > struct result_
|
Chris@16
|
149 : F::arity
|
Chris@16
|
150 {
|
Chris@16
|
151 };
|
Chris@16
|
152 };
|
Chris@16
|
153
|
Chris@16
|
154 template< typename F >
|
Chris@16
|
155 struct template_arity
|
Chris@16
|
156 : template_arity_impl< ::boost::mpl::aux::has_rebind<F>::value >
|
Chris@16
|
157 ::template result_<F>
|
Chris@16
|
158 {
|
Chris@16
|
159 };
|
Chris@16
|
160
|
Chris@16
|
161 #if defined(BOOST_MPL_CFG_MSVC_ETI_BUG)
|
Chris@16
|
162 template<>
|
Chris@16
|
163 struct template_arity<int>
|
Chris@16
|
164 : mpl::int_<-1>
|
Chris@16
|
165 {
|
Chris@16
|
166 };
|
Chris@16
|
167 #endif
|
Chris@16
|
168
|
Chris@16
|
169 }}}
|
Chris@16
|
170
|
Chris@16
|
171 # endif // BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT
|
Chris@16
|
172
|
Chris@16
|
173 #endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
|
Chris@16
|
174 #endif // BOOST_MPL_AUX_TEMPLATE_ARITY_HPP_INCLUDED
|
Chris@16
|
175
|
Chris@16
|
176 ///// iteration
|
Chris@16
|
177
|
Chris@16
|
178 #else
|
Chris@16
|
179 #define i_ BOOST_PP_FRAME_ITERATION(1)
|
Chris@16
|
180
|
Chris@16
|
181 template<
|
Chris@16
|
182 template< BOOST_MPL_PP_PARAMS(i_, typename P) > class F
|
Chris@16
|
183 , BOOST_MPL_PP_PARAMS(i_, typename T)
|
Chris@16
|
184 >
|
Chris@16
|
185 typename arity_tag<i_>::type
|
Chris@16
|
186 arity_helper(type_wrapper< F<BOOST_MPL_PP_PARAMS(i_, T)> >, arity_tag<i_>);
|
Chris@16
|
187
|
Chris@16
|
188 #undef i_
|
Chris@16
|
189 #endif // BOOST_PP_IS_ITERATING
|