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