blob: 53f894c7004a241cf4cd5bf2887592472c6ef546 [file] [log] [blame]
Jeff Thompsonf7d49942013-08-01 16:47:40 -07001// (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
2// Use, modification and distribution are subject to the Boost Software License,
3// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
4// http://www.boost.org/LICENSE_1_0.txt).
5//
6// See http://www.boost.org/libs/type_traits for most recent version including documentation.
7
8#ifndef BOOST_TT_INTRINSICS_HPP_INCLUDED
9#define BOOST_TT_INTRINSICS_HPP_INCLUDED
10
11#ifndef BOOST_TT_CONFIG_HPP_INCLUDED
Jeff Thompson2277ce52013-08-01 17:34:11 -070012#include <ndnboost/type_traits/config.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070013#endif
14
15//
16// Helper macros for builtin compiler support.
17// If your compiler has builtin support for any of the following
18// traits concepts, then redefine the appropriate macros to pick
19// up on the compiler support:
20//
21// (these should largely ignore cv-qualifiers)
22// BOOST_IS_UNION(T) should evaluate to true if T is a union type
23// BOOST_IS_POD(T) should evaluate to true if T is a POD type
24// BOOST_IS_EMPTY(T) should evaluate to true if T is an empty class type (and not a union)
25// BOOST_HAS_TRIVIAL_CONSTRUCTOR(T) should evaluate to true if "T x;" has no effect
26// BOOST_HAS_TRIVIAL_COPY(T) should evaluate to true if T(t) <==> memcpy
27// BOOST_HAS_TRIVIAL_ASSIGN(T) should evaluate to true if t = u <==> memcpy
28// BOOST_HAS_TRIVIAL_DESTRUCTOR(T) should evaluate to true if ~T() has no effect
29// BOOST_HAS_NOTHROW_CONSTRUCTOR(T) should evaluate to true if "T x;" can not throw
30// BOOST_HAS_NOTHROW_COPY(T) should evaluate to true if T(t) can not throw
31// BOOST_HAS_NOTHROW_ASSIGN(T) should evaluate to true if t = u can not throw
32// BOOST_HAS_VIRTUAL_DESTRUCTOR(T) should evaluate to true T has a virtual destructor
33//
34// The following can also be defined: when detected our implementation is greatly simplified.
35//
36// BOOST_IS_ABSTRACT(T) true if T is an abstract type
37// BOOST_IS_BASE_OF(T,U) true if T is a base class of U
38// BOOST_IS_CLASS(T) true if T is a class type (and not a union)
39// BOOST_IS_CONVERTIBLE(T,U) true if T is convertible to U
40// BOOST_IS_ENUM(T) true is T is an enum
41// BOOST_IS_POLYMORPHIC(T) true if T is a polymorphic type
42// BOOST_ALIGNMENT_OF(T) should evaluate to the alignment requirements of type T.
43
44#ifdef BOOST_HAS_SGI_TYPE_TRAITS
45 // Hook into SGI's __type_traits class, this will pick up user supplied
46 // specializations as well as SGI - compiler supplied specializations.
Jeff Thompson2277ce52013-08-01 17:34:11 -070047# include <ndnboost/type_traits/is_same.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070048# ifdef __NetBSD__
49 // There are two different versions of type_traits.h on NetBSD on Spark
50 // use an implicit include via algorithm instead, to make sure we get
51 // the same version as the std lib:
52# include <algorithm>
53# else
54# include <type_traits.h>
55# endif
56# define BOOST_IS_POD(T) ::ndnboost::is_same< typename ::__type_traits<T>::is_POD_type, ::__true_type>::value
57# define BOOST_HAS_TRIVIAL_CONSTRUCTOR(T) ::ndnboost::is_same< typename ::__type_traits<T>::has_trivial_default_constructor, ::__true_type>::value
58# define BOOST_HAS_TRIVIAL_COPY(T) ::ndnboost::is_same< typename ::__type_traits<T>::has_trivial_copy_constructor, ::__true_type>::value
59# define BOOST_HAS_TRIVIAL_ASSIGN(T) ::ndnboost::is_same< typename ::__type_traits<T>::has_trivial_assignment_operator, ::__true_type>::value
60# define BOOST_HAS_TRIVIAL_DESTRUCTOR(T) ::ndnboost::is_same< typename ::__type_traits<T>::has_trivial_destructor, ::__true_type>::value
61
62# ifdef __sgi
63# define BOOST_HAS_TYPE_TRAITS_INTRINSICS
64# endif
65#endif
66
67#if defined(__MSL_CPP__) && (__MSL_CPP__ >= 0x8000)
68 // Metrowerks compiler is acquiring intrinsic type traits support
69 // post version 8. We hook into the published interface to pick up
70 // user defined specializations as well as compiler intrinsics as
71 // and when they become available:
72# include <msl_utility>
73# define BOOST_IS_UNION(T) BOOST_STD_EXTENSION_NAMESPACE::is_union<T>::value
74# define BOOST_IS_POD(T) BOOST_STD_EXTENSION_NAMESPACE::is_POD<T>::value
75# define BOOST_HAS_TRIVIAL_CONSTRUCTOR(T) BOOST_STD_EXTENSION_NAMESPACE::has_trivial_default_ctor<T>::value
76# define BOOST_HAS_TRIVIAL_COPY(T) BOOST_STD_EXTENSION_NAMESPACE::has_trivial_copy_ctor<T>::value
77# define BOOST_HAS_TRIVIAL_ASSIGN(T) BOOST_STD_EXTENSION_NAMESPACE::has_trivial_assignment<T>::value
78# define BOOST_HAS_TRIVIAL_DESTRUCTOR(T) BOOST_STD_EXTENSION_NAMESPACE::has_trivial_dtor<T>::value
79# define BOOST_HAS_TYPE_TRAITS_INTRINSICS
80#endif
81
82#if (defined(BOOST_MSVC) && defined(BOOST_MSVC_FULL_VER) && (BOOST_MSVC_FULL_VER >=140050215))\
83 || (defined(BOOST_INTEL) && defined(_MSC_VER) && (_MSC_VER >= 1500))
Jeff Thompson2277ce52013-08-01 17:34:11 -070084# include <ndnboost/type_traits/is_same.hpp>
85# include <ndnboost/type_traits/is_function.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070086
87# define BOOST_IS_UNION(T) __is_union(T)
88# define BOOST_IS_POD(T) (__is_pod(T) && __has_trivial_constructor(T))
89# define BOOST_IS_EMPTY(T) __is_empty(T)
90# define BOOST_HAS_TRIVIAL_CONSTRUCTOR(T) __has_trivial_constructor(T)
91# define BOOST_HAS_TRIVIAL_COPY(T) (__has_trivial_copy(T)|| ( ::ndnboost::is_pod<T>::value && !::ndnboost::is_volatile<T>::value))
92# define BOOST_HAS_TRIVIAL_ASSIGN(T) (__has_trivial_assign(T) || ( ::ndnboost::is_pod<T>::value && ! ::ndnboost::is_const<T>::value && !::ndnboost::is_volatile<T>::value))
93# define BOOST_HAS_TRIVIAL_DESTRUCTOR(T) (__has_trivial_destructor(T) || ::ndnboost::is_pod<T>::value)
94# define BOOST_HAS_NOTHROW_CONSTRUCTOR(T) (__has_nothrow_constructor(T) || ::ndnboost::has_trivial_constructor<T>::value)
95# define BOOST_HAS_NOTHROW_COPY(T) (__has_nothrow_copy(T) || ::ndnboost::has_trivial_copy<T>::value)
96# define BOOST_HAS_NOTHROW_ASSIGN(T) (__has_nothrow_assign(T) || ::ndnboost::has_trivial_assign<T>::value)
97# define BOOST_HAS_VIRTUAL_DESTRUCTOR(T) __has_virtual_destructor(T)
98
99# define BOOST_IS_ABSTRACT(T) __is_abstract(T)
100# define BOOST_IS_BASE_OF(T,U) (__is_base_of(T,U) && !is_same<T,U>::value)
101# define BOOST_IS_CLASS(T) __is_class(T)
102# define BOOST_IS_CONVERTIBLE(T,U) ((__is_convertible_to(T,U) || (is_same<T,U>::value && !is_function<U>::value)) && !__is_abstract(U))
103# define BOOST_IS_ENUM(T) __is_enum(T)
104// This one doesn't quite always do the right thing:
105// # define BOOST_IS_POLYMORPHIC(T) __is_polymorphic(T)
106// This one fails if the default alignment has been changed with /Zp:
107// # define BOOST_ALIGNMENT_OF(T) __alignof(T)
108
109# define BOOST_HAS_TYPE_TRAITS_INTRINSICS
110#endif
111
112#if defined(__DMC__) && (__DMC__ >= 0x848)
113// For Digital Mars C++, www.digitalmars.com
114# define BOOST_IS_UNION(T) (__typeinfo(T) & 0x400)
115# define BOOST_IS_POD(T) (__typeinfo(T) & 0x800)
116# define BOOST_IS_EMPTY(T) (__typeinfo(T) & 0x1000)
117# define BOOST_HAS_TRIVIAL_CONSTRUCTOR(T) (__typeinfo(T) & 0x10)
118# define BOOST_HAS_TRIVIAL_COPY(T) (__typeinfo(T) & 0x20)
119# define BOOST_HAS_TRIVIAL_ASSIGN(T) (__typeinfo(T) & 0x40)
120# define BOOST_HAS_TRIVIAL_DESTRUCTOR(T) (__typeinfo(T) & 0x8)
121# define BOOST_HAS_NOTHROW_CONSTRUCTOR(T) (__typeinfo(T) & 0x80)
122# define BOOST_HAS_NOTHROW_COPY(T) (__typeinfo(T) & 0x100)
123# define BOOST_HAS_NOTHROW_ASSIGN(T) (__typeinfo(T) & 0x200)
124# define BOOST_HAS_VIRTUAL_DESTRUCTOR(T) (__typeinfo(T) & 0x4)
125# define BOOST_HAS_TYPE_TRAITS_INTRINSICS
126#endif
127
128#if defined(BOOST_CLANG) && defined(__has_feature)
129# include <cstddef>
Jeff Thompson2277ce52013-08-01 17:34:11 -0700130# include <ndnboost/type_traits/is_same.hpp>
131# include <ndnboost/type_traits/is_reference.hpp>
132# include <ndnboost/type_traits/is_volatile.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700133
134# if __has_feature(is_union)
135# define BOOST_IS_UNION(T) __is_union(T)
136# endif
137# if (!defined(__GLIBCXX__) || (__GLIBCXX__ >= 20080306 && __GLIBCXX__ != 20080519)) && __has_feature(is_pod)
138# define BOOST_IS_POD(T) __is_pod(T)
139# endif
140# if (!defined(__GLIBCXX__) || (__GLIBCXX__ >= 20080306 && __GLIBCXX__ != 20080519)) && __has_feature(is_empty)
141# define BOOST_IS_EMPTY(T) __is_empty(T)
142# endif
143# if __has_feature(has_trivial_constructor)
144# define BOOST_HAS_TRIVIAL_CONSTRUCTOR(T) __has_trivial_constructor(T)
145# endif
146# if __has_feature(has_trivial_copy)
147# define BOOST_HAS_TRIVIAL_COPY(T) (__has_trivial_copy(T) && !is_reference<T>::value && !is_volatile<T>::value)
148# endif
149# if __has_feature(has_trivial_assign)
150# define BOOST_HAS_TRIVIAL_ASSIGN(T) (__has_trivial_assign(T) && !is_volatile<T>::value)
151# endif
152# if __has_feature(has_trivial_destructor)
153# define BOOST_HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T)
154# endif
155# if __has_feature(has_nothrow_constructor)
156# define BOOST_HAS_NOTHROW_CONSTRUCTOR(T) __has_nothrow_constructor(T)
157# endif
158# if __has_feature(has_nothrow_copy)
159# define BOOST_HAS_NOTHROW_COPY(T) (__has_nothrow_copy(T) && !is_volatile<T>::value && !is_reference<T>::value)
160# endif
161# if __has_feature(has_nothrow_assign)
162# define BOOST_HAS_NOTHROW_ASSIGN(T) (__has_nothrow_assign(T) && !is_volatile<T>::value)
163# endif
164# if __has_feature(has_virtual_destructor)
165# define BOOST_HAS_VIRTUAL_DESTRUCTOR(T) __has_virtual_destructor(T)
166# endif
167# if __has_feature(is_abstract)
168# define BOOST_IS_ABSTRACT(T) __is_abstract(T)
169# endif
170# if __has_feature(is_base_of)
171# define BOOST_IS_BASE_OF(T,U) (__is_base_of(T,U) && !is_same<T,U>::value)
172# endif
173# if __has_feature(is_class)
174# define BOOST_IS_CLASS(T) __is_class(T)
175# endif
176# if __has_feature(is_convertible_to)
Jeff Thompson2277ce52013-08-01 17:34:11 -0700177# include <ndnboost/type_traits/is_abstract.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700178# define BOOST_IS_CONVERTIBLE(T,U) (__is_convertible_to(T,U) && !::ndnboost::is_abstract<U>::value)
179# endif
180# if __has_feature(is_enum)
181# define BOOST_IS_ENUM(T) __is_enum(T)
182# endif
183# if __has_feature(is_polymorphic)
184# define BOOST_IS_POLYMORPHIC(T) __is_polymorphic(T)
185# endif
186# define BOOST_ALIGNMENT_OF(T) __alignof(T)
187
188# define BOOST_HAS_TYPE_TRAITS_INTRINSICS
189#endif
190
191#if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3) && !defined(__GCCXML__))) && !defined(BOOST_CLANG)
Jeff Thompson2277ce52013-08-01 17:34:11 -0700192# include <ndnboost/type_traits/is_same.hpp>
193# include <ndnboost/type_traits/is_reference.hpp>
194# include <ndnboost/type_traits/is_volatile.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700195
196#ifdef BOOST_INTEL
197# define BOOST_INTEL_TT_OPTS || is_pod<T>::value
198#else
199# define BOOST_INTEL_TT_OPTS
200#endif
201
202# define BOOST_IS_UNION(T) __is_union(T)
203# define BOOST_IS_POD(T) __is_pod(T)
204# define BOOST_IS_EMPTY(T) __is_empty(T)
205# define BOOST_HAS_TRIVIAL_CONSTRUCTOR(T) ((__has_trivial_constructor(T) BOOST_INTEL_TT_OPTS) && ! ::ndnboost::is_volatile<T>::value)
206# define BOOST_HAS_TRIVIAL_COPY(T) ((__has_trivial_copy(T) BOOST_INTEL_TT_OPTS) && !is_reference<T>::value && ! ::ndnboost::is_volatile<T>::value)
207# define BOOST_HAS_TRIVIAL_ASSIGN(T) ((__has_trivial_assign(T) BOOST_INTEL_TT_OPTS) && ! ::ndnboost::is_volatile<T>::value && ! ::ndnboost::is_const<T>::value)
208# define BOOST_HAS_TRIVIAL_DESTRUCTOR(T) (__has_trivial_destructor(T) BOOST_INTEL_TT_OPTS)
209# define BOOST_HAS_NOTHROW_CONSTRUCTOR(T) (__has_nothrow_constructor(T) BOOST_INTEL_TT_OPTS)
210# define BOOST_HAS_NOTHROW_COPY(T) ((__has_nothrow_copy(T) BOOST_INTEL_TT_OPTS) && !is_volatile<T>::value && !is_reference<T>::value)
211# define BOOST_HAS_NOTHROW_ASSIGN(T) ((__has_nothrow_assign(T) BOOST_INTEL_TT_OPTS) && !is_volatile<T>::value && !is_const<T>::value)
212# define BOOST_HAS_VIRTUAL_DESTRUCTOR(T) __has_virtual_destructor(T)
213
214# define BOOST_IS_ABSTRACT(T) __is_abstract(T)
215# define BOOST_IS_BASE_OF(T,U) (__is_base_of(T,U) && !is_same<T,U>::value)
216# define BOOST_IS_CLASS(T) __is_class(T)
217# define BOOST_IS_ENUM(T) __is_enum(T)
218# define BOOST_IS_POLYMORPHIC(T) __is_polymorphic(T)
219# if (!defined(unix) && !defined(__unix__)) || defined(__LP64__)
220 // GCC sometimes lies about alignment requirements
221 // of type double on 32-bit unix platforms, use the
222 // old implementation instead in that case:
223# define BOOST_ALIGNMENT_OF(T) __alignof__(T)
224# endif
225
226# define BOOST_HAS_TYPE_TRAITS_INTRINSICS
227#endif
228
229#if defined(__ghs__) && (__GHS_VERSION_NUMBER >= 600)
Jeff Thompson2277ce52013-08-01 17:34:11 -0700230# include <ndnboost/type_traits/is_same.hpp>
231# include <ndnboost/type_traits/is_reference.hpp>
232# include <ndnboost/type_traits/is_volatile.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700233
234# define BOOST_IS_UNION(T) __is_union(T)
235# define BOOST_IS_POD(T) __is_pod(T)
236# define BOOST_IS_EMPTY(T) __is_empty(T)
237# define BOOST_HAS_TRIVIAL_CONSTRUCTOR(T) __has_trivial_constructor(T)
238# define BOOST_HAS_TRIVIAL_COPY(T) (__has_trivial_copy(T) && !is_reference<T>::value && !is_volatile<T>::value)
239# define BOOST_HAS_TRIVIAL_ASSIGN(T) (__has_trivial_assign(T) && !is_volatile<T>::value)
240# define BOOST_HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T)
241# define BOOST_HAS_NOTHROW_CONSTRUCTOR(T) __has_nothrow_constructor(T)
242# define BOOST_HAS_NOTHROW_COPY(T) (__has_nothrow_copy(T) && !is_volatile<T>::value && !is_reference<T>::value)
243# define BOOST_HAS_NOTHROW_ASSIGN(T) (__has_nothrow_assign(T) && !is_volatile<T>::value)
244# define BOOST_HAS_VIRTUAL_DESTRUCTOR(T) __has_virtual_destructor(T)
245
246# define BOOST_IS_ABSTRACT(T) __is_abstract(T)
247# define BOOST_IS_BASE_OF(T,U) (__is_base_of(T,U) && !is_same<T,U>::value)
248# define BOOST_IS_CLASS(T) __is_class(T)
249# define BOOST_IS_ENUM(T) __is_enum(T)
250# define BOOST_IS_POLYMORPHIC(T) __is_polymorphic(T)
251# define BOOST_ALIGNMENT_OF(T) __alignof__(T)
252
253# define BOOST_HAS_TYPE_TRAITS_INTRINSICS
254#endif
255
256# if defined(__CODEGEARC__)
Jeff Thompson2277ce52013-08-01 17:34:11 -0700257# include <ndnboost/type_traits/is_same.hpp>
258# include <ndnboost/type_traits/is_reference.hpp>
259# include <ndnboost/type_traits/is_volatile.hpp>
260# include <ndnboost/type_traits/is_void.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700261
262# define BOOST_IS_UNION(T) __is_union(T)
263# define BOOST_IS_POD(T) __is_pod(T)
264# define BOOST_IS_EMPTY(T) __is_empty(T)
265# define BOOST_HAS_TRIVIAL_CONSTRUCTOR(T) (__has_trivial_default_constructor(T))
266# define BOOST_HAS_TRIVIAL_COPY(T) (__has_trivial_copy_constructor(T) && !is_volatile<T>::value && !is_reference<T>::value)
267# define BOOST_HAS_TRIVIAL_ASSIGN(T) (__has_trivial_assign(T) && !is_volatile<T>::value)
268# define BOOST_HAS_TRIVIAL_DESTRUCTOR(T) (__has_trivial_destructor(T))
269# define BOOST_HAS_NOTHROW_CONSTRUCTOR(T) (__has_nothrow_default_constructor(T))
270# define BOOST_HAS_NOTHROW_COPY(T) (__has_nothrow_copy_constructor(T) && !is_volatile<T>::value && !is_reference<T>::value)
271# define BOOST_HAS_NOTHROW_ASSIGN(T) (__has_nothrow_assign(T) && !is_volatile<T>::value)
272# define BOOST_HAS_VIRTUAL_DESTRUCTOR(T) __has_virtual_destructor(T)
273
274# define BOOST_IS_ABSTRACT(T) __is_abstract(T)
275# define BOOST_IS_BASE_OF(T,U) (__is_base_of(T,U) && !is_void<T>::value && !is_void<U>::value)
276# define BOOST_IS_CLASS(T) __is_class(T)
277# define BOOST_IS_CONVERTIBLE(T,U) (__is_convertible(T,U) || is_void<U>::value)
278# define BOOST_IS_ENUM(T) __is_enum(T)
279# define BOOST_IS_POLYMORPHIC(T) __is_polymorphic(T)
280# define BOOST_ALIGNMENT_OF(T) alignof(T)
281
282# define BOOST_HAS_TYPE_TRAITS_INTRINSICS
283#endif
284
285#endif // BOOST_TT_INTRINSICS_HPP_INCLUDED
286
287
288
289
290
291
292