Chris@16
|
1 ///////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
2 /// \file template_arity.hpp
|
Chris@16
|
3 /// Replace all nodes stored by reference by nodes stored by value.
|
Chris@16
|
4 //
|
Chris@16
|
5 // Copyright 2011 Eric Niebler. Distributed under the Boost
|
Chris@16
|
6 // Software License, Version 1.0. (See accompanying file
|
Chris@16
|
7 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
8 //
|
Chris@16
|
9 // This file is based on a similar one in MPL from Aleksey Gurtovoy.
|
Chris@16
|
10
|
Chris@16
|
11 #ifndef BOOST_PROTO_DETAIL_TEMPLATE_ARITY_HPP_EAN_2011_05_07
|
Chris@16
|
12 #define BOOST_PROTO_DETAIL_TEMPLATE_ARITY_HPP_EAN_2011_05_07
|
Chris@16
|
13
|
Chris@16
|
14 // Somewhat indirect definition of BOOST_PROTO_TEMPLATE_ARITY_PARAM is
|
Chris@16
|
15 // to overcome a shortcoming of the Wave tool used to generate the
|
Chris@16
|
16 // pre-preprocessed headers.
|
Chris@16
|
17 #define BOOST_PROTO_TEMPLATE_ARITY_PARAM BOOST_PROTO_TEMPLATE_ARITY_PARAM2
|
Chris@16
|
18 #define BOOST_PROTO_TEMPLATE_ARITY_PARAM2(param)
|
Chris@16
|
19
|
Chris@16
|
20 #if defined(BOOST_PROTO_EXTENDED_TEMPLATE_PARAMETERS_MATCHING) || \
|
Chris@16
|
21 (defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES))
|
Chris@16
|
22
|
Chris@16
|
23 #include <boost/preprocessor/cat.hpp>
|
Chris@16
|
24 #include <boost/preprocessor/inc.hpp>
|
Chris@16
|
25 #include <boost/preprocessor/iteration/iterate.hpp>
|
Chris@16
|
26 #include <boost/preprocessor/repetition/enum_params.hpp>
|
Chris@16
|
27 #include <boost/mpl/int.hpp>
|
Chris@16
|
28 #include <boost/proto/proto_fwd.hpp>
|
Chris@16
|
29
|
Chris@16
|
30 #undef BOOST_PROTO_TEMPLATE_ARITY_PARAM2
|
Chris@16
|
31 #define BOOST_PROTO_TEMPLATE_ARITY_PARAM2(param) , param
|
Chris@16
|
32
|
Chris@16
|
33 namespace boost { namespace proto { namespace detail
|
Chris@16
|
34 {
|
Chris@16
|
35 sized_type<1>::type template_arity_helper(...);
|
Chris@16
|
36
|
Chris@16
|
37 // Other overloads generated by the preprocessor
|
Chris@16
|
38 #include <boost/proto/detail/template_arity_helper.hpp>
|
Chris@16
|
39
|
Chris@16
|
40 template<typename F, int N, int Size>
|
Chris@16
|
41 struct template_arity_impl2
|
Chris@16
|
42 : mpl::int_<Size - 1>
|
Chris@16
|
43 {};
|
Chris@16
|
44
|
Chris@16
|
45 template<typename F, int N = BOOST_PROTO_MAX_ARITY>
|
Chris@16
|
46 struct template_arity
|
Chris@16
|
47 : template_arity_impl2<
|
Chris@16
|
48 F
|
Chris@16
|
49 , N
|
Chris@16
|
50 , sizeof(detail::template_arity_helper((F **)0, (mpl::int_<N> *)0))
|
Chris@16
|
51 >
|
Chris@16
|
52 {};
|
Chris@16
|
53
|
Chris@16
|
54 template<typename F, int N>
|
Chris@16
|
55 struct template_arity_impl2<F, N, 1>
|
Chris@16
|
56 : template_arity<F, N-1>
|
Chris@16
|
57 {};
|
Chris@16
|
58
|
Chris@16
|
59 template<typename F>
|
Chris@16
|
60 struct template_arity_impl2<F, 0, 1>
|
Chris@16
|
61 : mpl::int_<-1>
|
Chris@16
|
62 {};
|
Chris@16
|
63
|
Chris@16
|
64 }}}
|
Chris@16
|
65
|
Chris@16
|
66 #endif // BOOST_PROTO_EXTENDED_TEMPLATE_PARAMETERS_MATCHING
|
Chris@16
|
67 #endif // BOOST_PROTO_DETAIL_TEMPLATE_ARITY_HPP_EAN_2011_05_07
|