2 #if !defined(BOOST_PP_IS_ITERATING)
6 #ifndef BOOST_MPL_AUX_TEMPLATE_ARITY_HPP_INCLUDED
7 #define BOOST_MPL_AUX_TEMPLATE_ARITY_HPP_INCLUDED
9 // Copyright Aleksey Gurtovoy 2001-2004
11 // Distributed under the Boost Software License, Version 1.0.
12 // (See accompanying file LICENSE_1_0.txt or copy at
13 // http://www.boost.org/LICENSE_1_0.txt)
15 // See http://www.boost.org/libs/mpl for documentation.
17 // $Source: /cvsroot/boost/boost/boost/mpl/aux_/template_arity.hpp,v $
18 // $Date: 2004/09/07 12:24:48 $
21 #include <boost/mpl/aux_/config/ttp.hpp>
22 #include <boost/mpl/aux_/config/lambda.hpp>
24 #if !defined(BOOST_MPL_PREPROCESSING_MODE)
25 # include <boost/mpl/aux_/template_arity_fwd.hpp>
26 # include <boost/mpl/int.hpp>
27 # if !defined(BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT)
28 # if defined(BOOST_MPL_CFG_EXTENDED_TEMPLATE_PARAMETERS_MATCHING)
29 # include <boost/mpl/aux_/type_wrapper.hpp>
32 # include <boost/mpl/aux_/has_rebind.hpp>
36 #include <boost/mpl/aux_/config/static_constant.hpp>
37 #include <boost/mpl/aux_/config/use_preprocessed.hpp>
39 #if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
40 && !defined(BOOST_MPL_PREPROCESSING_MODE)
42 # define BOOST_MPL_PREPROCESSED_HEADER template_arity.hpp
43 # include <boost/mpl/aux_/include_preprocessed.hpp>
47 # if !defined(BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT)
48 # if defined(BOOST_MPL_CFG_EXTENDED_TEMPLATE_PARAMETERS_MATCHING)
50 # include <boost/mpl/limits/arity.hpp>
51 # include <boost/mpl/aux_/preprocessor/range.hpp>
52 # include <boost/mpl/aux_/preprocessor/repeat.hpp>
53 # include <boost/mpl/aux_/preprocessor/params.hpp>
54 # include <boost/mpl/aux_/nttp_decl.hpp>
56 # include <boost/preprocessor/seq/fold_left.hpp>
57 # include <boost/preprocessor/comma_if.hpp>
58 # include <boost/preprocessor/iterate.hpp>
59 # include <boost/preprocessor/inc.hpp>
60 # include <boost/preprocessor/cat.hpp>
62 # define AUX778076_ARITY BOOST_PP_INC(BOOST_MPL_LIMIT_METAFUNCTION_ARITY)
64 namespace boost { namespace mpl { namespace aux {
66 template< BOOST_MPL_AUX_NTTP_DECL(int, N) > struct arity_tag
68 typedef char (&type)[N + 1];
71 # define AUX778076_MAX_ARITY_OP(unused, state, i_) \
72 ( BOOST_PP_CAT(C,i_) > 0 ? BOOST_PP_CAT(C,i_) : state ) \
76 BOOST_MPL_PP_PARAMS(AUX778076_ARITY, BOOST_MPL_AUX_NTTP_DECL(int, C))
80 BOOST_STATIC_CONSTANT(int, value =
81 BOOST_PP_SEQ_FOLD_LEFT(
82 AUX778076_MAX_ARITY_OP
84 , BOOST_MPL_PP_RANGE(1, AUX778076_ARITY)
89 # undef AUX778076_MAX_ARITY_OP
91 arity_tag<0>::type arity_helper(...);
93 # define BOOST_PP_ITERATION_LIMITS (1, AUX778076_ARITY)
94 # define BOOST_PP_FILENAME_1 <boost/mpl/aux_/template_arity.hpp>
95 # include BOOST_PP_ITERATE()
97 template< typename F, BOOST_MPL_AUX_NTTP_DECL(int, N) >
98 struct template_arity_impl
100 BOOST_STATIC_CONSTANT(int, value =
101 sizeof(arity_helper(type_wrapper<F>(),arity_tag<N>())) - 1
105 # define AUX778076_TEMPLATE_ARITY_IMPL_INVOCATION(unused, i_, F) \
106 BOOST_PP_COMMA_IF(i_) template_arity_impl<F,BOOST_PP_INC(i_)>::value \
109 template< typename F >
110 struct template_arity
112 BOOST_STATIC_CONSTANT(int, value = (
113 max_arity< BOOST_MPL_PP_REPEAT(
115 , AUX778076_TEMPLATE_ARITY_IMPL_INVOCATION
120 typedef mpl::int_<value> type;
123 # undef AUX778076_TEMPLATE_ARITY_IMPL_INVOCATION
125 # undef AUX778076_ARITY
129 # endif // BOOST_MPL_CFG_EXTENDED_TEMPLATE_PARAMETERS_MATCHING
130 # else // BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT
132 # include <boost/mpl/aux_/config/eti.hpp>
134 namespace boost { namespace mpl { namespace aux {
137 struct template_arity_impl
139 template< typename F > struct result_
146 struct template_arity_impl<true>
148 template< typename F > struct result_
154 template< typename F >
155 struct template_arity
156 : template_arity_impl< ::boost::mpl::aux::has_rebind<F>::value >
157 ::template result_<F>
161 #if defined(BOOST_MPL_CFG_MSVC_ETI_BUG)
163 struct template_arity<int>
171 # endif // BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT
173 #endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
174 #endif // BOOST_MPL_AUX_TEMPLATE_ARITY_HPP_INCLUDED
179 #define i_ BOOST_PP_FRAME_ITERATION(1)
182 template< BOOST_MPL_PP_PARAMS(i_, typename P) > class F
183 , BOOST_MPL_PP_PARAMS(i_, typename T)
185 typename arity_tag<i_>::type
186 arity_helper(type_wrapper< F<BOOST_MPL_PP_PARAMS(i_, T)> >, arity_tag<i_>);
189 #endif // BOOST_PP_IS_ITERATING