]> AND Private Git Repository - canny.git/blob - stc/exp/ml_stc_linux_make_v1.0/include/boost/mpl/aux_/template_arity.hpp
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
157fe5646c1017fb9e962c5e1c641170f1a64028
[canny.git] / stc / exp / ml_stc_linux_make_v1.0 / include / boost / mpl / aux_ / template_arity.hpp
1 \r
2 #if !defined(BOOST_PP_IS_ITERATING)\r
3 \r
4 ///// header body\r
5 \r
6 #ifndef BOOST_MPL_AUX_TEMPLATE_ARITY_HPP_INCLUDED\r
7 #define BOOST_MPL_AUX_TEMPLATE_ARITY_HPP_INCLUDED\r
8 \r
9 // Copyright Aleksey Gurtovoy 2001-2004\r
10 //\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
14 //\r
15 // See http://www.boost.org/libs/mpl for documentation.\r
16 \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
20 \r
21 #include <boost/mpl/aux_/config/ttp.hpp>\r
22 #include <boost/mpl/aux_/config/lambda.hpp>\r
23 \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
30 #   endif\r
31 #   else\r
32 #       include <boost/mpl/aux_/has_rebind.hpp>\r
33 #   endif\r
34 #endif\r
35 \r
36 #include <boost/mpl/aux_/config/static_constant.hpp>\r
37 #include <boost/mpl/aux_/config/use_preprocessed.hpp>\r
38 \r
39 #if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \\r
40     && !defined(BOOST_MPL_PREPROCESSING_MODE)\r
41 \r
42 #   define BOOST_MPL_PREPROCESSED_HEADER template_arity.hpp\r
43 #   include <boost/mpl/aux_/include_preprocessed.hpp>\r
44 \r
45 #else\r
46 \r
47 #   if !defined(BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT)\r
48 #   if defined(BOOST_MPL_CFG_EXTENDED_TEMPLATE_PARAMETERS_MATCHING)\r
49 \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
55 \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
61 \r
62 #   define AUX778076_ARITY BOOST_PP_INC(BOOST_MPL_LIMIT_METAFUNCTION_ARITY)\r
63 \r
64 namespace boost { namespace mpl { namespace aux {\r
65 \r
66 template< BOOST_MPL_AUX_NTTP_DECL(int, N) > struct arity_tag\r
67 {\r
68     typedef char (&type)[N + 1];\r
69 };\r
70 \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
73 /**/\r
74 \r
75 template<\r
76       BOOST_MPL_PP_PARAMS(AUX778076_ARITY, BOOST_MPL_AUX_NTTP_DECL(int, C))\r
77     >\r
78 struct max_arity\r
79 {\r
80     BOOST_STATIC_CONSTANT(int, value = \r
81           BOOST_PP_SEQ_FOLD_LEFT(\r
82               AUX778076_MAX_ARITY_OP\r
83             , -1\r
84             , BOOST_MPL_PP_RANGE(1, AUX778076_ARITY)\r
85             )\r
86         );\r
87 };\r
88 \r
89 #   undef AUX778076_MAX_ARITY_OP\r
90 \r
91 arity_tag<0>::type arity_helper(...);\r
92 \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
96 \r
97 template< typename F, BOOST_MPL_AUX_NTTP_DECL(int, N) >\r
98 struct template_arity_impl\r
99 {\r
100     BOOST_STATIC_CONSTANT(int, value = \r
101           sizeof(arity_helper(type_wrapper<F>(),arity_tag<N>())) - 1\r
102         );\r
103 };\r
104 \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
107 /**/\r
108 \r
109 template< typename F >\r
110 struct template_arity\r
111 {\r
112     BOOST_STATIC_CONSTANT(int, value = (\r
113           max_arity< BOOST_MPL_PP_REPEAT(\r
114               AUX778076_ARITY\r
115             , AUX778076_TEMPLATE_ARITY_IMPL_INVOCATION\r
116             , F\r
117             ) >::value\r
118         ));\r
119         \r
120     typedef mpl::int_<value> type;\r
121 };\r
122 \r
123 #   undef AUX778076_TEMPLATE_ARITY_IMPL_INVOCATION\r
124 \r
125 #   undef AUX778076_ARITY\r
126 \r
127 }}}\r
128 \r
129 #   endif // BOOST_MPL_CFG_EXTENDED_TEMPLATE_PARAMETERS_MATCHING\r
130 #   else // BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT\r
131 \r
132 #   include <boost/mpl/aux_/config/eti.hpp>\r
133 \r
134 namespace boost { namespace mpl { namespace aux {\r
135 \r
136 template< bool >\r
137 struct template_arity_impl\r
138 {\r
139     template< typename F > struct result_\r
140         : mpl::int_<-1>\r
141     {\r
142     };\r
143 };\r
144 \r
145 template<>\r
146 struct template_arity_impl<true>\r
147 {\r
148     template< typename F > struct result_\r
149         : F::arity\r
150     {\r
151     };\r
152 };\r
153 \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
158 {\r
159 };\r
160 \r
161 #if defined(BOOST_MPL_CFG_MSVC_ETI_BUG)\r
162 template<>\r
163 struct template_arity<int>\r
164     : mpl::int_<-1>\r
165 {\r
166 };\r
167 #endif\r
168 \r
169 }}}\r
170 \r
171 #   endif // BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT\r
172 \r
173 #endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS\r
174 #endif // BOOST_MPL_AUX_TEMPLATE_ARITY_HPP_INCLUDED\r
175 \r
176 ///// iteration\r
177 \r
178 #else\r
179 #define i_ BOOST_PP_FRAME_ITERATION(1)\r
180 \r
181 template<\r
182       template< BOOST_MPL_PP_PARAMS(i_, typename P) > class F\r
183     , BOOST_MPL_PP_PARAMS(i_, typename T)\r
184     >\r
185 typename arity_tag<i_>::type\r
186 arity_helper(type_wrapper< F<BOOST_MPL_PP_PARAMS(i_, T)> >, arity_tag<i_>);\r
187 \r
188 #undef i_\r
189 #endif // BOOST_PP_IS_ITERATING\r