1 | #ifndef BOOST_PP_IS_ITERATING
|
---|
2 | // Copyright David Abrahams 2002.
|
---|
3 | // Distributed under the Boost Software License, Version 1.0. (See
|
---|
4 | // accompanying file LICENSE_1_0.txt or copy at
|
---|
5 | // http://www.boost.org/LICENSE_1_0.txt)
|
---|
6 | # ifndef TYPE_LIST_IMPL_NO_PTS_DWA2002913_HPP
|
---|
7 | # define TYPE_LIST_IMPL_NO_PTS_DWA2002913_HPP
|
---|
8 |
|
---|
9 | # include <boost/python/detail/type_list.hpp>
|
---|
10 |
|
---|
11 | # include <boost/preprocessor/enum_params.hpp>
|
---|
12 | # include <boost/preprocessor/enum_params_with_a_default.hpp>
|
---|
13 | # include <boost/preprocessor/cat.hpp>
|
---|
14 | # include <boost/preprocessor/repeat.hpp>
|
---|
15 | # include <boost/preprocessor/empty.hpp>
|
---|
16 | # include <boost/preprocessor/iterate.hpp>
|
---|
17 | # include <boost/mpl/void.hpp>
|
---|
18 |
|
---|
19 | namespace boost { namespace python { namespace detail {
|
---|
20 |
|
---|
21 | template< typename T >
|
---|
22 | struct is_list_arg
|
---|
23 | {
|
---|
24 | enum { value = true };
|
---|
25 | };
|
---|
26 |
|
---|
27 | template<>
|
---|
28 | struct is_list_arg<mpl::void_>
|
---|
29 | {
|
---|
30 | enum { value = false };
|
---|
31 | };
|
---|
32 |
|
---|
33 | template<int> struct type_list_impl_chooser;
|
---|
34 |
|
---|
35 | # define BOOST_PYTHON_LIST_ACTUAL_PARAMS BOOST_PP_ENUM_PARAMS_Z(1,BOOST_PYTHON_LIST_SIZE,T)
|
---|
36 | # define BOOST_PYTHON_LIST_FORMAL_PARAMS BOOST_PP_ENUM_PARAMS_Z(1,BOOST_PYTHON_LIST_SIZE,class T)
|
---|
37 |
|
---|
38 | # define BOOST_PP_ITERATION_PARAMS_1 \
|
---|
39 | (3, (0, BOOST_PYTHON_LIST_SIZE, <boost/python/detail/type_list_impl_no_pts.hpp>))
|
---|
40 | # include BOOST_PP_ITERATE()
|
---|
41 |
|
---|
42 | # define BOOST_PYTHON_PLUS() +
|
---|
43 | # define BOOST_PYTHON_IS_LIST_ARG(z, n, data) \
|
---|
44 | BOOST_PP_IF(n, BOOST_PYTHON_PLUS, BOOST_PP_EMPTY)() \
|
---|
45 | is_list_arg< BOOST_PP_CAT(T,n) >::value
|
---|
46 |
|
---|
47 | template<
|
---|
48 | BOOST_PYTHON_LIST_FORMAL_PARAMS
|
---|
49 | >
|
---|
50 | struct type_list_count_args
|
---|
51 | {
|
---|
52 | enum { value =
|
---|
53 | BOOST_PP_REPEAT_1(BOOST_PYTHON_LIST_SIZE, BOOST_PYTHON_IS_LIST_ARG, _)
|
---|
54 | };
|
---|
55 | };
|
---|
56 |
|
---|
57 | template<
|
---|
58 | BOOST_PYTHON_LIST_FORMAL_PARAMS
|
---|
59 | >
|
---|
60 | struct type_list_impl
|
---|
61 | {
|
---|
62 | typedef type_list_count_args< BOOST_PYTHON_LIST_ACTUAL_PARAMS > arg_num_;
|
---|
63 | typedef typename detail::type_list_impl_chooser< arg_num_::value >
|
---|
64 | ::template result_< BOOST_PYTHON_LIST_ACTUAL_PARAMS >::type type;
|
---|
65 | };
|
---|
66 |
|
---|
67 | template<
|
---|
68 | BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PYTHON_LIST_SIZE, class T, mpl::void_)
|
---|
69 | >
|
---|
70 | struct type_list
|
---|
71 | : detail::type_list_impl< BOOST_PYTHON_LIST_ACTUAL_PARAMS >::type
|
---|
72 | {
|
---|
73 | typedef typename detail::type_list_impl<
|
---|
74 | BOOST_PYTHON_LIST_ACTUAL_PARAMS
|
---|
75 | >::type type;
|
---|
76 | };
|
---|
77 |
|
---|
78 | # undef BOOST_PYTHON_IS_LIST_ARG
|
---|
79 | # undef BOOST_PYTHON_PLUS
|
---|
80 | # undef BOOST_PYTHON_LIST_FORMAL_PARAMS
|
---|
81 | # undef BOOST_PYTHON_LIST_ACTUAL_PARAMS
|
---|
82 |
|
---|
83 | }}} // namespace boost::python::detail
|
---|
84 |
|
---|
85 | # endif // TYPE_LIST_IMPL_NO_PTS_DWA2002913_HPP
|
---|
86 |
|
---|
87 | #else // BOOST_PP_IS_ITERATING
|
---|
88 |
|
---|
89 | # define N BOOST_PP_ITERATION()
|
---|
90 |
|
---|
91 | template<>
|
---|
92 | struct type_list_impl_chooser<N>
|
---|
93 | {
|
---|
94 | template<
|
---|
95 | BOOST_PYTHON_LIST_FORMAL_PARAMS
|
---|
96 | >
|
---|
97 | struct result_
|
---|
98 | {
|
---|
99 | typedef typename BOOST_PP_CAT(mpl::vector,N)<
|
---|
100 | BOOST_PP_ENUM_PARAMS(N, T)
|
---|
101 | >::type type;
|
---|
102 | };
|
---|
103 | };
|
---|
104 |
|
---|
105 | # undef N
|
---|
106 |
|
---|
107 | #endif // BOOST_PP_IS_ITERATING
|
---|