Chris@16
|
1 // Copyright David Abrahams 2003.
|
Chris@16
|
2 // Distributed under the Boost Software License, Version 1.0. (See
|
Chris@16
|
3 // accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
4 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
5 #ifndef VALUE_IS_XXX_DWA2003224_HPP
|
Chris@16
|
6 # define VALUE_IS_XXX_DWA2003224_HPP
|
Chris@16
|
7
|
Chris@16
|
8 # include <boost/config.hpp>
|
Chris@16
|
9 # include <boost/mpl/bool.hpp>
|
Chris@16
|
10 # include <boost/preprocessor/enum_params.hpp>
|
Chris@16
|
11
|
Chris@16
|
12 # if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
Chris@16
|
13 # include <boost/type_traits/is_reference.hpp>
|
Chris@16
|
14 # include <boost/type_traits/add_reference.hpp>
|
Chris@16
|
15
|
Chris@16
|
16 # define BOOST_PYTHON_VALUE_IS_XXX_DEF(name, qualified_name, nargs) \
|
Chris@16
|
17 template <class X_> \
|
Chris@16
|
18 struct value_is_##name \
|
Chris@16
|
19 { \
|
Chris@16
|
20 typedef char yes; \
|
Chris@16
|
21 typedef char (&no)[2]; \
|
Chris@16
|
22 \
|
Chris@16
|
23 static typename add_reference<X_>::type dummy; \
|
Chris@16
|
24 \
|
Chris@16
|
25 template < BOOST_PP_ENUM_PARAMS_Z(1, nargs, class U) > \
|
Chris@16
|
26 static yes test( \
|
Chris@16
|
27 qualified_name< BOOST_PP_ENUM_PARAMS_Z(1, nargs, U) > const&, int \
|
Chris@16
|
28 ); \
|
Chris@16
|
29 \
|
Chris@16
|
30 template <class U> \
|
Chris@16
|
31 static no test(U&, ...); \
|
Chris@16
|
32 \
|
Chris@16
|
33 BOOST_STATIC_CONSTANT( \
|
Chris@16
|
34 bool, value \
|
Chris@16
|
35 = (sizeof(test(dummy, 0)) == sizeof(yes))); \
|
Chris@16
|
36 \
|
Chris@16
|
37 typedef mpl::bool_<value> type; \
|
Chris@16
|
38 };
|
Chris@16
|
39
|
Chris@16
|
40 # else
|
Chris@16
|
41
|
Chris@16
|
42 # include <boost/type_traits/remove_reference.hpp>
|
Chris@16
|
43 # include <boost/type_traits/remove_cv.hpp>
|
Chris@16
|
44 # include <boost/python/detail/is_xxx.hpp>
|
Chris@16
|
45
|
Chris@16
|
46 # define BOOST_PYTHON_VALUE_IS_XXX_DEF(name, qualified_name, nargs) \
|
Chris@16
|
47 template <class X_> \
|
Chris@16
|
48 struct value_is_##name \
|
Chris@16
|
49 { \
|
Chris@16
|
50 BOOST_PYTHON_IS_XXX_DEF(name,qualified_name,nargs) \
|
Chris@16
|
51 BOOST_STATIC_CONSTANT(bool, value = is_##name< \
|
Chris@16
|
52 typename remove_cv< \
|
Chris@16
|
53 typename remove_reference<X_>::type \
|
Chris@16
|
54 >::type \
|
Chris@16
|
55 >::value); \
|
Chris@16
|
56 typedef mpl::bool_<value> type; \
|
Chris@16
|
57 \
|
Chris@16
|
58 };
|
Chris@16
|
59
|
Chris@16
|
60 # endif
|
Chris@16
|
61
|
Chris@16
|
62 #endif // VALUE_IS_XXX_DWA2003224_HPP
|