blob: 1885d5cb2d41e038164647de9ac7f68b8d3b688d [file] [log] [blame]
Jeff Thompsonf7d49942013-08-01 16:47:40 -07001// (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
Jeff Thompson3d613fd2013-10-15 15:39:04 -070010#ifndef NDNBOOST_TT_IS_CLASS_HPP_INCLUDED
11#define NDNBOOST_TT_IS_CLASS_HPP_INCLUDED
Jeff Thompsonf7d49942013-08-01 16:47:40 -070012
Jeff Thompson2277ce52013-08-01 17:34:11 -070013#include <ndnboost/type_traits/config.hpp>
14#include <ndnboost/type_traits/intrinsics.hpp>
Jeff Thompson3d613fd2013-10-15 15:39:04 -070015#ifndef NDNBOOST_IS_CLASS
Jeff Thompson2277ce52013-08-01 17:34:11 -070016# include <ndnboost/type_traits/is_union.hpp>
17# include <ndnboost/type_traits/detail/ice_and.hpp>
18# include <ndnboost/type_traits/detail/ice_not.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070019
Jeff Thompson3d613fd2013-10-15 15:39:04 -070020#ifdef NDNBOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION
Jeff Thompson2277ce52013-08-01 17:34:11 -070021# include <ndnboost/type_traits/detail/yes_no_type.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070022#else
Jeff Thompson2277ce52013-08-01 17:34:11 -070023# include <ndnboost/type_traits/is_scalar.hpp>
24# include <ndnboost/type_traits/is_array.hpp>
25# include <ndnboost/type_traits/is_reference.hpp>
26# include <ndnboost/type_traits/is_void.hpp>
27# include <ndnboost/type_traits/is_function.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070028#endif
29
Jeff Thompson3d613fd2013-10-15 15:39:04 -070030#endif // NDNBOOST_IS_CLASS
Jeff Thompsonf7d49942013-08-01 16:47:40 -070031
32#ifdef __EDG_VERSION__
Jeff Thompson2277ce52013-08-01 17:34:11 -070033# include <ndnboost/type_traits/remove_cv.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070034#endif
35
36// should be the last #include
Jeff Thompson2277ce52013-08-01 17:34:11 -070037#include <ndnboost/type_traits/detail/bool_trait_def.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070038
39namespace ndnboost {
40
41namespace detail {
42
Jeff Thompson3d613fd2013-10-15 15:39:04 -070043#ifndef NDNBOOST_IS_CLASS
44#ifdef NDNBOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION
Jeff Thompsonf7d49942013-08-01 16:47:40 -070045
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
Jeff Thompson9939dcd2013-10-15 15:12:24 -070049// ndnboost/type_traits/object_traits.hpp. This implementation
Jeff Thompsonf7d49942013-08-01 16:47:40 -070050// actually works with VC7.0, but other interactions seem to fail
51// when we use it.
52
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__)
57
58template <class U> ::ndnboost::type_traits::yes_type is_class_tester(void(U::*)(void));
59template <class U> ::ndnboost::type_traits::no_type is_class_tester(...);
60
61template <typename T>
62struct is_class_impl
63{
64
Jeff Thompson3d613fd2013-10-15 15:39:04 -070065 NDNBOOST_STATIC_CONSTANT(bool, value =
Jeff Thompsonf7d49942013-08-01 16:47:40 -070066 (::ndnboost::type_traits::ice_and<
67 sizeof(is_class_tester<T>(0)) == sizeof(::ndnboost::type_traits::yes_type),
68 ::ndnboost::type_traits::ice_not< ::ndnboost::is_union<T>::value >::value
69 >::value)
70 );
71};
72
73#else
74
75template <typename T>
76struct is_class_impl
77{
78 template <class U> static ::ndnboost::type_traits::yes_type is_class_tester(void(U::*)(void));
79 template <class U> static ::ndnboost::type_traits::no_type is_class_tester(...);
80
Jeff Thompson3d613fd2013-10-15 15:39:04 -070081 NDNBOOST_STATIC_CONSTANT(bool, value =
Jeff Thompsonf7d49942013-08-01 16:47:40 -070082 (::ndnboost::type_traits::ice_and<
83 sizeof(is_class_tester<T>(0)) == sizeof(::ndnboost::type_traits::yes_type),
84 ::ndnboost::type_traits::ice_not< ::ndnboost::is_union<T>::value >::value
85 >::value)
86 );
87};
88
89#endif
90
91#else
92
93template <typename T>
94struct is_class_impl
95{
Jeff Thompson3d613fd2013-10-15 15:39:04 -070096# ifndef NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
97 NDNBOOST_STATIC_CONSTANT(bool, value =
Jeff Thompsonf7d49942013-08-01 16:47:40 -070098 (::ndnboost::type_traits::ice_and<
99 ::ndnboost::type_traits::ice_not< ::ndnboost::is_union<T>::value >::value,
100 ::ndnboost::type_traits::ice_not< ::ndnboost::is_scalar<T>::value >::value,
101 ::ndnboost::type_traits::ice_not< ::ndnboost::is_array<T>::value >::value,
102 ::ndnboost::type_traits::ice_not< ::ndnboost::is_reference<T>::value>::value,
103 ::ndnboost::type_traits::ice_not< ::ndnboost::is_void<T>::value >::value,
104 ::ndnboost::type_traits::ice_not< ::ndnboost::is_function<T>::value >::value
105 >::value));
106# else
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700107 NDNBOOST_STATIC_CONSTANT(bool, value =
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700108 (::ndnboost::type_traits::ice_and<
109 ::ndnboost::type_traits::ice_not< ::ndnboost::is_union<T>::value >::value,
110 ::ndnboost::type_traits::ice_not< ::ndnboost::is_scalar<T>::value >::value,
111 ::ndnboost::type_traits::ice_not< ::ndnboost::is_array<T>::value >::value,
112 ::ndnboost::type_traits::ice_not< ::ndnboost::is_reference<T>::value>::value,
113 ::ndnboost::type_traits::ice_not< ::ndnboost::is_void<T>::value >::value
114 >::value));
115# endif
116};
117
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700118# endif // NDNBOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION
119# else // NDNBOOST_IS_CLASS
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700120template <typename T>
121struct is_class_impl
122{
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700123 NDNBOOST_STATIC_CONSTANT(bool, value = NDNBOOST_IS_CLASS(T));
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700124};
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700125# endif // NDNBOOST_IS_CLASS
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700126
127} // namespace detail
128
129# ifdef __EDG_VERSION__
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700130NDNBOOST_TT_AUX_BOOL_TRAIT_DEF1(
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700131 is_class,T, ndnboost::detail::is_class_impl<typename ndnboost::remove_cv<T>::type>::value)
132# else
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700133NDNBOOST_TT_AUX_BOOL_TRAIT_DEF1(is_class,T,::ndnboost::detail::is_class_impl<T>::value)
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700134# endif
135
136} // namespace ndnboost
137
Jeff Thompson2277ce52013-08-01 17:34:11 -0700138#include <ndnboost/type_traits/detail/bool_trait_undef.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700139
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700140#endif // NDNBOOST_TT_IS_CLASS_HPP_INCLUDED