1
//-----------------------------------------------------------------------------
2
// boost mpl/aux_/has_xxx.hpp header file
3
// See http://www.boost.org for updates, documentation, and revision history.
4
//-----------------------------------------------------------------------------
9
// Permission to use, copy, modify, distribute and sell this software
10
// and its documentation for any purpose is hereby granted without fee,
11
// provided that the above copyright notice appears in all copies and
12
// that both the copyright notice and this permission notice appear in
13
// supporting documentation. No representations are made about the
14
// suitability of this software for any purpose. It is provided "as is"
15
// without express or implied warranty.
17
#ifndef BOOST_MPL_AUX_HAS_XXX_HPP_INCLUDED
18
#define BOOST_MPL_AUX_HAS_XXX_HPP_INCLUDED
20
#include "boost/mpl/aux_/type_wrapper.hpp"
21
#include "boost/mpl/aux_/yes_no.hpp"
22
#include "boost/mpl/aux_/config/msvc_typename.hpp"
23
#include "boost/mpl/aux_/config/overload_resolution.hpp"
24
#include "boost/mpl/aux_/config/static_constant.hpp"
26
#if !defined(BOOST_MPL_BROKEN_OVERLOAD_RESOLUTION) && (!defined(__GNUC__) || __GNUC__ == 3)
28
# if (!defined(BOOST_MSVC) || BOOST_MSVC > 1300)
30
// the implementation below is based on a USENET newsgroup's posting by
31
// Rani Sharoni (comp.lang.c++.moderated, 2002-03-17 07:45:09 PST)
33
# define BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(trait, name, unused) \
34
template< typename T > \
35
boost::mpl::aux::yes_tag \
37
boost::mpl::aux::type_wrapper<T> const volatile* \
38
, boost::mpl::aux::type_wrapper<BOOST_MSVC_TYPENAME T::name>* = 0 \
41
boost::mpl::aux::no_tag \
42
trait##_helper(...); \
44
template< typename T > \
47
typedef boost::mpl::aux::type_wrapper<T> t_; \
48
BOOST_STATIC_CONSTANT(bool, value = \
49
sizeof((trait##_helper)(static_cast<t_*>(0))) \
50
== sizeof(boost::mpl::aux::yes_tag) \
57
#include "boost/mpl/if.hpp"
58
#include "boost/mpl/bool.hpp"
59
#include "boost/preprocessor/cat.hpp"
61
// agurt, 11/sep/02: MSVC version, based on a USENET newsgroup's posting by
62
// John Madsen (comp.lang.c++.moderated, 1999-11-12 19:17:06 GMT);
63
// note that the code is _not_ standard-conforming, but it works,
64
// and it resolves some nasty ICE cases with the above implementation
66
// Modified dwa 8/Oct/02 to handle reference types.
68
namespace boost { namespace mpl { namespace aux {
72
template< typename T >
73
struct msvc_is_incomplete
76
BOOST_STATIC_CONSTANT(bool, value =
77
sizeof(void (T::*)()) == sizeof(void (incomplete_::*)())
82
struct msvc_is_incomplete<int>
84
BOOST_STATIC_CONSTANT(bool, value = false);
89
# define BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF_(trait, name, unused) \
90
template< typename T, typename name = ::boost::mpl::aux::has_xxx_tag > \
91
struct BOOST_PP_CAT(trait,_impl) : T \
94
static boost::mpl::aux::no_tag test(void(*)(::boost::mpl::aux::has_xxx_tag)); \
95
static boost::mpl::aux::yes_tag test(...); \
98
BOOST_STATIC_CONSTANT(bool, value = \
99
sizeof(test(static_cast<void(*)(name)>(0))) \
100
!= sizeof(boost::mpl::aux::no_tag) \
104
template< typename T > struct trait \
105
: boost::mpl::if_c< \
106
boost::mpl::aux::msvc_is_incomplete<T>::value \
107
, boost::mpl::bool_<false> \
108
, BOOST_PP_CAT(trait,_impl)<T> \
113
BOOST_MPL_AUX_HAS_XXX_TRAIT_SPEC(trait, void) \
114
BOOST_MPL_AUX_HAS_XXX_TRAIT_SPEC(trait, bool) \
115
BOOST_MPL_AUX_HAS_XXX_TRAIT_SPEC(trait, char) \
116
BOOST_MPL_AUX_HAS_XXX_TRAIT_SPEC(trait, signed char) \
117
BOOST_MPL_AUX_HAS_XXX_TRAIT_SPEC(trait, unsigned char) \
118
BOOST_MPL_AUX_HAS_XXX_TRAIT_SPEC(trait, signed short) \
119
BOOST_MPL_AUX_HAS_XXX_TRAIT_SPEC(trait, unsigned short) \
120
BOOST_MPL_AUX_HAS_XXX_TRAIT_SPEC(trait, signed int) \
121
BOOST_MPL_AUX_HAS_XXX_TRAIT_SPEC(trait, unsigned int) \
122
BOOST_MPL_AUX_HAS_XXX_TRAIT_SPEC(trait, signed long) \
123
BOOST_MPL_AUX_HAS_XXX_TRAIT_SPEC(trait, unsigned long) \
124
BOOST_MPL_AUX_HAS_XXX_TRAIT_SPEC(trait, float) \
125
BOOST_MPL_AUX_HAS_XXX_TRAIT_SPEC(trait, double) \
126
BOOST_MPL_AUX_HAS_XXX_TRAIT_SPEC(trait, long double) \
129
# define BOOST_MPL_AUX_HAS_XXX_TRAIT_SPEC(trait, T) \
130
template<> struct trait<T> \
132
BOOST_STATIC_CONSTANT(bool,value = false); \
136
#if !defined(BOOST_NO_INTRINSIC_WCHAR_T)
137
# define BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(trait, name, unused) \
138
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF_(trait, name, unused) \
139
BOOST_MPL_AUX_HAS_XXX_TRAIT_SPEC(trait, wchar_t) \
142
# define BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(trait, name, unused) \
143
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF_(trait, name, unused) \
147
# endif // BOOST_MSVC > 1300
151
// agurt, 11/jan/03: signals a stub-only implementation
152
# define BOOST_NO_MPL_AUX_HAS_XXX
154
# define BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(trait, name, default_value) \
155
template< typename T > \
158
BOOST_STATIC_CONSTANT(bool, value = default_value); \
162
#endif // BOOST_MPL_BROKEN_OVERLOAD_RESOLUTION
164
#define BOOST_MPL_HAS_XXX_TRAIT_DEF(name) \
165
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_##name, name, false) \
168
#endif // BOOST_MPL_AUX_HAS_XXX_HPP_INCLUDED