fix doc example typo
[boost.git] / boost / type_traits / is_class.hpp
blob1a2cd20157c254de641247e527a3af58cb3941ae
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.
10 #ifndef BOOST_TT_IS_CLASS_HPP_INCLUDED
11 #define BOOST_TT_IS_CLASS_HPP_INCLUDED
13 #include <boost/type_traits/config.hpp>
14 #include <boost/type_traits/intrinsics.hpp>
15 #ifndef BOOST_IS_CLASS
16 # include <boost/type_traits/is_union.hpp>
17 # include <boost/type_traits/detail/ice_and.hpp>
18 # include <boost/type_traits/detail/ice_not.hpp>
20 #ifdef BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION
21 # include <boost/type_traits/detail/yes_no_type.hpp>
22 #else
23 # include <boost/type_traits/is_scalar.hpp>
24 # include <boost/type_traits/is_array.hpp>
25 # include <boost/type_traits/is_reference.hpp>
26 # include <boost/type_traits/is_void.hpp>
27 # include <boost/type_traits/is_function.hpp>
28 #endif
30 #endif // BOOST_IS_CLASS
32 #ifdef __EDG_VERSION__
33 # include <boost/type_traits/remove_cv.hpp>
34 #endif
36 // should be the last #include
37 #include <boost/type_traits/detail/bool_trait_def.hpp>
39 namespace boost {
41 namespace detail {
43 #ifndef BOOST_IS_CLASS
44 #ifdef BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION
46 // This is actually the conforming implementation which works with
47 // abstract classes. However, enough compilers have trouble with
48 // it that most will use the one in
49 // boost/type_traits/object_traits.hpp. This implementation
50 // actually works with VC7.0, but other interactions seem to fail
51 // when we use it.
53 // is_class<> metafunction due to Paul Mensonides
54 // (leavings@attbi.com). For more details:
55 // http://groups.google.com/groups?hl=en&selm=000001c1cc83%24e154d5e0%247772e50c%40c161550a&rnum=1
56 #if defined(__GNUC__) && !defined(__EDG_VERSION__)
58 template <class U> ::boost::type_traits::yes_type is_class_tester(void(U::*)(void));
59 template <class U> ::boost::type_traits::no_type is_class_tester(...);
61 template <typename T>
62 struct is_class_impl
65 BOOST_STATIC_CONSTANT(bool, value =
66 (::boost::type_traits::ice_and<
67 sizeof(is_class_tester<T>(0)) == sizeof(::boost::type_traits::yes_type),
68 ::boost::type_traits::ice_not< ::boost::is_union<T>::value >::value
69 >::value)
73 #else
75 template <typename T>
76 struct is_class_impl
78 template <class U> static ::boost::type_traits::yes_type is_class_tester(void(U::*)(void));
79 template <class U> static ::boost::type_traits::no_type is_class_tester(...);
81 BOOST_STATIC_CONSTANT(bool, value =
82 (::boost::type_traits::ice_and<
83 sizeof(is_class_tester<T>(0)) == sizeof(::boost::type_traits::yes_type),
84 ::boost::type_traits::ice_not< ::boost::is_union<T>::value >::value
85 >::value)
89 #endif
91 #else
93 template <typename T>
94 struct is_class_impl
96 # ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
97 BOOST_STATIC_CONSTANT(bool, value =
98 (::boost::type_traits::ice_and<
99 ::boost::type_traits::ice_not< ::boost::is_union<T>::value >::value,
100 ::boost::type_traits::ice_not< ::boost::is_scalar<T>::value >::value,
101 ::boost::type_traits::ice_not< ::boost::is_array<T>::value >::value,
102 ::boost::type_traits::ice_not< ::boost::is_reference<T>::value>::value,
103 ::boost::type_traits::ice_not< ::boost::is_void<T>::value >::value,
104 ::boost::type_traits::ice_not< ::boost::is_function<T>::value >::value
105 >::value));
106 # else
107 BOOST_STATIC_CONSTANT(bool, value =
108 (::boost::type_traits::ice_and<
109 ::boost::type_traits::ice_not< ::boost::is_union<T>::value >::value,
110 ::boost::type_traits::ice_not< ::boost::is_scalar<T>::value >::value,
111 ::boost::type_traits::ice_not< ::boost::is_array<T>::value >::value,
112 ::boost::type_traits::ice_not< ::boost::is_reference<T>::value>::value,
113 ::boost::type_traits::ice_not< ::boost::is_void<T>::value >::value
114 >::value));
115 # endif
118 # endif // BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION
119 # else // BOOST_IS_CLASS
120 template <typename T>
121 struct is_class_impl
123 BOOST_STATIC_CONSTANT(bool, value = BOOST_IS_CLASS(T));
125 # endif // BOOST_IS_CLASS
127 } // namespace detail
129 # ifdef __EDG_VERSION__
130 BOOST_TT_AUX_BOOL_TRAIT_DEF1(
131 is_class,T, boost::detail::is_class_impl<typename boost::remove_cv<T>::type>::value)
132 # else
133 BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_class,T,::boost::detail::is_class_impl<T>::value)
134 # endif
136 } // namespace boost
138 #include <boost/type_traits/detail/bool_trait_undef.hpp>
140 #endif // BOOST_TT_IS_CLASS_HPP_INCLUDED