blob: f0defafec6d311e1d0e93b28333a1ff2ceaca7d9 [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001// -*- C++ -*-
2//===------------------------ type_traits ---------------------------------===//
3//
Howard Hinnantf5256e12010-05-11 21:36:01 +00004// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00005//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00006// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00008//
9//===----------------------------------------------------------------------===//
10
11#ifndef _LIBCPP_TYPE_TRAITS
12#define _LIBCPP_TYPE_TRAITS
13
14/*
15 type_traits synopsis
16
17namespace std
18{
19
20 // helper class:
21 template <class T, T v> struct integral_constant;
Marshall Clowe62560a2015-05-18 23:21:06 +000022 typedef integral_constant<bool, true> true_type; // C++11
23 typedef integral_constant<bool, false> false_type; // C++11
24
25 template <bool B> // C++14
26 using bool_constant = integral_constant<bool, B>; // C++14
27 typedef bool_constant<true> true_type; // C++14
28 typedef bool_constant<false> false_type; // C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000029
30 // helper traits
31 template <bool, class T = void> struct enable_if;
32 template <bool, class T, class F> struct conditional;
33
34 // Primary classification traits:
35 template <class T> struct is_void;
Marshall Clow79d8c992013-10-05 21:21:17 +000036 template <class T> struct is_null_pointer; // C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000037 template <class T> struct is_integral;
38 template <class T> struct is_floating_point;
39 template <class T> struct is_array;
40 template <class T> struct is_pointer;
41 template <class T> struct is_lvalue_reference;
42 template <class T> struct is_rvalue_reference;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000043 template <class T> struct is_member_object_pointer;
44 template <class T> struct is_member_function_pointer;
45 template <class T> struct is_enum;
46 template <class T> struct is_union;
47 template <class T> struct is_class;
48 template <class T> struct is_function;
Howard Hinnant324bb032010-08-22 00:02:43 +000049
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000050 // Secondary classification traits:
51 template <class T> struct is_reference;
52 template <class T> struct is_arithmetic;
53 template <class T> struct is_fundamental;
54 template <class T> struct is_member_pointer;
55 template <class T> struct is_scalar;
56 template <class T> struct is_object;
57 template <class T> struct is_compound;
Howard Hinnant324bb032010-08-22 00:02:43 +000058
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000059 // Const-volatile properties and transformations:
60 template <class T> struct is_const;
61 template <class T> struct is_volatile;
62 template <class T> struct remove_const;
63 template <class T> struct remove_volatile;
64 template <class T> struct remove_cv;
65 template <class T> struct add_const;
66 template <class T> struct add_volatile;
67 template <class T> struct add_cv;
Howard Hinnant324bb032010-08-22 00:02:43 +000068
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000069 // Reference transformations:
70 template <class T> struct remove_reference;
71 template <class T> struct add_lvalue_reference;
72 template <class T> struct add_rvalue_reference;
Howard Hinnant324bb032010-08-22 00:02:43 +000073
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000074 // Pointer transformations:
75 template <class T> struct remove_pointer;
76 template <class T> struct add_pointer;
Howard Hinnant324bb032010-08-22 00:02:43 +000077
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000078 // Integral properties:
79 template <class T> struct is_signed;
80 template <class T> struct is_unsigned;
81 template <class T> struct make_signed;
82 template <class T> struct make_unsigned;
Howard Hinnant324bb032010-08-22 00:02:43 +000083
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000084 // Array properties and transformations:
85 template <class T> struct rank;
86 template <class T, unsigned I = 0> struct extent;
87 template <class T> struct remove_extent;
88 template <class T> struct remove_all_extents;
Howard Hinnant324bb032010-08-22 00:02:43 +000089
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000090 // Member introspection:
91 template <class T> struct is_pod;
92 template <class T> struct is_trivial;
93 template <class T> struct is_trivially_copyable;
94 template <class T> struct is_standard_layout;
95 template <class T> struct is_literal_type;
96 template <class T> struct is_empty;
97 template <class T> struct is_polymorphic;
98 template <class T> struct is_abstract;
Marshall Clowebd6c2b2014-03-05 03:39:25 +000099 template <class T> struct is_final; // C++14
Howard Hinnant745d4732010-09-08 17:55:32 +0000100
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000101 template <class T, class... Args> struct is_constructible;
Howard Hinnant1468b662010-11-19 22:17:28 +0000102 template <class T> struct is_default_constructible;
103 template <class T> struct is_copy_constructible;
104 template <class T> struct is_move_constructible;
105 template <class T, class U> struct is_assignable;
106 template <class T> struct is_copy_assignable;
107 template <class T> struct is_move_assignable;
108 template <class T> struct is_destructible;
109
110 template <class T, class... Args> struct is_trivially_constructible;
111 template <class T> struct is_trivially_default_constructible;
112 template <class T> struct is_trivially_copy_constructible;
113 template <class T> struct is_trivially_move_constructible;
114 template <class T, class U> struct is_trivially_assignable;
115 template <class T> struct is_trivially_copy_assignable;
116 template <class T> struct is_trivially_move_assignable;
117 template <class T> struct is_trivially_destructible;
118
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000119 template <class T, class... Args> struct is_nothrow_constructible;
Howard Hinnant1468b662010-11-19 22:17:28 +0000120 template <class T> struct is_nothrow_default_constructible;
121 template <class T> struct is_nothrow_copy_constructible;
122 template <class T> struct is_nothrow_move_constructible;
123 template <class T, class U> struct is_nothrow_assignable;
124 template <class T> struct is_nothrow_copy_assignable;
125 template <class T> struct is_nothrow_move_assignable;
126 template <class T> struct is_nothrow_destructible;
Howard Hinnant745d4732010-09-08 17:55:32 +0000127
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000128 template <class T> struct has_virtual_destructor;
Howard Hinnant324bb032010-08-22 00:02:43 +0000129
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000130 // Relationships between types:
131 template <class T, class U> struct is_same;
132 template <class Base, class Derived> struct is_base_of;
133 template <class From, class To> struct is_convertible;
Howard Hinnant324bb032010-08-22 00:02:43 +0000134
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000135 // Alignment properties and transformations:
136 template <class T> struct alignment_of;
137 template <size_t Len, size_t Align = most_stringent_alignment_requirement>
138 struct aligned_storage;
Howard Hinnant5544f7e2013-04-22 19:37:49 +0000139 template <size_t Len, class... Types> struct aligned_union;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000140
141 template <class T> struct decay;
142 template <class... T> struct common_type;
143 template <class T> struct underlying_type;
144 template <class> class result_of; // undefined
145 template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>;
146
Marshall Clow933afa92013-07-04 00:10:01 +0000147 // const-volatile modifications:
148 template <class T>
149 using remove_const_t = typename remove_const<T>::type; // C++14
150 template <class T>
151 using remove_volatile_t = typename remove_volatile<T>::type; // C++14
152 template <class T>
153 using remove_cv_t = typename remove_cv<T>::type; // C++14
154 template <class T>
155 using add_const_t = typename add_const<T>::type; // C++14
156 template <class T>
157 using add_volatile_t = typename add_volatile<T>::type; // C++14
158 template <class T>
159 using add_cv_t = typename add_cv<T>::type; // C++14
160
161 // reference modifications:
162 template <class T>
163 using remove_reference_t = typename remove_reference<T>::type; // C++14
164 template <class T>
165 using add_lvalue_reference_t = typename add_lvalue_reference<T>::type; // C++14
166 template <class T>
167 using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; // C++14
168
169 // sign modifications:
170 template <class T>
171 using make_signed_t = typename make_signed<T>::type; // C++14
172 template <class T>
173 using make_unsigned_t = typename make_unsigned<T>::type; // C++14
174
175 // array modifications:
176 template <class T>
177 using remove_extent_t = typename remove_extent<T>::type; // C++14
178 template <class T>
179 using remove_all_extents_t = typename remove_all_extents<T>::type; // C++14
180
181 // pointer modifications:
182 template <class T>
183 using remove_pointer_t = typename remove_pointer<T>::type; // C++14
184 template <class T>
185 using add_pointer_t = typename add_pointer<T>::type; // C++14
186
187 // other transformations:
188 template <size_t Len, std::size_t Align=default-alignment>
189 using aligned_storage_t = typename aligned_storage<Len,Align>::type; // C++14
190 template <std::size_t Len, class... Types>
191 using aligned_union_t = typename aligned_union<Len,Types...>::type; // C++14
192 template <class T>
193 using decay_t = typename decay<T>::type; // C++14
194 template <bool b, class T=void>
195 using enable_if_t = typename enable_if<b,T>::type; // C++14
196 template <bool b, class T, class F>
197 using conditional_t = typename conditional<b,T,F>::type; // C++14
198 template <class... T>
199 using common_type_t = typename common_type<T...>::type; // C++14
200 template <class T>
201 using underlying_type_t = typename underlying_type<T>::type; // C++14
202 template <class F, class... ArgTypes>
203 using result_of_t = typename result_of<F(ArgTypes...)>::type; // C++14
204
Marshall Clow88aae922014-11-17 15:50:08 +0000205 template <class...>
Dan Albert1d4a1ed2016-05-25 22:36:09 -0700206 using void_t = void;
207} // C++17
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000208
209*/
210#include <__config>
211#include <cstddef>
212
Howard Hinnant08e17472011-10-17 20:05:10 +0000213#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000214#pragma GCC system_header
Howard Hinnant08e17472011-10-17 20:05:10 +0000215#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000216
217_LIBCPP_BEGIN_NAMESPACE_STD
218
Eric Fiselierb7fc49f2015-06-13 02:36:07 +0000219template <class>
Marshall Clow88aae922014-11-17 15:50:08 +0000220struct __void_t { typedef void type; };
Marshall Clow88aae922014-11-17 15:50:08 +0000221
Joerg Sonnenbergerba865ff2015-08-10 16:58:04 +0000222template <class _Tp>
223struct __identity { typedef _Tp type; };
Eric Fiselier49835802015-06-13 08:25:24 +0000224
Eric Fiselierda1818a2015-02-21 02:30:41 +0000225template <class _Tp, bool>
226struct _LIBCPP_TYPE_VIS_ONLY __dependent_type : public _Tp {};
227
Howard Hinnant99968442011-11-29 18:15:50 +0000228template <bool _Bp, class _If, class _Then>
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000229 struct _LIBCPP_TYPE_VIS_ONLY conditional {typedef _If type;};
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000230template <class _If, class _Then>
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000231 struct _LIBCPP_TYPE_VIS_ONLY conditional<false, _If, _Then> {typedef _Then type;};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000232
Marshall Clow933afa92013-07-04 00:10:01 +0000233#if _LIBCPP_STD_VER > 11
234template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type;
235#endif
236
Eric Fiselier950ee772014-10-17 00:31:47 +0000237template <bool, class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __lazy_enable_if {};
238template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __lazy_enable_if<true, _Tp> {typedef typename _Tp::type type;};
239
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000240template <bool, class _Tp = void> struct _LIBCPP_TYPE_VIS_ONLY enable_if {};
241template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY enable_if<true, _Tp> {typedef _Tp type;};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000242
Marshall Clow933afa92013-07-04 00:10:01 +0000243#if _LIBCPP_STD_VER > 11
244template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type;
245#endif
246
247
Howard Hinnant9c0df142012-10-30 19:06:59 +0000248struct __two {char __lx[2];};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000249
250// helper class:
251
252template <class _Tp, _Tp __v>
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000253struct _LIBCPP_TYPE_VIS_ONLY integral_constant
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000254{
Howard Hinnant27b4fd32012-04-02 00:40:41 +0000255 static _LIBCPP_CONSTEXPR const _Tp value = __v;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000256 typedef _Tp value_type;
257 typedef integral_constant type;
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000258 _LIBCPP_INLINE_VISIBILITY
Marshall Clowa2df82b2014-02-17 22:18:51 +0000259 _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT {return value;}
Marshall Clowd29bb4b2013-07-08 20:05:31 +0000260#if _LIBCPP_STD_VER > 11
261 _LIBCPP_INLINE_VISIBILITY
Marshall Clowa2df82b2014-02-17 22:18:51 +0000262 constexpr value_type operator ()() const _NOEXCEPT {return value;}
Marshall Clowd29bb4b2013-07-08 20:05:31 +0000263#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000264};
265
266template <class _Tp, _Tp __v>
Howard Hinnant27b4fd32012-04-02 00:40:41 +0000267_LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000268
Marshall Clowe62560a2015-05-18 23:21:06 +0000269#if _LIBCPP_STD_VER > 14
270template <bool __b>
271using bool_constant = integral_constant<bool, __b>;
Dan Albert1d4a1ed2016-05-25 22:36:09 -0700272#define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)>
Marshall Clowe62560a2015-05-18 23:21:06 +0000273#else
Dan Albert1d4a1ed2016-05-25 22:36:09 -0700274#define _LIBCPP_BOOL_CONSTANT(__b) integral_constant<bool,(__b)>
Marshall Clowe62560a2015-05-18 23:21:06 +0000275#endif
276
277typedef _LIBCPP_BOOL_CONSTANT(true) true_type;
278typedef _LIBCPP_BOOL_CONSTANT(false) false_type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000279
280// is_const
281
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000282template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_const : public false_type {};
283template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_const<_Tp const> : public true_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000284
285// is_volatile
286
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000287template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_volatile : public false_type {};
288template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_volatile<_Tp volatile> : public true_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000289
290// remove_const
291
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000292template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_const {typedef _Tp type;};
293template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_const<const _Tp> {typedef _Tp type;};
Marshall Clow933afa92013-07-04 00:10:01 +0000294#if _LIBCPP_STD_VER > 11
295template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type;
296#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000297
298// remove_volatile
299
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000300template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_volatile {typedef _Tp type;};
301template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_volatile<volatile _Tp> {typedef _Tp type;};
Marshall Clow933afa92013-07-04 00:10:01 +0000302#if _LIBCPP_STD_VER > 11
303template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type;
304#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000305
306// remove_cv
307
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000308template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_cv
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000309{typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
Marshall Clow933afa92013-07-04 00:10:01 +0000310#if _LIBCPP_STD_VER > 11
311template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type;
312#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000313
314// is_void
315
Marshall Clow8896ac32014-01-14 05:13:45 +0000316template <class _Tp> struct __libcpp_is_void : public false_type {};
317template <> struct __libcpp_is_void<void> : public true_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000318
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000319template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_void
Marshall Clow8896ac32014-01-14 05:13:45 +0000320 : public __libcpp_is_void<typename remove_cv<_Tp>::type> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000321
Howard Hinnant6e5e7e72011-03-09 17:17:06 +0000322// __is_nullptr_t
323
Marshall Clow0ea7f8c2014-01-06 14:00:09 +0000324template <class _Tp> struct __is_nullptr_t_impl : public false_type {};
325template <> struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
Howard Hinnant6e5e7e72011-03-09 17:17:06 +0000326
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000327template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __is_nullptr_t
Marshall Clow0ea7f8c2014-01-06 14:00:09 +0000328 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
Howard Hinnant6e5e7e72011-03-09 17:17:06 +0000329
Marshall Clow79d8c992013-10-05 21:21:17 +0000330#if _LIBCPP_STD_VER > 11
331template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_null_pointer
Marshall Clow0ea7f8c2014-01-06 14:00:09 +0000332 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
Marshall Clow79d8c992013-10-05 21:21:17 +0000333#endif
334
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000335// is_integral
336
Marshall Clow8896ac32014-01-14 05:13:45 +0000337template <class _Tp> struct __libcpp_is_integral : public false_type {};
338template <> struct __libcpp_is_integral<bool> : public true_type {};
339template <> struct __libcpp_is_integral<char> : public true_type {};
340template <> struct __libcpp_is_integral<signed char> : public true_type {};
341template <> struct __libcpp_is_integral<unsigned char> : public true_type {};
342template <> struct __libcpp_is_integral<wchar_t> : public true_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000343#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
Marshall Clow8896ac32014-01-14 05:13:45 +0000344template <> struct __libcpp_is_integral<char16_t> : public true_type {};
345template <> struct __libcpp_is_integral<char32_t> : public true_type {};
Howard Hinnant324bb032010-08-22 00:02:43 +0000346#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
Marshall Clow8896ac32014-01-14 05:13:45 +0000347template <> struct __libcpp_is_integral<short> : public true_type {};
348template <> struct __libcpp_is_integral<unsigned short> : public true_type {};
349template <> struct __libcpp_is_integral<int> : public true_type {};
350template <> struct __libcpp_is_integral<unsigned int> : public true_type {};
351template <> struct __libcpp_is_integral<long> : public true_type {};
352template <> struct __libcpp_is_integral<unsigned long> : public true_type {};
353template <> struct __libcpp_is_integral<long long> : public true_type {};
354template <> struct __libcpp_is_integral<unsigned long long> : public true_type {};
Stephan Tolksdorf8a71d232014-03-26 19:45:52 +0000355#ifndef _LIBCPP_HAS_NO_INT128
356template <> struct __libcpp_is_integral<__int128_t> : public true_type {};
357template <> struct __libcpp_is_integral<__uint128_t> : public true_type {};
358#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000359
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000360template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_integral
Marshall Clow8896ac32014-01-14 05:13:45 +0000361 : public __libcpp_is_integral<typename remove_cv<_Tp>::type> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000362
363// is_floating_point
364
Marshall Clow8896ac32014-01-14 05:13:45 +0000365template <class _Tp> struct __libcpp_is_floating_point : public false_type {};
366template <> struct __libcpp_is_floating_point<float> : public true_type {};
367template <> struct __libcpp_is_floating_point<double> : public true_type {};
368template <> struct __libcpp_is_floating_point<long double> : public true_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000369
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000370template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_floating_point
Marshall Clow8896ac32014-01-14 05:13:45 +0000371 : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000372
373// is_array
374
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000375template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_array
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000376 : public false_type {};
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000377template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[]>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000378 : public true_type {};
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000379template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[_Np]>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000380 : public true_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000381
382// is_pointer
383
Marshall Clow8896ac32014-01-14 05:13:45 +0000384template <class _Tp> struct __libcpp_is_pointer : public false_type {};
385template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000386
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000387template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pointer
Marshall Clow8896ac32014-01-14 05:13:45 +0000388 : public __libcpp_is_pointer<typename remove_cv<_Tp>::type> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000389
390// is_reference
391
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000392template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference : public false_type {};
393template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference<_Tp&> : public true_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000394
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000395template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference : public false_type {};
Howard Hinnant73d21a42010-09-04 23:28:19 +0000396#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000397template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference<_Tp&&> : public true_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000398#endif
399
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000400template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference : public false_type {};
401template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&> : public true_type {};
Howard Hinnant73d21a42010-09-04 23:28:19 +0000402#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000403template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&&> : public true_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000404#endif
405
406// is_union
407
Marshall Clow48e7e9f2014-07-10 15:38:20 +0000408#if __has_feature(is_union) || (_GNUC_VER >= 403)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000409
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000410template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_union
Howard Hinnant745d4732010-09-08 17:55:32 +0000411 : public integral_constant<bool, __is_union(_Tp)> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000412
Howard Hinnant36666952011-05-09 19:21:17 +0000413#else
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000414
415template <class _Tp> struct __libcpp_union : public false_type {};
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000416template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_union
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000417 : public __libcpp_union<typename remove_cv<_Tp>::type> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000418
Howard Hinnant36666952011-05-09 19:21:17 +0000419#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000420
421// is_class
422
Marshall Clow48e7e9f2014-07-10 15:38:20 +0000423#if __has_feature(is_class) || (_GNUC_VER >= 403)
Howard Hinnant745d4732010-09-08 17:55:32 +0000424
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000425template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_class
Howard Hinnant745d4732010-09-08 17:55:32 +0000426 : public integral_constant<bool, __is_class(_Tp)> {};
427
Howard Hinnant36666952011-05-09 19:21:17 +0000428#else
Howard Hinnant745d4732010-09-08 17:55:32 +0000429
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000430namespace __is_class_imp
431{
432template <class _Tp> char __test(int _Tp::*);
433template <class _Tp> __two __test(...);
434}
435
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000436template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_class
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000437 : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {};
438
Howard Hinnant36666952011-05-09 19:21:17 +0000439#endif
Howard Hinnant745d4732010-09-08 17:55:32 +0000440
Howard Hinnantd7373822011-06-01 17:25:11 +0000441// is_same
442
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000443template <class _Tp, class _Up> struct _LIBCPP_TYPE_VIS_ONLY is_same : public false_type {};
444template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_same<_Tp, _Tp> : public true_type {};
Howard Hinnantd7373822011-06-01 17:25:11 +0000445
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000446// is_function
447
Marshall Clow8896ac32014-01-14 05:13:45 +0000448namespace __libcpp_is_function_imp
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000449{
Eric Fiselier89465dc2015-02-18 16:31:46 +0000450struct __dummy_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000451template <class _Tp> char __test(_Tp*);
Eric Fiselier89465dc2015-02-18 16:31:46 +0000452template <class _Tp> char __test(__dummy_type);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000453template <class _Tp> __two __test(...);
Eric Fiselier89465dc2015-02-18 16:31:46 +0000454template <class _Tp> _Tp& __source(int);
455template <class _Tp> __dummy_type __source(...);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000456}
457
458template <class _Tp, bool = is_class<_Tp>::value ||
459 is_union<_Tp>::value ||
460 is_void<_Tp>::value ||
Howard Hinnantd7373822011-06-01 17:25:11 +0000461 is_reference<_Tp>::value ||
Marshall Clow79d8c992013-10-05 21:21:17 +0000462 __is_nullptr_t<_Tp>::value >
Marshall Clow8896ac32014-01-14 05:13:45 +0000463struct __libcpp_is_function
Eric Fiselier89465dc2015-02-18 16:31:46 +0000464 : public integral_constant<bool, sizeof(__libcpp_is_function_imp::__test<_Tp>(__libcpp_is_function_imp::__source<_Tp>(0))) == 1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000465 {};
Marshall Clow8896ac32014-01-14 05:13:45 +0000466template <class _Tp> struct __libcpp_is_function<_Tp, true> : public false_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000467
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000468template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_function
Marshall Clow8896ac32014-01-14 05:13:45 +0000469 : public __libcpp_is_function<_Tp> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000470
471// is_member_function_pointer
472
Marshall Clow4f3368e2014-05-29 01:10:28 +0000473// template <class _Tp> struct __libcpp_is_member_function_pointer : public false_type {};
474// template <class _Tp, class _Up> struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {};
475//
476
Nick Lewyckye1be30b2015-07-29 22:38:23 +0000477template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr>
Marshall Clow4f3368e2014-05-29 01:10:28 +0000478struct __member_pointer_traits_imp
479{ // forward declaration; specializations later
480};
481
482
Marshall Clow4f3368e2014-05-29 01:10:28 +0000483template <class _Tp> struct __libcpp_is_member_function_pointer
Eric Fiselier724b5ab2015-06-13 00:33:13 +0000484 : public false_type {};
485
486template <class _Ret, class _Class>
487struct __libcpp_is_member_function_pointer<_Ret _Class::*>
488 : public is_function<_Ret> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000489
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000490template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_function_pointer
Eric Fiselier724b5ab2015-06-13 00:33:13 +0000491 : public __libcpp_is_member_function_pointer<typename remove_cv<_Tp>::type>::type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000492
493// is_member_pointer
494
Marshall Clow8896ac32014-01-14 05:13:45 +0000495template <class _Tp> struct __libcpp_is_member_pointer : public false_type {};
496template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> : public true_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000497
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000498template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_pointer
Marshall Clow8896ac32014-01-14 05:13:45 +0000499 : public __libcpp_is_member_pointer<typename remove_cv<_Tp>::type> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000500
501// is_member_object_pointer
502
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000503template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_object_pointer
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000504 : public integral_constant<bool, is_member_pointer<_Tp>::value &&
505 !is_member_function_pointer<_Tp>::value> {};
506
507// is_enum
508
Marshall Clow48e7e9f2014-07-10 15:38:20 +0000509#if __has_feature(is_enum) || (_GNUC_VER >= 403)
Howard Hinnant745d4732010-09-08 17:55:32 +0000510
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000511template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_enum
Howard Hinnant745d4732010-09-08 17:55:32 +0000512 : public integral_constant<bool, __is_enum(_Tp)> {};
513
Howard Hinnant36666952011-05-09 19:21:17 +0000514#else
Howard Hinnant745d4732010-09-08 17:55:32 +0000515
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000516template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_enum
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000517 : public integral_constant<bool, !is_void<_Tp>::value &&
518 !is_integral<_Tp>::value &&
519 !is_floating_point<_Tp>::value &&
520 !is_array<_Tp>::value &&
521 !is_pointer<_Tp>::value &&
522 !is_reference<_Tp>::value &&
523 !is_member_pointer<_Tp>::value &&
524 !is_union<_Tp>::value &&
525 !is_class<_Tp>::value &&
526 !is_function<_Tp>::value > {};
527
Howard Hinnant36666952011-05-09 19:21:17 +0000528#endif
Howard Hinnant745d4732010-09-08 17:55:32 +0000529
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000530// is_arithmetic
531
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000532template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_arithmetic
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000533 : public integral_constant<bool, is_integral<_Tp>::value ||
534 is_floating_point<_Tp>::value> {};
535
536// is_fundamental
537
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000538template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_fundamental
Howard Hinnant6e5e7e72011-03-09 17:17:06 +0000539 : public integral_constant<bool, is_void<_Tp>::value ||
540 __is_nullptr_t<_Tp>::value ||
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000541 is_arithmetic<_Tp>::value> {};
542
543// is_scalar
544
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000545template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_scalar
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000546 : public integral_constant<bool, is_arithmetic<_Tp>::value ||
547 is_member_pointer<_Tp>::value ||
548 is_pointer<_Tp>::value ||
Howard Hinnant6e5e7e72011-03-09 17:17:06 +0000549 __is_nullptr_t<_Tp>::value ||
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000550 is_enum<_Tp>::value > {};
551
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000552template <> struct _LIBCPP_TYPE_VIS_ONLY is_scalar<nullptr_t> : public true_type {};
Howard Hinnant5885da32011-03-09 15:10:51 +0000553
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000554// is_object
555
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000556template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_object
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000557 : public integral_constant<bool, is_scalar<_Tp>::value ||
558 is_array<_Tp>::value ||
559 is_union<_Tp>::value ||
560 is_class<_Tp>::value > {};
561
562// is_compound
563
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000564template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_compound
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000565 : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000566
567// add_const
568
569template <class _Tp, bool = is_reference<_Tp>::value ||
570 is_function<_Tp>::value ||
571 is_const<_Tp>::value >
572struct __add_const {typedef _Tp type;};
573
574template <class _Tp>
575struct __add_const<_Tp, false> {typedef const _Tp type;};
576
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000577template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_const
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000578 {typedef typename __add_const<_Tp>::type type;};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000579
Marshall Clow933afa92013-07-04 00:10:01 +0000580#if _LIBCPP_STD_VER > 11
581template <class _Tp> using add_const_t = typename add_const<_Tp>::type;
582#endif
583
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000584// add_volatile
585
586template <class _Tp, bool = is_reference<_Tp>::value ||
587 is_function<_Tp>::value ||
588 is_volatile<_Tp>::value >
589struct __add_volatile {typedef _Tp type;};
590
591template <class _Tp>
592struct __add_volatile<_Tp, false> {typedef volatile _Tp type;};
593
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000594template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_volatile
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000595 {typedef typename __add_volatile<_Tp>::type type;};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000596
Marshall Clow933afa92013-07-04 00:10:01 +0000597#if _LIBCPP_STD_VER > 11
598template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type;
599#endif
600
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000601// add_cv
602
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000603template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_cv
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000604 {typedef typename add_const<typename add_volatile<_Tp>::type>::type type;};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000605
Marshall Clow933afa92013-07-04 00:10:01 +0000606#if _LIBCPP_STD_VER > 11
607template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type;
608#endif
609
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000610// remove_reference
611
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000612template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference {typedef _Tp type;};
613template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&> {typedef _Tp type;};
Howard Hinnant73d21a42010-09-04 23:28:19 +0000614#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000615template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&&> {typedef _Tp type;};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000616#endif
617
Marshall Clow933afa92013-07-04 00:10:01 +0000618#if _LIBCPP_STD_VER > 11
619template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
620#endif
621
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000622// add_lvalue_reference
623
Dan Albert1d4a1ed2016-05-25 22:36:09 -0700624template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference {typedef _Tp& type;};
625template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<_Tp&> {typedef _Tp& type;}; // for older compiler
626template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<void> {typedef void type;};
627template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<const void> {typedef const void type;};
628template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<volatile void> {typedef volatile void type;};
629template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<const volatile void> {typedef const volatile void type;};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000630
Marshall Clow933afa92013-07-04 00:10:01 +0000631#if _LIBCPP_STD_VER > 11
632template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
633#endif
634
Howard Hinnant73d21a42010-09-04 23:28:19 +0000635#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000636
Dan Albert1d4a1ed2016-05-25 22:36:09 -0700637template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference {typedef _Tp&& type;};
638template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<void> {typedef void type;};
639template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<const void> {typedef const void type;};
640template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<volatile void> {typedef volatile void type;};
641template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<const volatile void> {typedef const volatile void type;};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000642
Marshall Clow933afa92013-07-04 00:10:01 +0000643#if _LIBCPP_STD_VER > 11
644template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
645#endif
646
Howard Hinnant73d21a42010-09-04 23:28:19 +0000647#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000648
Howard Hinnant745d4732010-09-08 17:55:32 +0000649#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
650
651template <class _Tp>
Dan Albert1d4a1ed2016-05-25 22:36:09 -0700652typename add_rvalue_reference<_Tp>::type
Howard Hinnant5d37fb32011-05-11 20:19:40 +0000653declval() _NOEXCEPT;
Howard Hinnant745d4732010-09-08 17:55:32 +0000654
655#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
656
657template <class _Tp>
658typename add_lvalue_reference<_Tp>::type
659declval();
660
661#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
662
663struct __any
664{
665 __any(...);
666};
667
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000668// remove_pointer
669
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000670template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer {typedef _Tp type;};
671template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp*> {typedef _Tp type;};
672template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const> {typedef _Tp type;};
673template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* volatile> {typedef _Tp type;};
674template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const volatile> {typedef _Tp type;};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000675
Marshall Clow933afa92013-07-04 00:10:01 +0000676#if _LIBCPP_STD_VER > 11
677template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type;
678#endif
679
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000680// add_pointer
681
Marshall Clow7a7960f2016-01-21 18:22:43 +0000682template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_pointer
Dan Albert1d4a1ed2016-05-25 22:36:09 -0700683 {typedef typename remove_reference<_Tp>::type* type;};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000684
Marshall Clow933afa92013-07-04 00:10:01 +0000685#if _LIBCPP_STD_VER > 11
686template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
687#endif
688
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000689// is_signed
690
691template <class _Tp, bool = is_integral<_Tp>::value>
Marshall Clowe62560a2015-05-18 23:21:06 +0000692struct __libcpp_is_signed_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(-1) < _Tp(0)) {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000693
694template <class _Tp>
Marshall Clow8896ac32014-01-14 05:13:45 +0000695struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000696
697template <class _Tp, bool = is_arithmetic<_Tp>::value>
Marshall Clow8896ac32014-01-14 05:13:45 +0000698struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000699
Marshall Clow8896ac32014-01-14 05:13:45 +0000700template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000701
Marshall Clow8896ac32014-01-14 05:13:45 +0000702template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_signed : public __libcpp_is_signed<_Tp> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000703
704// is_unsigned
705
706template <class _Tp, bool = is_integral<_Tp>::value>
Marshall Clowe62560a2015-05-18 23:21:06 +0000707struct __libcpp_is_unsigned_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(0) < _Tp(-1)) {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000708
709template <class _Tp>
Marshall Clow8896ac32014-01-14 05:13:45 +0000710struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000711
712template <class _Tp, bool = is_arithmetic<_Tp>::value>
Marshall Clow8896ac32014-01-14 05:13:45 +0000713struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000714
Marshall Clow8896ac32014-01-14 05:13:45 +0000715template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000716
Marshall Clow8896ac32014-01-14 05:13:45 +0000717template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_unsigned : public __libcpp_is_unsigned<_Tp> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000718
719// rank
720
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000721template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY rank
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000722 : public integral_constant<size_t, 0> {};
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000723template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[]>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000724 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000725template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[_Np]>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000726 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000727
728// extent
729
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000730template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TYPE_VIS_ONLY extent
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000731 : public integral_constant<size_t, 0> {};
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000732template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], 0>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000733 : public integral_constant<size_t, 0> {};
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000734template <class _Tp, unsigned _Ip> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], _Ip>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000735 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000736template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], 0>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000737 : public integral_constant<size_t, _Np> {};
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000738template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], _Ip>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000739 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000740
741// remove_extent
742
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000743template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_extent
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000744 {typedef _Tp type;};
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000745template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[]>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000746 {typedef _Tp type;};
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000747template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[_Np]>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000748 {typedef _Tp type;};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000749
Marshall Clow933afa92013-07-04 00:10:01 +0000750#if _LIBCPP_STD_VER > 11
751template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type;
752#endif
753
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000754// remove_all_extents
755
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000756template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000757 {typedef _Tp type;};
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000758template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[]>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000759 {typedef typename remove_all_extents<_Tp>::type type;};
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000760template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[_Np]>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000761 {typedef typename remove_all_extents<_Tp>::type type;};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000762
Marshall Clow933afa92013-07-04 00:10:01 +0000763#if _LIBCPP_STD_VER > 11
764template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
765#endif
766
Marshall Clowdab89a12013-10-07 23:43:33 +0000767// decay
768
769template <class _Tp>
770struct _LIBCPP_TYPE_VIS_ONLY decay
771{
772private:
773 typedef typename remove_reference<_Tp>::type _Up;
774public:
775 typedef typename conditional
776 <
777 is_array<_Up>::value,
778 typename remove_extent<_Up>::type*,
779 typename conditional
780 <
781 is_function<_Up>::value,
782 typename add_pointer<_Up>::type,
783 typename remove_cv<_Up>::type
784 >::type
785 >::type type;
786};
787
788#if _LIBCPP_STD_VER > 11
789template <class _Tp> using decay_t = typename decay<_Tp>::type;
790#endif
791
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000792// is_abstract
793
794namespace __is_abstract_imp
795{
796template <class _Tp> char __test(_Tp (*)[1]);
797template <class _Tp> __two __test(...);
798}
799
800template <class _Tp, bool = is_class<_Tp>::value>
801struct __libcpp_abstract : public integral_constant<bool, sizeof(__is_abstract_imp::__test<_Tp>(0)) != 1> {};
802
803template <class _Tp> struct __libcpp_abstract<_Tp, false> : public false_type {};
804
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000805template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_abstract : public __libcpp_abstract<_Tp> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000806
Marshall Clowebd6c2b2014-03-05 03:39:25 +0000807// is_final
808
Eric Fiselier3a0e4302015-06-13 07:08:02 +0000809#if defined(_LIBCPP_HAS_IS_FINAL)
810template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY
811__libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {};
812#else
813template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY
814__libcpp_is_final : public false_type {};
815#endif
816
817#if defined(_LIBCPP_HAS_IS_FINAL) && _LIBCPP_STD_VER > 11
818template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY
Marshall Clowebd6c2b2014-03-05 03:39:25 +0000819is_final : public integral_constant<bool, __is_final(_Tp)> {};
820#endif
821
Howard Hinnanta5160282012-08-25 15:06:50 +0000822// is_base_of
823
Howard Hinnante9df0a52013-08-01 18:17:34 +0000824#ifdef _LIBCPP_HAS_IS_BASE_OF
Howard Hinnanta5160282012-08-25 15:06:50 +0000825
826template <class _Bp, class _Dp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000827struct _LIBCPP_TYPE_VIS_ONLY is_base_of
Howard Hinnanta5160282012-08-25 15:06:50 +0000828 : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
829
Marshall Clow48e7e9f2014-07-10 15:38:20 +0000830#else // _LIBCPP_HAS_IS_BASE_OF
Howard Hinnanta5160282012-08-25 15:06:50 +0000831
Richard Smithb2f2b682012-12-20 04:20:28 +0000832namespace __is_base_of_imp
833{
834template <class _Tp>
835struct _Dst
836{
837 _Dst(const volatile _Tp &);
838};
839template <class _Tp>
840struct _Src
841{
842 operator const volatile _Tp &();
843 template <class _Up> operator const _Dst<_Up> &();
844};
845template <size_t> struct __one { typedef char type; };
846template <class _Bp, class _Dp> typename __one<sizeof(_Dst<_Bp>(declval<_Src<_Dp> >()))>::type __test(int);
847template <class _Bp, class _Dp> __two __test(...);
848}
849
850template <class _Bp, class _Dp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000851struct _LIBCPP_TYPE_VIS_ONLY is_base_of
Richard Smithb2f2b682012-12-20 04:20:28 +0000852 : public integral_constant<bool, is_class<_Bp>::value &&
853 sizeof(__is_base_of_imp::__test<_Bp, _Dp>(0)) == 2> {};
Howard Hinnanta5160282012-08-25 15:06:50 +0000854
Marshall Clow48e7e9f2014-07-10 15:38:20 +0000855#endif // _LIBCPP_HAS_IS_BASE_OF
Howard Hinnanta5160282012-08-25 15:06:50 +0000856
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000857// is_convertible
858
Eric Fiselierffbfbcd2015-03-19 21:11:02 +0000859#if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
Howard Hinnant091c5ac2011-01-27 21:00:00 +0000860
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000861template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible
Howard Hinnante87514a2012-08-13 12:29:17 +0000862 : public integral_constant<bool, __is_convertible_to(_T1, _T2) &&
863 !is_abstract<_T2>::value> {};
Howard Hinnant091c5ac2011-01-27 21:00:00 +0000864
Howard Hinnant31b8e612011-02-10 17:46:03 +0000865#else // __has_feature(is_convertible_to)
Howard Hinnant091c5ac2011-01-27 21:00:00 +0000866
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000867namespace __is_convertible_imp
868{
Eric Fiselier4bd15462015-03-30 15:22:20 +0000869template <class _Tp> void __test_convert(_Tp);
870
871template <class _From, class _To, class = void>
872struct __is_convertible_test : public false_type {};
873
874template <class _From, class _To>
875struct __is_convertible_test<_From, _To,
Dan Albert1d4a1ed2016-05-25 22:36:09 -0700876 decltype(__test_convert<_To>(_VSTD::declval<_From>()))> : public true_type
Eric Fiselier4bd15462015-03-30 15:22:20 +0000877{};
878
Dan Albert1d4a1ed2016-05-25 22:36:09 -0700879template <class _Tp> __two __test(...);
880#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
881template <class _Tp> _Tp&& __source();
882#else
883template <class _Tp> typename remove_reference<_Tp>::type& __source();
884#endif
885
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000886template <class _Tp, bool _IsArray = is_array<_Tp>::value,
887 bool _IsFunction = is_function<_Tp>::value,
888 bool _IsVoid = is_void<_Tp>::value>
889 struct __is_array_function_or_void {enum {value = 0};};
890template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};};
891template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};};
892template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};};
893}
894
895template <class _Tp,
896 unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
897struct __is_convertible_check
898{
899 static const size_t __v = 0;
900};
901
902template <class _Tp>
903struct __is_convertible_check<_Tp, 0>
904{
905 static const size_t __v = sizeof(_Tp);
906};
907
908template <class _T1, class _T2,
909 unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value,
910 unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
911struct __is_convertible
912 : public integral_constant<bool,
Eric Fiselier4bd15462015-03-30 15:22:20 +0000913 __is_convertible_imp::__is_convertible_test<_T1, _T2>::value
914#if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
Howard Hinnanta0852ff2012-08-17 17:54:11 +0000915 && !(!is_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value
916 && (!is_const<typename remove_reference<_T2>::type>::value
Howard Hinnanta5160282012-08-25 15:06:50 +0000917 || is_volatile<typename remove_reference<_T2>::type>::value)
918 && (is_same<typename remove_cv<_T1>::type,
919 typename remove_cv<typename remove_reference<_T2>::type>::type>::value
920 || is_base_of<typename remove_reference<_T2>::type, _T1>::value))
Howard Hinnanta0852ff2012-08-17 17:54:11 +0000921#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000922 >
923{};
924
Dan Albert1d4a1ed2016-05-25 22:36:09 -0700925template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 0> : false_type {};
926
927template <class _T1> struct __is_convertible<_T1, const _T1&, 1, 0> : true_type {};
928template <class _T1> struct __is_convertible<const _T1, const _T1&, 1, 0> : true_type {};
929#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
930template <class _T1> struct __is_convertible<_T1, _T1&&, 1, 0> : true_type {};
931template <class _T1> struct __is_convertible<_T1, const _T1&&, 1, 0> : true_type {};
932template <class _T1> struct __is_convertible<_T1, volatile _T1&&, 1, 0> : true_type {};
933template <class _T1> struct __is_convertible<_T1, const volatile _T1&&, 1, 0> : true_type {};
934#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
935
936template <class _T1, class _T2> struct __is_convertible<_T1, _T2*, 1, 0>
937 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*>::value> {};
938
939template <class _T1, class _T2> struct __is_convertible<_T1, _T2* const, 1, 0>
940 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const>::value> {};
941
942template <class _T1, class _T2> struct __is_convertible<_T1, _T2* volatile, 1, 0>
943 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*volatile>::value> {};
944
945template <class _T1, class _T2> struct __is_convertible<_T1, _T2* const volatile, 1, 0>
946 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const volatile>::value> {};
947
948template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 0> : public false_type {};
949#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
950template <class _T1> struct __is_convertible<_T1, _T1&&, 2, 0> : public true_type {};
951#endif
952template <class _T1> struct __is_convertible<_T1, _T1&, 2, 0> : public true_type {};
953template <class _T1> struct __is_convertible<_T1, _T1*, 2, 0> : public true_type {};
954template <class _T1> struct __is_convertible<_T1, _T1*const, 2, 0> : public true_type {};
955template <class _T1> struct __is_convertible<_T1, _T1*volatile, 2, 0> : public true_type {};
956template <class _T1> struct __is_convertible<_T1, _T1*const volatile, 2, 0> : public true_type {};
957
958template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 0> : public false_type {};
959
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000960template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
961template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
962template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
963template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {};
964
965template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {};
966template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {};
967template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {};
968template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {};
969
970template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {};
971template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {};
972template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {};
973template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {};
974
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000975template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000976 : public __is_convertible<_T1, _T2>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000977{
978 static const size_t __complete_check1 = __is_convertible_check<_T1>::__v;
979 static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
980};
981
Howard Hinnant31b8e612011-02-10 17:46:03 +0000982#endif // __has_feature(is_convertible_to)
Howard Hinnant091c5ac2011-01-27 21:00:00 +0000983
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000984// is_empty
985
Marshall Clow48e7e9f2014-07-10 15:38:20 +0000986#if __has_feature(is_empty) || (_GNUC_VER >= 407)
Howard Hinnante814a902011-12-02 20:41:47 +0000987
988template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000989struct _LIBCPP_TYPE_VIS_ONLY is_empty
Howard Hinnante814a902011-12-02 20:41:47 +0000990 : public integral_constant<bool, __is_empty(_Tp)> {};
991
992#else // __has_feature(is_empty)
993
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000994template <class _Tp>
995struct __is_empty1
996 : public _Tp
997{
Howard Hinnant9c0df142012-10-30 19:06:59 +0000998 double __lx;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000999};
1000
1001struct __is_empty2
1002{
Howard Hinnant9c0df142012-10-30 19:06:59 +00001003 double __lx;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001004};
1005
1006template <class _Tp, bool = is_class<_Tp>::value>
1007struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {};
1008
1009template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {};
1010
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001011template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_empty : public __libcpp_empty<_Tp> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001012
Howard Hinnante814a902011-12-02 20:41:47 +00001013#endif // __has_feature(is_empty)
1014
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001015// is_polymorphic
1016
Yaron Keren0648cc52014-02-21 10:00:31 +00001017#if __has_feature(is_polymorphic) || defined(_LIBCPP_MSVC)
Howard Hinnant1e9f55f2012-02-15 20:47:11 +00001018
1019template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001020struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic
Howard Hinnant1e9f55f2012-02-15 20:47:11 +00001021 : public integral_constant<bool, __is_polymorphic(_Tp)> {};
1022
1023#else
1024
Howard Hinnant11a50ac2013-04-02 21:25:06 +00001025template<typename _Tp> char &__is_polymorphic_impl(
1026 typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0,
1027 int>::type);
1028template<typename _Tp> __two &__is_polymorphic_impl(...);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001029
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001030template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic
Howard Hinnant11a50ac2013-04-02 21:25:06 +00001031 : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001032
Howard Hinnant1e9f55f2012-02-15 20:47:11 +00001033#endif // __has_feature(is_polymorphic)
1034
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001035// has_virtual_destructor
1036
Marshall Clow48e7e9f2014-07-10 15:38:20 +00001037#if __has_feature(has_virtual_destructor) || (_GNUC_VER >= 403)
Howard Hinnant745d4732010-09-08 17:55:32 +00001038
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001039template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor
Howard Hinnant745d4732010-09-08 17:55:32 +00001040 : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
1041
Marshall Clow48e7e9f2014-07-10 15:38:20 +00001042#else
Howard Hinnant745d4732010-09-08 17:55:32 +00001043
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001044template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001045 : public false_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001046
Marshall Clow48e7e9f2014-07-10 15:38:20 +00001047#endif
Howard Hinnant745d4732010-09-08 17:55:32 +00001048
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001049// alignment_of
1050
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001051template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY alignment_of
Howard Hinnant5544f7e2013-04-22 19:37:49 +00001052 : public integral_constant<size_t, __alignof__(_Tp)> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001053
1054// aligned_storage
1055
1056template <class _Hp, class _Tp>
1057struct __type_list
1058{
1059 typedef _Hp _Head;
1060 typedef _Tp _Tail;
1061};
1062
Howard Hinnante003ce42011-05-22 00:09:02 +00001063struct __nat
1064{
1065#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
1066 __nat() = delete;
1067 __nat(const __nat&) = delete;
1068 __nat& operator=(const __nat&) = delete;
1069 ~__nat() = delete;
1070#endif
1071};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001072
1073template <class _Tp>
1074struct __align_type
1075{
1076 static const size_t value = alignment_of<_Tp>::value;
1077 typedef _Tp type;
1078};
1079
Howard Hinnant9c0df142012-10-30 19:06:59 +00001080struct __struct_double {long double __lx;};
1081struct __struct_double4 {double __lx[4];};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001082
1083typedef
1084 __type_list<__align_type<unsigned char>,
1085 __type_list<__align_type<unsigned short>,
1086 __type_list<__align_type<unsigned int>,
1087 __type_list<__align_type<unsigned long>,
1088 __type_list<__align_type<unsigned long long>,
1089 __type_list<__align_type<double>,
1090 __type_list<__align_type<long double>,
1091 __type_list<__align_type<__struct_double>,
1092 __type_list<__align_type<__struct_double4>,
1093 __type_list<__align_type<int*>,
1094 __nat
1095 > > > > > > > > > > __all_types;
1096
1097template <class _TL, size_t _Align> struct __find_pod;
1098
1099template <class _Hp, size_t _Align>
1100struct __find_pod<__type_list<_Hp, __nat>, _Align>
1101{
1102 typedef typename conditional<
1103 _Align == _Hp::value,
1104 typename _Hp::type,
1105 void
1106 >::type type;
1107};
1108
1109template <class _Hp, class _Tp, size_t _Align>
1110struct __find_pod<__type_list<_Hp, _Tp>, _Align>
1111{
1112 typedef typename conditional<
1113 _Align == _Hp::value,
1114 typename _Hp::type,
1115 typename __find_pod<_Tp, _Align>::type
1116 >::type type;
1117};
1118
1119template <class _TL, size_t _Len> struct __find_max_align;
1120
1121template <class _Hp, size_t _Len>
1122struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
1123
1124template <size_t _Len, size_t _A1, size_t _A2>
1125struct __select_align
1126{
1127private:
1128 static const size_t __min = _A2 < _A1 ? _A2 : _A1;
1129 static const size_t __max = _A1 < _A2 ? _A2 : _A1;
1130public:
1131 static const size_t value = _Len < __max ? __min : __max;
1132};
1133
1134template <class _Hp, class _Tp, size_t _Len>
1135struct __find_max_align<__type_list<_Hp, _Tp>, _Len>
1136 : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
1137
Marshall Clow933afa92013-07-04 00:10:01 +00001138template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001139struct _LIBCPP_TYPE_VIS_ONLY aligned_storage
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001140{
1141 typedef typename __find_pod<__all_types, _Align>::type _Aligner;
1142 static_assert(!is_void<_Aligner>::value, "");
1143 union type
1144 {
1145 _Aligner __align;
Dan Albert1d4a1ed2016-05-25 22:36:09 -07001146 unsigned char __data[_Len];
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001147 };
1148};
1149
Marshall Clow933afa92013-07-04 00:10:01 +00001150#if _LIBCPP_STD_VER > 11
1151template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1152 using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
1153#endif
1154
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001155#define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
1156template <size_t _Len>\
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001157struct _LIBCPP_TYPE_VIS_ONLY aligned_storage<_Len, n>\
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001158{\
Howard Hinnant08e17472011-10-17 20:05:10 +00001159 struct _ALIGNAS(n) type\
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001160 {\
Dan Albert1d4a1ed2016-05-25 22:36:09 -07001161 unsigned char __lx[_Len];\
Howard Hinnant08e17472011-10-17 20:05:10 +00001162 };\
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001163}
1164
1165_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
1166_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
1167_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
1168_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
1169_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
1170_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
1171_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
1172_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
1173_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
1174_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
1175_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
1176_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
1177_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
1178_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
Howard Hinnant08e17472011-10-17 20:05:10 +00001179// MSDN says that MSVC does not support alignment beyond 8192 (=0x2000)
Howard Hinnante9df0a52013-08-01 18:17:34 +00001180#if !defined(_LIBCPP_MSVC)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001181_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
Howard Hinnante9df0a52013-08-01 18:17:34 +00001182#endif // !_LIBCPP_MSVC
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001183
1184#undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
1185
Howard Hinnant5544f7e2013-04-22 19:37:49 +00001186#ifndef _LIBCPP_HAS_NO_VARIADICS
1187
1188// aligned_union
1189
1190template <size_t _I0, size_t ..._In>
1191struct __static_max;
1192
1193template <size_t _I0>
1194struct __static_max<_I0>
1195{
1196 static const size_t value = _I0;
1197};
1198
1199template <size_t _I0, size_t _I1, size_t ..._In>
1200struct __static_max<_I0, _I1, _In...>
1201{
1202 static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value :
1203 __static_max<_I1, _In...>::value;
1204};
1205
1206template <size_t _Len, class _Type0, class ..._Types>
1207struct aligned_union
1208{
1209 static const size_t alignment_value = __static_max<__alignof__(_Type0),
1210 __alignof__(_Types)...>::value;
1211 static const size_t __len = __static_max<_Len, sizeof(_Type0),
1212 sizeof(_Types)...>::value;
1213 typedef typename aligned_storage<__len, alignment_value>::type type;
1214};
1215
Marshall Clow933afa92013-07-04 00:10:01 +00001216#if _LIBCPP_STD_VER > 11
1217template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
1218#endif
1219
Howard Hinnant5544f7e2013-04-22 19:37:49 +00001220#endif // _LIBCPP_HAS_NO_VARIADICS
1221
Marshall Clow854a7a02014-01-03 18:21:14 +00001222template <class _Tp>
1223struct __numeric_type
1224{
1225 static void __test(...);
1226 static float __test(float);
1227 static double __test(char);
1228 static double __test(int);
1229 static double __test(unsigned);
1230 static double __test(long);
1231 static double __test(unsigned long);
1232 static double __test(long long);
1233 static double __test(unsigned long long);
1234 static double __test(double);
1235 static long double __test(long double);
1236
1237 typedef decltype(__test(declval<_Tp>())) type;
1238 static const bool value = !is_same<type, void>::value;
1239};
1240
1241template <>
1242struct __numeric_type<void>
1243{
1244 static const bool value = true;
1245};
1246
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001247// __promote
1248
1249template <class _A1, class _A2 = void, class _A3 = void,
Marshall Clow854a7a02014-01-03 18:21:14 +00001250 bool = __numeric_type<_A1>::value &&
1251 __numeric_type<_A2>::value &&
1252 __numeric_type<_A3>::value>
Eric Fiselier950ee772014-10-17 00:31:47 +00001253class __promote_imp
Marshall Clow854a7a02014-01-03 18:21:14 +00001254{
Eric Fiselier950ee772014-10-17 00:31:47 +00001255public:
Marshall Clow854a7a02014-01-03 18:21:14 +00001256 static const bool value = false;
1257};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001258
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001259template <class _A1, class _A2, class _A3>
Eric Fiselier950ee772014-10-17 00:31:47 +00001260class __promote_imp<_A1, _A2, _A3, true>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001261{
1262private:
Eric Fiselier950ee772014-10-17 00:31:47 +00001263 typedef typename __promote_imp<_A1>::type __type1;
1264 typedef typename __promote_imp<_A2>::type __type2;
1265 typedef typename __promote_imp<_A3>::type __type3;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001266public:
Howard Hinnant08e17472011-10-17 20:05:10 +00001267 typedef decltype(__type1() + __type2() + __type3()) type;
Marshall Clow854a7a02014-01-03 18:21:14 +00001268 static const bool value = true;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001269};
1270
1271template <class _A1, class _A2>
Eric Fiselier950ee772014-10-17 00:31:47 +00001272class __promote_imp<_A1, _A2, void, true>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001273{
1274private:
Eric Fiselier950ee772014-10-17 00:31:47 +00001275 typedef typename __promote_imp<_A1>::type __type1;
1276 typedef typename __promote_imp<_A2>::type __type2;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001277public:
Howard Hinnant08e17472011-10-17 20:05:10 +00001278 typedef decltype(__type1() + __type2()) type;
Marshall Clow854a7a02014-01-03 18:21:14 +00001279 static const bool value = true;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001280};
1281
1282template <class _A1>
Eric Fiselier950ee772014-10-17 00:31:47 +00001283class __promote_imp<_A1, void, void, true>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001284{
1285public:
Marshall Clow854a7a02014-01-03 18:21:14 +00001286 typedef typename __numeric_type<_A1>::type type;
1287 static const bool value = true;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001288};
1289
Eric Fiselier950ee772014-10-17 00:31:47 +00001290template <class _A1, class _A2 = void, class _A3 = void>
1291class __promote : public __promote_imp<_A1, _A2, _A3> {};
1292
Dan Albert1d4a1ed2016-05-25 22:36:09 -07001293#ifdef _LIBCPP_STORE_AS_OPTIMIZATION
1294
1295// __transform
1296
1297template <class _Tp, size_t = sizeof(_Tp), bool = is_scalar<_Tp>::value> struct __transform {typedef _Tp type;};
1298template <class _Tp> struct __transform<_Tp, 1, true> {typedef unsigned char type;};
1299template <class _Tp> struct __transform<_Tp, 2, true> {typedef unsigned short type;};
1300template <class _Tp> struct __transform<_Tp, 4, true> {typedef unsigned int type;};
1301template <class _Tp> struct __transform<_Tp, 8, true> {typedef unsigned long long type;};
1302
1303#endif // _LIBCPP_STORE_AS_OPTIMIZATION
1304
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001305// make_signed / make_unsigned
1306
1307typedef
1308 __type_list<signed char,
1309 __type_list<signed short,
1310 __type_list<signed int,
1311 __type_list<signed long,
1312 __type_list<signed long long,
Stephan Tolksdorf8a71d232014-03-26 19:45:52 +00001313#ifndef _LIBCPP_HAS_NO_INT128
1314 __type_list<__int128_t,
1315#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001316 __nat
Stephan Tolksdorf8a71d232014-03-26 19:45:52 +00001317#ifndef _LIBCPP_HAS_NO_INT128
1318 >
1319#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001320 > > > > > __signed_types;
1321
1322typedef
1323 __type_list<unsigned char,
1324 __type_list<unsigned short,
1325 __type_list<unsigned int,
1326 __type_list<unsigned long,
1327 __type_list<unsigned long long,
Stephan Tolksdorf8a71d232014-03-26 19:45:52 +00001328#ifndef _LIBCPP_HAS_NO_INT128
1329 __type_list<__uint128_t,
1330#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001331 __nat
Stephan Tolksdorf8a71d232014-03-26 19:45:52 +00001332#ifndef _LIBCPP_HAS_NO_INT128
1333 >
1334#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001335 > > > > > __unsigned_types;
1336
1337template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
1338
1339template <class _Hp, class _Tp, size_t _Size>
1340struct __find_first<__type_list<_Hp, _Tp>, _Size, true>
1341{
1342 typedef _Hp type;
1343};
1344
1345template <class _Hp, class _Tp, size_t _Size>
1346struct __find_first<__type_list<_Hp, _Tp>, _Size, false>
1347{
1348 typedef typename __find_first<_Tp, _Size>::type type;
1349};
1350
1351template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
1352 bool = is_volatile<typename remove_reference<_Tp>::type>::value>
1353struct __apply_cv
1354{
1355 typedef _Up type;
1356};
1357
1358template <class _Tp, class _Up>
1359struct __apply_cv<_Tp, _Up, true, false>
1360{
1361 typedef const _Up type;
1362};
1363
1364template <class _Tp, class _Up>
1365struct __apply_cv<_Tp, _Up, false, true>
1366{
1367 typedef volatile _Up type;
1368};
1369
1370template <class _Tp, class _Up>
1371struct __apply_cv<_Tp, _Up, true, true>
1372{
1373 typedef const volatile _Up type;
1374};
1375
1376template <class _Tp, class _Up>
1377struct __apply_cv<_Tp&, _Up, false, false>
1378{
1379 typedef _Up& type;
1380};
1381
1382template <class _Tp, class _Up>
1383struct __apply_cv<_Tp&, _Up, true, false>
1384{
1385 typedef const _Up& type;
1386};
1387
1388template <class _Tp, class _Up>
1389struct __apply_cv<_Tp&, _Up, false, true>
1390{
1391 typedef volatile _Up& type;
1392};
1393
1394template <class _Tp, class _Up>
1395struct __apply_cv<_Tp&, _Up, true, true>
1396{
1397 typedef const volatile _Up& type;
1398};
1399
1400template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1401struct __make_signed {};
1402
1403template <class _Tp>
1404struct __make_signed<_Tp, true>
1405{
1406 typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
1407};
1408
1409template <> struct __make_signed<bool, true> {};
1410template <> struct __make_signed< signed short, true> {typedef short type;};
1411template <> struct __make_signed<unsigned short, true> {typedef short type;};
1412template <> struct __make_signed< signed int, true> {typedef int type;};
1413template <> struct __make_signed<unsigned int, true> {typedef int type;};
1414template <> struct __make_signed< signed long, true> {typedef long type;};
1415template <> struct __make_signed<unsigned long, true> {typedef long type;};
1416template <> struct __make_signed< signed long long, true> {typedef long long type;};
1417template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
Stephan Tolksdorf8a71d232014-03-26 19:45:52 +00001418#ifndef _LIBCPP_HAS_NO_INT128
1419template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;};
1420template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;};
1421#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001422
1423template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001424struct _LIBCPP_TYPE_VIS_ONLY make_signed
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001425{
1426 typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
1427};
1428
Marshall Clow933afa92013-07-04 00:10:01 +00001429#if _LIBCPP_STD_VER > 11
1430template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
1431#endif
1432
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001433template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1434struct __make_unsigned {};
1435
1436template <class _Tp>
1437struct __make_unsigned<_Tp, true>
1438{
1439 typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
1440};
1441
1442template <> struct __make_unsigned<bool, true> {};
1443template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;};
1444template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;};
1445template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;};
1446template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;};
1447template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;};
1448template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;};
1449template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;};
1450template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
Stephan Tolksdorf8a71d232014-03-26 19:45:52 +00001451#ifndef _LIBCPP_HAS_NO_INT128
1452template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;};
1453template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;};
1454#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001455
1456template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001457struct _LIBCPP_TYPE_VIS_ONLY make_unsigned
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001458{
1459 typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
1460};
1461
Marshall Clow933afa92013-07-04 00:10:01 +00001462#if _LIBCPP_STD_VER > 11
1463template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
1464#endif
1465
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001466#ifdef _LIBCPP_HAS_NO_VARIADICS
1467
Marshall Clow60279932015-01-09 17:03:36 +00001468template <class _Tp, class _Up = void, class _Vp = void>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001469struct _LIBCPP_TYPE_VIS_ONLY common_type
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001470{
1471public:
Marshall Clow60279932015-01-09 17:03:36 +00001472 typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp>::type type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001473};
1474
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001475template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001476struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, void, void>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001477{
1478public:
Marshall Clow71e699d2014-02-10 17:40:28 +00001479 typedef typename decay<_Tp>::type type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001480};
1481
1482template <class _Tp, class _Up>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001483struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, void>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001484{
Dan Albert1d4a1ed2016-05-25 22:36:09 -07001485private:
1486#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1487 static _Tp&& __t();
1488 static _Up&& __u();
1489#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1490 static _Tp __t();
1491 static _Up __u();
1492#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1493public:
1494 typedef typename remove_reference<decltype(true ? __t() : __u())>::type type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001495};
1496
Howard Hinnant324bb032010-08-22 00:02:43 +00001497#else // _LIBCPP_HAS_NO_VARIADICS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001498
Dan Albert1d4a1ed2016-05-25 22:36:09 -07001499template <class ..._Tp> struct common_type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001500
1501template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001502struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001503{
Marshall Clowdab89a12013-10-07 23:43:33 +00001504 typedef typename decay<_Tp>::type type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001505};
1506
1507template <class _Tp, class _Up>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001508struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001509{
Dan Albert1d4a1ed2016-05-25 22:36:09 -07001510private:
1511 static _Tp&& __t();
1512 static _Up&& __u();
1513 static bool __f();
1514public:
1515 typedef typename decay<decltype(__f() ? __t() : __u())>::type type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001516};
1517
1518template <class _Tp, class _Up, class ..._Vp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001519struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, _Vp...>
Dan Albert1d4a1ed2016-05-25 22:36:09 -07001520{
1521 typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp...>::type type;
1522};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001523
Marshall Clow933afa92013-07-04 00:10:01 +00001524#if _LIBCPP_STD_VER > 11
1525template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type;
1526#endif
1527
Howard Hinnant324bb032010-08-22 00:02:43 +00001528#endif // _LIBCPP_HAS_NO_VARIADICS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001529
Howard Hinnant1468b662010-11-19 22:17:28 +00001530// is_assignable
1531
Joerg Sonnenbergerbfaafd52013-11-25 22:44:20 +00001532template<typename, typename _Tp> struct __select_2nd { typedef _Tp type; };
Howard Hinnant01afa5c2013-09-02 20:30:37 +00001533
Howard Hinnant745d4732010-09-08 17:55:32 +00001534template <class _Tp, class _Arg>
Howard Hinnant01afa5c2013-09-02 20:30:37 +00001535typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type
Howard Hinnant745d4732010-09-08 17:55:32 +00001536#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1537__is_assignable_test(_Tp&&, _Arg&&);
1538#else
Howard Hinnant6063ec12011-05-13 14:08:16 +00001539__is_assignable_test(_Tp, _Arg&);
Howard Hinnant745d4732010-09-08 17:55:32 +00001540#endif
1541
1542template <class _Arg>
1543false_type
1544#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1545__is_assignable_test(__any, _Arg&&);
1546#else
1547__is_assignable_test(__any, _Arg&);
1548#endif
1549
Howard Hinnant6063ec12011-05-13 14:08:16 +00001550template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
Howard Hinnant745d4732010-09-08 17:55:32 +00001551struct __is_assignable_imp
1552 : public common_type
1553 <
Marshall Clow3a4964a2015-04-14 13:53:53 +00001554 decltype(_VSTD::__is_assignable_test(declval<_Tp>(), declval<_Arg>()))
Howard Hinnant745d4732010-09-08 17:55:32 +00001555 >::type {};
1556
1557template <class _Tp, class _Arg>
Howard Hinnant6063ec12011-05-13 14:08:16 +00001558struct __is_assignable_imp<_Tp, _Arg, true>
1559 : public false_type
1560{
1561};
1562
1563template <class _Tp, class _Arg>
Howard Hinnant1468b662010-11-19 22:17:28 +00001564struct is_assignable
Howard Hinnant745d4732010-09-08 17:55:32 +00001565 : public __is_assignable_imp<_Tp, _Arg> {};
1566
Howard Hinnant1468b662010-11-19 22:17:28 +00001567// is_copy_assignable
Howard Hinnant745d4732010-09-08 17:55:32 +00001568
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001569template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_copy_assignable
Howard Hinnant6063ec12011-05-13 14:08:16 +00001570 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
Marshall Clowd132bf42014-09-22 23:58:00 +00001571 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
Howard Hinnant745d4732010-09-08 17:55:32 +00001572
Howard Hinnant1468b662010-11-19 22:17:28 +00001573// is_move_assignable
1574
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001575template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_move_assignable
Howard Hinnant1468b662010-11-19 22:17:28 +00001576#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant6063ec12011-05-13 14:08:16 +00001577 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
1578 const typename add_rvalue_reference<_Tp>::type> {};
Howard Hinnant1468b662010-11-19 22:17:28 +00001579#else
1580 : public is_copy_assignable<_Tp> {};
1581#endif
1582
1583// is_destructible
1584
Marshall Clow38d90052014-10-18 11:03:33 +00001585// if it's a reference, return true
1586// if it's a function, return false
1587// if it's void, return false
1588// if it's an array of unknown bound, return false
1589// Otherwise, return "std::declval<_Up&>().~_Up()" is well-formed
Marshall Clow2b44e3d2014-07-16 15:51:50 +00001590// where _Up is remove_all_extents<_Tp>::type
1591
Eric Fiselier6f8821d2014-07-31 19:09:26 +00001592template <class>
1593struct __is_destructible_apply { typedef int type; };
1594
Marshall Clow2b44e3d2014-07-16 15:51:50 +00001595template <typename _Tp>
1596struct __is_destructor_wellformed {
Marshall Clow38d90052014-10-18 11:03:33 +00001597 template <typename _Tp1>
1598 static char __test (
Eric Fiselier6f8821d2014-07-31 19:09:26 +00001599 typename __is_destructible_apply<decltype(_VSTD::declval<_Tp1&>().~_Tp1())>::type
1600 );
Marshall Clow2b44e3d2014-07-16 15:51:50 +00001601
Marshall Clow38d90052014-10-18 11:03:33 +00001602 template <typename _Tp1>
1603 static __two __test (...);
1604
1605 static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char);
Eric Fiselier6f8821d2014-07-31 19:09:26 +00001606};
Marshall Clow2b44e3d2014-07-16 15:51:50 +00001607
1608template <class _Tp, bool>
1609struct __destructible_imp;
Howard Hinnant1468b662010-11-19 22:17:28 +00001610
1611template <class _Tp>
Marshall Clow2b44e3d2014-07-16 15:51:50 +00001612struct __destructible_imp<_Tp, false>
1613 : public _VSTD::integral_constant<bool,
1614 __is_destructor_wellformed<typename _VSTD::remove_all_extents<_Tp>::type>::value> {};
Howard Hinnant1468b662010-11-19 22:17:28 +00001615
1616template <class _Tp>
1617struct __destructible_imp<_Tp, true>
Marshall Clow2b44e3d2014-07-16 15:51:50 +00001618 : public _VSTD::true_type {};
1619
1620template <class _Tp, bool>
1621struct __destructible_false;
1622
1623template <class _Tp>
1624struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, _VSTD::is_reference<_Tp>::value> {};
1625
1626template <class _Tp>
1627struct __destructible_false<_Tp, true> : public _VSTD::false_type {};
Howard Hinnant745d4732010-09-08 17:55:32 +00001628
Howard Hinnant1468b662010-11-19 22:17:28 +00001629template <class _Tp>
1630struct is_destructible
Marshall Clow2b44e3d2014-07-16 15:51:50 +00001631 : public __destructible_false<_Tp, _VSTD::is_function<_Tp>::value> {};
Howard Hinnant745d4732010-09-08 17:55:32 +00001632
Howard Hinnant80e19ac2013-08-09 16:53:45 +00001633template <class _Tp>
1634struct is_destructible<_Tp[]>
Marshall Clow2b44e3d2014-07-16 15:51:50 +00001635 : public _VSTD::false_type {};
1636
1637template <>
1638struct is_destructible<void>
1639 : public _VSTD::false_type {};
Howard Hinnant80e19ac2013-08-09 16:53:45 +00001640
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001641// move
1642
Howard Hinnant73d21a42010-09-04 23:28:19 +00001643#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001644
1645template <class _Tp>
Marshall Clow01a0e902013-07-15 20:46:11 +00001646inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001647typename remove_reference<_Tp>::type&&
Howard Hinnante9b2c2d2011-05-27 15:04:19 +00001648move(_Tp&& __t) _NOEXCEPT
Howard Hinnant60a0a8e2010-08-10 20:48:29 +00001649{
Howard Hinnant726a76f2010-11-16 21:10:23 +00001650 typedef typename remove_reference<_Tp>::type _Up;
1651 return static_cast<_Up&&>(__t);
Howard Hinnant60a0a8e2010-08-10 20:48:29 +00001652}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001653
Howard Hinnantd2a92512010-09-13 01:43:27 +00001654template <class _Tp>
Marshall Clow01a0e902013-07-15 20:46:11 +00001655inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantd2a92512010-09-13 01:43:27 +00001656_Tp&&
Dan Albert1d4a1ed2016-05-25 22:36:09 -07001657forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
Howard Hinnantd2a92512010-09-13 01:43:27 +00001658{
1659 return static_cast<_Tp&&>(__t);
1660}
1661
1662template <class _Tp>
Marshall Clow01a0e902013-07-15 20:46:11 +00001663inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantd2a92512010-09-13 01:43:27 +00001664_Tp&&
Dan Albert1d4a1ed2016-05-25 22:36:09 -07001665forward(typename std::remove_reference<_Tp>::type&& __t) _NOEXCEPT
Howard Hinnantd2a92512010-09-13 01:43:27 +00001666{
Dan Albert1d4a1ed2016-05-25 22:36:09 -07001667 static_assert(!std::is_lvalue_reference<_Tp>::value,
Howard Hinnant8db4aca2011-10-17 20:08:59 +00001668 "Can not forward an rvalue as an lvalue.");
1669 return static_cast<_Tp&&>(__t);
Howard Hinnantd2a92512010-09-13 01:43:27 +00001670}
1671
Howard Hinnant73d21a42010-09-04 23:28:19 +00001672#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001673
Howard Hinnantd8bc09b2010-05-18 17:32:30 +00001674template <class _Tp>
Howard Hinnant87073e42012-05-01 15:37:54 +00001675inline _LIBCPP_INLINE_VISIBILITY
1676_Tp&
1677move(_Tp& __t)
1678{
1679 return __t;
1680}
1681
1682template <class _Tp>
1683inline _LIBCPP_INLINE_VISIBILITY
1684const _Tp&
1685move(const _Tp& __t)
1686{
1687 return __t;
1688}
1689
1690template <class _Tp>
1691inline _LIBCPP_INLINE_VISIBILITY
1692_Tp&
Dan Albert1d4a1ed2016-05-25 22:36:09 -07001693forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
Howard Hinnant87073e42012-05-01 15:37:54 +00001694{
1695 return __t;
1696}
1697
1698
1699template <class _Tp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001700class __rv
1701{
Howard Hinnantd8bc09b2010-05-18 17:32:30 +00001702 typedef typename remove_reference<_Tp>::type _Trr;
1703 _Trr& t_;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001704public:
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001705 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantd8bc09b2010-05-18 17:32:30 +00001706 _Trr* operator->() {return &t_;}
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001707 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantd8bc09b2010-05-18 17:32:30 +00001708 explicit __rv(_Trr& __t) : t_(__t) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001709};
1710
Howard Hinnant73d21a42010-09-04 23:28:19 +00001711#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001712
Howard Hinnantd4b95782011-06-19 19:12:59 +00001713#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1714
Howard Hinnant656bdc32011-05-16 18:40:35 +00001715template <class _Tp>
1716inline _LIBCPP_INLINE_VISIBILITY
1717typename decay<_Tp>::type
1718__decay_copy(_Tp&& __t)
1719{
Howard Hinnant0949eed2011-06-30 21:18:19 +00001720 return _VSTD::forward<_Tp>(__t);
Howard Hinnant656bdc32011-05-16 18:40:35 +00001721}
1722
Howard Hinnantd4b95782011-06-19 19:12:59 +00001723#else
1724
1725template <class _Tp>
1726inline _LIBCPP_INLINE_VISIBILITY
1727typename decay<_Tp>::type
1728__decay_copy(const _Tp& __t)
1729{
Howard Hinnant0949eed2011-06-30 21:18:19 +00001730 return _VSTD::forward<_Tp>(__t);
Howard Hinnantd4b95782011-06-19 19:12:59 +00001731}
1732
1733#endif
1734
Howard Hinnant37c53b62011-05-16 16:17:21 +00001735#ifndef _LIBCPP_HAS_NO_VARIADICS
1736
Howard Hinnant99968442011-11-29 18:15:50 +00001737template <class _Rp, class _Class, class ..._Param>
1738struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00001739{
1740 typedef _Class _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00001741 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00001742 typedef _Rp (_FnType) (_Param...);
Howard Hinnant37c53b62011-05-16 16:17:21 +00001743};
1744
Howard Hinnant99968442011-11-29 18:15:50 +00001745template <class _Rp, class _Class, class ..._Param>
Eric Fiselier63648cf2014-08-19 16:31:47 +00001746struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false>
1747{
1748 typedef _Class _ClassType;
1749 typedef _Rp _ReturnType;
1750 typedef _Rp (_FnType) (_Param..., ...);
1751};
1752
1753template <class _Rp, class _Class, class ..._Param>
Howard Hinnant99968442011-11-29 18:15:50 +00001754struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00001755{
1756 typedef _Class const _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00001757 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00001758 typedef _Rp (_FnType) (_Param...);
Howard Hinnant37c53b62011-05-16 16:17:21 +00001759};
1760
Howard Hinnant99968442011-11-29 18:15:50 +00001761template <class _Rp, class _Class, class ..._Param>
Eric Fiselier63648cf2014-08-19 16:31:47 +00001762struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false>
1763{
1764 typedef _Class const _ClassType;
1765 typedef _Rp _ReturnType;
1766 typedef _Rp (_FnType) (_Param..., ...);
1767};
1768
1769template <class _Rp, class _Class, class ..._Param>
Howard Hinnant99968442011-11-29 18:15:50 +00001770struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00001771{
1772 typedef _Class volatile _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00001773 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00001774 typedef _Rp (_FnType) (_Param...);
Howard Hinnant37c53b62011-05-16 16:17:21 +00001775};
1776
Howard Hinnant99968442011-11-29 18:15:50 +00001777template <class _Rp, class _Class, class ..._Param>
Eric Fiselier63648cf2014-08-19 16:31:47 +00001778struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false>
1779{
1780 typedef _Class volatile _ClassType;
1781 typedef _Rp _ReturnType;
1782 typedef _Rp (_FnType) (_Param..., ...);
1783};
1784
1785template <class _Rp, class _Class, class ..._Param>
Howard Hinnant99968442011-11-29 18:15:50 +00001786struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00001787{
1788 typedef _Class const volatile _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00001789 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00001790 typedef _Rp (_FnType) (_Param...);
Howard Hinnant37c53b62011-05-16 16:17:21 +00001791};
1792
Eric Fiselier63648cf2014-08-19 16:31:47 +00001793template <class _Rp, class _Class, class ..._Param>
1794struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false>
1795{
1796 typedef _Class const volatile _ClassType;
1797 typedef _Rp _ReturnType;
1798 typedef _Rp (_FnType) (_Param..., ...);
1799};
1800
Eric Fiseliereeeada12015-06-13 02:18:44 +00001801#if __has_feature(cxx_reference_qualified_functions) || \
1802 (defined(_GNUC_VER) && _GNUC_VER >= 409)
Howard Hinnant37c53b62011-05-16 16:17:21 +00001803
Howard Hinnant99968442011-11-29 18:15:50 +00001804template <class _Rp, class _Class, class ..._Param>
1805struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00001806{
1807 typedef _Class& _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00001808 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00001809 typedef _Rp (_FnType) (_Param...);
Howard Hinnant37c53b62011-05-16 16:17:21 +00001810};
1811
Howard Hinnant99968442011-11-29 18:15:50 +00001812template <class _Rp, class _Class, class ..._Param>
Eric Fiselier63648cf2014-08-19 16:31:47 +00001813struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false>
1814{
1815 typedef _Class& _ClassType;
1816 typedef _Rp _ReturnType;
1817 typedef _Rp (_FnType) (_Param..., ...);
1818};
1819
1820template <class _Rp, class _Class, class ..._Param>
Howard Hinnant99968442011-11-29 18:15:50 +00001821struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00001822{
1823 typedef _Class const& _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00001824 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00001825 typedef _Rp (_FnType) (_Param...);
Howard Hinnant37c53b62011-05-16 16:17:21 +00001826};
1827
Howard Hinnant99968442011-11-29 18:15:50 +00001828template <class _Rp, class _Class, class ..._Param>
Eric Fiselier63648cf2014-08-19 16:31:47 +00001829struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false>
1830{
1831 typedef _Class const& _ClassType;
1832 typedef _Rp _ReturnType;
1833 typedef _Rp (_FnType) (_Param..., ...);
1834};
1835
1836template <class _Rp, class _Class, class ..._Param>
Howard Hinnant99968442011-11-29 18:15:50 +00001837struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00001838{
1839 typedef _Class volatile& _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00001840 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00001841 typedef _Rp (_FnType) (_Param...);
Howard Hinnant37c53b62011-05-16 16:17:21 +00001842};
1843
Howard Hinnant99968442011-11-29 18:15:50 +00001844template <class _Rp, class _Class, class ..._Param>
Eric Fiselier63648cf2014-08-19 16:31:47 +00001845struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false>
1846{
1847 typedef _Class volatile& _ClassType;
1848 typedef _Rp _ReturnType;
1849 typedef _Rp (_FnType) (_Param..., ...);
1850};
1851
1852template <class _Rp, class _Class, class ..._Param>
Howard Hinnant99968442011-11-29 18:15:50 +00001853struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00001854{
1855 typedef _Class const volatile& _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00001856 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00001857 typedef _Rp (_FnType) (_Param...);
Howard Hinnant37c53b62011-05-16 16:17:21 +00001858};
1859
Howard Hinnant99968442011-11-29 18:15:50 +00001860template <class _Rp, class _Class, class ..._Param>
Eric Fiselier63648cf2014-08-19 16:31:47 +00001861struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false>
1862{
1863 typedef _Class const volatile& _ClassType;
1864 typedef _Rp _ReturnType;
1865 typedef _Rp (_FnType) (_Param..., ...);
1866};
1867
1868template <class _Rp, class _Class, class ..._Param>
Howard Hinnant99968442011-11-29 18:15:50 +00001869struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00001870{
1871 typedef _Class&& _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00001872 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00001873 typedef _Rp (_FnType) (_Param...);
Howard Hinnant37c53b62011-05-16 16:17:21 +00001874};
1875
Howard Hinnant99968442011-11-29 18:15:50 +00001876template <class _Rp, class _Class, class ..._Param>
Eric Fiselier63648cf2014-08-19 16:31:47 +00001877struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false>
1878{
1879 typedef _Class&& _ClassType;
1880 typedef _Rp _ReturnType;
1881 typedef _Rp (_FnType) (_Param..., ...);
1882};
1883
1884template <class _Rp, class _Class, class ..._Param>
Howard Hinnant99968442011-11-29 18:15:50 +00001885struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00001886{
1887 typedef _Class const&& _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00001888 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00001889 typedef _Rp (_FnType) (_Param...);
Howard Hinnant37c53b62011-05-16 16:17:21 +00001890};
1891
Howard Hinnant99968442011-11-29 18:15:50 +00001892template <class _Rp, class _Class, class ..._Param>
Eric Fiselier63648cf2014-08-19 16:31:47 +00001893struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false>
1894{
1895 typedef _Class const&& _ClassType;
1896 typedef _Rp _ReturnType;
1897 typedef _Rp (_FnType) (_Param..., ...);
1898};
1899
1900template <class _Rp, class _Class, class ..._Param>
Howard Hinnant99968442011-11-29 18:15:50 +00001901struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00001902{
1903 typedef _Class volatile&& _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00001904 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00001905 typedef _Rp (_FnType) (_Param...);
Howard Hinnant37c53b62011-05-16 16:17:21 +00001906};
1907
Howard Hinnant99968442011-11-29 18:15:50 +00001908template <class _Rp, class _Class, class ..._Param>
Eric Fiselier63648cf2014-08-19 16:31:47 +00001909struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false>
1910{
1911 typedef _Class volatile&& _ClassType;
1912 typedef _Rp _ReturnType;
1913 typedef _Rp (_FnType) (_Param..., ...);
1914};
1915
1916template <class _Rp, class _Class, class ..._Param>
Howard Hinnant99968442011-11-29 18:15:50 +00001917struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00001918{
1919 typedef _Class const volatile&& _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00001920 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00001921 typedef _Rp (_FnType) (_Param...);
Howard Hinnant37c53b62011-05-16 16:17:21 +00001922};
1923
Eric Fiselier63648cf2014-08-19 16:31:47 +00001924template <class _Rp, class _Class, class ..._Param>
1925struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false>
1926{
1927 typedef _Class const volatile&& _ClassType;
1928 typedef _Rp _ReturnType;
1929 typedef _Rp (_FnType) (_Param..., ...);
1930};
1931
Eric Fiseliereeeada12015-06-13 02:18:44 +00001932#endif // __has_feature(cxx_reference_qualified_functions) || _GNUC_VER >= 409
Howard Hinnant37c53b62011-05-16 16:17:21 +00001933
1934#else // _LIBCPP_HAS_NO_VARIADICS
1935
Howard Hinnant99968442011-11-29 18:15:50 +00001936template <class _Rp, class _Class>
1937struct __member_pointer_traits_imp<_Rp (_Class::*)(), true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00001938{
1939 typedef _Class _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00001940 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00001941 typedef _Rp (_FnType) ();
Howard Hinnant37c53b62011-05-16 16:17:21 +00001942};
1943
Eric Fiselier63648cf2014-08-19 16:31:47 +00001944template <class _Rp, class _Class>
1945struct __member_pointer_traits_imp<_Rp (_Class::*)(...), true, false>
1946{
1947 typedef _Class _ClassType;
1948 typedef _Rp _ReturnType;
1949 typedef _Rp (_FnType) (...);
1950};
1951
Howard Hinnant99968442011-11-29 18:15:50 +00001952template <class _Rp, class _Class, class _P0>
1953struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00001954{
1955 typedef _Class _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00001956 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00001957 typedef _Rp (_FnType) (_P0);
Howard Hinnant37c53b62011-05-16 16:17:21 +00001958};
1959
Eric Fiselier63648cf2014-08-19 16:31:47 +00001960template <class _Rp, class _Class, class _P0>
1961struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...), true, false>
1962{
1963 typedef _Class _ClassType;
1964 typedef _Rp _ReturnType;
1965 typedef _Rp (_FnType) (_P0, ...);
1966};
1967
Howard Hinnant99968442011-11-29 18:15:50 +00001968template <class _Rp, class _Class, class _P0, class _P1>
1969struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00001970{
1971 typedef _Class _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00001972 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00001973 typedef _Rp (_FnType) (_P0, _P1);
Howard Hinnant37c53b62011-05-16 16:17:21 +00001974};
1975
Eric Fiselier63648cf2014-08-19 16:31:47 +00001976template <class _Rp, class _Class, class _P0, class _P1>
1977struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...), true, false>
1978{
1979 typedef _Class _ClassType;
1980 typedef _Rp _ReturnType;
1981 typedef _Rp (_FnType) (_P0, _P1, ...);
1982};
1983
Howard Hinnant99968442011-11-29 18:15:50 +00001984template <class _Rp, class _Class, class _P0, class _P1, class _P2>
1985struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00001986{
1987 typedef _Class _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00001988 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00001989 typedef _Rp (_FnType) (_P0, _P1, _P2);
Howard Hinnant37c53b62011-05-16 16:17:21 +00001990};
1991
Eric Fiselier63648cf2014-08-19 16:31:47 +00001992template <class _Rp, class _Class, class _P0, class _P1, class _P2>
1993struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...), true, false>
1994{
1995 typedef _Class _ClassType;
1996 typedef _Rp _ReturnType;
1997 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
1998};
1999
Howard Hinnant99968442011-11-29 18:15:50 +00002000template <class _Rp, class _Class>
2001struct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002002{
2003 typedef _Class const _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002004 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002005 typedef _Rp (_FnType) ();
Howard Hinnant37c53b62011-05-16 16:17:21 +00002006};
2007
Eric Fiselier63648cf2014-08-19 16:31:47 +00002008template <class _Rp, class _Class>
2009struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const, true, false>
2010{
2011 typedef _Class const _ClassType;
2012 typedef _Rp _ReturnType;
2013 typedef _Rp (_FnType) (...);
2014};
2015
Howard Hinnant99968442011-11-29 18:15:50 +00002016template <class _Rp, class _Class, class _P0>
2017struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002018{
2019 typedef _Class const _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002020 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002021 typedef _Rp (_FnType) (_P0);
Howard Hinnant37c53b62011-05-16 16:17:21 +00002022};
2023
Eric Fiselier63648cf2014-08-19 16:31:47 +00002024template <class _Rp, class _Class, class _P0>
2025struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const, true, false>
2026{
2027 typedef _Class const _ClassType;
2028 typedef _Rp _ReturnType;
2029 typedef _Rp (_FnType) (_P0, ...);
2030};
2031
Howard Hinnant99968442011-11-29 18:15:50 +00002032template <class _Rp, class _Class, class _P0, class _P1>
2033struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002034{
2035 typedef _Class const _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002036 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002037 typedef _Rp (_FnType) (_P0, _P1);
Howard Hinnant37c53b62011-05-16 16:17:21 +00002038};
2039
Eric Fiselier63648cf2014-08-19 16:31:47 +00002040template <class _Rp, class _Class, class _P0, class _P1>
2041struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const, true, false>
2042{
2043 typedef _Class const _ClassType;
2044 typedef _Rp _ReturnType;
2045 typedef _Rp (_FnType) (_P0, _P1, ...);
2046};
2047
Howard Hinnant99968442011-11-29 18:15:50 +00002048template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2049struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002050{
2051 typedef _Class const _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002052 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002053 typedef _Rp (_FnType) (_P0, _P1, _P2);
Howard Hinnant37c53b62011-05-16 16:17:21 +00002054};
2055
Eric Fiselier63648cf2014-08-19 16:31:47 +00002056template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2057struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const, true, false>
2058{
2059 typedef _Class const _ClassType;
2060 typedef _Rp _ReturnType;
2061 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2062};
2063
Howard Hinnant99968442011-11-29 18:15:50 +00002064template <class _Rp, class _Class>
2065struct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002066{
2067 typedef _Class volatile _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002068 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002069 typedef _Rp (_FnType) ();
Howard Hinnant37c53b62011-05-16 16:17:21 +00002070};
2071
Eric Fiselier63648cf2014-08-19 16:31:47 +00002072template <class _Rp, class _Class>
2073struct __member_pointer_traits_imp<_Rp (_Class::*)(...) volatile, true, false>
2074{
2075 typedef _Class volatile _ClassType;
2076 typedef _Rp _ReturnType;
2077 typedef _Rp (_FnType) (...);
2078};
2079
Howard Hinnant99968442011-11-29 18:15:50 +00002080template <class _Rp, class _Class, class _P0>
2081struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002082{
2083 typedef _Class volatile _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002084 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002085 typedef _Rp (_FnType) (_P0);
Howard Hinnant37c53b62011-05-16 16:17:21 +00002086};
2087
Eric Fiselier63648cf2014-08-19 16:31:47 +00002088template <class _Rp, class _Class, class _P0>
2089struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) volatile, true, false>
2090{
2091 typedef _Class volatile _ClassType;
2092 typedef _Rp _ReturnType;
2093 typedef _Rp (_FnType) (_P0, ...);
2094};
2095
Howard Hinnant99968442011-11-29 18:15:50 +00002096template <class _Rp, class _Class, class _P0, class _P1>
2097struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002098{
2099 typedef _Class volatile _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002100 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002101 typedef _Rp (_FnType) (_P0, _P1);
Howard Hinnant37c53b62011-05-16 16:17:21 +00002102};
2103
Eric Fiselier63648cf2014-08-19 16:31:47 +00002104template <class _Rp, class _Class, class _P0, class _P1>
2105struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) volatile, true, false>
2106{
2107 typedef _Class volatile _ClassType;
2108 typedef _Rp _ReturnType;
2109 typedef _Rp (_FnType) (_P0, _P1, ...);
2110};
2111
Howard Hinnant99968442011-11-29 18:15:50 +00002112template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2113struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002114{
2115 typedef _Class volatile _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002116 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002117 typedef _Rp (_FnType) (_P0, _P1, _P2);
Howard Hinnant37c53b62011-05-16 16:17:21 +00002118};
2119
Eric Fiselier63648cf2014-08-19 16:31:47 +00002120template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2121struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) volatile, true, false>
2122{
2123 typedef _Class volatile _ClassType;
2124 typedef _Rp _ReturnType;
2125 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2126};
2127
Howard Hinnant99968442011-11-29 18:15:50 +00002128template <class _Rp, class _Class>
2129struct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002130{
2131 typedef _Class const volatile _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002132 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002133 typedef _Rp (_FnType) ();
Howard Hinnant37c53b62011-05-16 16:17:21 +00002134};
2135
Eric Fiselier63648cf2014-08-19 16:31:47 +00002136template <class _Rp, class _Class>
2137struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const volatile, true, false>
2138{
2139 typedef _Class const volatile _ClassType;
2140 typedef _Rp _ReturnType;
2141 typedef _Rp (_FnType) (...);
2142};
2143
Howard Hinnant99968442011-11-29 18:15:50 +00002144template <class _Rp, class _Class, class _P0>
2145struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002146{
2147 typedef _Class const volatile _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002148 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002149 typedef _Rp (_FnType) (_P0);
Howard Hinnant37c53b62011-05-16 16:17:21 +00002150};
2151
Eric Fiselier63648cf2014-08-19 16:31:47 +00002152template <class _Rp, class _Class, class _P0>
2153struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const volatile, true, false>
2154{
2155 typedef _Class const volatile _ClassType;
2156 typedef _Rp _ReturnType;
2157 typedef _Rp (_FnType) (_P0, ...);
2158};
2159
Howard Hinnant99968442011-11-29 18:15:50 +00002160template <class _Rp, class _Class, class _P0, class _P1>
2161struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002162{
2163 typedef _Class const volatile _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002164 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002165 typedef _Rp (_FnType) (_P0, _P1);
Howard Hinnant37c53b62011-05-16 16:17:21 +00002166};
2167
Eric Fiselier63648cf2014-08-19 16:31:47 +00002168template <class _Rp, class _Class, class _P0, class _P1>
2169struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const volatile, true, false>
2170{
2171 typedef _Class const volatile _ClassType;
2172 typedef _Rp _ReturnType;
2173 typedef _Rp (_FnType) (_P0, _P1, ...);
2174};
2175
Howard Hinnant99968442011-11-29 18:15:50 +00002176template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2177struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002178{
2179 typedef _Class const volatile _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002180 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002181 typedef _Rp (_FnType) (_P0, _P1, _P2);
Howard Hinnant37c53b62011-05-16 16:17:21 +00002182};
2183
Eric Fiselier63648cf2014-08-19 16:31:47 +00002184template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2185struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const volatile, true, false>
2186{
2187 typedef _Class const volatile _ClassType;
2188 typedef _Rp _ReturnType;
2189 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2190};
2191
Howard Hinnant37c53b62011-05-16 16:17:21 +00002192#endif // _LIBCPP_HAS_NO_VARIADICS
2193
Howard Hinnant99968442011-11-29 18:15:50 +00002194template <class _Rp, class _Class>
2195struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002196{
2197 typedef _Class _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002198 typedef _Rp _ReturnType;
Howard Hinnant37c53b62011-05-16 16:17:21 +00002199};
2200
2201template <class _MP>
2202struct __member_pointer_traits
Howard Hinnant6287c652013-05-15 21:49:27 +00002203 : public __member_pointer_traits_imp<typename remove_cv<_MP>::type,
Howard Hinnant37c53b62011-05-16 16:17:21 +00002204 is_member_function_pointer<_MP>::value,
2205 is_member_object_pointer<_MP>::value>
2206{
2207// typedef ... _ClassType;
2208// typedef ... _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002209// typedef ... _FnType;
Howard Hinnant37c53b62011-05-16 16:17:21 +00002210};
2211
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002212// result_of
2213
Howard Hinnant2b1b2d42011-06-14 19:58:17 +00002214template <class _Callable> class result_of;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002215
Howard Hinnant2d622292012-06-26 17:37:15 +00002216#ifdef _LIBCPP_HAS_NO_VARIADICS
2217
Howard Hinnant37c53b62011-05-16 16:17:21 +00002218template <class _Fn, bool, bool>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002219class __result_of
2220{
2221};
2222
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002223template <class _Fn>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002224class __result_of<_Fn(), true, false>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002225{
2226public:
2227 typedef decltype(declval<_Fn>()()) type;
2228};
2229
2230template <class _Fn, class _A0>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002231class __result_of<_Fn(_A0), true, false>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002232{
2233public:
2234 typedef decltype(declval<_Fn>()(declval<_A0>())) type;
2235};
2236
2237template <class _Fn, class _A0, class _A1>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002238class __result_of<_Fn(_A0, _A1), true, false>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002239{
2240public:
2241 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type;
2242};
2243
2244template <class _Fn, class _A0, class _A1, class _A2>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002245class __result_of<_Fn(_A0, _A1, _A2), true, false>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002246{
2247public:
2248 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type;
2249};
2250
Howard Hinnant37c53b62011-05-16 16:17:21 +00002251template <class _MP, class _Tp, bool _IsMemberFunctionPtr>
2252struct __result_of_mp;
2253
2254// member function pointer
2255
2256template <class _MP, class _Tp>
2257struct __result_of_mp<_MP, _Tp, true>
Eric Fiselier49835802015-06-13 08:25:24 +00002258 : public __identity<typename __member_pointer_traits<_MP>::_ReturnType>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002259{
2260};
2261
2262// member data pointer
2263
2264template <class _MP, class _Tp, bool>
2265struct __result_of_mdp;
2266
Howard Hinnant99968442011-11-29 18:15:50 +00002267template <class _Rp, class _Class, class _Tp>
2268struct __result_of_mdp<_Rp _Class::*, _Tp, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002269{
Howard Hinnant99968442011-11-29 18:15:50 +00002270 typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type;
Howard Hinnant37c53b62011-05-16 16:17:21 +00002271};
2272
Howard Hinnant99968442011-11-29 18:15:50 +00002273template <class _Rp, class _Class, class _Tp>
2274struct __result_of_mdp<_Rp _Class::*, _Tp, true>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002275{
Howard Hinnant99968442011-11-29 18:15:50 +00002276 typedef typename __apply_cv<_Tp, _Rp>::type& type;
Howard Hinnant37c53b62011-05-16 16:17:21 +00002277};
2278
Howard Hinnant99968442011-11-29 18:15:50 +00002279template <class _Rp, class _Class, class _Tp>
2280struct __result_of_mp<_Rp _Class::*, _Tp, false>
2281 : public __result_of_mdp<_Rp _Class::*, _Tp,
Howard Hinnant37c53b62011-05-16 16:17:21 +00002282 is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
2283{
2284};
2285
2286
2287
2288template <class _Fn, class _Tp>
2289class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer
2290 : public __result_of_mp<typename remove_reference<_Fn>::type,
2291 _Tp,
2292 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2293{
2294};
2295
2296template <class _Fn, class _Tp, class _A0>
2297class __result_of<_Fn(_Tp, _A0), false, true> // _Fn must be member pointer
2298 : public __result_of_mp<typename remove_reference<_Fn>::type,
2299 _Tp,
2300 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2301{
2302};
2303
2304template <class _Fn, class _Tp, class _A0, class _A1>
2305class __result_of<_Fn(_Tp, _A0, _A1), false, true> // _Fn must be member pointer
2306 : public __result_of_mp<typename remove_reference<_Fn>::type,
2307 _Tp,
2308 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2309{
2310};
2311
2312template <class _Fn, class _Tp, class _A0, class _A1, class _A2>
2313class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true> // _Fn must be member pointer
2314 : public __result_of_mp<typename remove_reference<_Fn>::type,
2315 _Tp,
2316 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2317{
2318};
2319
2320// result_of
2321
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002322template <class _Fn>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002323class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn()>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002324 : public __result_of<_Fn(),
2325 is_class<typename remove_reference<_Fn>::type>::value ||
Eric Fiselier49835802015-06-13 08:25:24 +00002326 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
Howard Hinnant37c53b62011-05-16 16:17:21 +00002327 is_member_pointer<typename remove_reference<_Fn>::type>::value
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002328 >
2329{
2330};
2331
2332template <class _Fn, class _A0>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002333class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0)>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002334 : public __result_of<_Fn(_A0),
2335 is_class<typename remove_reference<_Fn>::type>::value ||
Eric Fiselier49835802015-06-13 08:25:24 +00002336 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
Howard Hinnant37c53b62011-05-16 16:17:21 +00002337 is_member_pointer<typename remove_reference<_Fn>::type>::value
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002338 >
2339{
2340};
2341
2342template <class _Fn, class _A0, class _A1>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002343class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1)>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002344 : public __result_of<_Fn(_A0, _A1),
2345 is_class<typename remove_reference<_Fn>::type>::value ||
Eric Fiselier49835802015-06-13 08:25:24 +00002346 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
Howard Hinnant37c53b62011-05-16 16:17:21 +00002347 is_member_pointer<typename remove_reference<_Fn>::type>::value
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002348 >
2349{
2350};
2351
2352template <class _Fn, class _A0, class _A1, class _A2>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002353class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1, _A2)>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002354 : public __result_of<_Fn(_A0, _A1, _A2),
2355 is_class<typename remove_reference<_Fn>::type>::value ||
Eric Fiselier49835802015-06-13 08:25:24 +00002356 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
Howard Hinnant37c53b62011-05-16 16:17:21 +00002357 is_member_pointer<typename remove_reference<_Fn>::type>::value
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002358 >
2359{
2360};
2361
Howard Hinnant324bb032010-08-22 00:02:43 +00002362#endif // _LIBCPP_HAS_NO_VARIADICS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002363
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002364// template <class T, class... Args> struct is_constructible;
2365
Marshall Clow067e91d2014-04-21 22:30:32 +00002366namespace __is_construct
2367{
2368struct __nat {};
2369}
2370
2371#if __has_feature(is_constructible)
2372
2373template <class _Tp, class ..._Args>
2374struct _LIBCPP_TYPE_VIS_ONLY is_constructible
2375 : public integral_constant<bool, __is_constructible(_Tp, _Args...)>
2376 {};
2377
2378#else
2379
2380#ifndef _LIBCPP_HAS_NO_VARIADICS
2381
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002382// main is_constructible test
2383
2384template <class _Tp, class ..._Args>
Howard Hinnant4af2cf32012-11-01 16:32:14 +00002385typename __select_2nd<decltype(_VSTD::move(_Tp(_VSTD::declval<_Args>()...))), true_type>::type
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002386__is_constructible_test(_Tp&&, _Args&& ...);
2387
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002388template <class ..._Args>
2389false_type
2390__is_constructible_test(__any, _Args&& ...);
2391
2392template <bool, class _Tp, class... _Args>
Marshall Clow708dd842014-01-24 15:27:41 +00002393struct __libcpp_is_constructible // false, _Tp is not a scalar
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002394 : public common_type
2395 <
2396 decltype(__is_constructible_test(declval<_Tp>(), declval<_Args>()...))
2397 >::type
2398 {};
2399
2400// function types are not constructible
2401
Howard Hinnant99968442011-11-29 18:15:50 +00002402template <class _Rp, class... _A1, class... _A2>
Marshall Clow708dd842014-01-24 15:27:41 +00002403struct __libcpp_is_constructible<false, _Rp(_A1...), _A2...>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002404 : public false_type
2405 {};
2406
2407// handle scalars and reference types
2408
2409// Scalars are default constructible, references are not
2410
2411template <class _Tp>
Marshall Clow708dd842014-01-24 15:27:41 +00002412struct __libcpp_is_constructible<true, _Tp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002413 : public is_scalar<_Tp>
2414 {};
2415
2416// Scalars and references are constructible from one arg if that arg is
2417// implicitly convertible to the scalar or reference.
2418
2419template <class _Tp>
2420struct __is_constructible_ref
2421{
Howard Hinnant9c0df142012-10-30 19:06:59 +00002422 true_type static __lxx(_Tp);
2423 false_type static __lxx(...);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002424};
2425
2426template <class _Tp, class _A0>
Marshall Clow708dd842014-01-24 15:27:41 +00002427struct __libcpp_is_constructible<true, _Tp, _A0>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002428 : public common_type
2429 <
Howard Hinnant9c0df142012-10-30 19:06:59 +00002430 decltype(__is_constructible_ref<_Tp>::__lxx(declval<_A0>()))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002431 >::type
2432 {};
2433
2434// Scalars and references are not constructible from multiple args.
2435
2436template <class _Tp, class _A0, class ..._Args>
Marshall Clow708dd842014-01-24 15:27:41 +00002437struct __libcpp_is_constructible<true, _Tp, _A0, _Args...>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002438 : public false_type
2439 {};
2440
2441// Treat scalars and reference types separately
2442
2443template <bool, class _Tp, class... _Args>
2444struct __is_constructible_void_check
Marshall Clow708dd842014-01-24 15:27:41 +00002445 : public __libcpp_is_constructible<is_scalar<_Tp>::value || is_reference<_Tp>::value,
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002446 _Tp, _Args...>
2447 {};
2448
2449// If any of T or Args is void, is_constructible should be false
2450
2451template <class _Tp, class... _Args>
2452struct __is_constructible_void_check<true, _Tp, _Args...>
2453 : public false_type
2454 {};
2455
Howard Hinnant17615b02010-07-27 01:25:38 +00002456template <class ..._Args> struct __contains_void;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002457
Howard Hinnant17615b02010-07-27 01:25:38 +00002458template <> struct __contains_void<> : false_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002459
2460template <class _A0, class ..._Args>
Howard Hinnant17615b02010-07-27 01:25:38 +00002461struct __contains_void<_A0, _Args...>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002462{
2463 static const bool value = is_void<_A0>::value ||
Howard Hinnant17615b02010-07-27 01:25:38 +00002464 __contains_void<_Args...>::value;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002465};
2466
2467// is_constructible entry point
2468
2469template <class _Tp, class... _Args>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002470struct _LIBCPP_TYPE_VIS_ONLY is_constructible
Howard Hinnant17615b02010-07-27 01:25:38 +00002471 : public __is_constructible_void_check<__contains_void<_Tp, _Args...>::value
2472 || is_abstract<_Tp>::value,
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002473 _Tp, _Args...>
2474 {};
2475
2476// Array types are default constructible if their element type
2477// is default constructible
2478
Howard Hinnant99968442011-11-29 18:15:50 +00002479template <class _Ap, size_t _Np>
Marshall Clow708dd842014-01-24 15:27:41 +00002480struct __libcpp_is_constructible<false, _Ap[_Np]>
Howard Hinnant99968442011-11-29 18:15:50 +00002481 : public is_constructible<typename remove_all_extents<_Ap>::type>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002482 {};
2483
2484// Otherwise array types are not constructible by this syntax
2485
Howard Hinnant99968442011-11-29 18:15:50 +00002486template <class _Ap, size_t _Np, class ..._Args>
Marshall Clow708dd842014-01-24 15:27:41 +00002487struct __libcpp_is_constructible<false, _Ap[_Np], _Args...>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002488 : public false_type
2489 {};
2490
2491// Incomplete array types are not constructible
2492
Howard Hinnant99968442011-11-29 18:15:50 +00002493template <class _Ap, class ..._Args>
Marshall Clow708dd842014-01-24 15:27:41 +00002494struct __libcpp_is_constructible<false, _Ap[], _Args...>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002495 : public false_type
2496 {};
2497
Howard Hinnant1468b662010-11-19 22:17:28 +00002498#else // _LIBCPP_HAS_NO_VARIADICS
Howard Hinnantbb73d762010-09-07 17:47:31 +00002499
2500// template <class T> struct is_constructible0;
2501
2502// main is_constructible0 test
2503
2504template <class _Tp>
Howard Hinnant1468b662010-11-19 22:17:28 +00002505decltype((_Tp(), true_type()))
Howard Hinnantbb73d762010-09-07 17:47:31 +00002506__is_constructible0_test(_Tp&);
2507
2508false_type
2509__is_constructible0_test(__any);
2510
Howard Hinnant1468b662010-11-19 22:17:28 +00002511template <class _Tp, class _A0>
Howard Hinnant0949eed2011-06-30 21:18:19 +00002512decltype((_Tp(_VSTD::declval<_A0>()), true_type()))
Howard Hinnant1468b662010-11-19 22:17:28 +00002513__is_constructible1_test(_Tp&, _A0&);
2514
2515template <class _A0>
2516false_type
2517__is_constructible1_test(__any, _A0&);
2518
2519template <class _Tp, class _A0, class _A1>
Howard Hinnant0949eed2011-06-30 21:18:19 +00002520decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>()), true_type()))
Howard Hinnant1468b662010-11-19 22:17:28 +00002521__is_constructible2_test(_Tp&, _A0&, _A1&);
2522
2523template <class _A0, class _A1>
2524false_type
2525__is_constructible2_test(__any, _A0&, _A1&);
2526
Howard Hinnantbb73d762010-09-07 17:47:31 +00002527template <bool, class _Tp>
2528struct __is_constructible0_imp // false, _Tp is not a scalar
2529 : public common_type
2530 <
2531 decltype(__is_constructible0_test(declval<_Tp&>()))
2532 >::type
2533 {};
2534
Howard Hinnant1468b662010-11-19 22:17:28 +00002535template <bool, class _Tp, class _A0>
2536struct __is_constructible1_imp // false, _Tp is not a scalar
2537 : public common_type
2538 <
2539 decltype(__is_constructible1_test(declval<_Tp&>(), declval<_A0&>()))
2540 >::type
2541 {};
2542
2543template <bool, class _Tp, class _A0, class _A1>
2544struct __is_constructible2_imp // false, _Tp is not a scalar
2545 : public common_type
2546 <
2547 decltype(__is_constructible2_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>()))
2548 >::type
2549 {};
2550
Howard Hinnantbb73d762010-09-07 17:47:31 +00002551// handle scalars and reference types
2552
2553// Scalars are default constructible, references are not
2554
2555template <class _Tp>
2556struct __is_constructible0_imp<true, _Tp>
2557 : public is_scalar<_Tp>
2558 {};
2559
Howard Hinnant1468b662010-11-19 22:17:28 +00002560template <class _Tp, class _A0>
2561struct __is_constructible1_imp<true, _Tp, _A0>
2562 : public is_convertible<_A0, _Tp>
2563 {};
2564
2565template <class _Tp, class _A0, class _A1>
2566struct __is_constructible2_imp<true, _Tp, _A0, _A1>
2567 : public false_type
2568 {};
2569
Howard Hinnantbb73d762010-09-07 17:47:31 +00002570// Treat scalars and reference types separately
2571
2572template <bool, class _Tp>
2573struct __is_constructible0_void_check
2574 : public __is_constructible0_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2575 _Tp>
2576 {};
2577
Howard Hinnant1468b662010-11-19 22:17:28 +00002578template <bool, class _Tp, class _A0>
2579struct __is_constructible1_void_check
2580 : public __is_constructible1_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2581 _Tp, _A0>
2582 {};
2583
2584template <bool, class _Tp, class _A0, class _A1>
2585struct __is_constructible2_void_check
2586 : public __is_constructible2_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2587 _Tp, _A0, _A1>
2588 {};
2589
Howard Hinnantbb73d762010-09-07 17:47:31 +00002590// If any of T or Args is void, is_constructible should be false
2591
2592template <class _Tp>
2593struct __is_constructible0_void_check<true, _Tp>
2594 : public false_type
2595 {};
2596
Howard Hinnant1468b662010-11-19 22:17:28 +00002597template <class _Tp, class _A0>
2598struct __is_constructible1_void_check<true, _Tp, _A0>
2599 : public false_type
2600 {};
2601
2602template <class _Tp, class _A0, class _A1>
2603struct __is_constructible2_void_check<true, _Tp, _A0, _A1>
2604 : public false_type
2605 {};
2606
2607// is_constructible entry point
2608
Howard Hinnant1468b662010-11-19 22:17:28 +00002609template <class _Tp, class _A0 = __is_construct::__nat,
2610 class _A1 = __is_construct::__nat>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002611struct _LIBCPP_TYPE_VIS_ONLY is_constructible
Howard Hinnant1468b662010-11-19 22:17:28 +00002612 : public __is_constructible2_void_check<is_void<_Tp>::value
2613 || is_abstract<_Tp>::value
2614 || is_function<_Tp>::value
2615 || is_void<_A0>::value
2616 || is_void<_A1>::value,
2617 _Tp, _A0, _A1>
2618 {};
Howard Hinnantbb73d762010-09-07 17:47:31 +00002619
2620template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002621struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat>
Howard Hinnantbb73d762010-09-07 17:47:31 +00002622 : public __is_constructible0_void_check<is_void<_Tp>::value
Howard Hinnant1468b662010-11-19 22:17:28 +00002623 || is_abstract<_Tp>::value
2624 || is_function<_Tp>::value,
Howard Hinnantbb73d762010-09-07 17:47:31 +00002625 _Tp>
2626 {};
2627
Howard Hinnant1468b662010-11-19 22:17:28 +00002628template <class _Tp, class _A0>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002629struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, _A0, __is_construct::__nat>
Howard Hinnant1468b662010-11-19 22:17:28 +00002630 : public __is_constructible1_void_check<is_void<_Tp>::value
2631 || is_abstract<_Tp>::value
2632 || is_function<_Tp>::value
2633 || is_void<_A0>::value,
2634 _Tp, _A0>
2635 {};
2636
Howard Hinnantbb73d762010-09-07 17:47:31 +00002637// Array types are default constructible if their element type
2638// is default constructible
2639
Howard Hinnant99968442011-11-29 18:15:50 +00002640template <class _Ap, size_t _Np>
2641struct __is_constructible0_imp<false, _Ap[_Np]>
2642 : public is_constructible<typename remove_all_extents<_Ap>::type>
Howard Hinnant1468b662010-11-19 22:17:28 +00002643 {};
2644
Howard Hinnant99968442011-11-29 18:15:50 +00002645template <class _Ap, size_t _Np, class _A0>
2646struct __is_constructible1_imp<false, _Ap[_Np], _A0>
Howard Hinnant1468b662010-11-19 22:17:28 +00002647 : public false_type
2648 {};
2649
Howard Hinnant99968442011-11-29 18:15:50 +00002650template <class _Ap, size_t _Np, class _A0, class _A1>
2651struct __is_constructible2_imp<false, _Ap[_Np], _A0, _A1>
Howard Hinnant1468b662010-11-19 22:17:28 +00002652 : public false_type
Howard Hinnantbb73d762010-09-07 17:47:31 +00002653 {};
2654
2655// Incomplete array types are not constructible
2656
Howard Hinnant99968442011-11-29 18:15:50 +00002657template <class _Ap>
2658struct __is_constructible0_imp<false, _Ap[]>
Howard Hinnantbb73d762010-09-07 17:47:31 +00002659 : public false_type
2660 {};
2661
Howard Hinnant99968442011-11-29 18:15:50 +00002662template <class _Ap, class _A0>
2663struct __is_constructible1_imp<false, _Ap[], _A0>
Howard Hinnant1468b662010-11-19 22:17:28 +00002664 : public false_type
Howard Hinnant954b3662010-09-07 23:11:28 +00002665 {};
2666
Howard Hinnant99968442011-11-29 18:15:50 +00002667template <class _Ap, class _A0, class _A1>
2668struct __is_constructible2_imp<false, _Ap[], _A0, _A1>
Howard Hinnant1468b662010-11-19 22:17:28 +00002669 : public false_type
Howard Hinnant954b3662010-09-07 23:11:28 +00002670 {};
2671
Howard Hinnant1468b662010-11-19 22:17:28 +00002672#endif // _LIBCPP_HAS_NO_VARIADICS
Marshall Clow067e91d2014-04-21 22:30:32 +00002673#endif // __has_feature(is_constructible)
Howard Hinnant1468b662010-11-19 22:17:28 +00002674
2675// is_default_constructible
2676
2677template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002678struct _LIBCPP_TYPE_VIS_ONLY is_default_constructible
Howard Hinnant1468b662010-11-19 22:17:28 +00002679 : public is_constructible<_Tp>
2680 {};
2681
2682// is_copy_constructible
2683
2684template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002685struct _LIBCPP_TYPE_VIS_ONLY is_copy_constructible
Marshall Clowd132bf42014-09-22 23:58:00 +00002686 : public is_constructible<_Tp,
2687 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
Howard Hinnant1468b662010-11-19 22:17:28 +00002688
2689// is_move_constructible
2690
2691template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002692struct _LIBCPP_TYPE_VIS_ONLY is_move_constructible
Howard Hinnant1468b662010-11-19 22:17:28 +00002693#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2694 : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2695#else
2696 : public is_copy_constructible<_Tp>
2697#endif
2698 {};
2699
2700// is_trivially_constructible
2701
2702#ifndef _LIBCPP_HAS_NO_VARIADICS
2703
Eric Fiseliereeeada12015-06-13 02:18:44 +00002704#if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
Howard Hinnant43008392012-02-24 23:32:26 +00002705
2706template <class _Tp, class... _Args>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002707struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
Howard Hinnant43008392012-02-24 23:32:26 +00002708 : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
2709{
2710};
2711
2712#else // !__has_feature(is_trivially_constructible)
2713
Howard Hinnant1468b662010-11-19 22:17:28 +00002714template <class _Tp, class... _Args>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002715struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
Howard Hinnant1468b662010-11-19 22:17:28 +00002716 : false_type
2717{
2718};
2719
2720template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002721struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp>
Marshall Clow48e7e9f2014-07-10 15:38:20 +00002722#if __has_feature(has_trivial_constructor) || (_GNUC_VER >= 403)
Howard Hinnant1468b662010-11-19 22:17:28 +00002723 : integral_constant<bool, __has_trivial_constructor(_Tp)>
2724#else
2725 : integral_constant<bool, is_scalar<_Tp>::value>
2726#endif
2727{
2728};
2729
2730template <class _Tp>
2731#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002732struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&&>
Howard Hinnant1468b662010-11-19 22:17:28 +00002733#else
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002734struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp>
Howard Hinnant1468b662010-11-19 22:17:28 +00002735#endif
Howard Hinnant1468b662010-11-19 22:17:28 +00002736 : integral_constant<bool, is_scalar<_Tp>::value>
Howard Hinnant1468b662010-11-19 22:17:28 +00002737{
2738};
2739
2740template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002741struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&>
Howard Hinnant1468b662010-11-19 22:17:28 +00002742 : integral_constant<bool, is_scalar<_Tp>::value>
Howard Hinnant1468b662010-11-19 22:17:28 +00002743{
2744};
2745
2746template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002747struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&>
Howard Hinnant1468b662010-11-19 22:17:28 +00002748 : integral_constant<bool, is_scalar<_Tp>::value>
Howard Hinnant1468b662010-11-19 22:17:28 +00002749{
2750};
2751
Howard Hinnant43008392012-02-24 23:32:26 +00002752#endif // !__has_feature(is_trivially_constructible)
2753
Howard Hinnant1468b662010-11-19 22:17:28 +00002754#else // _LIBCPP_HAS_NO_VARIADICS
2755
2756template <class _Tp, class _A0 = __is_construct::__nat,
2757 class _A1 = __is_construct::__nat>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002758struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
Howard Hinnant1468b662010-11-19 22:17:28 +00002759 : false_type
2760{
2761};
2762
Eric Fiseliereeeada12015-06-13 02:18:44 +00002763#if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
Howard Hinnant43008392012-02-24 23:32:26 +00002764
Howard Hinnant1468b662010-11-19 22:17:28 +00002765template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002766struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat,
Howard Hinnant1468b662010-11-19 22:17:28 +00002767 __is_construct::__nat>
Howard Hinnant43008392012-02-24 23:32:26 +00002768 : integral_constant<bool, __is_trivially_constructible(_Tp)>
Howard Hinnant1468b662010-11-19 22:17:28 +00002769{
2770};
2771
2772template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002773struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp,
Howard Hinnant1468b662010-11-19 22:17:28 +00002774 __is_construct::__nat>
Howard Hinnant43008392012-02-24 23:32:26 +00002775 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp)>
Howard Hinnant1468b662010-11-19 22:17:28 +00002776{
2777};
2778
2779template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002780struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&,
Howard Hinnant1468b662010-11-19 22:17:28 +00002781 __is_construct::__nat>
Howard Hinnant43008392012-02-24 23:32:26 +00002782 : integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)>
Howard Hinnant1468b662010-11-19 22:17:28 +00002783{
2784};
2785
2786template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002787struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&,
Howard Hinnant1468b662010-11-19 22:17:28 +00002788 __is_construct::__nat>
Howard Hinnant43008392012-02-24 23:32:26 +00002789 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&)>
Howard Hinnant1468b662010-11-19 22:17:28 +00002790{
2791};
2792
Howard Hinnant43008392012-02-24 23:32:26 +00002793#else // !__has_feature(is_trivially_constructible)
2794
2795template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002796struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat,
Howard Hinnant43008392012-02-24 23:32:26 +00002797 __is_construct::__nat>
2798 : integral_constant<bool, is_scalar<_Tp>::value>
2799{
2800};
2801
2802template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002803struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp,
Howard Hinnant43008392012-02-24 23:32:26 +00002804 __is_construct::__nat>
2805 : integral_constant<bool, is_scalar<_Tp>::value>
2806{
2807};
2808
2809template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002810struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&,
Howard Hinnant43008392012-02-24 23:32:26 +00002811 __is_construct::__nat>
2812 : integral_constant<bool, is_scalar<_Tp>::value>
2813{
2814};
2815
2816template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002817struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&,
Howard Hinnant43008392012-02-24 23:32:26 +00002818 __is_construct::__nat>
2819 : integral_constant<bool, is_scalar<_Tp>::value>
2820{
2821};
2822
2823#endif // !__has_feature(is_trivially_constructible)
2824
Howard Hinnant1468b662010-11-19 22:17:28 +00002825#endif // _LIBCPP_HAS_NO_VARIADICS
2826
2827// is_trivially_default_constructible
2828
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002829template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_default_constructible
Howard Hinnant1468b662010-11-19 22:17:28 +00002830 : public is_trivially_constructible<_Tp>
2831 {};
2832
2833// is_trivially_copy_constructible
2834
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002835template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_constructible
Howard Hinnant3f81e9e2013-11-13 00:39:22 +00002836 : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type>
Howard Hinnant1468b662010-11-19 22:17:28 +00002837 {};
2838
2839// is_trivially_move_constructible
2840
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002841template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_constructible
Howard Hinnant1468b662010-11-19 22:17:28 +00002842#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2843 : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2844#else
2845 : public is_trivially_copy_constructible<_Tp>
2846#endif
2847 {};
2848
2849// is_trivially_assignable
2850
Eric Fiseliereeeada12015-06-13 02:18:44 +00002851#if __has_feature(is_trivially_assignable) || _GNUC_VER >= 501
Howard Hinnant43008392012-02-24 23:32:26 +00002852
2853template <class _Tp, class _Arg>
2854struct is_trivially_assignable
2855 : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
2856{
2857};
2858
Marshall Clow48e7e9f2014-07-10 15:38:20 +00002859#else // !__has_feature(is_trivially_assignable)
Howard Hinnant43008392012-02-24 23:32:26 +00002860
Howard Hinnant1468b662010-11-19 22:17:28 +00002861template <class _Tp, class _Arg>
2862struct is_trivially_assignable
2863 : public false_type {};
2864
2865template <class _Tp>
2866struct is_trivially_assignable<_Tp&, _Tp>
Howard Hinnant1468b662010-11-19 22:17:28 +00002867 : integral_constant<bool, is_scalar<_Tp>::value> {};
Howard Hinnant1468b662010-11-19 22:17:28 +00002868
2869template <class _Tp>
2870struct is_trivially_assignable<_Tp&, _Tp&>
Howard Hinnant1468b662010-11-19 22:17:28 +00002871 : integral_constant<bool, is_scalar<_Tp>::value> {};
Howard Hinnant1468b662010-11-19 22:17:28 +00002872
2873template <class _Tp>
2874struct is_trivially_assignable<_Tp&, const _Tp&>
Howard Hinnant1468b662010-11-19 22:17:28 +00002875 : integral_constant<bool, is_scalar<_Tp>::value> {};
Howard Hinnant1468b662010-11-19 22:17:28 +00002876
2877#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2878
2879template <class _Tp>
2880struct is_trivially_assignable<_Tp&, _Tp&&>
Howard Hinnant1468b662010-11-19 22:17:28 +00002881 : integral_constant<bool, is_scalar<_Tp>::value> {};
Howard Hinnant1468b662010-11-19 22:17:28 +00002882
2883#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2884
Marshall Clow48e7e9f2014-07-10 15:38:20 +00002885#endif // !__has_feature(is_trivially_assignable)
Howard Hinnant43008392012-02-24 23:32:26 +00002886
Howard Hinnant1468b662010-11-19 22:17:28 +00002887// is_trivially_copy_assignable
2888
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002889template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_assignable
Howard Hinnant1468b662010-11-19 22:17:28 +00002890 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
Marshall Clowd132bf42014-09-22 23:58:00 +00002891 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
Howard Hinnant1468b662010-11-19 22:17:28 +00002892
2893// is_trivially_move_assignable
2894
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002895template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_assignable
Howard Hinnant1468b662010-11-19 22:17:28 +00002896 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
2897#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2898 typename add_rvalue_reference<_Tp>::type>
2899#else
2900 typename add_lvalue_reference<_Tp>::type>
2901#endif
2902 {};
2903
2904// is_trivially_destructible
2905
Marshall Clow48e7e9f2014-07-10 15:38:20 +00002906#if __has_feature(has_trivial_destructor) || (_GNUC_VER >= 403)
Howard Hinnant1468b662010-11-19 22:17:28 +00002907
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002908template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible
Marshall Clowe33e03e2014-09-02 16:19:38 +00002909 : public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {};
Howard Hinnant1468b662010-11-19 22:17:28 +00002910
Marshall Clow48e7e9f2014-07-10 15:38:20 +00002911#else
Howard Hinnant1468b662010-11-19 22:17:28 +00002912
2913template <class _Tp> struct __libcpp_trivial_destructor
2914 : public integral_constant<bool, is_scalar<_Tp>::value ||
2915 is_reference<_Tp>::value> {};
2916
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002917template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible
Howard Hinnant1468b662010-11-19 22:17:28 +00002918 : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
2919
Eric Fiselier12c6d9c2015-07-18 16:43:58 +00002920template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible<_Tp[]>
2921 : public false_type {};
2922
Marshall Clow48e7e9f2014-07-10 15:38:20 +00002923#endif
Howard Hinnant1468b662010-11-19 22:17:28 +00002924
2925// is_nothrow_constructible
2926
Marshall Clow4f3368e2014-05-29 01:10:28 +00002927#if 0
2928template <class _Tp, class... _Args>
2929struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
2930 : public integral_constant<bool, __is_nothrow_constructible(_Tp(_Args...))>
2931{
2932};
2933
2934#else
2935
Howard Hinnant1468b662010-11-19 22:17:28 +00002936#ifndef _LIBCPP_HAS_NO_VARIADICS
2937
Marshall Clow48e7e9f2014-07-10 15:38:20 +00002938#if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
Howard Hinnant5d37fb32011-05-11 20:19:40 +00002939
Marshall Clowdf9722e2014-10-07 21:42:12 +00002940template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;
Howard Hinnant5d37fb32011-05-11 20:19:40 +00002941
2942template <class _Tp, class... _Args>
Marshall Clowdf9722e2014-10-07 21:42:12 +00002943struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...>
Howard Hinnant5d37fb32011-05-11 20:19:40 +00002944 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
2945{
2946};
2947
Marshall Clowdf9722e2014-10-07 21:42:12 +00002948template <class _Tp>
2949void __implicit_conversion_to(_Tp) noexcept { }
2950
2951template <class _Tp, class _Arg>
2952struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg>
2953 : public integral_constant<bool, noexcept(__implicit_conversion_to<_Tp>(declval<_Arg>()))>
2954{
2955};
2956
2957template <class _Tp, bool _IsReference, class... _Args>
2958struct __libcpp_is_nothrow_constructible</*is constructible*/false, _IsReference, _Tp, _Args...>
Howard Hinnant5d37fb32011-05-11 20:19:40 +00002959 : public false_type
2960{
2961};
2962
2963template <class _Tp, class... _Args>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002964struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
Marshall Clowdf9722e2014-10-07 21:42:12 +00002965 : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...>
Howard Hinnant5d37fb32011-05-11 20:19:40 +00002966{
2967};
2968
Howard Hinnant6063ec12011-05-13 14:08:16 +00002969template <class _Tp, size_t _Ns>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002970struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp[_Ns]>
Marshall Clowdf9722e2014-10-07 21:42:12 +00002971 : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp>
Howard Hinnant6063ec12011-05-13 14:08:16 +00002972{
2973};
2974
Howard Hinnant5d37fb32011-05-11 20:19:40 +00002975#else // __has_feature(cxx_noexcept)
2976
Howard Hinnant1468b662010-11-19 22:17:28 +00002977template <class _Tp, class... _Args>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002978struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
Howard Hinnant1468b662010-11-19 22:17:28 +00002979 : false_type
2980{
2981};
2982
2983template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002984struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp>
Marshall Clow48e7e9f2014-07-10 15:38:20 +00002985#if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
Howard Hinnant1468b662010-11-19 22:17:28 +00002986 : integral_constant<bool, __has_nothrow_constructor(_Tp)>
2987#else
2988 : integral_constant<bool, is_scalar<_Tp>::value>
2989#endif
2990{
2991};
2992
2993template <class _Tp>
2994#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002995struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&&>
Howard Hinnant1468b662010-11-19 22:17:28 +00002996#else
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002997struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp>
Howard Hinnant1468b662010-11-19 22:17:28 +00002998#endif
Marshall Clow48e7e9f2014-07-10 15:38:20 +00002999#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
Howard Hinnant1468b662010-11-19 22:17:28 +00003000 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3001#else
3002 : integral_constant<bool, is_scalar<_Tp>::value>
3003#endif
3004{
3005};
3006
3007template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003008struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&>
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003009#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
Howard Hinnant1468b662010-11-19 22:17:28 +00003010 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3011#else
3012 : integral_constant<bool, is_scalar<_Tp>::value>
3013#endif
3014{
3015};
3016
3017template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003018struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&>
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003019#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
Howard Hinnant1468b662010-11-19 22:17:28 +00003020 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3021#else
3022 : integral_constant<bool, is_scalar<_Tp>::value>
3023#endif
3024{
3025};
3026
Howard Hinnant5d37fb32011-05-11 20:19:40 +00003027#endif // __has_feature(cxx_noexcept)
3028
Howard Hinnant1468b662010-11-19 22:17:28 +00003029#else // _LIBCPP_HAS_NO_VARIADICS
3030
3031template <class _Tp, class _A0 = __is_construct::__nat,
3032 class _A1 = __is_construct::__nat>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003033struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
Howard Hinnant1468b662010-11-19 22:17:28 +00003034 : false_type
3035{
3036};
3037
3038template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003039struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, __is_construct::__nat,
Howard Hinnant1468b662010-11-19 22:17:28 +00003040 __is_construct::__nat>
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003041#if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
Howard Hinnant1468b662010-11-19 22:17:28 +00003042 : integral_constant<bool, __has_nothrow_constructor(_Tp)>
3043#else
3044 : integral_constant<bool, is_scalar<_Tp>::value>
3045#endif
3046{
3047};
3048
3049template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003050struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp,
Howard Hinnant1468b662010-11-19 22:17:28 +00003051 __is_construct::__nat>
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003052#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
Howard Hinnant1468b662010-11-19 22:17:28 +00003053 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3054#else
3055 : integral_constant<bool, is_scalar<_Tp>::value>
3056#endif
3057{
3058};
3059
3060template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003061struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&,
Howard Hinnant1468b662010-11-19 22:17:28 +00003062 __is_construct::__nat>
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003063#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
Howard Hinnant1468b662010-11-19 22:17:28 +00003064 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3065#else
3066 : integral_constant<bool, is_scalar<_Tp>::value>
3067#endif
3068{
3069};
3070
3071template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003072struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&,
Howard Hinnant1468b662010-11-19 22:17:28 +00003073 __is_construct::__nat>
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003074#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
Howard Hinnant1468b662010-11-19 22:17:28 +00003075 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3076#else
3077 : integral_constant<bool, is_scalar<_Tp>::value>
3078#endif
3079{
3080};
3081
3082#endif // _LIBCPP_HAS_NO_VARIADICS
Marshall Clow4f3368e2014-05-29 01:10:28 +00003083#endif // __has_feature(is_nothrow_constructible)
Howard Hinnant1468b662010-11-19 22:17:28 +00003084
3085// is_nothrow_default_constructible
3086
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003087template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_default_constructible
Howard Hinnant1468b662010-11-19 22:17:28 +00003088 : public is_nothrow_constructible<_Tp>
3089 {};
3090
3091// is_nothrow_copy_constructible
3092
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003093template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_constructible
Marshall Clowd132bf42014-09-22 23:58:00 +00003094 : public is_nothrow_constructible<_Tp,
3095 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
Howard Hinnant1468b662010-11-19 22:17:28 +00003096
3097// is_nothrow_move_constructible
3098
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003099template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_constructible
Howard Hinnant1468b662010-11-19 22:17:28 +00003100#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3101 : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3102#else
3103 : public is_nothrow_copy_constructible<_Tp>
3104#endif
3105 {};
3106
3107// is_nothrow_assignable
3108
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003109#if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
Howard Hinnant5d37fb32011-05-11 20:19:40 +00003110
Marshall Clow708dd842014-01-24 15:27:41 +00003111template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable;
Howard Hinnant5d37fb32011-05-11 20:19:40 +00003112
Howard Hinnant1468b662010-11-19 22:17:28 +00003113template <class _Tp, class _Arg>
Marshall Clow708dd842014-01-24 15:27:41 +00003114struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg>
Howard Hinnant5d37fb32011-05-11 20:19:40 +00003115 : public false_type
3116{
3117};
3118
3119template <class _Tp, class _Arg>
Marshall Clow708dd842014-01-24 15:27:41 +00003120struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg>
Howard Hinnant0949eed2011-06-30 21:18:19 +00003121 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) >
Howard Hinnant5d37fb32011-05-11 20:19:40 +00003122{
3123};
3124
3125template <class _Tp, class _Arg>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003126struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable
Marshall Clow708dd842014-01-24 15:27:41 +00003127 : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
Howard Hinnant5d37fb32011-05-11 20:19:40 +00003128{
3129};
3130
3131#else // __has_feature(cxx_noexcept)
3132
3133template <class _Tp, class _Arg>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003134struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable
Howard Hinnant1468b662010-11-19 22:17:28 +00003135 : public false_type {};
3136
3137template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003138struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp>
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003139#if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
Howard Hinnant1468b662010-11-19 22:17:28 +00003140 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3141#else
3142 : integral_constant<bool, is_scalar<_Tp>::value> {};
3143#endif
3144
3145template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003146struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp&>
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003147#if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
Howard Hinnant1468b662010-11-19 22:17:28 +00003148 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3149#else
3150 : integral_constant<bool, is_scalar<_Tp>::value> {};
3151#endif
3152
3153template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003154struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, const _Tp&>
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003155#if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
Howard Hinnant1468b662010-11-19 22:17:28 +00003156 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3157#else
3158 : integral_constant<bool, is_scalar<_Tp>::value> {};
3159#endif
3160
3161#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3162
3163template <class _Tp>
3164struct is_nothrow_assignable<_Tp&, _Tp&&>
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003165#if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
Howard Hinnant1468b662010-11-19 22:17:28 +00003166 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3167#else
3168 : integral_constant<bool, is_scalar<_Tp>::value> {};
3169#endif
3170
3171#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3172
Howard Hinnant5d37fb32011-05-11 20:19:40 +00003173#endif // __has_feature(cxx_noexcept)
3174
Howard Hinnant1468b662010-11-19 22:17:28 +00003175// is_nothrow_copy_assignable
3176
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003177template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_assignable
Howard Hinnant1468b662010-11-19 22:17:28 +00003178 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
Marshall Clowd132bf42014-09-22 23:58:00 +00003179 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
Howard Hinnant1468b662010-11-19 22:17:28 +00003180
3181// is_nothrow_move_assignable
3182
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003183template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_assignable
Howard Hinnant1468b662010-11-19 22:17:28 +00003184 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3185#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3186 typename add_rvalue_reference<_Tp>::type>
3187#else
3188 typename add_lvalue_reference<_Tp>::type>
3189#endif
3190 {};
3191
3192// is_nothrow_destructible
3193
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003194#if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
Howard Hinnant5d37fb32011-05-11 20:19:40 +00003195
Marshall Clow708dd842014-01-24 15:27:41 +00003196template <bool, class _Tp> struct __libcpp_is_nothrow_destructible;
Howard Hinnant5d37fb32011-05-11 20:19:40 +00003197
3198template <class _Tp>
Marshall Clow708dd842014-01-24 15:27:41 +00003199struct __libcpp_is_nothrow_destructible<false, _Tp>
Howard Hinnant5d37fb32011-05-11 20:19:40 +00003200 : public false_type
3201{
3202};
3203
3204template <class _Tp>
Marshall Clow708dd842014-01-24 15:27:41 +00003205struct __libcpp_is_nothrow_destructible<true, _Tp>
Howard Hinnant0949eed2011-06-30 21:18:19 +00003206 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) >
Howard Hinnant5d37fb32011-05-11 20:19:40 +00003207{
3208};
3209
3210template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003211struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible
Marshall Clow708dd842014-01-24 15:27:41 +00003212 : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
Howard Hinnant5d37fb32011-05-11 20:19:40 +00003213{
3214};
3215
Howard Hinnant6063ec12011-05-13 14:08:16 +00003216template <class _Tp, size_t _Ns>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003217struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp[_Ns]>
Howard Hinnant6063ec12011-05-13 14:08:16 +00003218 : public is_nothrow_destructible<_Tp>
3219{
3220};
3221
3222template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003223struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&>
Howard Hinnant6063ec12011-05-13 14:08:16 +00003224 : public true_type
3225{
3226};
3227
3228#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3229
3230template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003231struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&&>
Howard Hinnant6063ec12011-05-13 14:08:16 +00003232 : public true_type
3233{
3234};
3235
3236#endif
3237
Howard Hinnant5d37fb32011-05-11 20:19:40 +00003238#else
3239
Howard Hinnant1468b662010-11-19 22:17:28 +00003240template <class _Tp> struct __libcpp_nothrow_destructor
3241 : public integral_constant<bool, is_scalar<_Tp>::value ||
3242 is_reference<_Tp>::value> {};
3243
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003244template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible
Howard Hinnant1468b662010-11-19 22:17:28 +00003245 : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
3246
Eric Fiselier12c6d9c2015-07-18 16:43:58 +00003247template <class _Tp>
3248struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp[]>
3249 : public false_type {};
3250
Howard Hinnant5d37fb32011-05-11 20:19:40 +00003251#endif
3252
Howard Hinnant1468b662010-11-19 22:17:28 +00003253// is_pod
3254
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003255#if __has_feature(is_pod) || (_GNUC_VER >= 403)
Howard Hinnant1468b662010-11-19 22:17:28 +00003256
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003257template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod
Howard Hinnant1468b662010-11-19 22:17:28 +00003258 : public integral_constant<bool, __is_pod(_Tp)> {};
3259
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003260#else
Howard Hinnant1468b662010-11-19 22:17:28 +00003261
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003262template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod
Howard Hinnant1468b662010-11-19 22:17:28 +00003263 : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value &&
3264 is_trivially_copy_constructible<_Tp>::value &&
3265 is_trivially_copy_assignable<_Tp>::value &&
3266 is_trivially_destructible<_Tp>::value> {};
3267
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003268#endif
Howard Hinnant954b3662010-09-07 23:11:28 +00003269
Howard Hinnant36666952011-05-09 19:21:17 +00003270// is_literal_type;
3271
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003272template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_literal_type
Marshall Clow81aa3a72014-06-26 01:07:56 +00003273#ifdef _LIBCPP_IS_LITERAL
3274 : public integral_constant<bool, _LIBCPP_IS_LITERAL(_Tp)>
Howard Hinnant36666952011-05-09 19:21:17 +00003275#else
3276 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value ||
3277 is_reference<typename remove_all_extents<_Tp>::type>::value>
3278#endif
3279 {};
3280
Howard Hinnant6063ec12011-05-13 14:08:16 +00003281// is_standard_layout;
3282
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003283template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_standard_layout
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003284#if __has_feature(is_standard_layout) || (_GNUC_VER >= 407)
Howard Hinnant6063ec12011-05-13 14:08:16 +00003285 : public integral_constant<bool, __is_standard_layout(_Tp)>
3286#else
3287 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
3288#endif
3289 {};
3290
3291// is_trivially_copyable;
3292
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003293template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copyable
Howard Hinnant6063ec12011-05-13 14:08:16 +00003294#if __has_feature(is_trivially_copyable)
3295 : public integral_constant<bool, __is_trivially_copyable(_Tp)>
Eric Fiseliereeeada12015-06-13 02:18:44 +00003296#elif _GNUC_VER >= 501
3297 : public integral_constant<bool, !is_volatile<_Tp>::value && __is_trivially_copyable(_Tp)>
Howard Hinnant6063ec12011-05-13 14:08:16 +00003298#else
3299 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
3300#endif
3301 {};
3302
3303// is_trivial;
3304
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003305template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivial
Eric Fiseliereeeada12015-06-13 02:18:44 +00003306#if __has_feature(is_trivial) || _GNUC_VER >= 407
Howard Hinnant6063ec12011-05-13 14:08:16 +00003307 : public integral_constant<bool, __is_trivial(_Tp)>
3308#else
3309 : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
Howard Hinnant5ec7f5a2011-05-14 18:20:45 +00003310 is_trivially_default_constructible<_Tp>::value>
Howard Hinnant6063ec12011-05-13 14:08:16 +00003311#endif
3312 {};
Howard Hinnant57cff292011-05-19 15:05:04 +00003313
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003314#ifndef _LIBCPP_HAS_NO_VARIADICS
Howard Hinnant57cff292011-05-19 15:05:04 +00003315
Howard Hinnante003ce42011-05-22 00:09:02 +00003316// Check for complete types
3317
Howard Hinnant99968442011-11-29 18:15:50 +00003318template <class ..._Tp> struct __check_complete;
Howard Hinnante003ce42011-05-22 00:09:02 +00003319
3320template <>
3321struct __check_complete<>
3322{
3323};
3324
Howard Hinnant99968442011-11-29 18:15:50 +00003325template <class _Hp, class _T0, class ..._Tp>
3326struct __check_complete<_Hp, _T0, _Tp...>
3327 : private __check_complete<_Hp>,
3328 private __check_complete<_T0, _Tp...>
Howard Hinnante003ce42011-05-22 00:09:02 +00003329{
3330};
3331
Howard Hinnant99968442011-11-29 18:15:50 +00003332template <class _Hp>
3333struct __check_complete<_Hp, _Hp>
3334 : private __check_complete<_Hp>
Howard Hinnante003ce42011-05-22 00:09:02 +00003335{
3336};
3337
Howard Hinnant99968442011-11-29 18:15:50 +00003338template <class _Tp>
3339struct __check_complete<_Tp>
Howard Hinnante003ce42011-05-22 00:09:02 +00003340{
Howard Hinnant99968442011-11-29 18:15:50 +00003341 static_assert(sizeof(_Tp) > 0, "Type must be complete.");
Howard Hinnante003ce42011-05-22 00:09:02 +00003342};
3343
Howard Hinnant99968442011-11-29 18:15:50 +00003344template <class _Tp>
3345struct __check_complete<_Tp&>
3346 : private __check_complete<_Tp>
Howard Hinnante003ce42011-05-22 00:09:02 +00003347{
3348};
3349
Howard Hinnant99968442011-11-29 18:15:50 +00003350template <class _Tp>
3351struct __check_complete<_Tp&&>
3352 : private __check_complete<_Tp>
Howard Hinnante003ce42011-05-22 00:09:02 +00003353{
3354};
3355
Howard Hinnant99968442011-11-29 18:15:50 +00003356template <class _Rp, class ..._Param>
3357struct __check_complete<_Rp (*)(_Param...)>
Howard Hinnante41f4752012-07-20 18:56:07 +00003358 : private __check_complete<_Rp>
Howard Hinnante003ce42011-05-22 00:09:02 +00003359{
3360};
3361
Howard Hinnantde8fc6b2013-08-14 21:28:31 +00003362template <class ..._Param>
3363struct __check_complete<void (*)(_Param...)>
3364{
3365};
3366
Howard Hinnant99968442011-11-29 18:15:50 +00003367template <class _Rp, class ..._Param>
3368struct __check_complete<_Rp (_Param...)>
Howard Hinnante41f4752012-07-20 18:56:07 +00003369 : private __check_complete<_Rp>
Howard Hinnante003ce42011-05-22 00:09:02 +00003370{
3371};
3372
Howard Hinnantde8fc6b2013-08-14 21:28:31 +00003373template <class ..._Param>
3374struct __check_complete<void (_Param...)>
3375{
3376};
3377
Howard Hinnant99968442011-11-29 18:15:50 +00003378template <class _Rp, class _Class, class ..._Param>
3379struct __check_complete<_Rp (_Class::*)(_Param...)>
Howard Hinnante41f4752012-07-20 18:56:07 +00003380 : private __check_complete<_Class>
Howard Hinnante003ce42011-05-22 00:09:02 +00003381{
3382};
3383
Howard Hinnant99968442011-11-29 18:15:50 +00003384template <class _Rp, class _Class, class ..._Param>
3385struct __check_complete<_Rp (_Class::*)(_Param...) const>
Howard Hinnante41f4752012-07-20 18:56:07 +00003386 : private __check_complete<_Class>
Howard Hinnante003ce42011-05-22 00:09:02 +00003387{
3388};
3389
Howard Hinnant99968442011-11-29 18:15:50 +00003390template <class _Rp, class _Class, class ..._Param>
3391struct __check_complete<_Rp (_Class::*)(_Param...) volatile>
Howard Hinnante41f4752012-07-20 18:56:07 +00003392 : private __check_complete<_Class>
Howard Hinnante003ce42011-05-22 00:09:02 +00003393{
3394};
3395
Howard Hinnant99968442011-11-29 18:15:50 +00003396template <class _Rp, class _Class, class ..._Param>
3397struct __check_complete<_Rp (_Class::*)(_Param...) const volatile>
Howard Hinnante41f4752012-07-20 18:56:07 +00003398 : private __check_complete<_Class>
Howard Hinnante003ce42011-05-22 00:09:02 +00003399{
3400};
3401
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003402#if __has_feature(cxx_reference_qualified_functions)
3403
Howard Hinnant99968442011-11-29 18:15:50 +00003404template <class _Rp, class _Class, class ..._Param>
3405struct __check_complete<_Rp (_Class::*)(_Param...) &>
Howard Hinnante41f4752012-07-20 18:56:07 +00003406 : private __check_complete<_Class>
Howard Hinnante003ce42011-05-22 00:09:02 +00003407{
3408};
3409
Howard Hinnant99968442011-11-29 18:15:50 +00003410template <class _Rp, class _Class, class ..._Param>
3411struct __check_complete<_Rp (_Class::*)(_Param...) const&>
Howard Hinnante41f4752012-07-20 18:56:07 +00003412 : private __check_complete<_Class>
Howard Hinnante003ce42011-05-22 00:09:02 +00003413{
3414};
3415
Howard Hinnant99968442011-11-29 18:15:50 +00003416template <class _Rp, class _Class, class ..._Param>
3417struct __check_complete<_Rp (_Class::*)(_Param...) volatile&>
Howard Hinnante41f4752012-07-20 18:56:07 +00003418 : private __check_complete<_Class>
Howard Hinnante003ce42011-05-22 00:09:02 +00003419{
3420};
3421
Howard Hinnant99968442011-11-29 18:15:50 +00003422template <class _Rp, class _Class, class ..._Param>
3423struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&>
Howard Hinnante41f4752012-07-20 18:56:07 +00003424 : private __check_complete<_Class>
Howard Hinnante003ce42011-05-22 00:09:02 +00003425{
3426};
3427
Howard Hinnant99968442011-11-29 18:15:50 +00003428template <class _Rp, class _Class, class ..._Param>
3429struct __check_complete<_Rp (_Class::*)(_Param...) &&>
Howard Hinnante41f4752012-07-20 18:56:07 +00003430 : private __check_complete<_Class>
Howard Hinnante003ce42011-05-22 00:09:02 +00003431{
3432};
3433
Howard Hinnant99968442011-11-29 18:15:50 +00003434template <class _Rp, class _Class, class ..._Param>
3435struct __check_complete<_Rp (_Class::*)(_Param...) const&&>
Howard Hinnante41f4752012-07-20 18:56:07 +00003436 : private __check_complete<_Class>
Howard Hinnante003ce42011-05-22 00:09:02 +00003437{
3438};
3439
Howard Hinnant99968442011-11-29 18:15:50 +00003440template <class _Rp, class _Class, class ..._Param>
3441struct __check_complete<_Rp (_Class::*)(_Param...) volatile&&>
Howard Hinnante41f4752012-07-20 18:56:07 +00003442 : private __check_complete<_Class>
Howard Hinnante003ce42011-05-22 00:09:02 +00003443{
3444};
3445
Howard Hinnant99968442011-11-29 18:15:50 +00003446template <class _Rp, class _Class, class ..._Param>
3447struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&&>
Howard Hinnante41f4752012-07-20 18:56:07 +00003448 : private __check_complete<_Class>
Howard Hinnante003ce42011-05-22 00:09:02 +00003449{
3450};
3451
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003452#endif
3453
Howard Hinnant99968442011-11-29 18:15:50 +00003454template <class _Rp, class _Class>
3455struct __check_complete<_Rp _Class::*>
Howard Hinnante003ce42011-05-22 00:09:02 +00003456 : private __check_complete<_Class>
3457{
3458};
3459
Howard Hinnantbd89e4b2011-05-20 22:02:53 +00003460// __invoke forward declarations
Howard Hinnant57cff292011-05-19 15:05:04 +00003461
Howard Hinnantbd89e4b2011-05-20 22:02:53 +00003462// fall back - none of the bullets
Howard Hinnant57cff292011-05-19 15:05:04 +00003463
3464template <class ..._Args>
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003465auto
3466__invoke(__any, _Args&& ...__args)
3467 -> __nat;
Eric Fiselier8d5cbd72016-04-20 00:14:32 +00003468
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003469// bullets 1 and 2
Howard Hinnantbd89e4b2011-05-20 22:02:53 +00003470
Howard Hinnantecc97422013-05-07 23:40:12 +00003471template <class _Fp, class _A0, class ..._Args,
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003472 class = typename enable_if
3473 <
3474 is_member_function_pointer<typename remove_reference<_Fp>::type>::value &&
3475 is_base_of<typename remove_reference<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType>::type,
3476 typename remove_reference<_A0>::type>::value
3477 >::type
3478 >
3479_LIBCPP_INLINE_VISIBILITY
Howard Hinnantbd89e4b2011-05-20 22:02:53 +00003480auto
Howard Hinnant99968442011-11-29 18:15:50 +00003481__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003482 -> decltype((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...));
Eric Fiselier134ff652016-04-18 06:17:30 +00003483
Howard Hinnantecc97422013-05-07 23:40:12 +00003484template <class _Fp, class _A0, class ..._Args,
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003485 class = typename enable_if
3486 <
3487 is_member_function_pointer<typename remove_reference<_Fp>::type>::value &&
3488 !is_base_of<typename remove_reference<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType>::type,
3489 typename remove_reference<_A0>::type>::value
3490 >::type
3491 >
3492_LIBCPP_INLINE_VISIBILITY
Howard Hinnantbd89e4b2011-05-20 22:02:53 +00003493auto
Howard Hinnant99968442011-11-29 18:15:50 +00003494__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003495 -> decltype(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...));
Eric Fiselier8d5cbd72016-04-20 00:14:32 +00003496
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003497// bullets 3 and 4
Howard Hinnantbd89e4b2011-05-20 22:02:53 +00003498
Howard Hinnantecc97422013-05-07 23:40:12 +00003499template <class _Fp, class _A0,
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003500 class = typename enable_if
3501 <
3502 is_member_object_pointer<typename remove_reference<_Fp>::type>::value &&
3503 is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType,
3504 typename remove_reference<_A0>::type>::value
3505 >::type
3506 >
3507_LIBCPP_INLINE_VISIBILITY
Howard Hinnantbd89e4b2011-05-20 22:02:53 +00003508auto
Howard Hinnant99968442011-11-29 18:15:50 +00003509__invoke(_Fp&& __f, _A0&& __a0)
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003510 -> decltype(_VSTD::forward<_A0>(__a0).*__f);
Eric Fiselier134ff652016-04-18 06:17:30 +00003511
Howard Hinnantecc97422013-05-07 23:40:12 +00003512template <class _Fp, class _A0,
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003513 class = typename enable_if
3514 <
3515 is_member_object_pointer<typename remove_reference<_Fp>::type>::value &&
3516 !is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType,
3517 typename remove_reference<_A0>::type>::value
3518 >::type
3519 >
3520_LIBCPP_INLINE_VISIBILITY
Howard Hinnantbd89e4b2011-05-20 22:02:53 +00003521auto
Howard Hinnant99968442011-11-29 18:15:50 +00003522__invoke(_Fp&& __f, _A0&& __a0)
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003523 -> decltype((*_VSTD::forward<_A0>(__a0)).*__f);
Eric Fiselier8d5cbd72016-04-20 00:14:32 +00003524
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003525// bullet 5
Howard Hinnantbd89e4b2011-05-20 22:02:53 +00003526
Howard Hinnant99968442011-11-29 18:15:50 +00003527template <class _Fp, class ..._Args>
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003528_LIBCPP_INLINE_VISIBILITY
Howard Hinnantbd89e4b2011-05-20 22:02:53 +00003529auto
Howard Hinnant99968442011-11-29 18:15:50 +00003530__invoke(_Fp&& __f, _Args&& ...__args)
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003531 -> decltype(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...));
Howard Hinnantbd89e4b2011-05-20 22:02:53 +00003532
3533// __invokable
3534
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003535template <class _Fp, class ..._Args>
3536struct __invokable_imp
Howard Hinnantc4253072012-07-16 16:17:34 +00003537 : private __check_complete<_Fp>
Howard Hinnant57cff292011-05-19 15:05:04 +00003538{
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003539 typedef decltype(
3540 __invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)
3541 ) type;
3542 static const bool value = !is_same<type, __nat>::value;
Howard Hinnant57cff292011-05-19 15:05:04 +00003543};
3544
Howard Hinnant99968442011-11-29 18:15:50 +00003545template <class _Fp, class ..._Args>
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003546struct __invokable
3547 : public integral_constant<bool,
3548 __invokable_imp<_Fp, _Args...>::value>
Howard Hinnant57cff292011-05-19 15:05:04 +00003549{
3550};
3551
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003552// __invoke_of
3553
3554template <bool _Invokable, class _Fp, class ..._Args>
3555struct __invoke_of_imp // false
Howard Hinnant57cff292011-05-19 15:05:04 +00003556{
Howard Hinnant57cff292011-05-19 15:05:04 +00003557};
3558
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003559template <class _Fp, class ..._Args>
3560struct __invoke_of_imp<true, _Fp, _Args...>
3561{
3562 typedef typename __invokable_imp<_Fp, _Args...>::type type;
3563};
Eric Fiselier8d5cbd72016-04-20 00:14:32 +00003564
Howard Hinnant99968442011-11-29 18:15:50 +00003565template <class _Fp, class ..._Args>
Howard Hinnant57cff292011-05-19 15:05:04 +00003566struct __invoke_of
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003567 : public __invoke_of_imp<__invokable<_Fp, _Args...>::value, _Fp, _Args...>
Howard Hinnant57cff292011-05-19 15:05:04 +00003568{
3569};
3570
Howard Hinnant2d622292012-06-26 17:37:15 +00003571template <class _Fp, class ..._Args>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003572class _LIBCPP_TYPE_VIS_ONLY result_of<_Fp(_Args...)>
Howard Hinnant2d622292012-06-26 17:37:15 +00003573 : public __invoke_of<_Fp, _Args...>
3574{
3575};
3576
Marshall Clow933afa92013-07-04 00:10:01 +00003577#if _LIBCPP_STD_VER > 11
3578template <class _Tp> using result_of_t = typename result_of<_Tp>::type;
3579#endif
3580
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003581#endif // _LIBCPP_HAS_NO_VARIADICS
Eric Fiselier8f1e73d2016-04-21 23:38:59 +00003582
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003583template <class _Tp>
3584inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantd36369d2011-07-27 18:34:06 +00003585#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
Howard Hinnant1694d232011-05-28 14:41:13 +00003586typename enable_if
3587<
3588 is_move_constructible<_Tp>::value &&
3589 is_move_assignable<_Tp>::value
3590>::type
Howard Hinnantd36369d2011-07-27 18:34:06 +00003591#else
3592void
3593#endif
Howard Hinnante9b2c2d2011-05-27 15:04:19 +00003594swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
3595 is_nothrow_move_assignable<_Tp>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003596{
Howard Hinnant0949eed2011-06-30 21:18:19 +00003597 _Tp __t(_VSTD::move(__x));
3598 __x = _VSTD::move(__y);
3599 __y = _VSTD::move(__t);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003600}
3601
Howard Hinnante9b2c2d2011-05-27 15:04:19 +00003602template <class _ForwardIterator1, class _ForwardIterator2>
3603inline _LIBCPP_INLINE_VISIBILITY
3604void
3605iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
3606 // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
Howard Hinnant0949eed2011-06-30 21:18:19 +00003607 _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(),
3608 *_VSTD::declval<_ForwardIterator2>())))
Howard Hinnante9b2c2d2011-05-27 15:04:19 +00003609{
3610 swap(*__a, *__b);
3611}
3612
Howard Hinnanta5e01212011-05-27 19:08:18 +00003613// __swappable
3614
Howard Hinnant1694d232011-05-28 14:41:13 +00003615namespace __detail
3616{
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003617
Howard Hinnant0949eed2011-06-30 21:18:19 +00003618using _VSTD::swap;
Howard Hinnanta5e01212011-05-27 19:08:18 +00003619__nat swap(__any, __any);
3620
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003621template <class _Tp>
3622struct __swappable
Howard Hinnanta5e01212011-05-27 19:08:18 +00003623{
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003624 typedef decltype(swap(_VSTD::declval<_Tp&>(), _VSTD::declval<_Tp&>())) type;
3625 static const bool value = !is_same<type, __nat>::value;
Howard Hinnanta5e01212011-05-27 19:08:18 +00003626};
3627
Howard Hinnant1694d232011-05-28 14:41:13 +00003628} // __detail
3629
Howard Hinnanta5e01212011-05-27 19:08:18 +00003630template <class _Tp>
3631struct __is_swappable
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003632 : public integral_constant<bool, __detail::__swappable<_Tp>::value>
3633{
3634};
3635
3636#if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
3637
3638template <bool, class _Tp>
3639struct __is_nothrow_swappable_imp
3640 : public integral_constant<bool, noexcept(swap(_VSTD::declval<_Tp&>(),
3641 _VSTD::declval<_Tp&>()))>
3642{
3643};
3644
3645template <class _Tp>
3646struct __is_nothrow_swappable_imp<false, _Tp>
3647 : public false_type
Howard Hinnanta5e01212011-05-27 19:08:18 +00003648{
3649};
3650
3651template <class _Tp>
3652struct __is_nothrow_swappable
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003653 : public __is_nothrow_swappable_imp<__is_swappable<_Tp>::value, _Tp>
Howard Hinnanta5e01212011-05-27 19:08:18 +00003654{
3655};
3656
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003657#else // __has_feature(cxx_noexcept)
Howard Hinnanta5e01212011-05-27 19:08:18 +00003658
3659template <class _Tp>
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003660struct __is_nothrow_swappable
3661 : public false_type
Howard Hinnanta5e01212011-05-27 19:08:18 +00003662{
3663};
3664
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003665#endif // __has_feature(cxx_noexcept)
Howard Hinnanta5e01212011-05-27 19:08:18 +00003666
Marshall Clow81aa3a72014-06-26 01:07:56 +00003667#ifdef _LIBCPP_UNDERLYING_TYPE
Sean Hunt737a3512011-07-18 18:37:21 +00003668
3669template <class _Tp>
3670struct underlying_type
3671{
Marshall Clow81aa3a72014-06-26 01:07:56 +00003672 typedef _LIBCPP_UNDERLYING_TYPE(_Tp) type;
Sean Hunt737a3512011-07-18 18:37:21 +00003673};
3674
Marshall Clow933afa92013-07-04 00:10:01 +00003675#if _LIBCPP_STD_VER > 11
3676template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
3677#endif
3678
Marshall Clow81aa3a72014-06-26 01:07:56 +00003679#else // _LIBCPP_UNDERLYING_TYPE
Sean Hunt737a3512011-07-18 18:37:21 +00003680
3681template <class _Tp, bool _Support = false>
3682struct underlying_type
3683{
3684 static_assert(_Support, "The underyling_type trait requires compiler "
3685 "support. Either no such support exists or "
3686 "libc++ does not know how to use it.");
3687};
3688
Marshall Clow81aa3a72014-06-26 01:07:56 +00003689#endif // _LIBCPP_UNDERLYING_TYPE
Sean Hunt737a3512011-07-18 18:37:21 +00003690
Eric Fiselier31cb7fe2015-02-10 16:46:42 +00003691
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003692template <class _Tp, bool = std::is_enum<_Tp>::value>
Eric Fiselier31cb7fe2015-02-10 16:46:42 +00003693struct __sfinae_underlying_type
3694{
3695 typedef typename underlying_type<_Tp>::type type;
3696 typedef decltype(((type)1) + 0) __promoted_type;
3697};
3698
3699template <class _Tp>
3700struct __sfinae_underlying_type<_Tp, false> {};
3701
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003702inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE
Eric Fiselier31cb7fe2015-02-10 16:46:42 +00003703int __convert_to_integral(int __val) { return __val; }
3704
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003705inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE
Eric Fiselier31cb7fe2015-02-10 16:46:42 +00003706unsigned __convert_to_integral(unsigned __val) { return __val; }
3707
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003708inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE
Eric Fiselier31cb7fe2015-02-10 16:46:42 +00003709long __convert_to_integral(long __val) { return __val; }
3710
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003711inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE
Eric Fiselier31cb7fe2015-02-10 16:46:42 +00003712unsigned long __convert_to_integral(unsigned long __val) { return __val; }
3713
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003714inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE
Eric Fiselier31cb7fe2015-02-10 16:46:42 +00003715long long __convert_to_integral(long long __val) { return __val; }
3716
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003717inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE
Eric Fiselier31cb7fe2015-02-10 16:46:42 +00003718unsigned long long __convert_to_integral(unsigned long long __val) {return __val; }
3719
3720#ifndef _LIBCPP_HAS_NO_INT128
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003721inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE
Eric Fiselier31cb7fe2015-02-10 16:46:42 +00003722__int128_t __convert_to_integral(__int128_t __val) { return __val; }
3723
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003724inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE
Eric Fiselier31cb7fe2015-02-10 16:46:42 +00003725__uint128_t __convert_to_integral(__uint128_t __val) { return __val; }
3726#endif
3727
3728template <class _Tp>
Dan Albert1d4a1ed2016-05-25 22:36:09 -07003729inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE
Eric Fiselier31cb7fe2015-02-10 16:46:42 +00003730typename __sfinae_underlying_type<_Tp>::__promoted_type
3731__convert_to_integral(_Tp __val) { return __val; }
3732
Howard Hinnant01afa5c2013-09-02 20:30:37 +00003733#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
3734
3735template <class _Tp>
Eric Fiselier341b5902014-11-05 20:59:18 +00003736struct __has_operator_addressof_member_imp
Howard Hinnant01afa5c2013-09-02 20:30:37 +00003737{
Howard Hinnant01afa5c2013-09-02 20:30:37 +00003738 template <class _Up>
Eric Fiselierb6e0ef22014-11-05 21:20:10 +00003739 static auto __test(int)
3740 -> typename __select_2nd<decltype(_VSTD::declval<_Up>().operator&()), true_type>::type;
3741 template <class>
3742 static auto __test(long) -> false_type;
Howard Hinnant01afa5c2013-09-02 20:30:37 +00003743
Eric Fiselierb6e0ef22014-11-05 21:20:10 +00003744 static const bool value = decltype(__test<_Tp>(0))::value;
Howard Hinnant01afa5c2013-09-02 20:30:37 +00003745};
3746
3747template <class _Tp>
Eric Fiselier341b5902014-11-05 20:59:18 +00003748struct __has_operator_addressof_free_imp
3749{
Eric Fiselier341b5902014-11-05 20:59:18 +00003750 template <class _Up>
Eric Fiselierb6e0ef22014-11-05 21:20:10 +00003751 static auto __test(int)
3752 -> typename __select_2nd<decltype(operator&(_VSTD::declval<_Up>())), true_type>::type;
3753 template <class>
3754 static auto __test(long) -> false_type;
Eric Fiselier341b5902014-11-05 20:59:18 +00003755
Eric Fiselierb6e0ef22014-11-05 21:20:10 +00003756 static const bool value = decltype(__test<_Tp>(0))::value;
Eric Fiselier341b5902014-11-05 20:59:18 +00003757};
3758
3759template <class _Tp>
Howard Hinnant01afa5c2013-09-02 20:30:37 +00003760struct __has_operator_addressof
Eric Fiselier341b5902014-11-05 20:59:18 +00003761 : public integral_constant<bool, __has_operator_addressof_member_imp<_Tp>::value
3762 || __has_operator_addressof_free_imp<_Tp>::value>
Howard Hinnant01afa5c2013-09-02 20:30:37 +00003763{};
3764
3765#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
3766
Marshall Clow88aae922014-11-17 15:50:08 +00003767#if _LIBCPP_STD_VER > 14
3768template <class...> using void_t = void;
Eric Fiselier83c9dc12016-04-15 23:27:27 +00003769#endif
3770
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003771_LIBCPP_END_NAMESPACE_STD
3772
3773#endif // _LIBCPP_TYPE_TRAITS