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