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