]> git.lyx.org Git - lyx.git/blob - boost/boost/python/detail/is_xxx.hpp
e6fb3f0b459d81e52de81c973e5de66cbfbdae62
[lyx.git] / boost / boost / python / detail / is_xxx.hpp
1 // Copyright David Abrahams 2003. Permission to copy, use,
2 // modify, sell and distribute this software is granted provided this
3 // copyright notice appears in all copies. This software is provided
4 // "as is" without express or implied warranty, and with no claim as
5 // to its suitability for any purpose.
6 #ifndef IS_XXX_DWA2003224_HPP
7 # define IS_XXX_DWA2003224_HPP
8
9 # include <boost/config.hpp>
10 # include <boost/mpl/bool.hpp>
11 # include <boost/preprocessor/enum_params.hpp>
12
13 # if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
14 # include <boost/type_traits/is_reference.hpp>
15 # include <boost/type_traits/add_reference.hpp>
16
17 #  define BOOST_PYTHON_IS_XXX_DEF(name, qualified_name, nargs)          \
18 template <class X_>                                                     \
19 struct is_##name                                                        \
20 {                                                                       \
21     typedef char yes;                                                   \
22     typedef char (&no)[2];                                              \
23                                                                         \
24     static typename add_reference<X_>::type dummy;                      \
25                                                                         \
26     struct helpers                                                      \
27     {                                                                   \
28         template < BOOST_PP_ENUM_PARAMS_Z(1, nargs, class U) >          \
29         static yes test(                                                \
30            qualified_name< BOOST_PP_ENUM_PARAMS_Z(1, nargs, U) >&, int  \
31         );                                                              \
32                                                                         \
33         template <class U>                                              \
34         static no test(U&, ...);                                        \
35     };                                                                  \
36                                                                         \
37     BOOST_STATIC_CONSTANT(                                              \
38         bool, value                                                     \
39         = !is_reference<X_>::value                                      \
40         & (sizeof(helpers::test(dummy, 0)) == sizeof(yes)));            \
41                                                                         \
42     typedef mpl::bool_<value> type;                                     \
43 };
44
45 # else
46
47 #  define BOOST_PYTHON_IS_XXX_DEF(name, qualified_name, nargs)  \
48 template <class T>                                              \
49 struct is_##name : mpl::false_                                  \
50 {                                                               \
51 };                                                              \
52                                                                 \
53 template < BOOST_PP_ENUM_PARAMS_Z(1, nargs, class T) >          \
54 struct is_##name<                                               \
55    qualified_name< BOOST_PP_ENUM_PARAMS_Z(1, nargs, T) >        \
56 >                                                               \
57    : mpl::true_                                                 \
58 {                                                               \
59 };
60
61 # endif
62
63 #endif // IS_XXX_DWA2003224_HPP