1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/python/detail/result.hpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,131 @@
1.4 +#if !defined(BOOST_PP_IS_ITERATING)
1.5 +
1.6 +// Copyright David Abrahams 2002.
1.7 +// Distributed under the Boost Software License, Version 1.0. (See
1.8 +// accompanying file LICENSE_1_0.txt or copy at
1.9 +// http://www.boost.org/LICENSE_1_0.txt)
1.10 +
1.11 +# ifndef RESULT_DWA2002521_HPP
1.12 +# define RESULT_DWA2002521_HPP
1.13 +
1.14 +# include <boost/type.hpp>
1.15 +
1.16 +# include <boost/python/detail/preprocessor.hpp>
1.17 +
1.18 +# include <boost/type_traits/object_traits.hpp>
1.19 +# include <boost/mpl/if.hpp>
1.20 +
1.21 +# include <boost/preprocessor/comma_if.hpp>
1.22 +# include <boost/preprocessor/iterate.hpp>
1.23 +# include <boost/preprocessor/debug/line.hpp>
1.24 +# include <boost/preprocessor/enum_params.hpp>
1.25 +# include <boost/preprocessor/repetition/enum_trailing_params.hpp>
1.26 +
1.27 +namespace boost { namespace python { namespace detail {
1.28 +
1.29 +// Defines a family of overloaded function which, given x, a function
1.30 +// pointer, member [function] pointer, or an AdaptableFunction object,
1.31 +// returns a pointer to type<R>*, where R is the result type of
1.32 +// invoking the result of bind(x).
1.33 +//
1.34 +// In order to work around bugs in deficient compilers, if x might be
1.35 +// an AdaptableFunction object, you must pass OL as a second argument
1.36 +// to get this to work portably.
1.37 +
1.38 +# define BOOST_PP_ITERATION_PARAMS_1 \
1.39 + (4, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/detail/result.hpp>, BOOST_PYTHON_FUNCTION_POINTER))
1.40 +# include BOOST_PP_ITERATE()
1.41 +
1.42 +# define BOOST_PP_ITERATION_PARAMS_1 \
1.43 + (4, (0, BOOST_PYTHON_CV_COUNT - 1, <boost/python/detail/result.hpp>, BOOST_PYTHON_POINTER_TO_MEMBER))
1.44 +# include BOOST_PP_ITERATE()
1.45 +
1.46 +template <class R, class T>
1.47 +boost::type<R>* result(R (T::*), int = 0) { return 0; }
1.48 +
1.49 +# if (defined(BOOST_MSVC) && _MSC_FULL_VER <= 13102140) \
1.50 + || (defined(__GNUC__) && __GNUC__ < 3) \
1.51 + || (defined(__MWERKS__) && __MWERKS__ < 0x3000)
1.52 +// This code actually works on all implementations, but why use it when we don't have to?
1.53 +template <class T>
1.54 +struct get_result_type
1.55 +{
1.56 + typedef boost::type<typename T::result_type> type;
1.57 +};
1.58 +
1.59 +struct void_type
1.60 +{
1.61 + typedef void type;
1.62 +};
1.63 +
1.64 +template <class T>
1.65 +struct result_result
1.66 +{
1.67 + typedef typename mpl::if_c<
1.68 + is_class<T>::value
1.69 + , get_result_type<T>
1.70 + , void_type
1.71 + >::type t1;
1.72 +
1.73 + typedef typename t1::type* type;
1.74 +};
1.75 +
1.76 +template <class X>
1.77 +typename result_result<X>::type
1.78 +result(X const&, short) { return 0; }
1.79 +
1.80 +# else // Simpler code for more-capable compilers
1.81 +template <class X>
1.82 +boost::type<typename X::result_type>*
1.83 +result(X const&, short = 0) { return 0; }
1.84 +
1.85 +# endif
1.86 +
1.87 +}}} // namespace boost::python::detail
1.88 +
1.89 +# endif // RESULT_DWA2002521_HPP
1.90 +
1.91 +/* --------------- function pointers --------------- */
1.92 +#elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == BOOST_PYTHON_FUNCTION_POINTER
1.93 +# if !(BOOST_WORKAROUND(__MWERKS__, > 0x3100) \
1.94 + && BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3201)))
1.95 +# line BOOST_PP_LINE(__LINE__, result.hpp(function pointers))
1.96 +# endif
1.97 +
1.98 +# define N BOOST_PP_ITERATION()
1.99 +
1.100 +template <class R BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)>
1.101 +boost::type<R>* result(R (*pf)(BOOST_PP_ENUM_PARAMS_Z(1, N, A)), int = 0)
1.102 +{
1.103 + return 0;
1.104 +}
1.105 +
1.106 +# undef N
1.107 +
1.108 +/* --------------- pointers-to-members --------------- */
1.109 +#elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == BOOST_PYTHON_POINTER_TO_MEMBER
1.110 +// Outer over cv-qualifiers
1.111 +
1.112 +# define BOOST_PP_ITERATION_PARAMS_2 (3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/detail/result.hpp>))
1.113 +# include BOOST_PP_ITERATE()
1.114 +
1.115 +#elif BOOST_PP_ITERATION_DEPTH() == 2
1.116 +# if !(BOOST_WORKAROUND(__MWERKS__, > 0x3100) \
1.117 + && BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3201)))
1.118 +# line BOOST_PP_LINE(__LINE__, result.hpp(pointers-to-members))
1.119 +# endif
1.120 +// Inner over arities
1.121 +
1.122 +# define N BOOST_PP_ITERATION()
1.123 +# define Q BOOST_PYTHON_CV_QUALIFIER(BOOST_PP_RELATIVE_ITERATION(1))
1.124 +
1.125 +template <class R, class T BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)>
1.126 +boost::type<R>* result(R (T::*pmf)(BOOST_PP_ENUM_PARAMS_Z(1, N, A)) Q, int = 0)
1.127 +{
1.128 + return 0;
1.129 +}
1.130 +
1.131 +# undef N
1.132 +# undef Q
1.133 +
1.134 +#endif