]> git.lyx.org Git - lyx.git/blob - boost/boost/type_traits/is_class.hpp
update to boost 1.30.1
[lyx.git] / boost / boost / type_traits / is_class.hpp
1 //  (C) Copyright Dave Abrahams, Steve Cleary, Beman Dawes, Howard
2 //  Hinnant & John Maddock 2000-2002.  Permission to copy, use,
3 //  modify, sell and distribute this software is granted provided this
4 //  copyright notice appears in all copies. This software is provided
5 //  "as is" without express or implied warranty, and with no claim as
6 //  to its suitability for any purpose.
7 //
8 //  See http://www.boost.org for most recent version including documentation.
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 // should be the last #include
29 #include "boost/type_traits/detail/bool_trait_def.hpp"
30
31 namespace boost {
32
33 namespace detail {
34
35 #ifdef BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION
36
37 // This is actually the conforming implementation which works with
38 // abstract classes.  However, enough compilers have trouble with
39 // it that most will use the one in
40 // boost/type_traits/object_traits.hpp. This implementation
41 // actually works with VC7.0, but other interactions seem to fail
42 // when we use it.
43
44 // is_class<> metafunction due to Paul Mensonides
45 // (leavings@attbi.com). For more details:
46 // http://groups.google.com/groups?hl=en&selm=000001c1cc83%24e154d5e0%247772e50c%40c161550a&rnum=1
47
48 template <typename T>
49 struct is_class_impl
50 {
51     template <class U> static ::boost::type_traits::yes_type is_class_tester(void(U::*)(void));
52     template <class U> static ::boost::type_traits::no_type is_class_tester(...);
53
54     BOOST_STATIC_CONSTANT(bool, value = 
55         (::boost::type_traits::ice_and<
56             sizeof(is_class_tester<T>(0)) == sizeof(::boost::type_traits::yes_type),
57             ::boost::type_traits::ice_not< ::boost::is_union<T>::value >::value
58         >::value)
59         );
60 };
61
62 #else
63
64 template <typename T>
65 struct is_class_impl
66 {
67 #   ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
68     BOOST_STATIC_CONSTANT(bool, value =
69     (::boost::type_traits::ice_and<
70         ::boost::type_traits::ice_not< ::boost::is_union<T>::value >::value,
71         ::boost::type_traits::ice_not< ::boost::is_scalar<T>::value >::value,
72         ::boost::type_traits::ice_not< ::boost::is_array<T>::value >::value,
73         ::boost::type_traits::ice_not< ::boost::is_reference<T>::value>::value,
74         ::boost::type_traits::ice_not< ::boost::is_void<T>::value >::value,
75         ::boost::type_traits::ice_not< ::boost::is_function<T>::value >::value
76         >::value));
77 #   else
78     BOOST_STATIC_CONSTANT(bool, value =
79     (::boost::type_traits::ice_and<
80         ::boost::type_traits::ice_not< ::boost::is_union<T>::value >::value,
81         ::boost::type_traits::ice_not< ::boost::is_scalar<T>::value >::value,
82         ::boost::type_traits::ice_not< ::boost::is_array<T>::value >::value,
83         ::boost::type_traits::ice_not< ::boost::is_reference<T>::value>::value,
84         ::boost::type_traits::ice_not< ::boost::is_void<T>::value >::value
85         >::value));
86 #   endif
87 };
88
89 # endif // BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION
90
91 } // namespace detail
92
93 BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_class,T,::boost::detail::is_class_impl<T>::value)
94
95 } // namespace boost
96
97 #include "boost/type_traits/detail/bool_trait_undef.hpp"
98
99 #endif // BOOST_TT_IS_CLASS_HPP_INCLUDED