1 | // (C) Copyright Dave Abrahams, Steve Cleary, Beman Dawes, Howard
|
---|
2 | // Hinnant & John Maddock 2000-2003.
|
---|
3 | // Use, modification and distribution are subject to the Boost Software License,
|
---|
4 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
---|
5 | // http://www.boost.org/LICENSE_1_0.txt).
|
---|
6 | //
|
---|
7 | // See http://www.boost.org/libs/type_traits for most recent version including documentation.
|
---|
8 |
|
---|
9 |
|
---|
10 | #ifndef BOOST_TT_IS_CLASS_HPP_INCLUDED
|
---|
11 | #define BOOST_TT_IS_CLASS_HPP_INCLUDED
|
---|
12 |
|
---|
13 | #include "boost/type_traits/config.hpp"
|
---|
14 | # include "boost/type_traits/is_union.hpp"
|
---|
15 | # include "boost/type_traits/detail/ice_and.hpp"
|
---|
16 | # include "boost/type_traits/detail/ice_not.hpp"
|
---|
17 |
|
---|
18 | #ifdef BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION
|
---|
19 | # include "boost/type_traits/detail/yes_no_type.hpp"
|
---|
20 | #else
|
---|
21 | # include "boost/type_traits/is_scalar.hpp"
|
---|
22 | # include "boost/type_traits/is_array.hpp"
|
---|
23 | # include "boost/type_traits/is_reference.hpp"
|
---|
24 | # include "boost/type_traits/is_void.hpp"
|
---|
25 | # include "boost/type_traits/is_function.hpp"
|
---|
26 | #endif
|
---|
27 |
|
---|
28 | #ifdef __EDG_VERSION__
|
---|
29 | # include "boost/type_traits/remove_cv.hpp"
|
---|
30 | #endif
|
---|
31 |
|
---|
32 | // should be the last #include
|
---|
33 | #include "boost/type_traits/detail/bool_trait_def.hpp"
|
---|
34 |
|
---|
35 | namespace boost {
|
---|
36 |
|
---|
37 | namespace detail {
|
---|
38 |
|
---|
39 | #ifdef BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION
|
---|
40 |
|
---|
41 | // This is actually the conforming implementation which works with
|
---|
42 | // abstract classes. However, enough compilers have trouble with
|
---|
43 | // it that most will use the one in
|
---|
44 | // boost/type_traits/object_traits.hpp. This implementation
|
---|
45 | // actually works with VC7.0, but other interactions seem to fail
|
---|
46 | // when we use it.
|
---|
47 |
|
---|
48 | // is_class<> metafunction due to Paul Mensonides
|
---|
49 | // (leavings@attbi.com). For more details:
|
---|
50 | // http://groups.google.com/groups?hl=en&selm=000001c1cc83%24e154d5e0%247772e50c%40c161550a&rnum=1
|
---|
51 | #if defined(__GNUC__) && !defined(__EDG_VERSION__)
|
---|
52 |
|
---|
53 | template <class U> ::boost::type_traits::yes_type is_class_tester(void(U::*)(void));
|
---|
54 | template <class U> ::boost::type_traits::no_type is_class_tester(...);
|
---|
55 |
|
---|
56 | template <typename T>
|
---|
57 | struct is_class_impl
|
---|
58 | {
|
---|
59 |
|
---|
60 | BOOST_STATIC_CONSTANT(bool, value =
|
---|
61 | (::boost::type_traits::ice_and<
|
---|
62 | sizeof(is_class_tester<T>(0)) == sizeof(::boost::type_traits::yes_type),
|
---|
63 | ::boost::type_traits::ice_not< ::boost::is_union<T>::value >::value
|
---|
64 | >::value)
|
---|
65 | );
|
---|
66 | };
|
---|
67 |
|
---|
68 | #else
|
---|
69 |
|
---|
70 | template <typename T>
|
---|
71 | struct is_class_impl
|
---|
72 | {
|
---|
73 | template <class U> static ::boost::type_traits::yes_type is_class_tester(void(U::*)(void));
|
---|
74 | template <class U> static ::boost::type_traits::no_type is_class_tester(...);
|
---|
75 |
|
---|
76 | BOOST_STATIC_CONSTANT(bool, value =
|
---|
77 | (::boost::type_traits::ice_and<
|
---|
78 | sizeof(is_class_tester<T>(0)) == sizeof(::boost::type_traits::yes_type),
|
---|
79 | ::boost::type_traits::ice_not< ::boost::is_union<T>::value >::value
|
---|
80 | >::value)
|
---|
81 | );
|
---|
82 | };
|
---|
83 |
|
---|
84 | #endif
|
---|
85 |
|
---|
86 | #else
|
---|
87 |
|
---|
88 | template <typename T>
|
---|
89 | struct is_class_impl
|
---|
90 | {
|
---|
91 | # ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
---|
92 | BOOST_STATIC_CONSTANT(bool, value =
|
---|
93 | (::boost::type_traits::ice_and<
|
---|
94 | ::boost::type_traits::ice_not< ::boost::is_union<T>::value >::value,
|
---|
95 | ::boost::type_traits::ice_not< ::boost::is_scalar<T>::value >::value,
|
---|
96 | ::boost::type_traits::ice_not< ::boost::is_array<T>::value >::value,
|
---|
97 | ::boost::type_traits::ice_not< ::boost::is_reference<T>::value>::value,
|
---|
98 | ::boost::type_traits::ice_not< ::boost::is_void<T>::value >::value,
|
---|
99 | ::boost::type_traits::ice_not< ::boost::is_function<T>::value >::value
|
---|
100 | >::value));
|
---|
101 | # else
|
---|
102 | BOOST_STATIC_CONSTANT(bool, value =
|
---|
103 | (::boost::type_traits::ice_and<
|
---|
104 | ::boost::type_traits::ice_not< ::boost::is_union<T>::value >::value,
|
---|
105 | ::boost::type_traits::ice_not< ::boost::is_scalar<T>::value >::value,
|
---|
106 | ::boost::type_traits::ice_not< ::boost::is_array<T>::value >::value,
|
---|
107 | ::boost::type_traits::ice_not< ::boost::is_reference<T>::value>::value,
|
---|
108 | ::boost::type_traits::ice_not< ::boost::is_void<T>::value >::value
|
---|
109 | >::value));
|
---|
110 | # endif
|
---|
111 | };
|
---|
112 |
|
---|
113 | # endif // BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION
|
---|
114 |
|
---|
115 | } // namespace detail
|
---|
116 |
|
---|
117 | # ifdef __EDG_VERSION__
|
---|
118 | BOOST_TT_AUX_BOOL_TRAIT_DEF1(
|
---|
119 | is_class,T, detail::is_class_impl<typename remove_cv<T>::type>::value)
|
---|
120 | # else
|
---|
121 | BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_class,T,::boost::detail::is_class_impl<T>::value)
|
---|
122 | # endif
|
---|
123 |
|
---|
124 | } // namespace boost
|
---|
125 |
|
---|
126 | #include "boost/type_traits/detail/bool_trait_undef.hpp"
|
---|
127 |
|
---|
128 | #endif // BOOST_TT_IS_CLASS_HPP_INCLUDED
|
---|