|
5 | 5 | // to its suitability for any purpose. |
6 | 6 | #ifndef ARGS_DWA2002323_HPP |
7 | 7 | # define ARGS_DWA2002323_HPP |
| 8 | +# include <boost/config.hpp> |
8 | 9 | # include <boost/mpl/type_list.hpp> |
| 10 | +# include <boost/python/detail/preprocessor.hpp> |
| 11 | +# include <boost/preprocessor/enum_params.hpp> |
| 12 | +# include <boost/preprocessor/enum_params_with_a_default.hpp> |
| 13 | +# include <boost/preprocessor/comma_if.hpp> |
9 | 14 |
|
| 15 | +# if !defined(__EDG_VERSION__) || __EDG_VERSION__ > 245 |
10 | 16 | namespace boost { namespace python { |
11 | 17 |
|
| 18 | + |
12 | 19 | // A type list for specifying arguments |
13 | | -template < BOOST_MPL_LIST_DEFAULT_PARAMETERS(typename A, ::boost::mpl::null_argument) > |
14 | | -struct args : ::boost::mpl::type_list< BOOST_MPL_LIST_PARAMETERS(A) >::type |
| 20 | +template < BOOST_MPL_LIST_DEFAULT_PARAMETERS(typename A, boost::mpl::null_argument) > |
| 21 | +struct args : boost::mpl::type_list< BOOST_MPL_LIST_PARAMETERS(A) >::type |
15 | 22 | {}; |
16 | 23 |
|
17 | 24 | }} // namespace boost::python |
18 | 25 |
|
| 26 | +# else // slow template instantiators need this other version with |
| 27 | + // explicit specializations of mpl::size<> and |
| 28 | + // mpl::at<>. Eventually, however, inheritance from mpl::list |
| 29 | + // *should* be eliminated and the two versions unified, just in |
| 30 | + // order to get true arity independence |
| 31 | + |
| 32 | +namespace boost { namespace python { |
| 33 | + |
| 34 | +template < BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PYTHON_MAX_ARITY, class A, boost::mpl::null_argument) > |
| 35 | +struct args |
| 36 | +{}; |
| 37 | + |
| 38 | +}} // namespace boost::python |
| 39 | + |
| 40 | +namespace boost { namespace mpl { |
| 41 | + |
| 42 | +template <class T> struct size; |
| 43 | +template <long N, class Seq> struct at; |
| 44 | + |
| 45 | +# ifndef BOOST_PYTHON_GENERATE_CODE |
| 46 | +# include <boost/python/preprocessed/args.hpp> |
| 47 | +# endif |
| 48 | + |
| 49 | +# define BOOST_PYTHON_ARGS_SIZE(index,ignored) \ |
| 50 | +template <BOOST_PP_ENUM_PARAMS(index, class A)> \ |
| 51 | +struct size<boost::python::args<BOOST_PP_ENUM_PARAMS(index, A)> > \ |
| 52 | +{ \ |
| 53 | + BOOST_STATIC_CONSTANT(long, value = index); \ |
| 54 | +}; \ |
| 55 | + |
| 56 | +BOOST_PYTHON_REPEAT_ARITY_2ND(BOOST_PYTHON_ARGS_SIZE, nil) |
| 57 | + |
| 58 | +# define BOOST_PYTHON_ARGS_AT(index,ignored) \ |
| 59 | +template < \ |
| 60 | + BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(BOOST_PYTHON_ARITY_FINISH), class A)> \ |
| 61 | +struct at<index, boost::python::args< \ |
| 62 | + BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(BOOST_PYTHON_ARITY_FINISH), A)> > \ |
| 63 | +{ \ |
| 64 | + typedef BOOST_PP_CAT(A,index) type; \ |
| 65 | +}; \ |
| 66 | + |
| 67 | +BOOST_PP_REPEAT_FROM_TO_2ND( |
| 68 | + BOOST_PP_DEC(BOOST_PYTHON_ARITY_START), BOOST_PP_DEC(BOOST_PYTHON_ARITY_FINISH) |
| 69 | + , BOOST_PYTHON_ARGS_AT, data) |
| 70 | + |
| 71 | +}} |
| 72 | +# endif |
19 | 73 | #endif // ARGS_DWA2002323_HPP |
0 commit comments