is_xxx.hpp
Go to the documentation of this file.
00001 // Copyright David Abrahams 2005. Distributed under the Boost
00002 // Software License, Version 1.0. (See accompanying
00003 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
00004 #ifndef BOOST_DETAIL_IS_XXX_DWA20051011_HPP
00005 # define BOOST_DETAIL_IS_XXX_DWA20051011_HPP
00006 
00007 # include <boost/config.hpp>
00008 # include <boost/mpl/bool.hpp>
00009 # include <boost/preprocessor/enum_params.hpp>
00010 
00011 # if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
00012 # include <boost/type_traits/is_reference.hpp>
00013 # include <boost/type_traits/add_reference.hpp>
00014 
00015 #  define BOOST_DETAIL_IS_XXX_DEF(name, qualified_name, nargs)          \
00016 template <class X_>                                                     \
00017 struct is_##name                                                        \
00018 {                                                                       \
00019     typedef char yes;                                                   \
00020     typedef char (&no)[2];                                              \
00021                                                                         \
00022     static typename add_reference<X_>::type dummy;                      \
00023                                                                         \
00024     struct helpers                                                      \
00025     {                                                                   \
00026         template < BOOST_PP_ENUM_PARAMS_Z(1, nargs, class U) >          \
00027         static yes test(                                                \
00028            qualified_name< BOOST_PP_ENUM_PARAMS_Z(1, nargs, U) >&, int  \
00029         );                                                              \
00030                                                                         \
00031         template <class U>                                              \
00032         static no test(U&, ...);                                        \
00033     };                                                                  \
00034                                                                         \
00035     BOOST_STATIC_CONSTANT(                                              \
00036         bool, value                                                     \
00037         = !is_reference<X_>::value                                      \
00038         & (sizeof(helpers::test(dummy, 0)) == sizeof(yes)));            \
00039                                                                         \
00040     typedef mpl::bool_<value> type;                                     \
00041 };
00042 
00043 # else
00044 
00045 #  define BOOST_DETAIL_IS_XXX_DEF(name, qualified_name, nargs)  \
00046 template <class T>                                              \
00047 struct is_##name : mpl::false_                                  \
00048 {                                                               \
00049 };                                                              \
00050                                                                 \
00051 template < BOOST_PP_ENUM_PARAMS_Z(1, nargs, class T) >          \
00052 struct is_##name<                                               \
00053    qualified_name< BOOST_PP_ENUM_PARAMS_Z(1, nargs, T) >        \
00054 >                                                               \
00055    : mpl::true_                                                 \
00056 {                                                               \
00057 };
00058 
00059 # endif
00060 
00061 #endif // BOOST_DETAIL_IS_XXX_DWA20051011_HPP


appl
Author(s): petercai
autogenerated on Tue Jan 7 2014 11:02:29