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