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