Update contrib.
1 #if !defined(BOOST_PP_IS_ITERATING)
3 // Copyright David Abrahams 2002.
4 // Distributed under the Boost Software License, Version 1.0. (See
5 // accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
8 # ifndef RESULT_DWA2002521_HPP
9 # define RESULT_DWA2002521_HPP
11 # include <boost/type.hpp>
13 # include <boost/python/detail/preprocessor.hpp>
15 # include <boost/type_traits/object_traits.hpp>
16 # include <boost/mpl/if.hpp>
18 # include <boost/preprocessor/comma_if.hpp>
19 # include <boost/preprocessor/iterate.hpp>
20 # include <boost/preprocessor/debug/line.hpp>
21 # include <boost/preprocessor/enum_params.hpp>
22 # include <boost/preprocessor/repetition/enum_trailing_params.hpp>
24 namespace boost { namespace python { namespace detail {
26 // Defines a family of overloaded function which, given x, a function
27 // pointer, member [function] pointer, or an AdaptableFunction object,
28 // returns a pointer to type<R>*, where R is the result type of
29 // invoking the result of bind(x).
31 // In order to work around bugs in deficient compilers, if x might be
32 // an AdaptableFunction object, you must pass OL as a second argument
33 // to get this to work portably.
35 # define BOOST_PP_ITERATION_PARAMS_1 \
36 (4, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/detail/result.hpp>, BOOST_PYTHON_FUNCTION_POINTER))
37 # include BOOST_PP_ITERATE()
39 # define BOOST_PP_ITERATION_PARAMS_1 \
40 (4, (0, BOOST_PYTHON_CV_COUNT - 1, <boost/python/detail/result.hpp>, BOOST_PYTHON_POINTER_TO_MEMBER))
41 # include BOOST_PP_ITERATE()
43 template <class R, class T>
44 boost::type<R>* result(R (T::*), int = 0) { return 0; }
46 # if (defined(BOOST_MSVC) && _MSC_FULL_VER <= 13102140) \
47 || (defined(__GNUC__) && __GNUC__ < 3) \
48 || (defined(__MWERKS__) && __MWERKS__ < 0x3000)
49 // This code actually works on all implementations, but why use it when we don't have to?
51 struct get_result_type
53 typedef boost::type<typename T::result_type> type;
64 typedef typename mpl::if_c<
70 typedef typename t1::type* type;
74 typename result_result<X>::type
75 result(X const&, short) { return 0; }
77 # else // Simpler code for more-capable compilers
79 boost::type<typename X::result_type>*
80 result(X const&, short = 0) { return 0; }
84 }}} // namespace boost::python::detail
86 # endif // RESULT_DWA2002521_HPP
88 /* --------------- function pointers --------------- */
89 #elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == BOOST_PYTHON_FUNCTION_POINTER
90 # if !(BOOST_WORKAROUND(__MWERKS__, > 0x3100) \
91 && BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3201)))
92 # line BOOST_PP_LINE(__LINE__, result.hpp(function pointers))
95 # define N BOOST_PP_ITERATION()
97 template <class R BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)>
98 boost::type<R>* result(R (*pf)(BOOST_PP_ENUM_PARAMS_Z(1, N, A)), int = 0)
105 /* --------------- pointers-to-members --------------- */
106 #elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == BOOST_PYTHON_POINTER_TO_MEMBER
107 // Outer over cv-qualifiers
109 # define BOOST_PP_ITERATION_PARAMS_2 (3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/detail/result.hpp>))
110 # include BOOST_PP_ITERATE()
112 #elif BOOST_PP_ITERATION_DEPTH() == 2
113 # if !(BOOST_WORKAROUND(__MWERKS__, > 0x3100) \
114 && BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3201)))
115 # line BOOST_PP_LINE(__LINE__, result.hpp(pointers-to-members))
117 // Inner over arities
119 # define N BOOST_PP_ITERATION()
120 # define Q BOOST_PYTHON_CV_QUALIFIER(BOOST_PP_RELATIVE_ITERATION(1))
122 template <class R, class T BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)>
123 boost::type<R>* result(R (T::*pmf)(BOOST_PP_ENUM_PARAMS_Z(1, N, A)) Q, int = 0)