1
//-----------------------------------------------------------------------------
2
// boost mpl/aux_/template_arity.hpp header file
3
// See http://www.boost.org for updates, documentation, and revision history.
4
//-----------------------------------------------------------------------------
6
// Copyright (c) 2001-02
9
// Permission to use, copy, modify, distribute and sell this software
10
// and its documentation for any purpose is hereby granted without fee,
11
// provided that the above copyright notice appears in all copies and
12
// that both the copyright notice and this permission notice appear in
13
// supporting documentation. No representations are made about the
14
// suitability of this software for any purpose. It is provided "as is"
15
// without express or implied warranty.
17
#if !defined(BOOST_PP_IS_ITERATING)
21
#ifndef BOOST_MPL_AUX_TEMPLATE_ARITY_HPP_INCLUDED
22
#define BOOST_MPL_AUX_TEMPLATE_ARITY_HPP_INCLUDED
24
#include "boost/mpl/aux_/config/ttp.hpp"
25
#include "boost/mpl/aux_/config/lambda.hpp"
27
#if !defined(BOOST_MPL_PREPROCESSING_MODE)
28
# include "boost/mpl/aux_/template_arity_fwd.hpp"
29
# if !defined(BOOST_MPL_NO_FULL_LAMBDA_SUPPORT)
30
# if defined(BOOST_EXTENDED_TEMPLATE_PARAMETERS_MATCHING)
31
# include "boost/mpl/aux_/type_wrapper.hpp"
34
# include "boost/mpl/aux_/has_rebind.hpp"
38
#include "boost/mpl/aux_/config/use_preprocessed.hpp"
40
#if !defined(BOOST_MPL_NO_PREPROCESSED_HEADERS) \
41
&& !defined(BOOST_MPL_PREPROCESSING_MODE)
43
# define BOOST_MPL_PREPROCESSED_HEADER template_arity.hpp
44
# include "boost/mpl/aux_/include_preprocessed.hpp"
48
# if !defined(BOOST_MPL_NO_FULL_LAMBDA_SUPPORT)
49
# if defined(BOOST_EXTENDED_TEMPLATE_PARAMETERS_MATCHING)
51
# include "boost/mpl/limits/arity.hpp"
52
# include "boost/mpl/aux_/config/nttp.hpp"
53
# include "boost/mpl/aux_/preprocessor/range.hpp"
54
# include "boost/mpl/aux_/preprocessor/repeat.hpp"
55
# include "boost/mpl/aux_/preprocessor/params.hpp"
57
# include "boost/preprocessor/seq/fold_left.hpp"
58
# include "boost/preprocessor/comma_if.hpp"
59
# include "boost/preprocessor/iterate.hpp"
60
# include "boost/preprocessor/inc.hpp"
61
# include "boost/preprocessor/cat.hpp"
63
namespace boost { namespace mpl { namespace aux {
65
template< BOOST_MPL_AUX_NTTP_DECL(int, N) > struct arity_tag
67
typedef char (&type)[N + 1];
70
#define AUX_MAX_ARITY_OP(unused, state, i) \
71
( BOOST_PP_CAT(C,i) > 0 ? BOOST_PP_CAT(C,i) : state ) \
76
BOOST_MPL_METAFUNCTION_MAX_ARITY
77
, BOOST_MPL_AUX_NTTP_DECL(int, C)
82
BOOST_STATIC_CONSTANT(int, value =
83
BOOST_PP_SEQ_FOLD_LEFT(
86
, BOOST_MPL_PP_RANGE(1, BOOST_MPL_METAFUNCTION_MAX_ARITY)
91
#undef AUX_MAX_ARITY_OP
93
arity_tag<0> arity_helper(...);
95
#define BOOST_PP_ITERATION_LIMITS (1, BOOST_MPL_METAFUNCTION_MAX_ARITY)
96
#define BOOST_PP_FILENAME_1 "boost/mpl/aux_/template_arity.hpp"
97
#include BOOST_PP_ITERATE()
99
template< typename F, BOOST_MPL_AUX_NTTP_DECL(int, N) >
100
struct template_arity_impl
102
BOOST_STATIC_CONSTANT(int, value =
103
sizeof(arity_helper(type_wrapper<F>(),arity_tag<N>())) - 1
107
#define AUX_TEMPLATE_ARITY_IMPL_INVOCATION(unused, i, F) \
108
BOOST_PP_COMMA_IF(i) template_arity_impl<F,BOOST_PP_INC(i)>::value \
111
template< typename F >
112
struct template_arity
114
BOOST_STATIC_CONSTANT(int, value = (
115
max_arity< BOOST_MPL_PP_REPEAT(
116
BOOST_MPL_METAFUNCTION_MAX_ARITY
117
, AUX_TEMPLATE_ARITY_IMPL_INVOCATION
123
#undef AUX_TEMPLATE_ARITY_IMPL_INVOCATION
125
}}} // namespace boost::mpl::aux
127
# endif // BOOST_EXTENDED_TEMPLATE_PARAMETERS_MATCHING
128
# else // BOOST_MPL_NO_FULL_LAMBDA_SUPPORT
130
# include "boost/mpl/aux_/config/eti.hpp"
131
# include "boost/mpl/aux_/config/static_constant.hpp"
132
# include "boost/mpl/aux_/config/workaround.hpp"
134
namespace boost { namespace mpl { namespace aux {
137
struct template_arity_impl
139
template< typename F > struct result_
141
BOOST_STATIC_CONSTANT(int, value = -1);
146
struct template_arity_impl<true>
148
template< typename F > struct result_
150
#if defined(__BORLANDC__) && (__BORLANDC__ >= 0x561 && !defined(BOOST_STRICT_CONFIG))
151
enum { value = F::arity };
153
BOOST_STATIC_CONSTANT(int, value = F::arity);
158
template< typename F >
159
struct template_arity
160
: template_arity_impl< ::boost::mpl::aux::has_rebind<F>::value >
161
::template result_<F>
165
#if defined(BOOST_MPL_MSVC_ETI_BUG)
167
struct template_arity<int>
169
BOOST_STATIC_CONSTANT(int, value = -1);
173
}}} // namespace boost::mpl::aux
175
# endif // BOOST_MPL_NO_FULL_LAMBDA_SUPPORT
177
#endif // BOOST_MPL_USE_PREPROCESSED_HEADERS
178
#endif // BOOST_MPL_AUX_TEMPLATE_ARITY_HPP_INCLUDED
183
#define i BOOST_PP_FRAME_ITERATION(1)
186
template< BOOST_MPL_PP_PARAMS(i, typename P) > class F
187
, BOOST_MPL_PP_PARAMS(i, typename T)
189
typename arity_tag<i>::type
190
arity_helper(type_wrapper< F<BOOST_MPL_PP_PARAMS(i, T)> >, arity_tag<i>);
193
#endif // BOOST_PP_IS_ITERATING