diff --git a/include/boost/python/detail/defaults_def.hpp b/include/boost/python/detail/defaults_def.hpp index f7105b6f..15eba294 100644 --- a/include/boost/python/detail/defaults_def.hpp +++ b/include/boost/python/detail/defaults_def.hpp @@ -15,9 +15,9 @@ #include #include #include -#include #include #include +#include /////////////////////////////////////////////////////////////////////////////// namespace boost { namespace python { @@ -134,7 +134,7 @@ struct define_stub_function {}; SigT sig, char const* doc) { - typedef typename mpl::at<0, SigT>::type nth_type; + typedef typename boost::python::detail::type_at<0, SigT>::type nth_type; typedef typename StubsT::v_type v_type; typedef typename StubsT::nv_type nv_type; @@ -145,7 +145,8 @@ struct define_stub_function {}; >::type stubs_type; BOOST_STATIC_ASSERT( - (stubs_type::max_args + 1) <= boost::mpl::size::value); + (stubs_type::max_args + 1) <= + boost::python::detail::type_list_size::value); typedef typename stubs_type::template gen gen_type; define_with_defaults_helper::def diff --git a/include/boost/python/detail/defaults_gen.hpp b/include/boost/python/detail/defaults_gen.hpp index 18931a61..9a43ed9b 100644 --- a/include/boost/python/detail/defaults_gen.hpp +++ b/include/boost/python/detail/defaults_gen.hpp @@ -21,6 +21,7 @@ #include #include #include +#include namespace boost { namespace python { namespace detail { @@ -44,7 +45,7 @@ struct func_stubs_base {}; /////////////////////////////////////////////////////////////////////////////// #define BPL_IMPL_TYPEDEF_GEN(INDEX, DATA) \ - typedef typename boost::mpl::at \ + typedef typename boost::python::detail::type_at \ < \ BOOST_PP_ADD(INDEX, DATA), \ SigT \ @@ -84,7 +85,7 @@ struct func_stubs_base {}; template \ struct gen { \ \ - typedef typename boost::mpl::at<0, SigT>::type RT; \ + typedef typename boost::python::detail::type_at<0, SigT>::type RT; \ \ BOOST_PP_FIX_REPEAT_2ND \ ( \ @@ -135,8 +136,8 @@ struct func_stubs_base {}; template \ struct gen { \ \ - typedef typename boost::mpl::at<0, SigT>::type RT; \ - typedef typename boost::mpl::at<1, SigT>::type ClassT; \ + typedef typename boost::python::detail::type_at<0, SigT>::type RT; \ + typedef typename boost::python::detail::type_at<1, SigT>::type ClassT;\ \ BOOST_PP_FIX_REPEAT_2ND \ ( \ diff --git a/include/boost/python/detail/type_list_utils.hpp b/include/boost/python/detail/type_list_utils.hpp new file mode 100644 index 00000000..9f87b9bf --- /dev/null +++ b/include/boost/python/detail/type_list_utils.hpp @@ -0,0 +1,115 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// Copyright David Abrahams 2002. Permission to copy, use, +// modify, sell and distribute this software is granted provided this +// copyright notice appears in all copies. This software is provided +// "as is" without express or implied warranty, and with no claim as +// to its suitability for any purpose. +// +/////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_PP_IS_ITERATING) + +#ifndef TYPE_LIST_UTILS_JDG20020826_HPP +#define TYPE_LIST_UTILS_JDG20020826_HPP + +# include +# include +//# include +//# include + +# include +# include +# include +# include +# include + +namespace boost { namespace python { namespace detail { + +# if (!defined(__EDG_VERSION__) || __EDG_VERSION__ > 245) \ + && (!defined(BOOST_INTEL_CXX_VERSION) || BOOST_INTEL_CXX_VERSION > 600) + + template + struct type_at : public boost::mpl::at {}; + + template + struct type_list_size : public boost::mpl::size {}; + +// template +// struct pop_front : public boost::mpl::pop_front {}; +// +// template +// struct pop_back : public boost::mpl::pop_back {}; + +# else + + template + struct type_at {}; + + template + struct type_list_size {}; + +// template +// struct pop_front {}; +// +// template +// struct pop_back {}; + +// template +// struct push_back {}; + +# define BOOST_PP_ITERATION_PARAMS_1 \ + (3, (0, BOOST_PYTHON_MAX_ARITY, )) +# include BOOST_PP_ITERATE() + +# endif + +}}} // namespace boost::python::detail + +#endif // TYPE_LIST_UTILS_JDG20020826_HPP + +#else // defined(BOOST_PP_IS_ITERATING) + +# define N BOOST_PP_ITERATION() +# define MAX BOOST_PYTHON_MAX_ARITY + +# if (N < MAX-1) + + template + struct type_at > + { + typedef BOOST_PP_CAT(A, N) type; + }; + +// template +// struct push_back, T> +// { +// typedef boost::mpl::type_list sequence; +// }; + +# if (N > 0) + +// template +// struct pop_front > +// { +// typedef boost::mpl::type_list sequence; +// }; +// +// template +// struct pop_back > +// { +// typedef boost::mpl::type_list sequence; +// }; + +# endif +# endif + + template + struct type_list_size > + { + BOOST_STATIC_CONSTANT(long, value = N); + }; + +# undef N +# undef MAX + +#endif // !defined(BOOST_PP_IS_ITERATING) diff --git a/test/defaults.cpp b/test/defaults.cpp index 0014ab36..fab13d5f 100644 --- a/test/defaults.cpp +++ b/test/defaults.cpp @@ -121,8 +121,14 @@ BOOST_PYTHON_MODULE_INIT(defaults_ext) ; class_("X") + +# if (!defined(__EDG_VERSION__) || __EDG_VERSION__ > 245) \ + && (!defined(BOOST_INTEL_CXX_VERSION) || BOOST_INTEL_CXX_VERSION > 600) .def(init >()) - .def("get_state", &X::get_state) +#endif + + + .def("get_state", &X::get_state) .def("bar", &X::bar, X_bar_stubs()) .def("foo", (object(X::*)(std::string, bool) const)0, X_foo_2_stubs()) .def("foo", (object(X::*)(int, bool) const)0, X_foo_2_stubs())