]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/python/include/boost/python/detail/result.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / python / include / boost / python / detail / result.hpp
CommitLineData
7c673cae
FG
1#if !defined(BOOST_PP_IS_ITERATING)
2
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)
7
8# ifndef RESULT_DWA2002521_HPP
9# define RESULT_DWA2002521_HPP
10
11# include <boost/type.hpp>
12
13# include <boost/python/detail/preprocessor.hpp>
14
15# include <boost/type_traits/object_traits.hpp>
16# include <boost/mpl/if.hpp>
17
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>
23
24namespace boost { namespace python { namespace detail {
25
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).
30//
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.
34
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()
38
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()
42
43template <class R, class T>
44boost::type<R>* result(R (T::*), int = 0) { return 0; }
45
46# if (defined(__MWERKS__) && __MWERKS__ < 0x3000)
47// This code actually works on all implementations, but why use it when we don't have to?
48template <class T>
49struct get_result_type
50{
51 typedef boost::type<typename T::result_type> type;
52};
53
54struct void_type
55{
56 typedef void type;
57};
58
59template <class T>
60struct result_result
61{
62 typedef typename mpl::if_c<
63 is_class<T>::value
64 , get_result_type<T>
65 , void_type
66 >::type t1;
67
68 typedef typename t1::type* type;
69};
70
71template <class X>
72typename result_result<X>::type
73result(X const&, short) { return 0; }
74
75# else // Simpler code for more-capable compilers
76template <class X>
77boost::type<typename X::result_type>*
78result(X const&, short = 0) { return 0; }
79
80# endif
81
82}}} // namespace boost::python::detail
83
84# endif // RESULT_DWA2002521_HPP
85
86/* --------------- function pointers --------------- */
87// For gcc 4.4 compatability, we must include the
88// BOOST_PP_ITERATION_DEPTH test inside an #else clause.
89#else // BOOST_PP_IS_ITERATING
90#if BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == BOOST_PYTHON_FUNCTION_POINTER
91# if !(BOOST_WORKAROUND(__MWERKS__, > 0x3100) \
92 && BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3201)))
93# line BOOST_PP_LINE(__LINE__, result.hpp(function pointers))
94# endif
95
96# define N BOOST_PP_ITERATION()
97
98template <class R BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)>
99boost::type<R>* result(R (*)(BOOST_PP_ENUM_PARAMS_Z(1, N, A)), int = 0)
100{
101 return 0;
102}
103
104# undef N
105
106/* --------------- pointers-to-members --------------- */
107#elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == BOOST_PYTHON_POINTER_TO_MEMBER
108// Outer over cv-qualifiers
109
110# define BOOST_PP_ITERATION_PARAMS_2 (3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/detail/result.hpp>))
111# include BOOST_PP_ITERATE()
112
113#elif BOOST_PP_ITERATION_DEPTH() == 2
114# if !(BOOST_WORKAROUND(__MWERKS__, > 0x3100) \
115 && BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3201)))
116# line BOOST_PP_LINE(__LINE__, result.hpp(pointers-to-members))
117# endif
118// Inner over arities
119
120# define N BOOST_PP_ITERATION()
121# define Q BOOST_PYTHON_CV_QUALIFIER(BOOST_PP_RELATIVE_ITERATION(1))
122
123template <class R, class T BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)>
124boost::type<R>* result(R (T::*)(BOOST_PP_ENUM_PARAMS_Z(1, N, A)) Q, int = 0)
125{
126 return 0;
127}
128
129# undef N
130# undef Q
131
132#endif // BOOST_PP_ITERATION_DEPTH()
133#endif