PageRenderTime 22ms CodeModel.GetById 10ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/extlibs/Boost/include/boost/type_traits/intrinsics.hpp

https://bitbucket.org/hugoruscitti/pilascpp
C++ Header | 240 lines | 148 code | 37 blank | 55 comment | 36 complexity | 6719f56d0613d2658f628dbb04ce63bf MD5 | raw file
  1
  2//  (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
  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#ifndef BOOST_TT_INTRINSICS_HPP_INCLUDED
 10#define BOOST_TT_INTRINSICS_HPP_INCLUDED
 11
 12#ifndef BOOST_TT_CONFIG_HPP_INCLUDED
 13#include <boost/type_traits/config.hpp>
 14#endif
 15
 16//
 17// Helper macros for builtin compiler support.
 18// If your compiler has builtin support for any of the following
 19// traits concepts, then redefine the appropriate macros to pick
 20// up on the compiler support:
 21//
 22// (these should largely ignore cv-qualifiers)
 23// BOOST_IS_UNION(T) should evaluate to true if T is a union type
 24// BOOST_IS_POD(T) should evaluate to true if T is a POD type
 25// BOOST_IS_EMPTY(T) should evaluate to true if T is an empty struct or union
 26// BOOST_HAS_TRIVIAL_CONSTRUCTOR(T) should evaluate to true if "T x;" has no effect
 27// BOOST_HAS_TRIVIAL_COPY(T) should evaluate to true if T(t) <==> memcpy
 28// BOOST_HAS_TRIVIAL_ASSIGN(T) should evaluate to true if t = u <==> memcpy
 29// BOOST_HAS_TRIVIAL_DESTRUCTOR(T) should evaluate to true if ~T() has no effect
 30// BOOST_HAS_NOTHROW_CONSTRUCTOR(T) should evaluate to true if "T x;" can not throw
 31// BOOST_HAS_NOTHROW_COPY(T) should evaluate to true if T(t) can not throw
 32// BOOST_HAS_NOTHROW_ASSIGN(T) should evaluate to true if t = u can not throw
 33// BOOST_HAS_VIRTUAL_DESTRUCTOR(T) should evaluate to true T has a virtual destructor
 34//
 35// The following can also be defined: when detected our implementation is greatly simplified.
 36// Note that unlike the macros above these do not have default definitions, so we can use
 37// #ifdef MACRONAME to detect when these are available.
 38//
 39// BOOST_IS_ABSTRACT(T) true if T is an abstract type
 40// BOOST_IS_BASE_OF(T,U) true if T is a base class of U
 41// BOOST_IS_CLASS(T) true if T is a class type
 42// BOOST_IS_CONVERTIBLE(T,U) true if T is convertible to U
 43// BOOST_IS_ENUM(T) true is T is an enum
 44// BOOST_IS_POLYMORPHIC(T) true if T is a polymorphic type
 45// BOOST_ALIGNMENT_OF(T) should evaluate to the alignment requirements of type T.
 46
 47#ifdef BOOST_HAS_SGI_TYPE_TRAITS
 48    // Hook into SGI's __type_traits class, this will pick up user supplied
 49    // specializations as well as SGI - compiler supplied specializations.
 50#   include <boost/type_traits/is_same.hpp>
 51#   ifdef __NetBSD__
 52      // There are two different versions of type_traits.h on NetBSD on Spark
 53      // use an implicit include via algorithm instead, to make sure we get
 54      // the same version as the std lib:
 55#     include <algorithm>
 56#   else
 57#    include <type_traits.h>
 58#   endif
 59#   define BOOST_IS_POD(T) ::boost::is_same< typename ::__type_traits<T>::is_POD_type, ::__true_type>::value
 60#   define BOOST_HAS_TRIVIAL_CONSTRUCTOR(T) ::boost::is_same< typename ::__type_traits<T>::has_trivial_default_constructor, ::__true_type>::value
 61#   define BOOST_HAS_TRIVIAL_COPY(T) ::boost::is_same< typename ::__type_traits<T>::has_trivial_copy_constructor, ::__true_type>::value
 62#   define BOOST_HAS_TRIVIAL_ASSIGN(T) ::boost::is_same< typename ::__type_traits<T>::has_trivial_assignment_operator, ::__true_type>::value
 63#   define BOOST_HAS_TRIVIAL_DESTRUCTOR(T) ::boost::is_same< typename ::__type_traits<T>::has_trivial_destructor, ::__true_type>::value
 64
 65#   ifdef __sgi
 66#      define BOOST_HAS_TYPE_TRAITS_INTRINSICS
 67#   endif
 68#endif
 69
 70#if defined(__MSL_CPP__) && (__MSL_CPP__ >= 0x8000)
 71    // Metrowerks compiler is acquiring intrinsic type traits support
 72    // post version 8.  We hook into the published interface to pick up
 73    // user defined specializations as well as compiler intrinsics as 
 74    // and when they become available:
 75#   include <msl_utility>
 76#   define BOOST_IS_UNION(T) BOOST_STD_EXTENSION_NAMESPACE::is_union<T>::value
 77#   define BOOST_IS_POD(T) BOOST_STD_EXTENSION_NAMESPACE::is_POD<T>::value
 78#   define BOOST_HAS_TRIVIAL_CONSTRUCTOR(T) BOOST_STD_EXTENSION_NAMESPACE::has_trivial_default_ctor<T>::value
 79#   define BOOST_HAS_TRIVIAL_COPY(T) BOOST_STD_EXTENSION_NAMESPACE::has_trivial_copy_ctor<T>::value
 80#   define BOOST_HAS_TRIVIAL_ASSIGN(T) BOOST_STD_EXTENSION_NAMESPACE::has_trivial_assignment<T>::value
 81#   define BOOST_HAS_TRIVIAL_DESTRUCTOR(T) BOOST_STD_EXTENSION_NAMESPACE::has_trivial_dtor<T>::value
 82#   define BOOST_HAS_TYPE_TRAITS_INTRINSICS
 83#endif
 84
 85#if defined(BOOST_MSVC) && defined(BOOST_MSVC_FULL_VER) && (BOOST_MSVC_FULL_VER >=140050215)
 86#   include <boost/type_traits/is_same.hpp>
 87
 88#   define BOOST_IS_UNION(T) __is_union(T)
 89#   define BOOST_IS_POD(T) (__is_pod(T) && __has_trivial_constructor(T))
 90#   define BOOST_IS_EMPTY(T) __is_empty(T)
 91#   define BOOST_HAS_TRIVIAL_CONSTRUCTOR(T) __has_trivial_constructor(T)
 92#   define BOOST_HAS_TRIVIAL_COPY(T) __has_trivial_copy(T)
 93#   define BOOST_HAS_TRIVIAL_ASSIGN(T) __has_trivial_assign(T)
 94#   define BOOST_HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T)
 95#   define BOOST_HAS_NOTHROW_CONSTRUCTOR(T) __has_nothrow_constructor(T)
 96#   define BOOST_HAS_NOTHROW_COPY(T) __has_nothrow_copy(T)
 97#   define BOOST_HAS_NOTHROW_ASSIGN(T) __has_nothrow_assign(T)
 98#   define BOOST_HAS_VIRTUAL_DESTRUCTOR(T) __has_virtual_destructor(T)
 99
100#   define BOOST_IS_ABSTRACT(T) __is_abstract(T)
101#   define BOOST_IS_BASE_OF(T,U) (__is_base_of(T,U) && !is_same<T,U>::value)
102#   define BOOST_IS_CLASS(T) __is_class(T)
103//  This one doesn't quite always do the right thing:
104//  #   define BOOST_IS_CONVERTIBLE(T,U) __is_convertible_to(T,U)
105#   define BOOST_IS_ENUM(T) __is_enum(T)
106//  This one doesn't quite always do the right thing:
107//  #   define BOOST_IS_POLYMORPHIC(T) __is_polymorphic(T)
108//  This one fails if the default alignment has been changed with /Zp:
109//  #   define BOOST_ALIGNMENT_OF(T) __alignof(T)
110
111#   define BOOST_HAS_TYPE_TRAITS_INTRINSICS
112#endif
113
114#if defined(__DMC__) && (__DMC__ >= 0x848)
115// For Digital Mars C++, www.digitalmars.com
116#   define BOOST_IS_UNION(T) (__typeinfo(T) & 0x400)
117#   define BOOST_IS_POD(T) (__typeinfo(T) & 0x800)
118#   define BOOST_IS_EMPTY(T) (__typeinfo(T) & 0x1000)
119#   define BOOST_HAS_TRIVIAL_CONSTRUCTOR(T) (__typeinfo(T) & 0x10)
120#   define BOOST_HAS_TRIVIAL_COPY(T) (__typeinfo(T) & 0x20)
121#   define BOOST_HAS_TRIVIAL_ASSIGN(T) (__typeinfo(T) & 0x40)
122#   define BOOST_HAS_TRIVIAL_DESTRUCTOR(T) (__typeinfo(T) & 0x8)
123#   define BOOST_HAS_NOTHROW_CONSTRUCTOR(T) (__typeinfo(T) & 0x80)
124#   define BOOST_HAS_NOTHROW_COPY(T) (__typeinfo(T) & 0x100)
125#   define BOOST_HAS_NOTHROW_ASSIGN(T) (__typeinfo(T) & 0x200)
126#   define BOOST_HAS_VIRTUAL_DESTRUCTOR(T) (__typeinfo(T) & 0x4)
127#   define BOOST_HAS_TYPE_TRAITS_INTRINSICS
128#endif
129
130#if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3) && !defined(__GCCXML__)))
131#   include <boost/type_traits/is_same.hpp>
132#   include <boost/type_traits/is_reference.hpp>
133#   include <boost/type_traits/is_volatile.hpp>
134
135#   define BOOST_IS_UNION(T) __is_union(T)
136#   define BOOST_IS_POD(T) __is_pod(T)
137#   define BOOST_IS_EMPTY(T) __is_empty(T)
138#   define BOOST_HAS_TRIVIAL_CONSTRUCTOR(T) __has_trivial_constructor(T)
139#   define BOOST_HAS_TRIVIAL_COPY(T) (__has_trivial_copy(T) && !is_reference<T>::value)
140#   define BOOST_HAS_TRIVIAL_ASSIGN(T) __has_trivial_assign(T)
141#   define BOOST_HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T)
142#   define BOOST_HAS_NOTHROW_CONSTRUCTOR(T) __has_nothrow_constructor(T)
143#   define BOOST_HAS_NOTHROW_COPY(T) (__has_nothrow_copy(T) && !is_volatile<T>::value && !is_reference<T>::value)
144#   define BOOST_HAS_NOTHROW_ASSIGN(T) (__has_nothrow_assign(T) && !is_volatile<T>::value)
145#   define BOOST_HAS_VIRTUAL_DESTRUCTOR(T) __has_virtual_destructor(T)
146
147#   define BOOST_IS_ABSTRACT(T) __is_abstract(T)
148#   define BOOST_IS_BASE_OF(T,U) (__is_base_of(T,U) && !is_same<T,U>::value)
149#   define BOOST_IS_CLASS(T) __is_class(T)
150#   define BOOST_IS_ENUM(T) __is_enum(T)
151#   define BOOST_IS_POLYMORPHIC(T) __is_polymorphic(T)
152#   if (!defined(unix) && !defined(__unix__)) || defined(__LP64__)
153      // GCC sometimes lies about alignment requirements
154      // of type double on 32-bit unix platforms, use the
155      // old implementation instead in that case:
156#     define BOOST_ALIGNMENT_OF(T) __alignof__(T)
157#   endif
158
159#   define BOOST_HAS_TYPE_TRAITS_INTRINSICS
160#endif
161
162# if defined(__CODEGEARC__)
163#   include <boost/type_traits/is_same.hpp>
164#   include <boost/type_traits/is_reference.hpp>
165#   include <boost/type_traits/is_volatile.hpp>
166#   include <boost/type_traits/is_void.hpp>
167
168#   define BOOST_IS_UNION(T) __is_union(T)
169#   define BOOST_IS_POD(T) __is_pod(T)
170#   define BOOST_IS_EMPTY(T) __is_empty(T)
171#   define BOOST_HAS_TRIVIAL_CONSTRUCTOR(T) (__has_trivial_default_constructor(T) || is_void<T>::value)
172#   define BOOST_HAS_TRIVIAL_COPY(T) (__has_trivial_copy_constructor(T) && !is_volatile<T>::value && !is_reference<T>::value || is_void<T>::value)
173#   define BOOST_HAS_TRIVIAL_ASSIGN(T) (__has_trivial_assign(T) && !is_volatile<T>::value || is_void<T>::value)
174#   define BOOST_HAS_TRIVIAL_DESTRUCTOR(T) (__has_trivial_destructor(T) || is_void<T>::value)
175#   define BOOST_HAS_NOTHROW_CONSTRUCTOR(T) (__has_nothrow_default_constructor(T) || is_void<T>::value)
176#   define BOOST_HAS_NOTHROW_COPY(T) (__has_nothrow_copy_constructor(T) && !is_volatile<T>::value && !is_reference<T>::value || is_void<T>::value)
177#   define BOOST_HAS_NOTHROW_ASSIGN(T) (__has_nothrow_assign(T) && !is_volatile<T>::value || is_void<T>::value)
178#   define BOOST_HAS_VIRTUAL_DESTRUCTOR(T) __has_virtual_destructor(T)
179
180#   define BOOST_IS_ABSTRACT(T) __is_abstract(T)
181#   define BOOST_IS_BASE_OF(T,U) (__is_base_of(T,U) && !is_void<T>::value && !is_void<U>::value)
182#   define BOOST_IS_CLASS(T) __is_class(T)
183#   define BOOST_IS_CONVERTIBLE(T,U) (__is_convertible(T,U) || is_void<U>::value)
184#   define BOOST_IS_ENUM(T) __is_enum(T)
185#   define BOOST_IS_POLYMORPHIC(T) __is_polymorphic(T)
186#   define BOOST_ALIGNMENT_OF(T) alignof(T)
187
188#   define BOOST_HAS_TYPE_TRAITS_INTRINSICS
189#endif
190
191#ifndef BOOST_IS_UNION
192#   define BOOST_IS_UNION(T) false
193#endif
194
195#ifndef BOOST_IS_POD
196#   define BOOST_IS_POD(T) false
197#endif
198
199#ifndef BOOST_IS_EMPTY
200#   define BOOST_IS_EMPTY(T) false
201#endif
202
203#ifndef BOOST_HAS_TRIVIAL_CONSTRUCTOR
204#   define BOOST_HAS_TRIVIAL_CONSTRUCTOR(T) false
205#endif
206
207#ifndef BOOST_HAS_TRIVIAL_COPY
208#   define BOOST_HAS_TRIVIAL_COPY(T) false
209#endif
210
211#ifndef BOOST_HAS_TRIVIAL_ASSIGN
212#   define BOOST_HAS_TRIVIAL_ASSIGN(T) false
213#endif
214
215#ifndef BOOST_HAS_TRIVIAL_DESTRUCTOR
216#   define BOOST_HAS_TRIVIAL_DESTRUCTOR(T) false
217#endif
218
219#ifndef BOOST_HAS_NOTHROW_CONSTRUCTOR
220#   define BOOST_HAS_NOTHROW_CONSTRUCTOR(T) false
221#endif
222
223#ifndef BOOST_HAS_NOTHROW_COPY
224#   define BOOST_HAS_NOTHROW_COPY(T) false
225#endif
226
227#ifndef BOOST_HAS_NOTHROW_ASSIGN
228#   define BOOST_HAS_NOTHROW_ASSIGN(T) false
229#endif
230
231#ifndef BOOST_HAS_VIRTUAL_DESTRUCTOR
232#   define BOOST_HAS_VIRTUAL_DESTRUCTOR(T) false
233#endif
234
235#endif // BOOST_TT_INTRINSICS_HPP_INCLUDED
236
237
238
239
240