type_traits 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. // -*- C++ -*-
  2. //===-------------------------- type_traits -------------------------------===//
  3. //
  4. // The LLVM Compiler Infrastructure
  5. //
  6. // This file is dual licensed under the MIT and the University of Illinois Open
  7. // Source Licenses. See LICENSE.TXT for details.
  8. //
  9. //===----------------------------------------------------------------------===//
  10. #ifndef _LIBCPP_EXPERIMENTAL_TYPE_TRAITS
  11. #define _LIBCPP_EXPERIMENTAL_TYPE_TRAITS
  12. /**
  13. experimental/type_traits synopsis
  14. // C++1y
  15. #include <type_traits>
  16. namespace std {
  17. namespace experimental {
  18. inline namespace fundamentals_v1 {
  19. // See C++14 20.10.4.1, primary type categories
  20. template <class T> constexpr bool is_void_v
  21. = is_void<T>::value;
  22. template <class T> constexpr bool is_null_pointer_v
  23. = is_null_pointer<T>::value;
  24. template <class T> constexpr bool is_integral_v
  25. = is_integral<T>::value;
  26. template <class T> constexpr bool is_floating_point_v
  27. = is_floating_point<T>::value;
  28. template <class T> constexpr bool is_array_v
  29. = is_array<T>::value;
  30. template <class T> constexpr bool is_pointer_v
  31. = is_pointer<T>::value;
  32. template <class T> constexpr bool is_lvalue_reference_v
  33. = is_lvalue_reference<T>::value;
  34. template <class T> constexpr bool is_rvalue_reference_v
  35. = is_rvalue_reference<T>::value;
  36. template <class T> constexpr bool is_member_object_pointer_v
  37. = is_member_object_pointer<T>::value;
  38. template <class T> constexpr bool is_member_function_pointer_v
  39. = is_member_function_pointer<T>::value;
  40. template <class T> constexpr bool is_enum_v
  41. = is_enum<T>::value;
  42. template <class T> constexpr bool is_union_v
  43. = is_union<T>::value;
  44. template <class T> constexpr bool is_class_v
  45. = is_class<T>::value;
  46. template <class T> constexpr bool is_function_v
  47. = is_function<T>::value;
  48. // See C++14 20.10.4.2, composite type categories
  49. template <class T> constexpr bool is_reference_v
  50. = is_reference<T>::value;
  51. template <class T> constexpr bool is_arithmetic_v
  52. = is_arithmetic<T>::value;
  53. template <class T> constexpr bool is_fundamental_v
  54. = is_fundamental<T>::value;
  55. template <class T> constexpr bool is_object_v
  56. = is_object<T>::value;
  57. template <class T> constexpr bool is_scalar_v
  58. = is_scalar<T>::value;
  59. template <class T> constexpr bool is_compound_v
  60. = is_compound<T>::value;
  61. template <class T> constexpr bool is_member_pointer_v
  62. = is_member_pointer<T>::value;
  63. // See C++14 20.10.4.3, type properties
  64. template <class T> constexpr bool is_const_v
  65. = is_const<T>::value;
  66. template <class T> constexpr bool is_volatile_v
  67. = is_volatile<T>::value;
  68. template <class T> constexpr bool is_trivial_v
  69. = is_trivial<T>::value;
  70. template <class T> constexpr bool is_trivially_copyable_v
  71. = is_trivially_copyable<T>::value;
  72. template <class T> constexpr bool is_standard_layout_v
  73. = is_standard_layout<T>::value;
  74. template <class T> constexpr bool is_pod_v
  75. = is_pod<T>::value;
  76. template <class T> constexpr bool is_literal_type_v
  77. = is_literal_type<T>::value;
  78. template <class T> constexpr bool is_empty_v
  79. = is_empty<T>::value;
  80. template <class T> constexpr bool is_polymorphic_v
  81. = is_polymorphic<T>::value;
  82. template <class T> constexpr bool is_abstract_v
  83. = is_abstract<T>::value;
  84. template <class T> constexpr bool is_final_v
  85. = is_final<T>::value;
  86. template <class T> constexpr bool is_signed_v
  87. = is_signed<T>::value;
  88. template <class T> constexpr bool is_unsigned_v
  89. = is_unsigned<T>::value;
  90. template <class T, class... Args> constexpr bool is_constructible_v
  91. = is_constructible<T, Args...>::value;
  92. template <class T> constexpr bool is_default_constructible_v
  93. = is_default_constructible<T>::value;
  94. template <class T> constexpr bool is_copy_constructible_v
  95. = is_copy_constructible<T>::value;
  96. template <class T> constexpr bool is_move_constructible_v
  97. = is_move_constructible<T>::value;
  98. template <class T, class U> constexpr bool is_assignable_v
  99. = is_assignable<T, U>::value;
  100. template <class T> constexpr bool is_copy_assignable_v
  101. = is_copy_assignable<T>::value;
  102. template <class T> constexpr bool is_move_assignable_v
  103. = is_move_assignable<T>::value;
  104. template <class T> constexpr bool is_destructible_v
  105. = is_destructible<T>::value;
  106. template <class T, class... Args> constexpr bool is_trivially_constructible_v
  107. = is_trivially_constructible<T, Args...>::value;
  108. template <class T> constexpr bool is_trivially_default_constructible_v
  109. = is_trivially_default_constructible<T>::value;
  110. template <class T> constexpr bool is_trivially_copy_constructible_v
  111. = is_trivially_copy_constructible<T>::value;
  112. template <class T> constexpr bool is_trivially_move_constructible_v
  113. = is_trivially_move_constructible<T>::value;
  114. template <class T, class U> constexpr bool is_trivially_assignable_v
  115. = is_trivially_assignable<T, U>::value;
  116. template <class T> constexpr bool is_trivially_copy_assignable_v
  117. = is_trivially_copy_assignable<T>::value;
  118. template <class T> constexpr bool is_trivially_move_assignable_v
  119. = is_trivially_move_assignable<T>::value;
  120. template <class T> constexpr bool is_trivially_destructible_v
  121. = is_trivially_destructible<T>::value;
  122. template <class T, class... Args> constexpr bool is_nothrow_constructible_v
  123. = is_nothrow_constructible<T, Args...>::value;
  124. template <class T> constexpr bool is_nothrow_default_constructible_v
  125. = is_nothrow_default_constructible<T>::value;
  126. template <class T> constexpr bool is_nothrow_copy_constructible_v
  127. = is_nothrow_copy_constructible<T>::value;
  128. template <class T> constexpr bool is_nothrow_move_constructible_v
  129. = is_nothrow_move_constructible<T>::value;
  130. template <class T, class U> constexpr bool is_nothrow_assignable_v
  131. = is_nothrow_assignable<T, U>::value;
  132. template <class T> constexpr bool is_nothrow_copy_assignable_v
  133. = is_nothrow_copy_assignable<T>::value;
  134. template <class T> constexpr bool is_nothrow_move_assignable_v
  135. = is_nothrow_move_assignable<T>::value;
  136. template <class T> constexpr bool is_nothrow_destructible_v
  137. = is_nothrow_destructible<T>::value;
  138. template <class T> constexpr bool has_virtual_destructor_v
  139. = has_virtual_destructor<T>::value;
  140. // See C++14 20.10.5, type property queries
  141. template <class T> constexpr size_t alignment_of_v
  142. = alignment_of<T>::value;
  143. template <class T> constexpr size_t rank_v
  144. = rank<T>::value;
  145. template <class T, unsigned I = 0> constexpr size_t extent_v
  146. = extent<T, I>::value;
  147. // See C++14 20.10.6, type relations
  148. template <class T, class U> constexpr bool is_same_v
  149. = is_same<T, U>::value;
  150. template <class Base, class Derived> constexpr bool is_base_of_v
  151. = is_base_of<Base, Derived>::value;
  152. template <class From, class To> constexpr bool is_convertible_v
  153. = is_convertible<From, To>::value;
  154. // 3.3.2, Other type transformations
  155. template <class> class invocation_type; // not defined
  156. template <class F, class... ArgTypes> class invocation_type<F(ArgTypes...)>;
  157. template <class> class raw_invocation_type; // not defined
  158. template <class F, class... ArgTypes> class raw_invocation_type<F(ArgTypes...)>;
  159. template <class T>
  160. using invocation_type_t = typename invocation_type<T>::type;
  161. template <class T>
  162. using raw_invocation_type_t = typename raw_invocation_type<T>::type;
  163. } // namespace fundamentals_v1
  164. } // namespace experimental
  165. } // namespace std
  166. */
  167. #include <experimental/__config>
  168. #if _LIBCPP_STD_VER > 11
  169. #include <type_traits>
  170. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  171. #pragma GCC system_header
  172. #endif
  173. _LIBCPP_BEGIN_NAMESPACE_LFTS
  174. #ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
  175. // C++14 20.10.4.1, primary type categories
  176. template <class _Tp> _LIBCPP_CONSTEXPR bool is_void_v
  177. = is_void<_Tp>::value;
  178. template <class _Tp> _LIBCPP_CONSTEXPR bool is_null_pointer_v
  179. = is_null_pointer<_Tp>::value;
  180. template <class _Tp> _LIBCPP_CONSTEXPR bool is_integral_v
  181. = is_integral<_Tp>::value;
  182. template <class _Tp> _LIBCPP_CONSTEXPR bool is_floating_point_v
  183. = is_floating_point<_Tp>::value;
  184. template <class _Tp> _LIBCPP_CONSTEXPR bool is_array_v
  185. = is_array<_Tp>::value;
  186. template <class _Tp> _LIBCPP_CONSTEXPR bool is_pointer_v
  187. = is_pointer<_Tp>::value;
  188. template <class _Tp> _LIBCPP_CONSTEXPR bool is_lvalue_reference_v
  189. = is_lvalue_reference<_Tp>::value;
  190. template <class _Tp> _LIBCPP_CONSTEXPR bool is_rvalue_reference_v
  191. = is_rvalue_reference<_Tp>::value;
  192. template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_object_pointer_v
  193. = is_member_object_pointer<_Tp>::value;
  194. template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_function_pointer_v
  195. = is_member_function_pointer<_Tp>::value;
  196. template <class _Tp> _LIBCPP_CONSTEXPR bool is_enum_v
  197. = is_enum<_Tp>::value;
  198. template <class _Tp> _LIBCPP_CONSTEXPR bool is_union_v
  199. = is_union<_Tp>::value;
  200. template <class _Tp> _LIBCPP_CONSTEXPR bool is_class_v
  201. = is_class<_Tp>::value;
  202. template <class _Tp> _LIBCPP_CONSTEXPR bool is_function_v
  203. = is_function<_Tp>::value;
  204. // C++14 20.10.4.2, composite type categories
  205. template <class _Tp> _LIBCPP_CONSTEXPR bool is_reference_v
  206. = is_reference<_Tp>::value;
  207. template <class _Tp> _LIBCPP_CONSTEXPR bool is_arithmetic_v
  208. = is_arithmetic<_Tp>::value;
  209. template <class _Tp> _LIBCPP_CONSTEXPR bool is_fundamental_v
  210. = is_fundamental<_Tp>::value;
  211. template <class _Tp> _LIBCPP_CONSTEXPR bool is_object_v
  212. = is_object<_Tp>::value;
  213. template <class _Tp> _LIBCPP_CONSTEXPR bool is_scalar_v
  214. = is_scalar<_Tp>::value;
  215. template <class _Tp> _LIBCPP_CONSTEXPR bool is_compound_v
  216. = is_compound<_Tp>::value;
  217. template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_pointer_v
  218. = is_member_pointer<_Tp>::value;
  219. // C++14 20.10.4.3, type properties
  220. template <class _Tp> _LIBCPP_CONSTEXPR bool is_const_v
  221. = is_const<_Tp>::value;
  222. template <class _Tp> _LIBCPP_CONSTEXPR bool is_volatile_v
  223. = is_volatile<_Tp>::value;
  224. template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivial_v
  225. = is_trivial<_Tp>::value;
  226. template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copyable_v
  227. = is_trivially_copyable<_Tp>::value;
  228. template <class _Tp> _LIBCPP_CONSTEXPR bool is_standard_layout_v
  229. = is_standard_layout<_Tp>::value;
  230. template <class _Tp> _LIBCPP_CONSTEXPR bool is_pod_v
  231. = is_pod<_Tp>::value;
  232. template <class _Tp> _LIBCPP_CONSTEXPR bool is_literal_type_v
  233. = is_literal_type<_Tp>::value;
  234. template <class _Tp> _LIBCPP_CONSTEXPR bool is_empty_v
  235. = is_empty<_Tp>::value;
  236. template <class _Tp> _LIBCPP_CONSTEXPR bool is_polymorphic_v
  237. = is_polymorphic<_Tp>::value;
  238. template <class _Tp> _LIBCPP_CONSTEXPR bool is_abstract_v
  239. = is_abstract<_Tp>::value;
  240. template <class _Tp> _LIBCPP_CONSTEXPR bool is_final_v
  241. = is_final<_Tp>::value;
  242. template <class _Tp> _LIBCPP_CONSTEXPR bool is_signed_v
  243. = is_signed<_Tp>::value;
  244. template <class _Tp> _LIBCPP_CONSTEXPR bool is_unsigned_v
  245. = is_unsigned<_Tp>::value;
  246. template <class _Tp, class ..._Ts> _LIBCPP_CONSTEXPR bool is_constructible_v
  247. = is_constructible<_Tp, _Ts...>::value;
  248. template <class _Tp> _LIBCPP_CONSTEXPR bool is_default_constructible_v
  249. = is_default_constructible<_Tp>::value;
  250. template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_constructible_v
  251. = is_copy_constructible<_Tp>::value;
  252. template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_constructible_v
  253. = is_move_constructible<_Tp>::value;
  254. template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_assignable_v
  255. = is_assignable<_Tp, _Up>::value;
  256. template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_assignable_v
  257. = is_copy_assignable<_Tp>::value;
  258. template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_assignable_v
  259. = is_move_assignable<_Tp>::value;
  260. template <class _Tp> _LIBCPP_CONSTEXPR bool is_destructible_v
  261. = is_destructible<_Tp>::value;
  262. template <class _Tp, class ..._Ts> _LIBCPP_CONSTEXPR bool is_trivially_constructible_v
  263. = is_trivially_constructible<_Tp, _Ts...>::value;
  264. template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v
  265. = is_trivially_default_constructible<_Tp>::value;
  266. template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v
  267. = is_trivially_copy_constructible<_Tp>::value;
  268. template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v
  269. = is_trivially_move_constructible<_Tp>::value;
  270. template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_trivially_assignable_v
  271. = is_trivially_assignable<_Tp, _Up>::value;
  272. template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v
  273. = is_trivially_copy_assignable<_Tp>::value;
  274. template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v
  275. = is_trivially_move_assignable<_Tp>::value;
  276. template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_destructible_v
  277. = is_trivially_destructible<_Tp>::value;
  278. template <class _Tp, class ..._Ts> _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v
  279. = is_nothrow_constructible<_Tp, _Ts...>::value;
  280. template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v
  281. = is_nothrow_default_constructible<_Tp>::value;
  282. template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v
  283. = is_nothrow_copy_constructible<_Tp>::value;
  284. template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v
  285. = is_nothrow_move_constructible<_Tp>::value;
  286. template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v
  287. = is_nothrow_assignable<_Tp, _Up>::value;
  288. template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v
  289. = is_nothrow_copy_assignable<_Tp>::value;
  290. template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v
  291. = is_nothrow_move_assignable<_Tp>::value;
  292. template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v
  293. = is_nothrow_destructible<_Tp>::value;
  294. template <class _Tp> _LIBCPP_CONSTEXPR bool has_virtual_destructor_v
  295. = has_virtual_destructor<_Tp>::value;
  296. // C++14 20.10.5, type properties queries
  297. template <class _Tp> _LIBCPP_CONSTEXPR size_t alignment_of_v
  298. = alignment_of<_Tp>::value;
  299. template <class _Tp> _LIBCPP_CONSTEXPR size_t rank_v
  300. = rank<_Tp>::value;
  301. template <class _Tp, unsigned _Id = 0> _LIBCPP_CONSTEXPR size_t extent_v
  302. = extent<_Tp, _Id>::value;
  303. // C++14 20.10.6, type relations
  304. template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_same_v
  305. = is_same<_Tp, _Up>::value;
  306. template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_base_of_v
  307. = is_base_of<_Tp, _Up>::value;
  308. template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_convertible_v
  309. = is_convertible<_Tp, _Up>::value;
  310. #endif /* _LIBCPP_HAS_NO_VARIABLE_TEMPLATES */
  311. // 3.3.2, Other type transformations
  312. /*
  313. template <class>
  314. class _LIBCPP_TYPE_VIS_ONLY raw_invocation_type;
  315. template <class _Fn, class ..._Args>
  316. class _LIBCPP_TYPE_VIS_ONLY raw_invocation_type<_Fn(_Args...)>;
  317. template <class>
  318. class _LIBCPP_TYPE_VIS_ONLY invokation_type;
  319. template <class _Fn, class ..._Args>
  320. class _LIBCPP_TYPE_VIS_ONLY invokation_type<_Fn(_Args...)>;
  321. template <class _Tp>
  322. using invokation_type_t = typename invokation_type<_Tp>::type;
  323. template <class _Tp>
  324. using raw_invocation_type_t = typename raw_invocation_type<_Tp>::type;
  325. */
  326. _LIBCPP_END_NAMESPACE_LFTS
  327. #endif /* _LIBCPP_STD_VER > 11 */
  328. #endif /* _LIBCPP_EXPERIMENTAL_TYPE_TRAITS */