blob: 0d578bbe0bd5b6c2c4012c39c79a1e0257288a23 [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;
Eric Fiselier8f1e73d2016-04-21 23:38:59 +0000108 template <class T, class U> struct is_swappable_with; // C++17
109 template <class T> struct is_swappable; // C++17
Howard Hinnant1468b662010-11-19 22:17:28 +0000110 template <class T> struct is_destructible;
111
112 template <class T, class... Args> struct is_trivially_constructible;
113 template <class T> struct is_trivially_default_constructible;
114 template <class T> struct is_trivially_copy_constructible;
115 template <class T> struct is_trivially_move_constructible;
116 template <class T, class U> struct is_trivially_assignable;
117 template <class T> struct is_trivially_copy_assignable;
118 template <class T> struct is_trivially_move_assignable;
119 template <class T> struct is_trivially_destructible;
120
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000121 template <class T, class... Args> struct is_nothrow_constructible;
Howard Hinnant1468b662010-11-19 22:17:28 +0000122 template <class T> struct is_nothrow_default_constructible;
123 template <class T> struct is_nothrow_copy_constructible;
124 template <class T> struct is_nothrow_move_constructible;
125 template <class T, class U> struct is_nothrow_assignable;
126 template <class T> struct is_nothrow_copy_assignable;
127 template <class T> struct is_nothrow_move_assignable;
Eric Fiselier8f1e73d2016-04-21 23:38:59 +0000128 template <class T, class U> struct is_nothrow_swappable_with; // C++17
129 template <class T> struct is_nothrow_swappable; // C++17
Howard Hinnant1468b662010-11-19 22:17:28 +0000130 template <class T> struct is_nothrow_destructible;
Howard Hinnant745d4732010-09-08 17:55:32 +0000131
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000132 template <class T> struct has_virtual_destructor;
Howard Hinnant324bb032010-08-22 00:02:43 +0000133
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000134 // Relationships between types:
135 template <class T, class U> struct is_same;
136 template <class Base, class Derived> struct is_base_of;
137 template <class From, class To> struct is_convertible;
Howard Hinnant324bb032010-08-22 00:02:43 +0000138
Eric Fiselier8d5cbd72016-04-20 00:14:32 +0000139 template <class, class R = void> struct is_callable; // not defined
140 template <class Fn, class... ArgTypes, class R>
141 struct is_callable<Fn(ArgTypes...), R>;
142
143 template <class, class R = void> struct is_nothrow_callable; // not defined
144 template <class Fn, class... ArgTypes, class R>
145 struct is_nothrow_callable<Fn(ArgTypes...), R>;
146
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000147 // Alignment properties and transformations:
148 template <class T> struct alignment_of;
149 template <size_t Len, size_t Align = most_stringent_alignment_requirement>
150 struct aligned_storage;
Howard Hinnant5544f7e2013-04-22 19:37:49 +0000151 template <size_t Len, class... Types> struct aligned_union;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000152
153 template <class T> struct decay;
154 template <class... T> struct common_type;
155 template <class T> struct underlying_type;
156 template <class> class result_of; // undefined
157 template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>;
158
Marshall Clow933afa92013-07-04 00:10:01 +0000159 // const-volatile modifications:
160 template <class T>
161 using remove_const_t = typename remove_const<T>::type; // C++14
162 template <class T>
163 using remove_volatile_t = typename remove_volatile<T>::type; // C++14
164 template <class T>
165 using remove_cv_t = typename remove_cv<T>::type; // C++14
166 template <class T>
167 using add_const_t = typename add_const<T>::type; // C++14
168 template <class T>
169 using add_volatile_t = typename add_volatile<T>::type; // C++14
170 template <class T>
171 using add_cv_t = typename add_cv<T>::type; // C++14
172
173 // reference modifications:
174 template <class T>
175 using remove_reference_t = typename remove_reference<T>::type; // C++14
176 template <class T>
177 using add_lvalue_reference_t = typename add_lvalue_reference<T>::type; // C++14
178 template <class T>
179 using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; // C++14
180
181 // sign modifications:
182 template <class T>
183 using make_signed_t = typename make_signed<T>::type; // C++14
184 template <class T>
185 using make_unsigned_t = typename make_unsigned<T>::type; // C++14
186
187 // array modifications:
188 template <class T>
189 using remove_extent_t = typename remove_extent<T>::type; // C++14
190 template <class T>
191 using remove_all_extents_t = typename remove_all_extents<T>::type; // C++14
192
193 // pointer modifications:
194 template <class T>
195 using remove_pointer_t = typename remove_pointer<T>::type; // C++14
196 template <class T>
197 using add_pointer_t = typename add_pointer<T>::type; // C++14
198
199 // other transformations:
200 template <size_t Len, std::size_t Align=default-alignment>
201 using aligned_storage_t = typename aligned_storage<Len,Align>::type; // C++14
202 template <std::size_t Len, class... Types>
203 using aligned_union_t = typename aligned_union<Len,Types...>::type; // C++14
204 template <class T>
205 using decay_t = typename decay<T>::type; // C++14
206 template <bool b, class T=void>
207 using enable_if_t = typename enable_if<b,T>::type; // C++14
208 template <bool b, class T, class F>
209 using conditional_t = typename conditional<b,T,F>::type; // C++14
210 template <class... T>
211 using common_type_t = typename common_type<T...>::type; // C++14
212 template <class T>
213 using underlying_type_t = typename underlying_type<T>::type; // C++14
214 template <class F, class... ArgTypes>
215 using result_of_t = typename result_of<F(ArgTypes...)>::type; // C++14
216
Marshall Clow88aae922014-11-17 15:50:08 +0000217 template <class...>
Marshall Clow94611a82015-11-01 20:24:59 +0000218 using void_t = void; // C++17
219
Marshall Clowfe99a302015-11-16 15:54:13 +0000220 // See C++14 20.10.4.1, primary type categories
221 template <class T> constexpr bool is_void_v
222 = is_void<T>::value; // C++17
223 template <class T> constexpr bool is_null_pointer_v
224 = is_null_pointer<T>::value; // C++17
225 template <class T> constexpr bool is_integral_v
226 = is_integral<T>::value; // C++17
227 template <class T> constexpr bool is_floating_point_v
228 = is_floating_point<T>::value; // C++17
229 template <class T> constexpr bool is_array_v
230 = is_array<T>::value; // C++17
231 template <class T> constexpr bool is_pointer_v
232 = is_pointer<T>::value; // C++17
233 template <class T> constexpr bool is_lvalue_reference_v
234 = is_lvalue_reference<T>::value; // C++17
235 template <class T> constexpr bool is_rvalue_reference_v
236 = is_rvalue_reference<T>::value; // C++17
237 template <class T> constexpr bool is_member_object_pointer_v
238 = is_member_object_pointer<T>::value; // C++17
239 template <class T> constexpr bool is_member_function_pointer_v
240 = is_member_function_pointer<T>::value; // C++17
241 template <class T> constexpr bool is_enum_v
242 = is_enum<T>::value; // C++17
243 template <class T> constexpr bool is_union_v
244 = is_union<T>::value; // C++17
245 template <class T> constexpr bool is_class_v
246 = is_class<T>::value; // C++17
247 template <class T> constexpr bool is_function_v
248 = is_function<T>::value; // C++17
Marshall Clow94611a82015-11-01 20:24:59 +0000249
Marshall Clowfe99a302015-11-16 15:54:13 +0000250 // See C++14 20.10.4.2, composite type categories
251 template <class T> constexpr bool is_reference_v
252 = is_reference<T>::value; // C++17
253 template <class T> constexpr bool is_arithmetic_v
254 = is_arithmetic<T>::value; // C++17
255 template <class T> constexpr bool is_fundamental_v
256 = is_fundamental<T>::value; // C++17
257 template <class T> constexpr bool is_object_v
258 = is_object<T>::value; // C++17
259 template <class T> constexpr bool is_scalar_v
260 = is_scalar<T>::value; // C++17
261 template <class T> constexpr bool is_compound_v
262 = is_compound<T>::value; // C++17
263 template <class T> constexpr bool is_member_pointer_v
264 = is_member_pointer<T>::value; // C++17
Marshall Clow94611a82015-11-01 20:24:59 +0000265
Marshall Clowfe99a302015-11-16 15:54:13 +0000266 // See C++14 20.10.4.3, type properties
267 template <class T> constexpr bool is_const_v
268 = is_const<T>::value; // C++17
269 template <class T> constexpr bool is_volatile_v
270 = is_volatile<T>::value; // C++17
271 template <class T> constexpr bool is_trivial_v
272 = is_trivial<T>::value; // C++17
273 template <class T> constexpr bool is_trivially_copyable_v
274 = is_trivially_copyable<T>::value; // C++17
275 template <class T> constexpr bool is_standard_layout_v
276 = is_standard_layout<T>::value; // C++17
277 template <class T> constexpr bool is_pod_v
278 = is_pod<T>::value; // C++17
279 template <class T> constexpr bool is_literal_type_v
280 = is_literal_type<T>::value; // C++17
281 template <class T> constexpr bool is_empty_v
282 = is_empty<T>::value; // C++17
283 template <class T> constexpr bool is_polymorphic_v
284 = is_polymorphic<T>::value; // C++17
285 template <class T> constexpr bool is_abstract_v
286 = is_abstract<T>::value; // C++17
287 template <class T> constexpr bool is_final_v
288 = is_final<T>::value; // C++17
289 template <class T> constexpr bool is_signed_v
290 = is_signed<T>::value; // C++17
291 template <class T> constexpr bool is_unsigned_v
292 = is_unsigned<T>::value; // C++17
293 template <class T, class... Args> constexpr bool is_constructible_v
294 = is_constructible<T, Args...>::value; // C++17
295 template <class T> constexpr bool is_default_constructible_v
296 = is_default_constructible<T>::value; // C++17
297 template <class T> constexpr bool is_copy_constructible_v
298 = is_copy_constructible<T>::value; // C++17
299 template <class T> constexpr bool is_move_constructible_v
300 = is_move_constructible<T>::value; // C++17
301 template <class T, class U> constexpr bool is_assignable_v
302 = is_assignable<T, U>::value; // C++17
303 template <class T> constexpr bool is_copy_assignable_v
304 = is_copy_assignable<T>::value; // C++17
305 template <class T> constexpr bool is_move_assignable_v
306 = is_move_assignable<T>::value; // C++17
Eric Fiselier8f1e73d2016-04-21 23:38:59 +0000307 template <class T, class U> constexpr bool is_swappable_with_v
308 = is_swappable_with<T, U>::value; // C++17
309 template <class T> constexpr bool is_swappable_v
310 = is_swappable<T>::value; // C++17
Marshall Clowfe99a302015-11-16 15:54:13 +0000311 template <class T> constexpr bool is_destructible_v
312 = is_destructible<T>::value; // C++17
313 template <class T, class... Args> constexpr bool is_trivially_constructible_v
314 = is_trivially_constructible<T, Args...>::value; // C++17
315 template <class T> constexpr bool is_trivially_default_constructible_v
316 = is_trivially_default_constructible<T>::value; // C++17
317 template <class T> constexpr bool is_trivially_copy_constructible_v
318 = is_trivially_copy_constructible<T>::value; // C++17
319 template <class T> constexpr bool is_trivially_move_constructible_v
320 = is_trivially_move_constructible<T>::value; // C++17
321 template <class T, class U> constexpr bool is_trivially_assignable_v
322 = is_trivially_assignable<T, U>::value; // C++17
323 template <class T> constexpr bool is_trivially_copy_assignable_v
324 = is_trivially_copy_assignable<T>::value; // C++17
325 template <class T> constexpr bool is_trivially_move_assignable_v
326 = is_trivially_move_assignable<T>::value; // C++17
327 template <class T> constexpr bool is_trivially_destructible_v
328 = is_trivially_destructible<T>::value; // C++17
329 template <class T, class... Args> constexpr bool is_nothrow_constructible_v
330 = is_nothrow_constructible<T, Args...>::value; // C++17
331 template <class T> constexpr bool is_nothrow_default_constructible_v
332 = is_nothrow_default_constructible<T>::value; // C++17
333 template <class T> constexpr bool is_nothrow_copy_constructible_v
334 = is_nothrow_copy_constructible<T>::value; // C++17
335 template <class T> constexpr bool is_nothrow_move_constructible_v
336 = is_nothrow_move_constructible<T>::value; // C++17
337 template <class T, class U> constexpr bool is_nothrow_assignable_v
338 = is_nothrow_assignable<T, U>::value; // C++17
339 template <class T> constexpr bool is_nothrow_copy_assignable_v
340 = is_nothrow_copy_assignable<T>::value; // C++17
341 template <class T> constexpr bool is_nothrow_move_assignable_v
342 = is_nothrow_move_assignable<T>::value; // C++17
Eric Fiselier8f1e73d2016-04-21 23:38:59 +0000343 template <class T, class U> constexpr bool is_nothrow_swappable_with_v
344 = is_nothrow_swappable_with<T, U>::value; // C++17
345 template <class T> constexpr bool is_nothrow_swappable_v
346 = is_nothrow_swappable<T>::value; // C++17
Marshall Clowfe99a302015-11-16 15:54:13 +0000347 template <class T> constexpr bool is_nothrow_destructible_v
348 = is_nothrow_destructible<T>::value; // C++17
349 template <class T> constexpr bool has_virtual_destructor_v
350 = has_virtual_destructor<T>::value; // C++17
Marshall Clow94611a82015-11-01 20:24:59 +0000351
Marshall Clowfe99a302015-11-16 15:54:13 +0000352 // See C++14 20.10.5, type property queries
353 template <class T> constexpr size_t alignment_of_v
354 = alignment_of<T>::value; // C++17
355 template <class T> constexpr size_t rank_v
356 = rank<T>::value; // C++17
357 template <class T, unsigned I = 0> constexpr size_t extent_v
358 = extent<T, I>::value; // C++17
Marshall Clow94611a82015-11-01 20:24:59 +0000359
Marshall Clowfe99a302015-11-16 15:54:13 +0000360 // See C++14 20.10.6, type relations
361 template <class T, class U> constexpr bool is_same_v
362 = is_same<T, U>::value; // C++17
363 template <class Base, class Derived> constexpr bool is_base_of_v
364 = is_base_of<Base, Derived>::value; // C++17
365 template <class From, class To> constexpr bool is_convertible_v
366 = is_convertible<From, To>::value; // C++17
Eric Fiselier8d5cbd72016-04-20 00:14:32 +0000367 template <class T, class R = void> constexpr bool is_callable_v
368 = is_callable<T, R>::value; // C++17
369 template <class T, class R = void> constexpr bool is_nothrow_callable_v
370 = is_nothrow_callable<T, R>::value; // C++17
Marshall Clowfe99a302015-11-16 15:54:13 +0000371
372 // [meta.logical], logical operator traits:
373 template<class... B> struct conjunction; // C++17
374 template<class... B>
375 constexpr bool conjunction_v = conjunction<B...>::value; // C++17
376 template<class... B> struct disjunction; // C++17
377 template<class... B>
378 constexpr bool disjunction_v = disjunction<B...>::value; // C++17
379 template<class B> struct negation; // C++17
380 template<class B>
381 constexpr bool negation_v = negation<B>::value; // C++17
382
Marshall Clow94611a82015-11-01 20:24:59 +0000383}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000384
385*/
386#include <__config>
387#include <cstddef>
388
Howard Hinnant08e17472011-10-17 20:05:10 +0000389#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000390#pragma GCC system_header
Howard Hinnant08e17472011-10-17 20:05:10 +0000391#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000392
393_LIBCPP_BEGIN_NAMESPACE_STD
394
Eric Fiselier83c9dc12016-04-15 23:27:27 +0000395template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY pair;
Eric Fiselier134ff652016-04-18 06:17:30 +0000396template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY reference_wrapper;
Eric Fiselier566bcb42016-04-21 22:54:21 +0000397template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY hash;
Eric Fiselier83c9dc12016-04-15 23:27:27 +0000398
Eric Fiselierb7fc49f2015-06-13 02:36:07 +0000399template <class>
Marshall Clow88aae922014-11-17 15:50:08 +0000400struct __void_t { typedef void type; };
Marshall Clow88aae922014-11-17 15:50:08 +0000401
Joerg Sonnenbergerba865ff2015-08-10 16:58:04 +0000402template <class _Tp>
403struct __identity { typedef _Tp type; };
Eric Fiselier49835802015-06-13 08:25:24 +0000404
Eric Fiselierda1818a2015-02-21 02:30:41 +0000405template <class _Tp, bool>
406struct _LIBCPP_TYPE_VIS_ONLY __dependent_type : public _Tp {};
407
Howard Hinnant99968442011-11-29 18:15:50 +0000408template <bool _Bp, class _If, class _Then>
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000409 struct _LIBCPP_TYPE_VIS_ONLY conditional {typedef _If type;};
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000410template <class _If, class _Then>
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000411 struct _LIBCPP_TYPE_VIS_ONLY conditional<false, _If, _Then> {typedef _Then type;};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000412
Marshall Clow933afa92013-07-04 00:10:01 +0000413#if _LIBCPP_STD_VER > 11
414template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type;
415#endif
416
Eric Fiselier950ee772014-10-17 00:31:47 +0000417template <bool, class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __lazy_enable_if {};
418template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __lazy_enable_if<true, _Tp> {typedef typename _Tp::type type;};
419
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000420template <bool, class _Tp = void> struct _LIBCPP_TYPE_VIS_ONLY enable_if {};
421template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY enable_if<true, _Tp> {typedef _Tp type;};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000422
Marshall Clow933afa92013-07-04 00:10:01 +0000423#if _LIBCPP_STD_VER > 11
424template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type;
425#endif
426
Marshall Clowd18b4962015-12-14 18:02:23 +0000427// addressof
Eric Fiselier735026e2016-03-17 03:30:56 +0000428#if __has_builtin(__builtin_addressof)
429
430template <class _Tp>
431inline _LIBCPP_CONSTEXPR_AFTER_CXX14
432_LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
433_Tp*
434addressof(_Tp& __x) _NOEXCEPT
435{
436 return __builtin_addressof(__x);
437}
438
439#else
Marshall Clowd18b4962015-12-14 18:02:23 +0000440
441template <class _Tp>
Evgeniy Stepanov2fe62cd2016-03-11 23:50:57 +0000442inline _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
Marshall Clowd18b4962015-12-14 18:02:23 +0000443_Tp*
444addressof(_Tp& __x) _NOEXCEPT
445{
446 return (_Tp*)&reinterpret_cast<const volatile char&>(__x);
447}
448
Eric Fiselier735026e2016-03-17 03:30:56 +0000449#endif // __has_builtin(__builtin_addressof)
450
Marshall Clowd18b4962015-12-14 18:02:23 +0000451#if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF)
452// Objective-C++ Automatic Reference Counting uses qualified pointers
453// that require special addressof() signatures. When
454// _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler
455// itself is providing these definitions. Otherwise, we provide them.
456template <class _Tp>
457inline _LIBCPP_INLINE_VISIBILITY
458__strong _Tp*
459addressof(__strong _Tp& __x) _NOEXCEPT
460{
461 return &__x;
462}
463
464#ifdef _LIBCPP_HAS_OBJC_ARC_WEAK
465template <class _Tp>
466inline _LIBCPP_INLINE_VISIBILITY
467__weak _Tp*
468addressof(__weak _Tp& __x) _NOEXCEPT
469{
470 return &__x;
471}
472#endif
473
474template <class _Tp>
475inline _LIBCPP_INLINE_VISIBILITY
476__autoreleasing _Tp*
477addressof(__autoreleasing _Tp& __x) _NOEXCEPT
478{
479 return &__x;
480}
481
482template <class _Tp>
483inline _LIBCPP_INLINE_VISIBILITY
484__unsafe_unretained _Tp*
485addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT
486{
487 return &__x;
488}
489#endif
Marshall Clow933afa92013-07-04 00:10:01 +0000490
Howard Hinnant9c0df142012-10-30 19:06:59 +0000491struct __two {char __lx[2];};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000492
493// helper class:
494
495template <class _Tp, _Tp __v>
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000496struct _LIBCPP_TYPE_VIS_ONLY integral_constant
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000497{
Howard Hinnant27b4fd32012-04-02 00:40:41 +0000498 static _LIBCPP_CONSTEXPR const _Tp value = __v;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000499 typedef _Tp value_type;
500 typedef integral_constant type;
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000501 _LIBCPP_INLINE_VISIBILITY
Marshall Clowa2df82b2014-02-17 22:18:51 +0000502 _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT {return value;}
Marshall Clowd29bb4b2013-07-08 20:05:31 +0000503#if _LIBCPP_STD_VER > 11
504 _LIBCPP_INLINE_VISIBILITY
Marshall Clowa2df82b2014-02-17 22:18:51 +0000505 constexpr value_type operator ()() const _NOEXCEPT {return value;}
Marshall Clowd29bb4b2013-07-08 20:05:31 +0000506#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000507};
508
509template <class _Tp, _Tp __v>
Howard Hinnant27b4fd32012-04-02 00:40:41 +0000510_LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000511
Marshall Clowe62560a2015-05-18 23:21:06 +0000512#if _LIBCPP_STD_VER > 14
513template <bool __b>
514using bool_constant = integral_constant<bool, __b>;
Marshall Clowfe99a302015-11-16 15:54:13 +0000515#define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)>
Marshall Clowe62560a2015-05-18 23:21:06 +0000516#else
Marshall Clowfe99a302015-11-16 15:54:13 +0000517#define _LIBCPP_BOOL_CONSTANT(__b) integral_constant<bool,(__b)>
Marshall Clowe62560a2015-05-18 23:21:06 +0000518#endif
519
520typedef _LIBCPP_BOOL_CONSTANT(true) true_type;
521typedef _LIBCPP_BOOL_CONSTANT(false) false_type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000522
Eric Fiseliercae4cab2015-08-31 03:50:31 +0000523#if !defined(_LIBCPP_HAS_NO_VARIADICS)
524
525// __lazy_and
526
527template <bool _Last, class ..._Preds>
528struct __lazy_and_impl;
529
530template <class ..._Preds>
531struct __lazy_and_impl<false, _Preds...> : false_type {};
532
533template <>
534struct __lazy_and_impl<true> : true_type {};
535
536template <class _Pred>
537struct __lazy_and_impl<true, _Pred> : integral_constant<bool, _Pred::type::value> {};
538
539template <class _Hp, class ..._Tp>
540struct __lazy_and_impl<true, _Hp, _Tp...> : __lazy_and_impl<_Hp::type::value, _Tp...> {};
541
542template <class _P1, class ..._Pr>
543struct __lazy_and : __lazy_and_impl<_P1::type::value, _Pr...> {};
544
545// __lazy_or
546
547template <bool _List, class ..._Preds>
548struct __lazy_or_impl;
549
550template <class ..._Preds>
551struct __lazy_or_impl<true, _Preds...> : true_type {};
552
553template <>
554struct __lazy_or_impl<false> : false_type {};
555
556template <class _Hp, class ..._Tp>
557struct __lazy_or_impl<false, _Hp, _Tp...>
558 : __lazy_or_impl<_Hp::type::value, _Tp...> {};
559
560template <class _P1, class ..._Pr>
561struct __lazy_or : __lazy_or_impl<_P1::type::value, _Pr...> {};
562
563// __lazy_not
564
565template <class _Pred>
566struct __lazy_not : integral_constant<bool, !_Pred::type::value> {};
567
Marshall Clowfe99a302015-11-16 15:54:13 +0000568// __and_
569template<class...> struct __and_;
570template<> struct __and_<> : true_type {};
571
572template<class _B0> struct __and_<_B0> : _B0 {};
573
574template<class _B0, class _B1>
575struct __and_<_B0, _B1> : conditional<_B0::value, _B1, _B0>::type {};
576
577template<class _B0, class _B1, class _B2, class... _Bn>
578struct __and_<_B0, _B1, _B2, _Bn...>
579 : conditional<_B0::value, __and_<_B1, _B2, _Bn...>, _B0>::type {};
580
581// __or_
582template<class...> struct __or_;
583template<> struct __or_<> : false_type {};
584
585template<class _B0> struct __or_<_B0> : _B0 {};
586
587template<class _B0, class _B1>
588struct __or_<_B0, _B1> : conditional<_B0::value, _B0, _B1>::type {};
589
590template<class _B0, class _B1, class _B2, class... _Bn>
591struct __or_<_B0, _B1, _B2, _Bn...>
592 : conditional<_B0::value, _B0, __or_<_B1, _B2, _Bn...> >::type {};
593
594// __not_
595template<class _Tp>
596struct __not_ : conditional<_Tp::value, false_type, true_type>::type {};
597
Eric Fiseliercae4cab2015-08-31 03:50:31 +0000598#endif // !defined(_LIBCPP_HAS_NO_VARIADICS)
599
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000600// is_const
601
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000602template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_const : public false_type {};
603template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_const<_Tp const> : public true_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000604
Marshall Clow94611a82015-11-01 20:24:59 +0000605#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
606template <class _Tp> _LIBCPP_CONSTEXPR bool is_const_v
607 = is_const<_Tp>::value;
608#endif
609
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000610// is_volatile
611
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000612template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_volatile : public false_type {};
613template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_volatile<_Tp volatile> : public true_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000614
Marshall Clow94611a82015-11-01 20:24:59 +0000615#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
616template <class _Tp> _LIBCPP_CONSTEXPR bool is_volatile_v
617 = is_volatile<_Tp>::value;
618#endif
619
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000620// remove_const
621
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000622template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_const {typedef _Tp type;};
623template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_const<const _Tp> {typedef _Tp type;};
Marshall Clow933afa92013-07-04 00:10:01 +0000624#if _LIBCPP_STD_VER > 11
625template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type;
626#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000627
628// remove_volatile
629
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000630template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_volatile {typedef _Tp type;};
631template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_volatile<volatile _Tp> {typedef _Tp type;};
Marshall Clow933afa92013-07-04 00:10:01 +0000632#if _LIBCPP_STD_VER > 11
633template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type;
634#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000635
636// remove_cv
637
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000638template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_cv
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000639{typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
Marshall Clow933afa92013-07-04 00:10:01 +0000640#if _LIBCPP_STD_VER > 11
641template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type;
642#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000643
644// is_void
645
Marshall Clow8896ac32014-01-14 05:13:45 +0000646template <class _Tp> struct __libcpp_is_void : public false_type {};
647template <> struct __libcpp_is_void<void> : public true_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000648
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000649template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_void
Marshall Clow8896ac32014-01-14 05:13:45 +0000650 : public __libcpp_is_void<typename remove_cv<_Tp>::type> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000651
Marshall Clow94611a82015-11-01 20:24:59 +0000652#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
653template <class _Tp> _LIBCPP_CONSTEXPR bool is_void_v
654 = is_void<_Tp>::value;
655#endif
656
Howard Hinnant6e5e7e72011-03-09 17:17:06 +0000657// __is_nullptr_t
658
Marshall Clow0ea7f8c2014-01-06 14:00:09 +0000659template <class _Tp> struct __is_nullptr_t_impl : public false_type {};
660template <> struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
Howard Hinnant6e5e7e72011-03-09 17:17:06 +0000661
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000662template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __is_nullptr_t
Marshall Clow0ea7f8c2014-01-06 14:00:09 +0000663 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
Howard Hinnant6e5e7e72011-03-09 17:17:06 +0000664
Marshall Clow79d8c992013-10-05 21:21:17 +0000665#if _LIBCPP_STD_VER > 11
666template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_null_pointer
Marshall Clow0ea7f8c2014-01-06 14:00:09 +0000667 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
Marshall Clow94611a82015-11-01 20:24:59 +0000668
669#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
670template <class _Tp> _LIBCPP_CONSTEXPR bool is_null_pointer_v
671 = is_null_pointer<_Tp>::value;
672#endif
Marshall Clow79d8c992013-10-05 21:21:17 +0000673#endif
674
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000675// is_integral
676
Marshall Clow8896ac32014-01-14 05:13:45 +0000677template <class _Tp> struct __libcpp_is_integral : public false_type {};
678template <> struct __libcpp_is_integral<bool> : public true_type {};
679template <> struct __libcpp_is_integral<char> : public true_type {};
680template <> struct __libcpp_is_integral<signed char> : public true_type {};
681template <> struct __libcpp_is_integral<unsigned char> : public true_type {};
682template <> struct __libcpp_is_integral<wchar_t> : public true_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000683#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
Marshall Clow8896ac32014-01-14 05:13:45 +0000684template <> struct __libcpp_is_integral<char16_t> : public true_type {};
685template <> struct __libcpp_is_integral<char32_t> : public true_type {};
Howard Hinnant324bb032010-08-22 00:02:43 +0000686#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
Marshall Clow8896ac32014-01-14 05:13:45 +0000687template <> struct __libcpp_is_integral<short> : public true_type {};
688template <> struct __libcpp_is_integral<unsigned short> : public true_type {};
689template <> struct __libcpp_is_integral<int> : public true_type {};
690template <> struct __libcpp_is_integral<unsigned int> : public true_type {};
691template <> struct __libcpp_is_integral<long> : public true_type {};
692template <> struct __libcpp_is_integral<unsigned long> : public true_type {};
693template <> struct __libcpp_is_integral<long long> : public true_type {};
694template <> struct __libcpp_is_integral<unsigned long long> : public true_type {};
Stephan Tolksdorf8a71d232014-03-26 19:45:52 +0000695#ifndef _LIBCPP_HAS_NO_INT128
696template <> struct __libcpp_is_integral<__int128_t> : public true_type {};
697template <> struct __libcpp_is_integral<__uint128_t> : public true_type {};
698#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000699
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000700template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_integral
Marshall Clow8896ac32014-01-14 05:13:45 +0000701 : public __libcpp_is_integral<typename remove_cv<_Tp>::type> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000702
Marshall Clow94611a82015-11-01 20:24:59 +0000703#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
704template <class _Tp> _LIBCPP_CONSTEXPR bool is_integral_v
705 = is_integral<_Tp>::value;
706#endif
707
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000708// is_floating_point
709
Marshall Clow8896ac32014-01-14 05:13:45 +0000710template <class _Tp> struct __libcpp_is_floating_point : public false_type {};
711template <> struct __libcpp_is_floating_point<float> : public true_type {};
712template <> struct __libcpp_is_floating_point<double> : public true_type {};
713template <> struct __libcpp_is_floating_point<long double> : public true_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000714
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000715template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_floating_point
Marshall Clow8896ac32014-01-14 05:13:45 +0000716 : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000717
Marshall Clow94611a82015-11-01 20:24:59 +0000718#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
719template <class _Tp> _LIBCPP_CONSTEXPR bool is_floating_point_v
720 = is_floating_point<_Tp>::value;
721#endif
722
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000723// is_array
724
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000725template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_array
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000726 : public false_type {};
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000727template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[]>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000728 : public true_type {};
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000729template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[_Np]>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000730 : public true_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000731
Marshall Clow94611a82015-11-01 20:24:59 +0000732#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
733template <class _Tp> _LIBCPP_CONSTEXPR bool is_array_v
734 = is_array<_Tp>::value;
735#endif
736
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000737// is_pointer
738
Marshall Clow8896ac32014-01-14 05:13:45 +0000739template <class _Tp> struct __libcpp_is_pointer : public false_type {};
740template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000741
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000742template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pointer
Marshall Clow8896ac32014-01-14 05:13:45 +0000743 : public __libcpp_is_pointer<typename remove_cv<_Tp>::type> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000744
Marshall Clow94611a82015-11-01 20:24:59 +0000745#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
746template <class _Tp> _LIBCPP_CONSTEXPR bool is_pointer_v
747 = is_pointer<_Tp>::value;
748#endif
749
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000750// is_reference
751
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000752template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference : public false_type {};
753template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference<_Tp&> : public true_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000754
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000755template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference : public false_type {};
Howard Hinnant73d21a42010-09-04 23:28:19 +0000756#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000757template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference<_Tp&&> : public true_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000758#endif
759
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000760template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference : public false_type {};
761template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&> : public true_type {};
Howard Hinnant73d21a42010-09-04 23:28:19 +0000762#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000763template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&&> : public true_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000764#endif
765
Marshall Clow94611a82015-11-01 20:24:59 +0000766#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
767template <class _Tp> _LIBCPP_CONSTEXPR bool is_reference_v
768 = is_reference<_Tp>::value;
769
770template <class _Tp> _LIBCPP_CONSTEXPR bool is_lvalue_reference_v
771 = is_lvalue_reference<_Tp>::value;
772
773template <class _Tp> _LIBCPP_CONSTEXPR bool is_rvalue_reference_v
774 = is_rvalue_reference<_Tp>::value;
775#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000776// is_union
777
Marshall Clow48e7e9f2014-07-10 15:38:20 +0000778#if __has_feature(is_union) || (_GNUC_VER >= 403)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000779
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000780template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_union
Howard Hinnant745d4732010-09-08 17:55:32 +0000781 : public integral_constant<bool, __is_union(_Tp)> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000782
Howard Hinnant36666952011-05-09 19:21:17 +0000783#else
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000784
785template <class _Tp> struct __libcpp_union : public false_type {};
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000786template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_union
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000787 : public __libcpp_union<typename remove_cv<_Tp>::type> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000788
Howard Hinnant36666952011-05-09 19:21:17 +0000789#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000790
Marshall Clow94611a82015-11-01 20:24:59 +0000791#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
792template <class _Tp> _LIBCPP_CONSTEXPR bool is_union_v
793 = is_union<_Tp>::value;
794#endif
795
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000796// is_class
797
Marshall Clow48e7e9f2014-07-10 15:38:20 +0000798#if __has_feature(is_class) || (_GNUC_VER >= 403)
Howard Hinnant745d4732010-09-08 17:55:32 +0000799
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000800template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_class
Howard Hinnant745d4732010-09-08 17:55:32 +0000801 : public integral_constant<bool, __is_class(_Tp)> {};
802
Howard Hinnant36666952011-05-09 19:21:17 +0000803#else
Howard Hinnant745d4732010-09-08 17:55:32 +0000804
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000805namespace __is_class_imp
806{
807template <class _Tp> char __test(int _Tp::*);
808template <class _Tp> __two __test(...);
809}
810
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000811template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_class
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000812 : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {};
813
Howard Hinnant36666952011-05-09 19:21:17 +0000814#endif
Howard Hinnant745d4732010-09-08 17:55:32 +0000815
Marshall Clow94611a82015-11-01 20:24:59 +0000816#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
817template <class _Tp> _LIBCPP_CONSTEXPR bool is_class_v
818 = is_class<_Tp>::value;
819#endif
820
Howard Hinnantd7373822011-06-01 17:25:11 +0000821// is_same
822
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000823template <class _Tp, class _Up> struct _LIBCPP_TYPE_VIS_ONLY is_same : public false_type {};
824template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_same<_Tp, _Tp> : public true_type {};
Howard Hinnantd7373822011-06-01 17:25:11 +0000825
Marshall Clow94611a82015-11-01 20:24:59 +0000826#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
827template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_same_v
828 = is_same<_Tp, _Up>::value;
829#endif
830
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000831// is_function
832
Marshall Clow8896ac32014-01-14 05:13:45 +0000833namespace __libcpp_is_function_imp
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000834{
Eric Fiselier89465dc2015-02-18 16:31:46 +0000835struct __dummy_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000836template <class _Tp> char __test(_Tp*);
Eric Fiselier89465dc2015-02-18 16:31:46 +0000837template <class _Tp> char __test(__dummy_type);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000838template <class _Tp> __two __test(...);
Eric Fiselier89465dc2015-02-18 16:31:46 +0000839template <class _Tp> _Tp& __source(int);
840template <class _Tp> __dummy_type __source(...);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000841}
842
843template <class _Tp, bool = is_class<_Tp>::value ||
844 is_union<_Tp>::value ||
845 is_void<_Tp>::value ||
Howard Hinnantd7373822011-06-01 17:25:11 +0000846 is_reference<_Tp>::value ||
Marshall Clow79d8c992013-10-05 21:21:17 +0000847 __is_nullptr_t<_Tp>::value >
Marshall Clow8896ac32014-01-14 05:13:45 +0000848struct __libcpp_is_function
Eric Fiselier89465dc2015-02-18 16:31:46 +0000849 : 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 +0000850 {};
Marshall Clow8896ac32014-01-14 05:13:45 +0000851template <class _Tp> struct __libcpp_is_function<_Tp, true> : public false_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000852
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000853template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_function
Marshall Clow8896ac32014-01-14 05:13:45 +0000854 : public __libcpp_is_function<_Tp> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000855
Marshall Clow94611a82015-11-01 20:24:59 +0000856#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
857template <class _Tp> _LIBCPP_CONSTEXPR bool is_function_v
858 = is_function<_Tp>::value;
859#endif
860
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000861// is_member_function_pointer
862
Marshall Clow4f3368e2014-05-29 01:10:28 +0000863// template <class _Tp> struct __libcpp_is_member_function_pointer : public false_type {};
864// template <class _Tp, class _Up> struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {};
865//
866
Nick Lewyckye1be30b2015-07-29 22:38:23 +0000867template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr>
Marshall Clow4f3368e2014-05-29 01:10:28 +0000868struct __member_pointer_traits_imp
869{ // forward declaration; specializations later
870};
871
872
Marshall Clow4f3368e2014-05-29 01:10:28 +0000873template <class _Tp> struct __libcpp_is_member_function_pointer
Eric Fiselier724b5ab2015-06-13 00:33:13 +0000874 : public false_type {};
875
876template <class _Ret, class _Class>
877struct __libcpp_is_member_function_pointer<_Ret _Class::*>
878 : public is_function<_Ret> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000879
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000880template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_function_pointer
Eric Fiselier724b5ab2015-06-13 00:33:13 +0000881 : public __libcpp_is_member_function_pointer<typename remove_cv<_Tp>::type>::type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000882
Marshall Clow94611a82015-11-01 20:24:59 +0000883#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
884template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_function_pointer_v
885 = is_member_function_pointer<_Tp>::value;
886#endif
887
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000888// is_member_pointer
889
Marshall Clow8896ac32014-01-14 05:13:45 +0000890template <class _Tp> struct __libcpp_is_member_pointer : public false_type {};
891template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> : public true_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000892
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000893template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_pointer
Marshall Clow8896ac32014-01-14 05:13:45 +0000894 : public __libcpp_is_member_pointer<typename remove_cv<_Tp>::type> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000895
Marshall Clow94611a82015-11-01 20:24:59 +0000896#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
897template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_pointer_v
898 = is_member_pointer<_Tp>::value;
899#endif
900
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000901// is_member_object_pointer
902
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000903template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_object_pointer
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000904 : public integral_constant<bool, is_member_pointer<_Tp>::value &&
905 !is_member_function_pointer<_Tp>::value> {};
906
Marshall Clow94611a82015-11-01 20:24:59 +0000907#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
908template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_object_pointer_v
909 = is_member_object_pointer<_Tp>::value;
910#endif
911
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000912// is_enum
913
Marshall Clow48e7e9f2014-07-10 15:38:20 +0000914#if __has_feature(is_enum) || (_GNUC_VER >= 403)
Howard Hinnant745d4732010-09-08 17:55:32 +0000915
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000916template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_enum
Howard Hinnant745d4732010-09-08 17:55:32 +0000917 : public integral_constant<bool, __is_enum(_Tp)> {};
918
Howard Hinnant36666952011-05-09 19:21:17 +0000919#else
Howard Hinnant745d4732010-09-08 17:55:32 +0000920
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000921template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_enum
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000922 : public integral_constant<bool, !is_void<_Tp>::value &&
923 !is_integral<_Tp>::value &&
924 !is_floating_point<_Tp>::value &&
925 !is_array<_Tp>::value &&
926 !is_pointer<_Tp>::value &&
927 !is_reference<_Tp>::value &&
928 !is_member_pointer<_Tp>::value &&
929 !is_union<_Tp>::value &&
930 !is_class<_Tp>::value &&
931 !is_function<_Tp>::value > {};
932
Howard Hinnant36666952011-05-09 19:21:17 +0000933#endif
Howard Hinnant745d4732010-09-08 17:55:32 +0000934
Marshall Clow94611a82015-11-01 20:24:59 +0000935#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
936template <class _Tp> _LIBCPP_CONSTEXPR bool is_enum_v
937 = is_enum<_Tp>::value;
938#endif
939
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000940// is_arithmetic
941
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000942template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_arithmetic
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000943 : public integral_constant<bool, is_integral<_Tp>::value ||
944 is_floating_point<_Tp>::value> {};
945
Marshall Clow94611a82015-11-01 20:24:59 +0000946#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
947template <class _Tp> _LIBCPP_CONSTEXPR bool is_arithmetic_v
948 = is_arithmetic<_Tp>::value;
949#endif
950
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000951// is_fundamental
952
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000953template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_fundamental
Howard Hinnant6e5e7e72011-03-09 17:17:06 +0000954 : public integral_constant<bool, is_void<_Tp>::value ||
955 __is_nullptr_t<_Tp>::value ||
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000956 is_arithmetic<_Tp>::value> {};
957
Marshall Clow94611a82015-11-01 20:24:59 +0000958#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
959template <class _Tp> _LIBCPP_CONSTEXPR bool is_fundamental_v
960 = is_fundamental<_Tp>::value;
961#endif
962
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000963// is_scalar
964
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000965template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_scalar
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000966 : public integral_constant<bool, is_arithmetic<_Tp>::value ||
967 is_member_pointer<_Tp>::value ||
968 is_pointer<_Tp>::value ||
Howard Hinnant6e5e7e72011-03-09 17:17:06 +0000969 __is_nullptr_t<_Tp>::value ||
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000970 is_enum<_Tp>::value > {};
971
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000972template <> struct _LIBCPP_TYPE_VIS_ONLY is_scalar<nullptr_t> : public true_type {};
Howard Hinnant5885da32011-03-09 15:10:51 +0000973
Marshall Clow94611a82015-11-01 20:24:59 +0000974#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
975template <class _Tp> _LIBCPP_CONSTEXPR bool is_scalar_v
976 = is_scalar<_Tp>::value;
977#endif
978
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000979// is_object
980
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000981template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_object
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000982 : public integral_constant<bool, is_scalar<_Tp>::value ||
983 is_array<_Tp>::value ||
984 is_union<_Tp>::value ||
985 is_class<_Tp>::value > {};
986
Marshall Clow94611a82015-11-01 20:24:59 +0000987#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
988template <class _Tp> _LIBCPP_CONSTEXPR bool is_object_v
989 = is_object<_Tp>::value;
990#endif
991
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000992// is_compound
993
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000994template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_compound
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000995 : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000996
Marshall Clow94611a82015-11-01 20:24:59 +0000997#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
998template <class _Tp> _LIBCPP_CONSTEXPR bool is_compound_v
999 = is_compound<_Tp>::value;
1000#endif
1001
Marshall Clow7a7960f2016-01-21 18:22:43 +00001002
1003// __is_referenceable [defns.referenceable]
Marshall Clow7a7960f2016-01-21 18:22:43 +00001004
Marshall Clowd8128652016-02-22 22:13:03 +00001005struct __is_referenceable_impl {
1006 template <class _Tp> static _Tp& __test(int);
1007 template <class _Tp> static __two __test(...);
1008};
Marshall Clow7a7960f2016-01-21 18:22:43 +00001009
Marshall Clowd8128652016-02-22 22:13:03 +00001010template <class _Tp>
Eric Fiselier14273e82016-05-18 23:09:24 +00001011struct __is_referenceable : integral_constant<bool,
1012 !is_same<decltype(__is_referenceable_impl::__test<_Tp>(0)), __two>::value> {};
Marshall Clow7a7960f2016-01-21 18:22:43 +00001013
1014
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001015// add_const
1016
1017template <class _Tp, bool = is_reference<_Tp>::value ||
1018 is_function<_Tp>::value ||
1019 is_const<_Tp>::value >
1020struct __add_const {typedef _Tp type;};
1021
1022template <class _Tp>
1023struct __add_const<_Tp, false> {typedef const _Tp type;};
1024
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001025template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_const
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001026 {typedef typename __add_const<_Tp>::type type;};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001027
Marshall Clow933afa92013-07-04 00:10:01 +00001028#if _LIBCPP_STD_VER > 11
1029template <class _Tp> using add_const_t = typename add_const<_Tp>::type;
1030#endif
1031
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001032// add_volatile
1033
1034template <class _Tp, bool = is_reference<_Tp>::value ||
1035 is_function<_Tp>::value ||
1036 is_volatile<_Tp>::value >
1037struct __add_volatile {typedef _Tp type;};
1038
1039template <class _Tp>
1040struct __add_volatile<_Tp, false> {typedef volatile _Tp type;};
1041
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001042template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_volatile
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001043 {typedef typename __add_volatile<_Tp>::type type;};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001044
Marshall Clow933afa92013-07-04 00:10:01 +00001045#if _LIBCPP_STD_VER > 11
1046template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type;
1047#endif
1048
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001049// add_cv
1050
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001051template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_cv
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001052 {typedef typename add_const<typename add_volatile<_Tp>::type>::type type;};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001053
Marshall Clow933afa92013-07-04 00:10:01 +00001054#if _LIBCPP_STD_VER > 11
1055template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type;
1056#endif
1057
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001058// remove_reference
1059
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001060template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference {typedef _Tp type;};
1061template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&> {typedef _Tp type;};
Howard Hinnant73d21a42010-09-04 23:28:19 +00001062#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001063template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&&> {typedef _Tp type;};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001064#endif
1065
Marshall Clow933afa92013-07-04 00:10:01 +00001066#if _LIBCPP_STD_VER > 11
1067template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
1068#endif
1069
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001070// add_lvalue_reference
1071
Marshall Clow7a7960f2016-01-21 18:22:43 +00001072template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _Tp type; };
1073template <class _Tp > struct __add_lvalue_reference_impl<_Tp, true> { typedef _Tp& type; };
1074
1075template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference
1076{typedef typename __add_lvalue_reference_impl<_Tp>::type type;};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001077
Marshall Clow933afa92013-07-04 00:10:01 +00001078#if _LIBCPP_STD_VER > 11
1079template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
1080#endif
1081
Howard Hinnant73d21a42010-09-04 23:28:19 +00001082#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001083
Marshall Clow7a7960f2016-01-21 18:22:43 +00001084template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl { typedef _Tp type; };
1085template <class _Tp > struct __add_rvalue_reference_impl<_Tp, true> { typedef _Tp&& type; };
1086
1087template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference
1088{typedef typename __add_rvalue_reference_impl<_Tp>::type type;};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001089
Marshall Clow933afa92013-07-04 00:10:01 +00001090#if _LIBCPP_STD_VER > 11
1091template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
1092#endif
1093
Howard Hinnant73d21a42010-09-04 23:28:19 +00001094#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001095
Howard Hinnant745d4732010-09-08 17:55:32 +00001096#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1097
Eric Fiselier7995c482016-05-18 22:23:46 +00001098template <class _Tp> _Tp&& __declval(int);
1099template <class _Tp> _Tp __declval(long);
1100
Howard Hinnant745d4732010-09-08 17:55:32 +00001101template <class _Tp>
Eric Fiselier7995c482016-05-18 22:23:46 +00001102decltype(_VSTD::__declval<_Tp>(0))
Howard Hinnant5d37fb32011-05-11 20:19:40 +00001103declval() _NOEXCEPT;
Howard Hinnant745d4732010-09-08 17:55:32 +00001104
1105#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1106
1107template <class _Tp>
1108typename add_lvalue_reference<_Tp>::type
1109declval();
1110
1111#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1112
Eric Fiselier219d4ef2016-01-22 06:25:47 +00001113// __uncvref
1114
1115template <class _Tp>
1116struct __uncvref {
1117 typedef typename remove_cv<typename remove_reference<_Tp>::type>::type type;
1118};
1119
Eric Fiselier8b15aee2016-03-16 20:32:07 +00001120template <class _Tp>
1121struct __unconstref {
1122 typedef typename remove_const<typename remove_reference<_Tp>::type>::type type;
1123};
1124
Eric Fiselier2960ae22016-02-11 11:59:44 +00001125// __is_same_uncvref
1126
1127template <class _Tp, class _Up>
1128struct __is_same_uncvref : is_same<typename __uncvref<_Tp>::type,
1129 typename __uncvref<_Up>::type> {};
1130
Howard Hinnant745d4732010-09-08 17:55:32 +00001131struct __any
1132{
1133 __any(...);
1134};
1135
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001136// remove_pointer
1137
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001138template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer {typedef _Tp type;};
1139template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp*> {typedef _Tp type;};
1140template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const> {typedef _Tp type;};
1141template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* volatile> {typedef _Tp type;};
1142template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const volatile> {typedef _Tp type;};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001143
Marshall Clow933afa92013-07-04 00:10:01 +00001144#if _LIBCPP_STD_VER > 11
1145template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type;
1146#endif
1147
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001148// add_pointer
1149
Marshall Clow7a7960f2016-01-21 18:22:43 +00001150template <class _Tp,
1151 bool = __is_referenceable<_Tp>::value ||
1152 is_same<typename remove_cv<_Tp>::type, void>::value>
1153struct __add_pointer_impl
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001154 {typedef typename remove_reference<_Tp>::type* type;};
Marshall Clow7a7960f2016-01-21 18:22:43 +00001155template <class _Tp> struct __add_pointer_impl<_Tp, false>
1156 {typedef _Tp type;};
1157
1158template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_pointer
1159 {typedef typename __add_pointer_impl<_Tp>::type type;};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001160
Marshall Clow933afa92013-07-04 00:10:01 +00001161#if _LIBCPP_STD_VER > 11
1162template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
1163#endif
1164
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001165// is_signed
1166
1167template <class _Tp, bool = is_integral<_Tp>::value>
Marshall Clowe62560a2015-05-18 23:21:06 +00001168struct __libcpp_is_signed_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(-1) < _Tp(0)) {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001169
1170template <class _Tp>
Marshall Clow8896ac32014-01-14 05:13:45 +00001171struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001172
1173template <class _Tp, bool = is_arithmetic<_Tp>::value>
Marshall Clow8896ac32014-01-14 05:13:45 +00001174struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001175
Marshall Clow8896ac32014-01-14 05:13:45 +00001176template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001177
Marshall Clow8896ac32014-01-14 05:13:45 +00001178template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_signed : public __libcpp_is_signed<_Tp> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001179
Marshall Clow94611a82015-11-01 20:24:59 +00001180#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1181template <class _Tp> _LIBCPP_CONSTEXPR bool is_signed_v
1182 = is_signed<_Tp>::value;
1183#endif
1184
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001185// is_unsigned
1186
1187template <class _Tp, bool = is_integral<_Tp>::value>
Marshall Clowe62560a2015-05-18 23:21:06 +00001188struct __libcpp_is_unsigned_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(0) < _Tp(-1)) {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001189
1190template <class _Tp>
Marshall Clow8896ac32014-01-14 05:13:45 +00001191struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001192
1193template <class _Tp, bool = is_arithmetic<_Tp>::value>
Marshall Clow8896ac32014-01-14 05:13:45 +00001194struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001195
Marshall Clow8896ac32014-01-14 05:13:45 +00001196template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001197
Marshall Clow8896ac32014-01-14 05:13:45 +00001198template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_unsigned : public __libcpp_is_unsigned<_Tp> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001199
Marshall Clow94611a82015-11-01 20:24:59 +00001200#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1201template <class _Tp> _LIBCPP_CONSTEXPR bool is_unsigned_v
1202 = is_unsigned<_Tp>::value;
1203#endif
1204
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001205// rank
1206
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001207template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY rank
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001208 : public integral_constant<size_t, 0> {};
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001209template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[]>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001210 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001211template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[_Np]>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001212 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001213
Marshall Clowa3e7f522015-11-30 04:30:02 +00001214#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
Marshall Clowea972902015-11-30 05:20:00 +00001215template <class _Tp> _LIBCPP_CONSTEXPR size_t rank_v
Marshall Clowa3e7f522015-11-30 04:30:02 +00001216 = rank<_Tp>::value;
1217#endif
1218
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001219// extent
1220
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001221template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TYPE_VIS_ONLY extent
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001222 : public integral_constant<size_t, 0> {};
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001223template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], 0>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001224 : public integral_constant<size_t, 0> {};
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001225template <class _Tp, unsigned _Ip> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], _Ip>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001226 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001227template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], 0>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001228 : public integral_constant<size_t, _Np> {};
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001229template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], _Ip>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001230 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001231
Marshall Clowa3e7f522015-11-30 04:30:02 +00001232#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
Marshall Clowea972902015-11-30 05:20:00 +00001233template <class _Tp, unsigned _Ip = 0> _LIBCPP_CONSTEXPR size_t extent_v
Marshall Clowa3e7f522015-11-30 04:30:02 +00001234 = extent<_Tp, _Ip>::value;
1235#endif
1236
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001237// remove_extent
1238
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001239template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_extent
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001240 {typedef _Tp type;};
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001241template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[]>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001242 {typedef _Tp type;};
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001243template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[_Np]>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001244 {typedef _Tp type;};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001245
Marshall Clow933afa92013-07-04 00:10:01 +00001246#if _LIBCPP_STD_VER > 11
1247template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type;
1248#endif
1249
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001250// remove_all_extents
1251
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001252template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001253 {typedef _Tp type;};
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001254template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[]>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001255 {typedef typename remove_all_extents<_Tp>::type type;};
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001256template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[_Np]>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001257 {typedef typename remove_all_extents<_Tp>::type type;};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001258
Marshall Clow933afa92013-07-04 00:10:01 +00001259#if _LIBCPP_STD_VER > 11
1260template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
1261#endif
1262
Marshall Clowdab89a12013-10-07 23:43:33 +00001263// decay
1264
1265template <class _Tp>
1266struct _LIBCPP_TYPE_VIS_ONLY decay
1267{
1268private:
1269 typedef typename remove_reference<_Tp>::type _Up;
1270public:
1271 typedef typename conditional
1272 <
1273 is_array<_Up>::value,
1274 typename remove_extent<_Up>::type*,
1275 typename conditional
1276 <
1277 is_function<_Up>::value,
1278 typename add_pointer<_Up>::type,
1279 typename remove_cv<_Up>::type
1280 >::type
1281 >::type type;
1282};
1283
1284#if _LIBCPP_STD_VER > 11
1285template <class _Tp> using decay_t = typename decay<_Tp>::type;
1286#endif
1287
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001288// is_abstract
1289
1290namespace __is_abstract_imp
1291{
1292template <class _Tp> char __test(_Tp (*)[1]);
1293template <class _Tp> __two __test(...);
1294}
1295
1296template <class _Tp, bool = is_class<_Tp>::value>
1297struct __libcpp_abstract : public integral_constant<bool, sizeof(__is_abstract_imp::__test<_Tp>(0)) != 1> {};
1298
1299template <class _Tp> struct __libcpp_abstract<_Tp, false> : public false_type {};
1300
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001301template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_abstract : public __libcpp_abstract<_Tp> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001302
Marshall Clow94611a82015-11-01 20:24:59 +00001303#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1304template <class _Tp> _LIBCPP_CONSTEXPR bool is_abstract_v
1305 = is_abstract<_Tp>::value;
1306#endif
1307
Marshall Clowebd6c2b2014-03-05 03:39:25 +00001308// is_final
1309
Eric Fiselier3a0e4302015-06-13 07:08:02 +00001310#if defined(_LIBCPP_HAS_IS_FINAL)
1311template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY
1312__libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {};
1313#else
1314template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY
1315__libcpp_is_final : public false_type {};
1316#endif
1317
1318#if defined(_LIBCPP_HAS_IS_FINAL) && _LIBCPP_STD_VER > 11
1319template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY
Marshall Clowebd6c2b2014-03-05 03:39:25 +00001320is_final : public integral_constant<bool, __is_final(_Tp)> {};
1321#endif
1322
Marshall Clow94611a82015-11-01 20:24:59 +00001323#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1324template <class _Tp> _LIBCPP_CONSTEXPR bool is_final_v
1325 = is_final<_Tp>::value;
1326#endif
1327
Howard Hinnanta5160282012-08-25 15:06:50 +00001328// is_base_of
1329
Howard Hinnante9df0a52013-08-01 18:17:34 +00001330#ifdef _LIBCPP_HAS_IS_BASE_OF
Howard Hinnanta5160282012-08-25 15:06:50 +00001331
1332template <class _Bp, class _Dp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001333struct _LIBCPP_TYPE_VIS_ONLY is_base_of
Howard Hinnanta5160282012-08-25 15:06:50 +00001334 : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
1335
Marshall Clow48e7e9f2014-07-10 15:38:20 +00001336#else // _LIBCPP_HAS_IS_BASE_OF
Howard Hinnanta5160282012-08-25 15:06:50 +00001337
Richard Smithb2f2b682012-12-20 04:20:28 +00001338namespace __is_base_of_imp
1339{
1340template <class _Tp>
1341struct _Dst
1342{
1343 _Dst(const volatile _Tp &);
1344};
1345template <class _Tp>
1346struct _Src
1347{
1348 operator const volatile _Tp &();
1349 template <class _Up> operator const _Dst<_Up> &();
1350};
1351template <size_t> struct __one { typedef char type; };
1352template <class _Bp, class _Dp> typename __one<sizeof(_Dst<_Bp>(declval<_Src<_Dp> >()))>::type __test(int);
1353template <class _Bp, class _Dp> __two __test(...);
1354}
1355
1356template <class _Bp, class _Dp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001357struct _LIBCPP_TYPE_VIS_ONLY is_base_of
Richard Smithb2f2b682012-12-20 04:20:28 +00001358 : public integral_constant<bool, is_class<_Bp>::value &&
1359 sizeof(__is_base_of_imp::__test<_Bp, _Dp>(0)) == 2> {};
Howard Hinnanta5160282012-08-25 15:06:50 +00001360
Marshall Clow48e7e9f2014-07-10 15:38:20 +00001361#endif // _LIBCPP_HAS_IS_BASE_OF
Howard Hinnanta5160282012-08-25 15:06:50 +00001362
Marshall Clowa3e7f522015-11-30 04:30:02 +00001363#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1364template <class _Bp, class _Dp> _LIBCPP_CONSTEXPR bool is_base_of_v
1365 = is_base_of<_Bp, _Dp>::value;
1366#endif
1367
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001368// is_convertible
1369
Eric Fiselierffbfbcd2015-03-19 21:11:02 +00001370#if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
Howard Hinnant091c5ac2011-01-27 21:00:00 +00001371
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001372template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible
Howard Hinnante87514a2012-08-13 12:29:17 +00001373 : public integral_constant<bool, __is_convertible_to(_T1, _T2) &&
1374 !is_abstract<_T2>::value> {};
Howard Hinnant091c5ac2011-01-27 21:00:00 +00001375
Howard Hinnant31b8e612011-02-10 17:46:03 +00001376#else // __has_feature(is_convertible_to)
Howard Hinnant091c5ac2011-01-27 21:00:00 +00001377
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001378namespace __is_convertible_imp
1379{
Eric Fiselier4bd15462015-03-30 15:22:20 +00001380template <class _Tp> void __test_convert(_Tp);
1381
1382template <class _From, class _To, class = void>
1383struct __is_convertible_test : public false_type {};
1384
1385template <class _From, class _To>
1386struct __is_convertible_test<_From, _To,
Eric Fiseliere01f9462016-01-26 20:24:30 +00001387 decltype(_VSTD::__is_convertible_imp::__test_convert<_To>(_VSTD::declval<_From>()))> : public true_type
Eric Fiselier4bd15462015-03-30 15:22:20 +00001388{};
1389
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001390template <class _Tp, bool _IsArray = is_array<_Tp>::value,
1391 bool _IsFunction = is_function<_Tp>::value,
1392 bool _IsVoid = is_void<_Tp>::value>
1393 struct __is_array_function_or_void {enum {value = 0};};
1394template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};};
1395template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};};
1396template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};};
1397}
1398
1399template <class _Tp,
1400 unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
1401struct __is_convertible_check
1402{
1403 static const size_t __v = 0;
1404};
1405
1406template <class _Tp>
1407struct __is_convertible_check<_Tp, 0>
1408{
1409 static const size_t __v = sizeof(_Tp);
1410};
1411
1412template <class _T1, class _T2,
1413 unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value,
1414 unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
1415struct __is_convertible
1416 : public integral_constant<bool,
Eric Fiselier4bd15462015-03-30 15:22:20 +00001417 __is_convertible_imp::__is_convertible_test<_T1, _T2>::value
1418#if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
Howard Hinnanta0852ff2012-08-17 17:54:11 +00001419 && !(!is_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value
1420 && (!is_const<typename remove_reference<_T2>::type>::value
Howard Hinnanta5160282012-08-25 15:06:50 +00001421 || is_volatile<typename remove_reference<_T2>::type>::value)
1422 && (is_same<typename remove_cv<_T1>::type,
1423 typename remove_cv<typename remove_reference<_T2>::type>::type>::value
1424 || is_base_of<typename remove_reference<_T2>::type, _T1>::value))
Howard Hinnanta0852ff2012-08-17 17:54:11 +00001425#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001426 >
1427{};
1428
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001429template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
1430template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
1431template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
1432template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {};
1433
1434template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {};
1435template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {};
1436template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {};
1437template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {};
1438
1439template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {};
1440template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {};
1441template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {};
1442template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {};
1443
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001444template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001445 : public __is_convertible<_T1, _T2>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001446{
1447 static const size_t __complete_check1 = __is_convertible_check<_T1>::__v;
1448 static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
1449};
1450
Howard Hinnant31b8e612011-02-10 17:46:03 +00001451#endif // __has_feature(is_convertible_to)
Howard Hinnant091c5ac2011-01-27 21:00:00 +00001452
Marshall Clowa3e7f522015-11-30 04:30:02 +00001453#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1454template <class _From, class _To> _LIBCPP_CONSTEXPR bool is_convertible_v
1455 = is_convertible<_From, _To>::value;
1456#endif
1457
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001458// is_empty
1459
Marshall Clow48e7e9f2014-07-10 15:38:20 +00001460#if __has_feature(is_empty) || (_GNUC_VER >= 407)
Howard Hinnante814a902011-12-02 20:41:47 +00001461
1462template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001463struct _LIBCPP_TYPE_VIS_ONLY is_empty
Howard Hinnante814a902011-12-02 20:41:47 +00001464 : public integral_constant<bool, __is_empty(_Tp)> {};
1465
1466#else // __has_feature(is_empty)
1467
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001468template <class _Tp>
1469struct __is_empty1
1470 : public _Tp
1471{
Howard Hinnant9c0df142012-10-30 19:06:59 +00001472 double __lx;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001473};
1474
1475struct __is_empty2
1476{
Howard Hinnant9c0df142012-10-30 19:06:59 +00001477 double __lx;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001478};
1479
1480template <class _Tp, bool = is_class<_Tp>::value>
1481struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {};
1482
1483template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {};
1484
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001485template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_empty : public __libcpp_empty<_Tp> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001486
Howard Hinnante814a902011-12-02 20:41:47 +00001487#endif // __has_feature(is_empty)
1488
Marshall Clow94611a82015-11-01 20:24:59 +00001489#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1490template <class _Tp> _LIBCPP_CONSTEXPR bool is_empty_v
1491 = is_empty<_Tp>::value;
1492#endif
1493
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001494// is_polymorphic
1495
Yaron Keren0648cc52014-02-21 10:00:31 +00001496#if __has_feature(is_polymorphic) || defined(_LIBCPP_MSVC)
Howard Hinnant1e9f55f2012-02-15 20:47:11 +00001497
1498template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001499struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic
Howard Hinnant1e9f55f2012-02-15 20:47:11 +00001500 : public integral_constant<bool, __is_polymorphic(_Tp)> {};
1501
1502#else
1503
Howard Hinnant11a50ac2013-04-02 21:25:06 +00001504template<typename _Tp> char &__is_polymorphic_impl(
1505 typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0,
1506 int>::type);
1507template<typename _Tp> __two &__is_polymorphic_impl(...);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001508
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001509template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic
Howard Hinnant11a50ac2013-04-02 21:25:06 +00001510 : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001511
Howard Hinnant1e9f55f2012-02-15 20:47:11 +00001512#endif // __has_feature(is_polymorphic)
1513
Marshall Clow94611a82015-11-01 20:24:59 +00001514#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1515template <class _Tp> _LIBCPP_CONSTEXPR bool is_polymorphic_v
1516 = is_polymorphic<_Tp>::value;
1517#endif
1518
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001519// has_virtual_destructor
1520
Marshall Clow48e7e9f2014-07-10 15:38:20 +00001521#if __has_feature(has_virtual_destructor) || (_GNUC_VER >= 403)
Howard Hinnant745d4732010-09-08 17:55:32 +00001522
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001523template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor
Howard Hinnant745d4732010-09-08 17:55:32 +00001524 : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
1525
Marshall Clow48e7e9f2014-07-10 15:38:20 +00001526#else
Howard Hinnant745d4732010-09-08 17:55:32 +00001527
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001528template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001529 : public false_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001530
Marshall Clow48e7e9f2014-07-10 15:38:20 +00001531#endif
Howard Hinnant745d4732010-09-08 17:55:32 +00001532
Marshall Clow6455d852015-11-07 17:44:36 +00001533#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1534template <class _Tp> _LIBCPP_CONSTEXPR bool has_virtual_destructor_v
1535 = has_virtual_destructor<_Tp>::value;
1536#endif
1537
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001538// alignment_of
1539
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001540template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY alignment_of
Howard Hinnant5544f7e2013-04-22 19:37:49 +00001541 : public integral_constant<size_t, __alignof__(_Tp)> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001542
Marshall Clowa3e7f522015-11-30 04:30:02 +00001543#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
Marshall Clowea972902015-11-30 05:20:00 +00001544template <class _Tp> _LIBCPP_CONSTEXPR size_t alignment_of_v
Marshall Clowa3e7f522015-11-30 04:30:02 +00001545 = alignment_of<_Tp>::value;
1546#endif
1547
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001548// aligned_storage
1549
1550template <class _Hp, class _Tp>
1551struct __type_list
1552{
1553 typedef _Hp _Head;
1554 typedef _Tp _Tail;
1555};
1556
Howard Hinnante003ce42011-05-22 00:09:02 +00001557struct __nat
1558{
1559#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
1560 __nat() = delete;
1561 __nat(const __nat&) = delete;
1562 __nat& operator=(const __nat&) = delete;
1563 ~__nat() = delete;
1564#endif
1565};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001566
1567template <class _Tp>
1568struct __align_type
1569{
1570 static const size_t value = alignment_of<_Tp>::value;
1571 typedef _Tp type;
1572};
1573
Howard Hinnant9c0df142012-10-30 19:06:59 +00001574struct __struct_double {long double __lx;};
1575struct __struct_double4 {double __lx[4];};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001576
1577typedef
1578 __type_list<__align_type<unsigned char>,
1579 __type_list<__align_type<unsigned short>,
1580 __type_list<__align_type<unsigned int>,
1581 __type_list<__align_type<unsigned long>,
1582 __type_list<__align_type<unsigned long long>,
1583 __type_list<__align_type<double>,
1584 __type_list<__align_type<long double>,
1585 __type_list<__align_type<__struct_double>,
1586 __type_list<__align_type<__struct_double4>,
1587 __type_list<__align_type<int*>,
1588 __nat
1589 > > > > > > > > > > __all_types;
1590
1591template <class _TL, size_t _Align> struct __find_pod;
1592
1593template <class _Hp, size_t _Align>
1594struct __find_pod<__type_list<_Hp, __nat>, _Align>
1595{
1596 typedef typename conditional<
1597 _Align == _Hp::value,
1598 typename _Hp::type,
1599 void
1600 >::type type;
1601};
1602
1603template <class _Hp, class _Tp, size_t _Align>
1604struct __find_pod<__type_list<_Hp, _Tp>, _Align>
1605{
1606 typedef typename conditional<
1607 _Align == _Hp::value,
1608 typename _Hp::type,
1609 typename __find_pod<_Tp, _Align>::type
1610 >::type type;
1611};
1612
1613template <class _TL, size_t _Len> struct __find_max_align;
1614
1615template <class _Hp, size_t _Len>
1616struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
1617
1618template <size_t _Len, size_t _A1, size_t _A2>
1619struct __select_align
1620{
1621private:
1622 static const size_t __min = _A2 < _A1 ? _A2 : _A1;
1623 static const size_t __max = _A1 < _A2 ? _A2 : _A1;
1624public:
1625 static const size_t value = _Len < __max ? __min : __max;
1626};
1627
1628template <class _Hp, class _Tp, size_t _Len>
1629struct __find_max_align<__type_list<_Hp, _Tp>, _Len>
1630 : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
1631
Marshall Clow933afa92013-07-04 00:10:01 +00001632template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001633struct _LIBCPP_TYPE_VIS_ONLY aligned_storage
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001634{
1635 typedef typename __find_pod<__all_types, _Align>::type _Aligner;
1636 static_assert(!is_void<_Aligner>::value, "");
1637 union type
1638 {
1639 _Aligner __align;
Eric Fiselier514c8312015-09-22 18:37:03 +00001640 unsigned char __data[(_Len + _Align - 1)/_Align * _Align];
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001641 };
1642};
1643
Marshall Clow933afa92013-07-04 00:10:01 +00001644#if _LIBCPP_STD_VER > 11
1645template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1646 using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
1647#endif
1648
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001649#define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
1650template <size_t _Len>\
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001651struct _LIBCPP_TYPE_VIS_ONLY aligned_storage<_Len, n>\
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001652{\
Howard Hinnant08e17472011-10-17 20:05:10 +00001653 struct _ALIGNAS(n) type\
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001654 {\
Eric Fiselier514c8312015-09-22 18:37:03 +00001655 unsigned char __lx[(_Len + n - 1)/n * n];\
Howard Hinnant08e17472011-10-17 20:05:10 +00001656 };\
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001657}
1658
1659_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
1660_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
1661_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
1662_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
1663_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
1664_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
1665_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
1666_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
1667_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
1668_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
1669_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
1670_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
1671_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
1672_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
Howard Hinnant08e17472011-10-17 20:05:10 +00001673// MSDN says that MSVC does not support alignment beyond 8192 (=0x2000)
Howard Hinnante9df0a52013-08-01 18:17:34 +00001674#if !defined(_LIBCPP_MSVC)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001675_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
Howard Hinnante9df0a52013-08-01 18:17:34 +00001676#endif // !_LIBCPP_MSVC
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001677
1678#undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
1679
Howard Hinnant5544f7e2013-04-22 19:37:49 +00001680#ifndef _LIBCPP_HAS_NO_VARIADICS
1681
1682// aligned_union
1683
1684template <size_t _I0, size_t ..._In>
1685struct __static_max;
1686
1687template <size_t _I0>
1688struct __static_max<_I0>
1689{
1690 static const size_t value = _I0;
1691};
1692
1693template <size_t _I0, size_t _I1, size_t ..._In>
1694struct __static_max<_I0, _I1, _In...>
1695{
1696 static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value :
1697 __static_max<_I1, _In...>::value;
1698};
1699
1700template <size_t _Len, class _Type0, class ..._Types>
1701struct aligned_union
1702{
1703 static const size_t alignment_value = __static_max<__alignof__(_Type0),
1704 __alignof__(_Types)...>::value;
1705 static const size_t __len = __static_max<_Len, sizeof(_Type0),
1706 sizeof(_Types)...>::value;
1707 typedef typename aligned_storage<__len, alignment_value>::type type;
1708};
1709
Marshall Clow933afa92013-07-04 00:10:01 +00001710#if _LIBCPP_STD_VER > 11
1711template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
1712#endif
1713
Howard Hinnant5544f7e2013-04-22 19:37:49 +00001714#endif // _LIBCPP_HAS_NO_VARIADICS
1715
Marshall Clow854a7a02014-01-03 18:21:14 +00001716template <class _Tp>
1717struct __numeric_type
1718{
1719 static void __test(...);
1720 static float __test(float);
1721 static double __test(char);
1722 static double __test(int);
1723 static double __test(unsigned);
1724 static double __test(long);
1725 static double __test(unsigned long);
1726 static double __test(long long);
1727 static double __test(unsigned long long);
1728 static double __test(double);
1729 static long double __test(long double);
1730
1731 typedef decltype(__test(declval<_Tp>())) type;
1732 static const bool value = !is_same<type, void>::value;
1733};
1734
1735template <>
1736struct __numeric_type<void>
1737{
1738 static const bool value = true;
1739};
1740
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001741// __promote
1742
1743template <class _A1, class _A2 = void, class _A3 = void,
Marshall Clow854a7a02014-01-03 18:21:14 +00001744 bool = __numeric_type<_A1>::value &&
1745 __numeric_type<_A2>::value &&
1746 __numeric_type<_A3>::value>
Eric Fiselier950ee772014-10-17 00:31:47 +00001747class __promote_imp
Marshall Clow854a7a02014-01-03 18:21:14 +00001748{
Eric Fiselier950ee772014-10-17 00:31:47 +00001749public:
Marshall Clow854a7a02014-01-03 18:21:14 +00001750 static const bool value = false;
1751};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001752
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001753template <class _A1, class _A2, class _A3>
Eric Fiselier950ee772014-10-17 00:31:47 +00001754class __promote_imp<_A1, _A2, _A3, true>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001755{
1756private:
Eric Fiselier950ee772014-10-17 00:31:47 +00001757 typedef typename __promote_imp<_A1>::type __type1;
1758 typedef typename __promote_imp<_A2>::type __type2;
1759 typedef typename __promote_imp<_A3>::type __type3;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001760public:
Howard Hinnant08e17472011-10-17 20:05:10 +00001761 typedef decltype(__type1() + __type2() + __type3()) type;
Marshall Clow854a7a02014-01-03 18:21:14 +00001762 static const bool value = true;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001763};
1764
1765template <class _A1, class _A2>
Eric Fiselier950ee772014-10-17 00:31:47 +00001766class __promote_imp<_A1, _A2, void, true>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001767{
1768private:
Eric Fiselier950ee772014-10-17 00:31:47 +00001769 typedef typename __promote_imp<_A1>::type __type1;
1770 typedef typename __promote_imp<_A2>::type __type2;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001771public:
Howard Hinnant08e17472011-10-17 20:05:10 +00001772 typedef decltype(__type1() + __type2()) type;
Marshall Clow854a7a02014-01-03 18:21:14 +00001773 static const bool value = true;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001774};
1775
1776template <class _A1>
Eric Fiselier950ee772014-10-17 00:31:47 +00001777class __promote_imp<_A1, void, void, true>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001778{
1779public:
Marshall Clow854a7a02014-01-03 18:21:14 +00001780 typedef typename __numeric_type<_A1>::type type;
1781 static const bool value = true;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001782};
1783
Eric Fiselier950ee772014-10-17 00:31:47 +00001784template <class _A1, class _A2 = void, class _A3 = void>
1785class __promote : public __promote_imp<_A1, _A2, _A3> {};
1786
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001787// make_signed / make_unsigned
1788
1789typedef
1790 __type_list<signed char,
1791 __type_list<signed short,
1792 __type_list<signed int,
1793 __type_list<signed long,
1794 __type_list<signed long long,
Stephan Tolksdorf8a71d232014-03-26 19:45:52 +00001795#ifndef _LIBCPP_HAS_NO_INT128
1796 __type_list<__int128_t,
1797#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001798 __nat
Stephan Tolksdorf8a71d232014-03-26 19:45:52 +00001799#ifndef _LIBCPP_HAS_NO_INT128
1800 >
1801#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001802 > > > > > __signed_types;
1803
1804typedef
1805 __type_list<unsigned char,
1806 __type_list<unsigned short,
1807 __type_list<unsigned int,
1808 __type_list<unsigned long,
1809 __type_list<unsigned long long,
Stephan Tolksdorf8a71d232014-03-26 19:45:52 +00001810#ifndef _LIBCPP_HAS_NO_INT128
1811 __type_list<__uint128_t,
1812#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001813 __nat
Stephan Tolksdorf8a71d232014-03-26 19:45:52 +00001814#ifndef _LIBCPP_HAS_NO_INT128
1815 >
1816#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001817 > > > > > __unsigned_types;
1818
1819template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
1820
1821template <class _Hp, class _Tp, size_t _Size>
1822struct __find_first<__type_list<_Hp, _Tp>, _Size, true>
1823{
1824 typedef _Hp type;
1825};
1826
1827template <class _Hp, class _Tp, size_t _Size>
1828struct __find_first<__type_list<_Hp, _Tp>, _Size, false>
1829{
1830 typedef typename __find_first<_Tp, _Size>::type type;
1831};
1832
1833template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
1834 bool = is_volatile<typename remove_reference<_Tp>::type>::value>
1835struct __apply_cv
1836{
1837 typedef _Up type;
1838};
1839
1840template <class _Tp, class _Up>
1841struct __apply_cv<_Tp, _Up, true, false>
1842{
1843 typedef const _Up type;
1844};
1845
1846template <class _Tp, class _Up>
1847struct __apply_cv<_Tp, _Up, false, true>
1848{
1849 typedef volatile _Up type;
1850};
1851
1852template <class _Tp, class _Up>
1853struct __apply_cv<_Tp, _Up, true, true>
1854{
1855 typedef const volatile _Up type;
1856};
1857
1858template <class _Tp, class _Up>
1859struct __apply_cv<_Tp&, _Up, false, false>
1860{
1861 typedef _Up& type;
1862};
1863
1864template <class _Tp, class _Up>
1865struct __apply_cv<_Tp&, _Up, true, false>
1866{
1867 typedef const _Up& type;
1868};
1869
1870template <class _Tp, class _Up>
1871struct __apply_cv<_Tp&, _Up, false, true>
1872{
1873 typedef volatile _Up& type;
1874};
1875
1876template <class _Tp, class _Up>
1877struct __apply_cv<_Tp&, _Up, true, true>
1878{
1879 typedef const volatile _Up& type;
1880};
1881
1882template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1883struct __make_signed {};
1884
1885template <class _Tp>
1886struct __make_signed<_Tp, true>
1887{
1888 typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
1889};
1890
1891template <> struct __make_signed<bool, true> {};
1892template <> struct __make_signed< signed short, true> {typedef short type;};
1893template <> struct __make_signed<unsigned short, true> {typedef short type;};
1894template <> struct __make_signed< signed int, true> {typedef int type;};
1895template <> struct __make_signed<unsigned int, true> {typedef int type;};
1896template <> struct __make_signed< signed long, true> {typedef long type;};
1897template <> struct __make_signed<unsigned long, true> {typedef long type;};
1898template <> struct __make_signed< signed long long, true> {typedef long long type;};
1899template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
Stephan Tolksdorf8a71d232014-03-26 19:45:52 +00001900#ifndef _LIBCPP_HAS_NO_INT128
1901template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;};
1902template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;};
1903#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001904
1905template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001906struct _LIBCPP_TYPE_VIS_ONLY make_signed
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001907{
1908 typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
1909};
1910
Marshall Clow933afa92013-07-04 00:10:01 +00001911#if _LIBCPP_STD_VER > 11
1912template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
1913#endif
1914
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001915template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1916struct __make_unsigned {};
1917
1918template <class _Tp>
1919struct __make_unsigned<_Tp, true>
1920{
1921 typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
1922};
1923
1924template <> struct __make_unsigned<bool, true> {};
1925template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;};
1926template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;};
1927template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;};
1928template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;};
1929template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;};
1930template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;};
1931template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;};
1932template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
Stephan Tolksdorf8a71d232014-03-26 19:45:52 +00001933#ifndef _LIBCPP_HAS_NO_INT128
1934template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;};
1935template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;};
1936#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001937
1938template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001939struct _LIBCPP_TYPE_VIS_ONLY make_unsigned
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001940{
1941 typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
1942};
1943
Marshall Clow933afa92013-07-04 00:10:01 +00001944#if _LIBCPP_STD_VER > 11
1945template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
1946#endif
1947
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001948#ifdef _LIBCPP_HAS_NO_VARIADICS
1949
Marshall Clow60279932015-01-09 17:03:36 +00001950template <class _Tp, class _Up = void, class _Vp = void>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001951struct _LIBCPP_TYPE_VIS_ONLY common_type
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001952{
1953public:
Marshall Clow60279932015-01-09 17:03:36 +00001954 typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp>::type type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001955};
1956
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001957template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001958struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, void, void>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001959{
1960public:
Marshall Clow71e699d2014-02-10 17:40:28 +00001961 typedef typename decay<_Tp>::type type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001962};
1963
1964template <class _Tp, class _Up>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001965struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, void>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001966{
Eric Fiselier65a6f642015-09-08 00:13:57 +00001967 typedef typename decay<decltype(
1968 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
1969 )>::type type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001970};
1971
Howard Hinnant324bb032010-08-22 00:02:43 +00001972#else // _LIBCPP_HAS_NO_VARIADICS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001973
Eric Fiselier65a6f642015-09-08 00:13:57 +00001974// bullet 1 - sizeof...(Tp) == 0
1975
1976template <class ..._Tp>
1977struct _LIBCPP_TYPE_VIS_ONLY common_type {};
1978
1979// bullet 2 - sizeof...(Tp) == 1
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001980
1981template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001982struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001983{
Marshall Clowdab89a12013-10-07 23:43:33 +00001984 typedef typename decay<_Tp>::type type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001985};
1986
Eric Fiselier65a6f642015-09-08 00:13:57 +00001987// bullet 3 - sizeof...(Tp) == 2
1988
1989template <class _Tp, class _Up, class = void>
1990struct __common_type2 {};
1991
1992template <class _Tp, class _Up>
1993struct __common_type2<_Tp, _Up,
1994 typename __void_t<decltype(
1995 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
1996 )>::type>
1997{
1998 typedef typename decay<decltype(
1999 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
2000 )>::type type;
2001};
2002
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002003template <class _Tp, class _Up>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002004struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up>
Eric Fiselier65a6f642015-09-08 00:13:57 +00002005 : __common_type2<_Tp, _Up> {};
2006
2007// bullet 4 - sizeof...(Tp) > 2
2008
2009template <class ...Tp> struct __common_types;
2010
2011template <class, class = void>
2012struct __common_type_impl {};
2013
2014template <class _Tp, class _Up, class ..._Vp>
2015struct __common_type_impl<__common_types<_Tp, _Up, _Vp...>,
2016 typename __void_t<typename common_type<_Tp, _Up>::type>::type>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002017{
Eric Fiselier65a6f642015-09-08 00:13:57 +00002018 typedef typename common_type<
2019 typename common_type<_Tp, _Up>::type, _Vp...
2020 >::type type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002021};
2022
2023template <class _Tp, class _Up, class ..._Vp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002024struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, _Vp...>
Eric Fiselier65a6f642015-09-08 00:13:57 +00002025 : __common_type_impl<__common_types<_Tp, _Up, _Vp...> > {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002026
Marshall Clow933afa92013-07-04 00:10:01 +00002027#if _LIBCPP_STD_VER > 11
2028template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type;
2029#endif
2030
Howard Hinnant324bb032010-08-22 00:02:43 +00002031#endif // _LIBCPP_HAS_NO_VARIADICS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002032
Howard Hinnant1468b662010-11-19 22:17:28 +00002033// is_assignable
2034
Joerg Sonnenbergerbfaafd52013-11-25 22:44:20 +00002035template<typename, typename _Tp> struct __select_2nd { typedef _Tp type; };
Howard Hinnant01afa5c2013-09-02 20:30:37 +00002036
Howard Hinnant745d4732010-09-08 17:55:32 +00002037template <class _Tp, class _Arg>
Howard Hinnant01afa5c2013-09-02 20:30:37 +00002038typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type
Eric Fiselier602fe152016-07-25 02:08:55 +00002039__is_assignable_test(int);
Howard Hinnant745d4732010-09-08 17:55:32 +00002040
Eric Fiselier602fe152016-07-25 02:08:55 +00002041template <class, class>
2042false_type __is_assignable_test(...);
2043
Howard Hinnant745d4732010-09-08 17:55:32 +00002044
Howard Hinnant6063ec12011-05-13 14:08:16 +00002045template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
Howard Hinnant745d4732010-09-08 17:55:32 +00002046struct __is_assignable_imp
Eric Fiselier602fe152016-07-25 02:08:55 +00002047 : public decltype((_VSTD::__is_assignable_test<_Tp, _Arg>(0))) {};
Howard Hinnant745d4732010-09-08 17:55:32 +00002048
2049template <class _Tp, class _Arg>
Howard Hinnant6063ec12011-05-13 14:08:16 +00002050struct __is_assignable_imp<_Tp, _Arg, true>
2051 : public false_type
2052{
2053};
2054
2055template <class _Tp, class _Arg>
Howard Hinnant1468b662010-11-19 22:17:28 +00002056struct is_assignable
Howard Hinnant745d4732010-09-08 17:55:32 +00002057 : public __is_assignable_imp<_Tp, _Arg> {};
2058
Marshall Clow6455d852015-11-07 17:44:36 +00002059#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2060template <class _Tp, class _Arg> _LIBCPP_CONSTEXPR bool is_assignable_v
2061 = is_assignable<_Tp, _Arg>::value;
2062#endif
2063
Howard Hinnant1468b662010-11-19 22:17:28 +00002064// is_copy_assignable
Howard Hinnant745d4732010-09-08 17:55:32 +00002065
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002066template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_copy_assignable
Howard Hinnant6063ec12011-05-13 14:08:16 +00002067 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
Marshall Clowd132bf42014-09-22 23:58:00 +00002068 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
Howard Hinnant745d4732010-09-08 17:55:32 +00002069
Marshall Clow6455d852015-11-07 17:44:36 +00002070#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2071template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_assignable_v
2072 = is_copy_assignable<_Tp>::value;
2073#endif
2074
Howard Hinnant1468b662010-11-19 22:17:28 +00002075// is_move_assignable
2076
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002077template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_move_assignable
Howard Hinnant1468b662010-11-19 22:17:28 +00002078#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant6063ec12011-05-13 14:08:16 +00002079 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
2080 const typename add_rvalue_reference<_Tp>::type> {};
Howard Hinnant1468b662010-11-19 22:17:28 +00002081#else
2082 : public is_copy_assignable<_Tp> {};
2083#endif
2084
Marshall Clow6455d852015-11-07 17:44:36 +00002085#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2086template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_assignable_v
2087 = is_move_assignable<_Tp>::value;
2088#endif
2089
Howard Hinnant1468b662010-11-19 22:17:28 +00002090// is_destructible
2091
Marshall Clow38d90052014-10-18 11:03:33 +00002092// if it's a reference, return true
2093// if it's a function, return false
2094// if it's void, return false
2095// if it's an array of unknown bound, return false
2096// Otherwise, return "std::declval<_Up&>().~_Up()" is well-formed
Marshall Clow2b44e3d2014-07-16 15:51:50 +00002097// where _Up is remove_all_extents<_Tp>::type
2098
Eric Fiselier6f8821d2014-07-31 19:09:26 +00002099template <class>
2100struct __is_destructible_apply { typedef int type; };
2101
Marshall Clow2b44e3d2014-07-16 15:51:50 +00002102template <typename _Tp>
2103struct __is_destructor_wellformed {
Marshall Clow38d90052014-10-18 11:03:33 +00002104 template <typename _Tp1>
2105 static char __test (
Eric Fiselier6f8821d2014-07-31 19:09:26 +00002106 typename __is_destructible_apply<decltype(_VSTD::declval<_Tp1&>().~_Tp1())>::type
2107 );
Marshall Clow2b44e3d2014-07-16 15:51:50 +00002108
Marshall Clow38d90052014-10-18 11:03:33 +00002109 template <typename _Tp1>
2110 static __two __test (...);
2111
2112 static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char);
Eric Fiselier6f8821d2014-07-31 19:09:26 +00002113};
Marshall Clow2b44e3d2014-07-16 15:51:50 +00002114
2115template <class _Tp, bool>
2116struct __destructible_imp;
Howard Hinnant1468b662010-11-19 22:17:28 +00002117
2118template <class _Tp>
Marshall Clow2b44e3d2014-07-16 15:51:50 +00002119struct __destructible_imp<_Tp, false>
2120 : public _VSTD::integral_constant<bool,
2121 __is_destructor_wellformed<typename _VSTD::remove_all_extents<_Tp>::type>::value> {};
Howard Hinnant1468b662010-11-19 22:17:28 +00002122
2123template <class _Tp>
2124struct __destructible_imp<_Tp, true>
Marshall Clow2b44e3d2014-07-16 15:51:50 +00002125 : public _VSTD::true_type {};
2126
2127template <class _Tp, bool>
2128struct __destructible_false;
2129
2130template <class _Tp>
2131struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, _VSTD::is_reference<_Tp>::value> {};
2132
2133template <class _Tp>
2134struct __destructible_false<_Tp, true> : public _VSTD::false_type {};
Howard Hinnant745d4732010-09-08 17:55:32 +00002135
Howard Hinnant1468b662010-11-19 22:17:28 +00002136template <class _Tp>
2137struct is_destructible
Marshall Clow2b44e3d2014-07-16 15:51:50 +00002138 : public __destructible_false<_Tp, _VSTD::is_function<_Tp>::value> {};
Howard Hinnant745d4732010-09-08 17:55:32 +00002139
Howard Hinnant80e19ac2013-08-09 16:53:45 +00002140template <class _Tp>
2141struct is_destructible<_Tp[]>
Marshall Clow2b44e3d2014-07-16 15:51:50 +00002142 : public _VSTD::false_type {};
2143
2144template <>
2145struct is_destructible<void>
2146 : public _VSTD::false_type {};
Howard Hinnant80e19ac2013-08-09 16:53:45 +00002147
Marshall Clow6455d852015-11-07 17:44:36 +00002148#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2149template <class _Tp> _LIBCPP_CONSTEXPR bool is_destructible_v
2150 = is_destructible<_Tp>::value;
2151#endif
2152
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002153// move
2154
Howard Hinnant73d21a42010-09-04 23:28:19 +00002155#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002156
2157template <class _Tp>
Marshall Clow01a0e902013-07-15 20:46:11 +00002158inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002159typename remove_reference<_Tp>::type&&
Howard Hinnante9b2c2d2011-05-27 15:04:19 +00002160move(_Tp&& __t) _NOEXCEPT
Howard Hinnant60a0a8e2010-08-10 20:48:29 +00002161{
Howard Hinnant726a76f2010-11-16 21:10:23 +00002162 typedef typename remove_reference<_Tp>::type _Up;
2163 return static_cast<_Up&&>(__t);
Howard Hinnant60a0a8e2010-08-10 20:48:29 +00002164}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002165
Howard Hinnantd2a92512010-09-13 01:43:27 +00002166template <class _Tp>
Marshall Clow01a0e902013-07-15 20:46:11 +00002167inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantd2a92512010-09-13 01:43:27 +00002168_Tp&&
Eric Fiselier14273e82016-05-18 23:09:24 +00002169forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT
Howard Hinnantd2a92512010-09-13 01:43:27 +00002170{
2171 return static_cast<_Tp&&>(__t);
2172}
2173
2174template <class _Tp>
Marshall Clow01a0e902013-07-15 20:46:11 +00002175inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantd2a92512010-09-13 01:43:27 +00002176_Tp&&
Eric Fiselier14273e82016-05-18 23:09:24 +00002177forward(typename remove_reference<_Tp>::type&& __t) _NOEXCEPT
Howard Hinnantd2a92512010-09-13 01:43:27 +00002178{
Eric Fiselier14273e82016-05-18 23:09:24 +00002179 static_assert(!is_lvalue_reference<_Tp>::value,
Howard Hinnant8db4aca2011-10-17 20:08:59 +00002180 "Can not forward an rvalue as an lvalue.");
2181 return static_cast<_Tp&&>(__t);
Howard Hinnantd2a92512010-09-13 01:43:27 +00002182}
2183
Howard Hinnant73d21a42010-09-04 23:28:19 +00002184#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002185
Howard Hinnantd8bc09b2010-05-18 17:32:30 +00002186template <class _Tp>
Howard Hinnant87073e42012-05-01 15:37:54 +00002187inline _LIBCPP_INLINE_VISIBILITY
2188_Tp&
2189move(_Tp& __t)
2190{
2191 return __t;
2192}
2193
2194template <class _Tp>
2195inline _LIBCPP_INLINE_VISIBILITY
2196const _Tp&
2197move(const _Tp& __t)
2198{
2199 return __t;
2200}
2201
2202template <class _Tp>
2203inline _LIBCPP_INLINE_VISIBILITY
2204_Tp&
Eric Fiselier14273e82016-05-18 23:09:24 +00002205forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT
Howard Hinnant87073e42012-05-01 15:37:54 +00002206{
2207 return __t;
2208}
2209
2210
2211template <class _Tp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002212class __rv
2213{
Howard Hinnantd8bc09b2010-05-18 17:32:30 +00002214 typedef typename remove_reference<_Tp>::type _Trr;
2215 _Trr& t_;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002216public:
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002217 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantd8bc09b2010-05-18 17:32:30 +00002218 _Trr* operator->() {return &t_;}
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002219 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantd8bc09b2010-05-18 17:32:30 +00002220 explicit __rv(_Trr& __t) : t_(__t) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002221};
2222
Howard Hinnant73d21a42010-09-04 23:28:19 +00002223#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002224
Howard Hinnantd4b95782011-06-19 19:12:59 +00002225#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2226
Howard Hinnant656bdc32011-05-16 18:40:35 +00002227template <class _Tp>
2228inline _LIBCPP_INLINE_VISIBILITY
2229typename decay<_Tp>::type
2230__decay_copy(_Tp&& __t)
2231{
Howard Hinnant0949eed2011-06-30 21:18:19 +00002232 return _VSTD::forward<_Tp>(__t);
Howard Hinnant656bdc32011-05-16 18:40:35 +00002233}
2234
Howard Hinnantd4b95782011-06-19 19:12:59 +00002235#else
2236
2237template <class _Tp>
2238inline _LIBCPP_INLINE_VISIBILITY
2239typename decay<_Tp>::type
2240__decay_copy(const _Tp& __t)
2241{
Howard Hinnant0949eed2011-06-30 21:18:19 +00002242 return _VSTD::forward<_Tp>(__t);
Howard Hinnantd4b95782011-06-19 19:12:59 +00002243}
2244
2245#endif
2246
Howard Hinnant37c53b62011-05-16 16:17:21 +00002247#ifndef _LIBCPP_HAS_NO_VARIADICS
2248
Howard Hinnant99968442011-11-29 18:15:50 +00002249template <class _Rp, class _Class, class ..._Param>
2250struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002251{
2252 typedef _Class _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002253 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002254 typedef _Rp (_FnType) (_Param...);
Howard Hinnant37c53b62011-05-16 16:17:21 +00002255};
2256
Howard Hinnant99968442011-11-29 18:15:50 +00002257template <class _Rp, class _Class, class ..._Param>
Eric Fiselier63648cf2014-08-19 16:31:47 +00002258struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false>
2259{
2260 typedef _Class _ClassType;
2261 typedef _Rp _ReturnType;
2262 typedef _Rp (_FnType) (_Param..., ...);
2263};
2264
2265template <class _Rp, class _Class, class ..._Param>
Howard Hinnant99968442011-11-29 18:15:50 +00002266struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002267{
2268 typedef _Class const _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002269 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002270 typedef _Rp (_FnType) (_Param...);
Howard Hinnant37c53b62011-05-16 16:17:21 +00002271};
2272
Howard Hinnant99968442011-11-29 18:15:50 +00002273template <class _Rp, class _Class, class ..._Param>
Eric Fiselier63648cf2014-08-19 16:31:47 +00002274struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false>
2275{
2276 typedef _Class const _ClassType;
2277 typedef _Rp _ReturnType;
2278 typedef _Rp (_FnType) (_Param..., ...);
2279};
2280
2281template <class _Rp, class _Class, class ..._Param>
Howard Hinnant99968442011-11-29 18:15:50 +00002282struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002283{
2284 typedef _Class volatile _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002285 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002286 typedef _Rp (_FnType) (_Param...);
Howard Hinnant37c53b62011-05-16 16:17:21 +00002287};
2288
Howard Hinnant99968442011-11-29 18:15:50 +00002289template <class _Rp, class _Class, class ..._Param>
Eric Fiselier63648cf2014-08-19 16:31:47 +00002290struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false>
2291{
2292 typedef _Class volatile _ClassType;
2293 typedef _Rp _ReturnType;
2294 typedef _Rp (_FnType) (_Param..., ...);
2295};
2296
2297template <class _Rp, class _Class, class ..._Param>
Howard Hinnant99968442011-11-29 18:15:50 +00002298struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002299{
2300 typedef _Class const volatile _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002301 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002302 typedef _Rp (_FnType) (_Param...);
Howard Hinnant37c53b62011-05-16 16:17:21 +00002303};
2304
Eric Fiselier63648cf2014-08-19 16:31:47 +00002305template <class _Rp, class _Class, class ..._Param>
2306struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false>
2307{
2308 typedef _Class const volatile _ClassType;
2309 typedef _Rp _ReturnType;
2310 typedef _Rp (_FnType) (_Param..., ...);
2311};
2312
Eric Fiseliereeeada12015-06-13 02:18:44 +00002313#if __has_feature(cxx_reference_qualified_functions) || \
2314 (defined(_GNUC_VER) && _GNUC_VER >= 409)
Howard Hinnant37c53b62011-05-16 16:17:21 +00002315
Howard Hinnant99968442011-11-29 18:15:50 +00002316template <class _Rp, class _Class, class ..._Param>
2317struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002318{
2319 typedef _Class& _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002320 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002321 typedef _Rp (_FnType) (_Param...);
Howard Hinnant37c53b62011-05-16 16:17:21 +00002322};
2323
Howard Hinnant99968442011-11-29 18:15:50 +00002324template <class _Rp, class _Class, class ..._Param>
Eric Fiselier63648cf2014-08-19 16:31:47 +00002325struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false>
2326{
2327 typedef _Class& _ClassType;
2328 typedef _Rp _ReturnType;
2329 typedef _Rp (_FnType) (_Param..., ...);
2330};
2331
2332template <class _Rp, class _Class, class ..._Param>
Howard Hinnant99968442011-11-29 18:15:50 +00002333struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002334{
2335 typedef _Class const& _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002336 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002337 typedef _Rp (_FnType) (_Param...);
Howard Hinnant37c53b62011-05-16 16:17:21 +00002338};
2339
Howard Hinnant99968442011-11-29 18:15:50 +00002340template <class _Rp, class _Class, class ..._Param>
Eric Fiselier63648cf2014-08-19 16:31:47 +00002341struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false>
2342{
2343 typedef _Class const& _ClassType;
2344 typedef _Rp _ReturnType;
2345 typedef _Rp (_FnType) (_Param..., ...);
2346};
2347
2348template <class _Rp, class _Class, class ..._Param>
Howard Hinnant99968442011-11-29 18:15:50 +00002349struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002350{
2351 typedef _Class volatile& _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002352 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002353 typedef _Rp (_FnType) (_Param...);
Howard Hinnant37c53b62011-05-16 16:17:21 +00002354};
2355
Howard Hinnant99968442011-11-29 18:15:50 +00002356template <class _Rp, class _Class, class ..._Param>
Eric Fiselier63648cf2014-08-19 16:31:47 +00002357struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false>
2358{
2359 typedef _Class volatile& _ClassType;
2360 typedef _Rp _ReturnType;
2361 typedef _Rp (_FnType) (_Param..., ...);
2362};
2363
2364template <class _Rp, class _Class, class ..._Param>
Howard Hinnant99968442011-11-29 18:15:50 +00002365struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002366{
2367 typedef _Class const volatile& _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002368 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002369 typedef _Rp (_FnType) (_Param...);
Howard Hinnant37c53b62011-05-16 16:17:21 +00002370};
2371
Howard Hinnant99968442011-11-29 18:15:50 +00002372template <class _Rp, class _Class, class ..._Param>
Eric Fiselier63648cf2014-08-19 16:31:47 +00002373struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false>
2374{
2375 typedef _Class const volatile& _ClassType;
2376 typedef _Rp _ReturnType;
2377 typedef _Rp (_FnType) (_Param..., ...);
2378};
2379
2380template <class _Rp, class _Class, class ..._Param>
Howard Hinnant99968442011-11-29 18:15:50 +00002381struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002382{
2383 typedef _Class&& _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002384 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002385 typedef _Rp (_FnType) (_Param...);
Howard Hinnant37c53b62011-05-16 16:17:21 +00002386};
2387
Howard Hinnant99968442011-11-29 18:15:50 +00002388template <class _Rp, class _Class, class ..._Param>
Eric Fiselier63648cf2014-08-19 16:31:47 +00002389struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false>
2390{
2391 typedef _Class&& _ClassType;
2392 typedef _Rp _ReturnType;
2393 typedef _Rp (_FnType) (_Param..., ...);
2394};
2395
2396template <class _Rp, class _Class, class ..._Param>
Howard Hinnant99968442011-11-29 18:15:50 +00002397struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002398{
2399 typedef _Class const&& _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002400 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002401 typedef _Rp (_FnType) (_Param...);
Howard Hinnant37c53b62011-05-16 16:17:21 +00002402};
2403
Howard Hinnant99968442011-11-29 18:15:50 +00002404template <class _Rp, class _Class, class ..._Param>
Eric Fiselier63648cf2014-08-19 16:31:47 +00002405struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false>
2406{
2407 typedef _Class const&& _ClassType;
2408 typedef _Rp _ReturnType;
2409 typedef _Rp (_FnType) (_Param..., ...);
2410};
2411
2412template <class _Rp, class _Class, class ..._Param>
Howard Hinnant99968442011-11-29 18:15:50 +00002413struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002414{
2415 typedef _Class volatile&& _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002416 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002417 typedef _Rp (_FnType) (_Param...);
Howard Hinnant37c53b62011-05-16 16:17:21 +00002418};
2419
Howard Hinnant99968442011-11-29 18:15:50 +00002420template <class _Rp, class _Class, class ..._Param>
Eric Fiselier63648cf2014-08-19 16:31:47 +00002421struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false>
2422{
2423 typedef _Class volatile&& _ClassType;
2424 typedef _Rp _ReturnType;
2425 typedef _Rp (_FnType) (_Param..., ...);
2426};
2427
2428template <class _Rp, class _Class, class ..._Param>
Howard Hinnant99968442011-11-29 18:15:50 +00002429struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002430{
2431 typedef _Class const volatile&& _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002432 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002433 typedef _Rp (_FnType) (_Param...);
Howard Hinnant37c53b62011-05-16 16:17:21 +00002434};
2435
Eric Fiselier63648cf2014-08-19 16:31:47 +00002436template <class _Rp, class _Class, class ..._Param>
2437struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false>
2438{
2439 typedef _Class const volatile&& _ClassType;
2440 typedef _Rp _ReturnType;
2441 typedef _Rp (_FnType) (_Param..., ...);
2442};
2443
Eric Fiseliereeeada12015-06-13 02:18:44 +00002444#endif // __has_feature(cxx_reference_qualified_functions) || _GNUC_VER >= 409
Howard Hinnant37c53b62011-05-16 16:17:21 +00002445
2446#else // _LIBCPP_HAS_NO_VARIADICS
2447
Howard Hinnant99968442011-11-29 18:15:50 +00002448template <class _Rp, class _Class>
2449struct __member_pointer_traits_imp<_Rp (_Class::*)(), true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002450{
2451 typedef _Class _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002452 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002453 typedef _Rp (_FnType) ();
Howard Hinnant37c53b62011-05-16 16:17:21 +00002454};
2455
Eric Fiselier63648cf2014-08-19 16:31:47 +00002456template <class _Rp, class _Class>
2457struct __member_pointer_traits_imp<_Rp (_Class::*)(...), true, false>
2458{
2459 typedef _Class _ClassType;
2460 typedef _Rp _ReturnType;
2461 typedef _Rp (_FnType) (...);
2462};
2463
Howard Hinnant99968442011-11-29 18:15:50 +00002464template <class _Rp, class _Class, class _P0>
2465struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002466{
2467 typedef _Class _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002468 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002469 typedef _Rp (_FnType) (_P0);
Howard Hinnant37c53b62011-05-16 16:17:21 +00002470};
2471
Eric Fiselier63648cf2014-08-19 16:31:47 +00002472template <class _Rp, class _Class, class _P0>
2473struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...), true, false>
2474{
2475 typedef _Class _ClassType;
2476 typedef _Rp _ReturnType;
2477 typedef _Rp (_FnType) (_P0, ...);
2478};
2479
Howard Hinnant99968442011-11-29 18:15:50 +00002480template <class _Rp, class _Class, class _P0, class _P1>
2481struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002482{
2483 typedef _Class _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002484 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002485 typedef _Rp (_FnType) (_P0, _P1);
Howard Hinnant37c53b62011-05-16 16:17:21 +00002486};
2487
Eric Fiselier63648cf2014-08-19 16:31:47 +00002488template <class _Rp, class _Class, class _P0, class _P1>
2489struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...), true, false>
2490{
2491 typedef _Class _ClassType;
2492 typedef _Rp _ReturnType;
2493 typedef _Rp (_FnType) (_P0, _P1, ...);
2494};
2495
Howard Hinnant99968442011-11-29 18:15:50 +00002496template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2497struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002498{
2499 typedef _Class _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002500 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002501 typedef _Rp (_FnType) (_P0, _P1, _P2);
Howard Hinnant37c53b62011-05-16 16:17:21 +00002502};
2503
Eric Fiselier63648cf2014-08-19 16:31:47 +00002504template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2505struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...), true, false>
2506{
2507 typedef _Class _ClassType;
2508 typedef _Rp _ReturnType;
2509 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2510};
2511
Howard Hinnant99968442011-11-29 18:15:50 +00002512template <class _Rp, class _Class>
2513struct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002514{
2515 typedef _Class const _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002516 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002517 typedef _Rp (_FnType) ();
Howard Hinnant37c53b62011-05-16 16:17:21 +00002518};
2519
Eric Fiselier63648cf2014-08-19 16:31:47 +00002520template <class _Rp, class _Class>
2521struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const, true, false>
2522{
2523 typedef _Class const _ClassType;
2524 typedef _Rp _ReturnType;
2525 typedef _Rp (_FnType) (...);
2526};
2527
Howard Hinnant99968442011-11-29 18:15:50 +00002528template <class _Rp, class _Class, class _P0>
2529struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002530{
2531 typedef _Class const _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002532 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002533 typedef _Rp (_FnType) (_P0);
Howard Hinnant37c53b62011-05-16 16:17:21 +00002534};
2535
Eric Fiselier63648cf2014-08-19 16:31:47 +00002536template <class _Rp, class _Class, class _P0>
2537struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const, true, false>
2538{
2539 typedef _Class const _ClassType;
2540 typedef _Rp _ReturnType;
2541 typedef _Rp (_FnType) (_P0, ...);
2542};
2543
Howard Hinnant99968442011-11-29 18:15:50 +00002544template <class _Rp, class _Class, class _P0, class _P1>
2545struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002546{
2547 typedef _Class const _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002548 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002549 typedef _Rp (_FnType) (_P0, _P1);
Howard Hinnant37c53b62011-05-16 16:17:21 +00002550};
2551
Eric Fiselier63648cf2014-08-19 16:31:47 +00002552template <class _Rp, class _Class, class _P0, class _P1>
2553struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const, true, false>
2554{
2555 typedef _Class const _ClassType;
2556 typedef _Rp _ReturnType;
2557 typedef _Rp (_FnType) (_P0, _P1, ...);
2558};
2559
Howard Hinnant99968442011-11-29 18:15:50 +00002560template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2561struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002562{
2563 typedef _Class const _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002564 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002565 typedef _Rp (_FnType) (_P0, _P1, _P2);
Howard Hinnant37c53b62011-05-16 16:17:21 +00002566};
2567
Eric Fiselier63648cf2014-08-19 16:31:47 +00002568template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2569struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const, true, false>
2570{
2571 typedef _Class const _ClassType;
2572 typedef _Rp _ReturnType;
2573 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2574};
2575
Howard Hinnant99968442011-11-29 18:15:50 +00002576template <class _Rp, class _Class>
2577struct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002578{
2579 typedef _Class volatile _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002580 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002581 typedef _Rp (_FnType) ();
Howard Hinnant37c53b62011-05-16 16:17:21 +00002582};
2583
Eric Fiselier63648cf2014-08-19 16:31:47 +00002584template <class _Rp, class _Class>
2585struct __member_pointer_traits_imp<_Rp (_Class::*)(...) volatile, true, false>
2586{
2587 typedef _Class volatile _ClassType;
2588 typedef _Rp _ReturnType;
2589 typedef _Rp (_FnType) (...);
2590};
2591
Howard Hinnant99968442011-11-29 18:15:50 +00002592template <class _Rp, class _Class, class _P0>
2593struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002594{
2595 typedef _Class volatile _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002596 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002597 typedef _Rp (_FnType) (_P0);
Howard Hinnant37c53b62011-05-16 16:17:21 +00002598};
2599
Eric Fiselier63648cf2014-08-19 16:31:47 +00002600template <class _Rp, class _Class, class _P0>
2601struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) volatile, true, false>
2602{
2603 typedef _Class volatile _ClassType;
2604 typedef _Rp _ReturnType;
2605 typedef _Rp (_FnType) (_P0, ...);
2606};
2607
Howard Hinnant99968442011-11-29 18:15:50 +00002608template <class _Rp, class _Class, class _P0, class _P1>
2609struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002610{
2611 typedef _Class volatile _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002612 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002613 typedef _Rp (_FnType) (_P0, _P1);
Howard Hinnant37c53b62011-05-16 16:17:21 +00002614};
2615
Eric Fiselier63648cf2014-08-19 16:31:47 +00002616template <class _Rp, class _Class, class _P0, class _P1>
2617struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) volatile, true, false>
2618{
2619 typedef _Class volatile _ClassType;
2620 typedef _Rp _ReturnType;
2621 typedef _Rp (_FnType) (_P0, _P1, ...);
2622};
2623
Howard Hinnant99968442011-11-29 18:15:50 +00002624template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2625struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002626{
2627 typedef _Class volatile _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002628 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002629 typedef _Rp (_FnType) (_P0, _P1, _P2);
Howard Hinnant37c53b62011-05-16 16:17:21 +00002630};
2631
Eric Fiselier63648cf2014-08-19 16:31:47 +00002632template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2633struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) volatile, true, false>
2634{
2635 typedef _Class volatile _ClassType;
2636 typedef _Rp _ReturnType;
2637 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2638};
2639
Howard Hinnant99968442011-11-29 18:15:50 +00002640template <class _Rp, class _Class>
2641struct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002642{
2643 typedef _Class const volatile _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002644 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002645 typedef _Rp (_FnType) ();
Howard Hinnant37c53b62011-05-16 16:17:21 +00002646};
2647
Eric Fiselier63648cf2014-08-19 16:31:47 +00002648template <class _Rp, class _Class>
2649struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const volatile, true, false>
2650{
2651 typedef _Class const volatile _ClassType;
2652 typedef _Rp _ReturnType;
2653 typedef _Rp (_FnType) (...);
2654};
2655
Howard Hinnant99968442011-11-29 18:15:50 +00002656template <class _Rp, class _Class, class _P0>
2657struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002658{
2659 typedef _Class const volatile _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002660 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002661 typedef _Rp (_FnType) (_P0);
Howard Hinnant37c53b62011-05-16 16:17:21 +00002662};
2663
Eric Fiselier63648cf2014-08-19 16:31:47 +00002664template <class _Rp, class _Class, class _P0>
2665struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const volatile, true, false>
2666{
2667 typedef _Class const volatile _ClassType;
2668 typedef _Rp _ReturnType;
2669 typedef _Rp (_FnType) (_P0, ...);
2670};
2671
Howard Hinnant99968442011-11-29 18:15:50 +00002672template <class _Rp, class _Class, class _P0, class _P1>
2673struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002674{
2675 typedef _Class const volatile _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002676 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002677 typedef _Rp (_FnType) (_P0, _P1);
Howard Hinnant37c53b62011-05-16 16:17:21 +00002678};
2679
Eric Fiselier63648cf2014-08-19 16:31:47 +00002680template <class _Rp, class _Class, class _P0, class _P1>
2681struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const volatile, true, false>
2682{
2683 typedef _Class const volatile _ClassType;
2684 typedef _Rp _ReturnType;
2685 typedef _Rp (_FnType) (_P0, _P1, ...);
2686};
2687
Howard Hinnant99968442011-11-29 18:15:50 +00002688template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2689struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile, true, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002690{
2691 typedef _Class const volatile _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002692 typedef _Rp _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002693 typedef _Rp (_FnType) (_P0, _P1, _P2);
Howard Hinnant37c53b62011-05-16 16:17:21 +00002694};
2695
Eric Fiselier63648cf2014-08-19 16:31:47 +00002696template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2697struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const volatile, true, false>
2698{
2699 typedef _Class const volatile _ClassType;
2700 typedef _Rp _ReturnType;
2701 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2702};
2703
Howard Hinnant37c53b62011-05-16 16:17:21 +00002704#endif // _LIBCPP_HAS_NO_VARIADICS
2705
Howard Hinnant99968442011-11-29 18:15:50 +00002706template <class _Rp, class _Class>
2707struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002708{
2709 typedef _Class _ClassType;
Howard Hinnant99968442011-11-29 18:15:50 +00002710 typedef _Rp _ReturnType;
Howard Hinnant37c53b62011-05-16 16:17:21 +00002711};
2712
2713template <class _MP>
2714struct __member_pointer_traits
Howard Hinnant6287c652013-05-15 21:49:27 +00002715 : public __member_pointer_traits_imp<typename remove_cv<_MP>::type,
Howard Hinnant37c53b62011-05-16 16:17:21 +00002716 is_member_function_pointer<_MP>::value,
2717 is_member_object_pointer<_MP>::value>
2718{
2719// typedef ... _ClassType;
2720// typedef ... _ReturnType;
Marshall Clow4f3368e2014-05-29 01:10:28 +00002721// typedef ... _FnType;
Howard Hinnant37c53b62011-05-16 16:17:21 +00002722};
2723
Eric Fiselier8d5cbd72016-04-20 00:14:32 +00002724
2725template <class _DecayedFp>
2726struct __member_pointer_class_type {};
2727
2728template <class _Ret, class _ClassType>
2729struct __member_pointer_class_type<_Ret _ClassType::*> {
2730 typedef _ClassType type;
2731};
2732
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002733// result_of
2734
Howard Hinnant2b1b2d42011-06-14 19:58:17 +00002735template <class _Callable> class result_of;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002736
Howard Hinnant2d622292012-06-26 17:37:15 +00002737#ifdef _LIBCPP_HAS_NO_VARIADICS
2738
Howard Hinnant37c53b62011-05-16 16:17:21 +00002739template <class _Fn, bool, bool>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002740class __result_of
2741{
2742};
2743
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002744template <class _Fn>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002745class __result_of<_Fn(), true, false>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002746{
2747public:
2748 typedef decltype(declval<_Fn>()()) type;
2749};
2750
2751template <class _Fn, class _A0>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002752class __result_of<_Fn(_A0), true, false>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002753{
2754public:
2755 typedef decltype(declval<_Fn>()(declval<_A0>())) type;
2756};
2757
2758template <class _Fn, class _A0, class _A1>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002759class __result_of<_Fn(_A0, _A1), true, false>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002760{
2761public:
2762 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type;
2763};
2764
2765template <class _Fn, class _A0, class _A1, class _A2>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002766class __result_of<_Fn(_A0, _A1, _A2), true, false>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002767{
2768public:
2769 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type;
2770};
2771
Howard Hinnant37c53b62011-05-16 16:17:21 +00002772template <class _MP, class _Tp, bool _IsMemberFunctionPtr>
2773struct __result_of_mp;
2774
2775// member function pointer
2776
2777template <class _MP, class _Tp>
2778struct __result_of_mp<_MP, _Tp, true>
Eric Fiselier49835802015-06-13 08:25:24 +00002779 : public __identity<typename __member_pointer_traits<_MP>::_ReturnType>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002780{
2781};
2782
2783// member data pointer
2784
2785template <class _MP, class _Tp, bool>
2786struct __result_of_mdp;
2787
Howard Hinnant99968442011-11-29 18:15:50 +00002788template <class _Rp, class _Class, class _Tp>
2789struct __result_of_mdp<_Rp _Class::*, _Tp, false>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002790{
Howard Hinnant99968442011-11-29 18:15:50 +00002791 typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type;
Howard Hinnant37c53b62011-05-16 16:17:21 +00002792};
2793
Howard Hinnant99968442011-11-29 18:15:50 +00002794template <class _Rp, class _Class, class _Tp>
2795struct __result_of_mdp<_Rp _Class::*, _Tp, true>
Howard Hinnant37c53b62011-05-16 16:17:21 +00002796{
Howard Hinnant99968442011-11-29 18:15:50 +00002797 typedef typename __apply_cv<_Tp, _Rp>::type& type;
Howard Hinnant37c53b62011-05-16 16:17:21 +00002798};
2799
Howard Hinnant99968442011-11-29 18:15:50 +00002800template <class _Rp, class _Class, class _Tp>
2801struct __result_of_mp<_Rp _Class::*, _Tp, false>
2802 : public __result_of_mdp<_Rp _Class::*, _Tp,
Howard Hinnant37c53b62011-05-16 16:17:21 +00002803 is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
2804{
2805};
2806
2807
2808
2809template <class _Fn, class _Tp>
2810class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer
2811 : public __result_of_mp<typename remove_reference<_Fn>::type,
2812 _Tp,
2813 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2814{
2815};
2816
2817template <class _Fn, class _Tp, class _A0>
2818class __result_of<_Fn(_Tp, _A0), false, true> // _Fn must be member pointer
2819 : public __result_of_mp<typename remove_reference<_Fn>::type,
2820 _Tp,
2821 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2822{
2823};
2824
2825template <class _Fn, class _Tp, class _A0, class _A1>
2826class __result_of<_Fn(_Tp, _A0, _A1), false, true> // _Fn must be member pointer
2827 : public __result_of_mp<typename remove_reference<_Fn>::type,
2828 _Tp,
2829 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2830{
2831};
2832
2833template <class _Fn, class _Tp, class _A0, class _A1, class _A2>
2834class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true> // _Fn must be member pointer
2835 : public __result_of_mp<typename remove_reference<_Fn>::type,
2836 _Tp,
2837 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2838{
2839};
2840
2841// result_of
2842
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002843template <class _Fn>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002844class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn()>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002845 : public __result_of<_Fn(),
2846 is_class<typename remove_reference<_Fn>::type>::value ||
Eric Fiselier49835802015-06-13 08:25:24 +00002847 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
Howard Hinnant37c53b62011-05-16 16:17:21 +00002848 is_member_pointer<typename remove_reference<_Fn>::type>::value
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002849 >
2850{
2851};
2852
2853template <class _Fn, class _A0>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002854class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0)>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002855 : public __result_of<_Fn(_A0),
2856 is_class<typename remove_reference<_Fn>::type>::value ||
Eric Fiselier49835802015-06-13 08:25:24 +00002857 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
Howard Hinnant37c53b62011-05-16 16:17:21 +00002858 is_member_pointer<typename remove_reference<_Fn>::type>::value
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002859 >
2860{
2861};
2862
2863template <class _Fn, class _A0, class _A1>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002864class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1)>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002865 : public __result_of<_Fn(_A0, _A1),
2866 is_class<typename remove_reference<_Fn>::type>::value ||
Eric Fiselier49835802015-06-13 08:25:24 +00002867 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
Howard Hinnant37c53b62011-05-16 16:17:21 +00002868 is_member_pointer<typename remove_reference<_Fn>::type>::value
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002869 >
2870{
2871};
2872
2873template <class _Fn, class _A0, class _A1, class _A2>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002874class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1, _A2)>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002875 : public __result_of<_Fn(_A0, _A1, _A2),
2876 is_class<typename remove_reference<_Fn>::type>::value ||
Eric Fiselier49835802015-06-13 08:25:24 +00002877 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
Howard Hinnant37c53b62011-05-16 16:17:21 +00002878 is_member_pointer<typename remove_reference<_Fn>::type>::value
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002879 >
2880{
2881};
2882
Howard Hinnant324bb032010-08-22 00:02:43 +00002883#endif // _LIBCPP_HAS_NO_VARIADICS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002884
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002885// template <class T, class... Args> struct is_constructible;
2886
Marshall Clow067e91d2014-04-21 22:30:32 +00002887namespace __is_construct
2888{
2889struct __nat {};
2890}
2891
2892#if __has_feature(is_constructible)
2893
2894template <class _Tp, class ..._Args>
2895struct _LIBCPP_TYPE_VIS_ONLY is_constructible
2896 : public integral_constant<bool, __is_constructible(_Tp, _Args...)>
2897 {};
2898
2899#else
2900
2901#ifndef _LIBCPP_HAS_NO_VARIADICS
2902
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002903// main is_constructible test
2904
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002905
Eric Fiselier155b6812016-07-20 05:01:24 +00002906struct __is_constructible_helper
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002907{
Eric Fiselier155b6812016-07-20 05:01:24 +00002908 template <class _Tp>
2909 static true_type __test_ref(_Tp);
2910 template <class>
2911 static false_type __test_ref(...);
2912
2913 template <class _Tp, class ..._Args,
2914 class = decltype(_Tp(_VSTD::declval<_Args>()...))>
2915 static true_type __test_nary(int);
2916 template <class _Tp, class...>
2917 static false_type __test_nary(...);
2918
2919 template <class _Tp, class _A0, class = decltype(::new _Tp(_VSTD::declval<_A0>()))>
2920 static is_destructible<_Tp> __test_unary(int);
2921 template <class, class>
2922 static false_type __test_unary(...);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002923};
2924
Eric Fiselier155b6812016-07-20 05:01:24 +00002925template <class _Tp, bool = is_void<_Tp>::value>
2926struct __is_default_constructible
2927 : decltype(__is_constructible_helper::__test_nary<_Tp>(0))
2928{};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002929
Eric Fiselier155b6812016-07-20 05:01:24 +00002930template <class _Tp>
2931struct __is_default_constructible<_Tp, true> : false_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002932
Eric Fiselier155b6812016-07-20 05:01:24 +00002933template <class _Tp>
2934struct __is_default_constructible<_Tp[], false> : false_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002935
Eric Fiselier155b6812016-07-20 05:01:24 +00002936template <class _Tp, size_t _Nx>
2937struct __is_default_constructible<_Tp[_Nx], false>
2938 : __is_default_constructible<typename remove_all_extents<_Tp>::type> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002939
2940template <class _Tp, class... _Args>
Eric Fiselier155b6812016-07-20 05:01:24 +00002941struct __libcpp_is_constructible
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002942{
Eric Fiselier155b6812016-07-20 05:01:24 +00002943 static_assert(sizeof...(_Args) > 1, "Wrong specialization");
2944 typedef decltype(__is_constructible_helper::__test_nary<_Tp, _Args...>(0))
2945 type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002946};
2947
Eric Fiselier155b6812016-07-20 05:01:24 +00002948template <class _Tp>
2949struct __libcpp_is_constructible<_Tp> : __is_default_constructible<_Tp> {};
2950
2951template <class _Tp, class _A0>
2952struct __libcpp_is_constructible<_Tp, _A0>
2953 : public decltype(__is_constructible_helper::__test_unary<_Tp, _A0>(0))
2954{};
2955
2956template <class _Tp, class _A0>
2957struct __libcpp_is_constructible<_Tp&, _A0>
2958 : public decltype(__is_constructible_helper::
2959 __test_ref<_Tp&>(_VSTD::declval<_A0>()))
2960{};
2961
2962template <class _Tp, class _A0>
2963struct __libcpp_is_constructible<_Tp&&, _A0>
2964 : public decltype(__is_constructible_helper::
2965 __test_ref<_Tp&&>(_VSTD::declval<_A0>()))
2966{};
2967
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002968// is_constructible entry point
2969
2970template <class _Tp, class... _Args>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00002971struct _LIBCPP_TYPE_VIS_ONLY is_constructible
Eric Fiselier155b6812016-07-20 05:01:24 +00002972 : public __libcpp_is_constructible<_Tp, _Args...>::type {};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002973
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002974
Howard Hinnant1468b662010-11-19 22:17:28 +00002975#else // _LIBCPP_HAS_NO_VARIADICS
Howard Hinnantbb73d762010-09-07 17:47:31 +00002976
2977// template <class T> struct is_constructible0;
2978
2979// main is_constructible0 test
2980
2981template <class _Tp>
Howard Hinnant1468b662010-11-19 22:17:28 +00002982decltype((_Tp(), true_type()))
Howard Hinnantbb73d762010-09-07 17:47:31 +00002983__is_constructible0_test(_Tp&);
2984
2985false_type
2986__is_constructible0_test(__any);
2987
Howard Hinnant1468b662010-11-19 22:17:28 +00002988template <class _Tp, class _A0>
Howard Hinnant0949eed2011-06-30 21:18:19 +00002989decltype((_Tp(_VSTD::declval<_A0>()), true_type()))
Howard Hinnant1468b662010-11-19 22:17:28 +00002990__is_constructible1_test(_Tp&, _A0&);
2991
2992template <class _A0>
2993false_type
2994__is_constructible1_test(__any, _A0&);
2995
2996template <class _Tp, class _A0, class _A1>
Howard Hinnant0949eed2011-06-30 21:18:19 +00002997decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>()), true_type()))
Howard Hinnant1468b662010-11-19 22:17:28 +00002998__is_constructible2_test(_Tp&, _A0&, _A1&);
2999
3000template <class _A0, class _A1>
3001false_type
3002__is_constructible2_test(__any, _A0&, _A1&);
3003
Howard Hinnantbb73d762010-09-07 17:47:31 +00003004template <bool, class _Tp>
3005struct __is_constructible0_imp // false, _Tp is not a scalar
3006 : public common_type
3007 <
3008 decltype(__is_constructible0_test(declval<_Tp&>()))
3009 >::type
3010 {};
3011
Howard Hinnant1468b662010-11-19 22:17:28 +00003012template <bool, class _Tp, class _A0>
3013struct __is_constructible1_imp // false, _Tp is not a scalar
3014 : public common_type
3015 <
3016 decltype(__is_constructible1_test(declval<_Tp&>(), declval<_A0&>()))
3017 >::type
3018 {};
3019
3020template <bool, class _Tp, class _A0, class _A1>
3021struct __is_constructible2_imp // false, _Tp is not a scalar
3022 : public common_type
3023 <
3024 decltype(__is_constructible2_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>()))
3025 >::type
3026 {};
3027
Howard Hinnantbb73d762010-09-07 17:47:31 +00003028// handle scalars and reference types
3029
3030// Scalars are default constructible, references are not
3031
3032template <class _Tp>
3033struct __is_constructible0_imp<true, _Tp>
3034 : public is_scalar<_Tp>
3035 {};
3036
Howard Hinnant1468b662010-11-19 22:17:28 +00003037template <class _Tp, class _A0>
3038struct __is_constructible1_imp<true, _Tp, _A0>
3039 : public is_convertible<_A0, _Tp>
3040 {};
3041
3042template <class _Tp, class _A0, class _A1>
3043struct __is_constructible2_imp<true, _Tp, _A0, _A1>
3044 : public false_type
3045 {};
3046
Howard Hinnantbb73d762010-09-07 17:47:31 +00003047// Treat scalars and reference types separately
3048
3049template <bool, class _Tp>
3050struct __is_constructible0_void_check
3051 : public __is_constructible0_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
3052 _Tp>
3053 {};
3054
Howard Hinnant1468b662010-11-19 22:17:28 +00003055template <bool, class _Tp, class _A0>
3056struct __is_constructible1_void_check
3057 : public __is_constructible1_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
3058 _Tp, _A0>
3059 {};
3060
3061template <bool, class _Tp, class _A0, class _A1>
3062struct __is_constructible2_void_check
3063 : public __is_constructible2_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
3064 _Tp, _A0, _A1>
3065 {};
3066
Howard Hinnantbb73d762010-09-07 17:47:31 +00003067// If any of T or Args is void, is_constructible should be false
3068
3069template <class _Tp>
3070struct __is_constructible0_void_check<true, _Tp>
3071 : public false_type
3072 {};
3073
Howard Hinnant1468b662010-11-19 22:17:28 +00003074template <class _Tp, class _A0>
3075struct __is_constructible1_void_check<true, _Tp, _A0>
3076 : public false_type
3077 {};
3078
3079template <class _Tp, class _A0, class _A1>
3080struct __is_constructible2_void_check<true, _Tp, _A0, _A1>
3081 : public false_type
3082 {};
3083
3084// is_constructible entry point
3085
Howard Hinnant1468b662010-11-19 22:17:28 +00003086template <class _Tp, class _A0 = __is_construct::__nat,
3087 class _A1 = __is_construct::__nat>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003088struct _LIBCPP_TYPE_VIS_ONLY is_constructible
Howard Hinnant1468b662010-11-19 22:17:28 +00003089 : public __is_constructible2_void_check<is_void<_Tp>::value
3090 || is_abstract<_Tp>::value
3091 || is_function<_Tp>::value
3092 || is_void<_A0>::value
3093 || is_void<_A1>::value,
3094 _Tp, _A0, _A1>
3095 {};
Howard Hinnantbb73d762010-09-07 17:47:31 +00003096
3097template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003098struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat>
Howard Hinnantbb73d762010-09-07 17:47:31 +00003099 : public __is_constructible0_void_check<is_void<_Tp>::value
Howard Hinnant1468b662010-11-19 22:17:28 +00003100 || is_abstract<_Tp>::value
3101 || is_function<_Tp>::value,
Howard Hinnantbb73d762010-09-07 17:47:31 +00003102 _Tp>
3103 {};
3104
Howard Hinnant1468b662010-11-19 22:17:28 +00003105template <class _Tp, class _A0>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003106struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, _A0, __is_construct::__nat>
Howard Hinnant1468b662010-11-19 22:17:28 +00003107 : public __is_constructible1_void_check<is_void<_Tp>::value
3108 || is_abstract<_Tp>::value
3109 || is_function<_Tp>::value
3110 || is_void<_A0>::value,
3111 _Tp, _A0>
3112 {};
3113
Howard Hinnantbb73d762010-09-07 17:47:31 +00003114// Array types are default constructible if their element type
3115// is default constructible
3116
Howard Hinnant99968442011-11-29 18:15:50 +00003117template <class _Ap, size_t _Np>
3118struct __is_constructible0_imp<false, _Ap[_Np]>
3119 : public is_constructible<typename remove_all_extents<_Ap>::type>
Howard Hinnant1468b662010-11-19 22:17:28 +00003120 {};
3121
Howard Hinnant99968442011-11-29 18:15:50 +00003122template <class _Ap, size_t _Np, class _A0>
3123struct __is_constructible1_imp<false, _Ap[_Np], _A0>
Howard Hinnant1468b662010-11-19 22:17:28 +00003124 : public false_type
3125 {};
3126
Howard Hinnant99968442011-11-29 18:15:50 +00003127template <class _Ap, size_t _Np, class _A0, class _A1>
3128struct __is_constructible2_imp<false, _Ap[_Np], _A0, _A1>
Howard Hinnant1468b662010-11-19 22:17:28 +00003129 : public false_type
Howard Hinnantbb73d762010-09-07 17:47:31 +00003130 {};
3131
3132// Incomplete array types are not constructible
3133
Howard Hinnant99968442011-11-29 18:15:50 +00003134template <class _Ap>
3135struct __is_constructible0_imp<false, _Ap[]>
Howard Hinnantbb73d762010-09-07 17:47:31 +00003136 : public false_type
3137 {};
3138
Howard Hinnant99968442011-11-29 18:15:50 +00003139template <class _Ap, class _A0>
3140struct __is_constructible1_imp<false, _Ap[], _A0>
Howard Hinnant1468b662010-11-19 22:17:28 +00003141 : public false_type
Howard Hinnant954b3662010-09-07 23:11:28 +00003142 {};
3143
Howard Hinnant99968442011-11-29 18:15:50 +00003144template <class _Ap, class _A0, class _A1>
3145struct __is_constructible2_imp<false, _Ap[], _A0, _A1>
Howard Hinnant1468b662010-11-19 22:17:28 +00003146 : public false_type
Howard Hinnant954b3662010-09-07 23:11:28 +00003147 {};
3148
Howard Hinnant1468b662010-11-19 22:17:28 +00003149#endif // _LIBCPP_HAS_NO_VARIADICS
Marshall Clow067e91d2014-04-21 22:30:32 +00003150#endif // __has_feature(is_constructible)
Howard Hinnant1468b662010-11-19 22:17:28 +00003151
Marshall Clow6455d852015-11-07 17:44:36 +00003152#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
3153template <class _Tp, class ..._Args> _LIBCPP_CONSTEXPR bool is_constructible_v
3154 = is_constructible<_Tp, _Args...>::value;
3155#endif
3156
Howard Hinnant1468b662010-11-19 22:17:28 +00003157// is_default_constructible
3158
3159template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003160struct _LIBCPP_TYPE_VIS_ONLY is_default_constructible
Howard Hinnant1468b662010-11-19 22:17:28 +00003161 : public is_constructible<_Tp>
3162 {};
3163
Marshall Clow6455d852015-11-07 17:44:36 +00003164#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3165template <class _Tp> _LIBCPP_CONSTEXPR bool is_default_constructible_v
3166 = is_default_constructible<_Tp>::value;
3167#endif
3168
Howard Hinnant1468b662010-11-19 22:17:28 +00003169// is_copy_constructible
3170
3171template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003172struct _LIBCPP_TYPE_VIS_ONLY is_copy_constructible
Marshall Clowd132bf42014-09-22 23:58:00 +00003173 : public is_constructible<_Tp,
3174 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
Howard Hinnant1468b662010-11-19 22:17:28 +00003175
Marshall Clow6455d852015-11-07 17:44:36 +00003176#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3177template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_constructible_v
3178 = is_copy_constructible<_Tp>::value;
3179#endif
3180
Howard Hinnant1468b662010-11-19 22:17:28 +00003181// is_move_constructible
3182
3183template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003184struct _LIBCPP_TYPE_VIS_ONLY is_move_constructible
Howard Hinnant1468b662010-11-19 22:17:28 +00003185#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3186 : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3187#else
3188 : public is_copy_constructible<_Tp>
3189#endif
3190 {};
3191
Marshall Clow6455d852015-11-07 17:44:36 +00003192#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3193template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_constructible_v
3194 = is_move_constructible<_Tp>::value;
3195#endif
3196
Howard Hinnant1468b662010-11-19 22:17:28 +00003197// is_trivially_constructible
3198
3199#ifndef _LIBCPP_HAS_NO_VARIADICS
3200
Eric Fiseliereeeada12015-06-13 02:18:44 +00003201#if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
Howard Hinnant43008392012-02-24 23:32:26 +00003202
3203template <class _Tp, class... _Args>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003204struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
Howard Hinnant43008392012-02-24 23:32:26 +00003205 : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
3206{
3207};
3208
3209#else // !__has_feature(is_trivially_constructible)
3210
Howard Hinnant1468b662010-11-19 22:17:28 +00003211template <class _Tp, class... _Args>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003212struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
Howard Hinnant1468b662010-11-19 22:17:28 +00003213 : false_type
3214{
3215};
3216
3217template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003218struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp>
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003219#if __has_feature(has_trivial_constructor) || (_GNUC_VER >= 403)
Howard Hinnant1468b662010-11-19 22:17:28 +00003220 : integral_constant<bool, __has_trivial_constructor(_Tp)>
3221#else
3222 : integral_constant<bool, is_scalar<_Tp>::value>
3223#endif
3224{
3225};
3226
3227template <class _Tp>
3228#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003229struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&&>
Howard Hinnant1468b662010-11-19 22:17:28 +00003230#else
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003231struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp>
Howard Hinnant1468b662010-11-19 22:17:28 +00003232#endif
Howard Hinnant1468b662010-11-19 22:17:28 +00003233 : integral_constant<bool, is_scalar<_Tp>::value>
Howard Hinnant1468b662010-11-19 22:17:28 +00003234{
3235};
3236
3237template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003238struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&>
Howard Hinnant1468b662010-11-19 22:17:28 +00003239 : integral_constant<bool, is_scalar<_Tp>::value>
Howard Hinnant1468b662010-11-19 22:17:28 +00003240{
3241};
3242
3243template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003244struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&>
Howard Hinnant1468b662010-11-19 22:17:28 +00003245 : integral_constant<bool, is_scalar<_Tp>::value>
Howard Hinnant1468b662010-11-19 22:17:28 +00003246{
3247};
3248
Howard Hinnant43008392012-02-24 23:32:26 +00003249#endif // !__has_feature(is_trivially_constructible)
3250
Howard Hinnant1468b662010-11-19 22:17:28 +00003251#else // _LIBCPP_HAS_NO_VARIADICS
3252
3253template <class _Tp, class _A0 = __is_construct::__nat,
3254 class _A1 = __is_construct::__nat>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003255struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
Howard Hinnant1468b662010-11-19 22:17:28 +00003256 : false_type
3257{
3258};
3259
Eric Fiseliereeeada12015-06-13 02:18:44 +00003260#if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
Howard Hinnant43008392012-02-24 23:32:26 +00003261
Howard Hinnant1468b662010-11-19 22:17:28 +00003262template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003263struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat,
Howard Hinnant1468b662010-11-19 22:17:28 +00003264 __is_construct::__nat>
Howard Hinnant43008392012-02-24 23:32:26 +00003265 : integral_constant<bool, __is_trivially_constructible(_Tp)>
Howard Hinnant1468b662010-11-19 22:17:28 +00003266{
3267};
3268
3269template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003270struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp,
Howard Hinnant1468b662010-11-19 22:17:28 +00003271 __is_construct::__nat>
Howard Hinnant43008392012-02-24 23:32:26 +00003272 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp)>
Howard Hinnant1468b662010-11-19 22:17:28 +00003273{
3274};
3275
3276template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003277struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&,
Howard Hinnant1468b662010-11-19 22:17:28 +00003278 __is_construct::__nat>
Howard Hinnant43008392012-02-24 23:32:26 +00003279 : integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)>
Howard Hinnant1468b662010-11-19 22:17:28 +00003280{
3281};
3282
3283template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003284struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&,
Howard Hinnant1468b662010-11-19 22:17:28 +00003285 __is_construct::__nat>
Howard Hinnant43008392012-02-24 23:32:26 +00003286 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&)>
Howard Hinnant1468b662010-11-19 22:17:28 +00003287{
3288};
3289
Howard Hinnant43008392012-02-24 23:32:26 +00003290#else // !__has_feature(is_trivially_constructible)
3291
3292template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003293struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat,
Howard Hinnant43008392012-02-24 23:32:26 +00003294 __is_construct::__nat>
3295 : integral_constant<bool, is_scalar<_Tp>::value>
3296{
3297};
3298
3299template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003300struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp,
Howard Hinnant43008392012-02-24 23:32:26 +00003301 __is_construct::__nat>
3302 : integral_constant<bool, is_scalar<_Tp>::value>
3303{
3304};
3305
3306template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003307struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&,
Howard Hinnant43008392012-02-24 23:32:26 +00003308 __is_construct::__nat>
3309 : integral_constant<bool, is_scalar<_Tp>::value>
3310{
3311};
3312
3313template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003314struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&,
Howard Hinnant43008392012-02-24 23:32:26 +00003315 __is_construct::__nat>
3316 : integral_constant<bool, is_scalar<_Tp>::value>
3317{
3318};
3319
3320#endif // !__has_feature(is_trivially_constructible)
3321
Howard Hinnant1468b662010-11-19 22:17:28 +00003322#endif // _LIBCPP_HAS_NO_VARIADICS
3323
Marshall Clow6455d852015-11-07 17:44:36 +00003324#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
Marshall Clow55d741c2015-11-10 15:48:23 +00003325template <class _Tp, class... _Args> _LIBCPP_CONSTEXPR bool is_trivially_constructible_v
3326 = is_trivially_constructible<_Tp, _Args...>::value;
Marshall Clow6455d852015-11-07 17:44:36 +00003327#endif
3328
Howard Hinnant1468b662010-11-19 22:17:28 +00003329// is_trivially_default_constructible
3330
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003331template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_default_constructible
Howard Hinnant1468b662010-11-19 22:17:28 +00003332 : public is_trivially_constructible<_Tp>
3333 {};
3334
Marshall Clow6455d852015-11-07 17:44:36 +00003335#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3336template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v
3337 = is_trivially_default_constructible<_Tp>::value;
3338#endif
3339
Howard Hinnant1468b662010-11-19 22:17:28 +00003340// is_trivially_copy_constructible
3341
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003342template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_constructible
Howard Hinnant3f81e9e2013-11-13 00:39:22 +00003343 : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type>
Howard Hinnant1468b662010-11-19 22:17:28 +00003344 {};
3345
Marshall Clow6455d852015-11-07 17:44:36 +00003346#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3347template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v
3348 = is_trivially_copy_constructible<_Tp>::value;
3349#endif
3350
Howard Hinnant1468b662010-11-19 22:17:28 +00003351// is_trivially_move_constructible
3352
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003353template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_constructible
Howard Hinnant1468b662010-11-19 22:17:28 +00003354#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3355 : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3356#else
3357 : public is_trivially_copy_constructible<_Tp>
3358#endif
3359 {};
3360
Marshall Clow6455d852015-11-07 17:44:36 +00003361#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3362template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v
3363 = is_trivially_move_constructible<_Tp>::value;
3364#endif
3365
Howard Hinnant1468b662010-11-19 22:17:28 +00003366// is_trivially_assignable
3367
Eric Fiseliereeeada12015-06-13 02:18:44 +00003368#if __has_feature(is_trivially_assignable) || _GNUC_VER >= 501
Howard Hinnant43008392012-02-24 23:32:26 +00003369
3370template <class _Tp, class _Arg>
3371struct is_trivially_assignable
3372 : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
3373{
3374};
3375
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003376#else // !__has_feature(is_trivially_assignable)
Howard Hinnant43008392012-02-24 23:32:26 +00003377
Howard Hinnant1468b662010-11-19 22:17:28 +00003378template <class _Tp, class _Arg>
3379struct is_trivially_assignable
3380 : public false_type {};
3381
3382template <class _Tp>
3383struct is_trivially_assignable<_Tp&, _Tp>
Howard Hinnant1468b662010-11-19 22:17:28 +00003384 : integral_constant<bool, is_scalar<_Tp>::value> {};
Howard Hinnant1468b662010-11-19 22:17:28 +00003385
3386template <class _Tp>
3387struct is_trivially_assignable<_Tp&, _Tp&>
Howard Hinnant1468b662010-11-19 22:17:28 +00003388 : integral_constant<bool, is_scalar<_Tp>::value> {};
Howard Hinnant1468b662010-11-19 22:17:28 +00003389
3390template <class _Tp>
3391struct is_trivially_assignable<_Tp&, const _Tp&>
Howard Hinnant1468b662010-11-19 22:17:28 +00003392 : integral_constant<bool, is_scalar<_Tp>::value> {};
Howard Hinnant1468b662010-11-19 22:17:28 +00003393
3394#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3395
3396template <class _Tp>
3397struct is_trivially_assignable<_Tp&, _Tp&&>
Howard Hinnant1468b662010-11-19 22:17:28 +00003398 : integral_constant<bool, is_scalar<_Tp>::value> {};
Howard Hinnant1468b662010-11-19 22:17:28 +00003399
3400#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3401
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003402#endif // !__has_feature(is_trivially_assignable)
Howard Hinnant43008392012-02-24 23:32:26 +00003403
Marshall Clow6455d852015-11-07 17:44:36 +00003404#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3405template <class _Tp, class _Arg> _LIBCPP_CONSTEXPR bool is_trivially_assignable_v
3406 = is_trivially_assignable<_Tp, _Arg>::value;
3407#endif
3408
Howard Hinnant1468b662010-11-19 22:17:28 +00003409// is_trivially_copy_assignable
3410
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003411template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_assignable
Howard Hinnant1468b662010-11-19 22:17:28 +00003412 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
Marshall Clowd132bf42014-09-22 23:58:00 +00003413 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
Howard Hinnant1468b662010-11-19 22:17:28 +00003414
Marshall Clow6455d852015-11-07 17:44:36 +00003415#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3416template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v
3417 = is_trivially_copy_assignable<_Tp>::value;
3418#endif
3419
Howard Hinnant1468b662010-11-19 22:17:28 +00003420// is_trivially_move_assignable
3421
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003422template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_assignable
Howard Hinnant1468b662010-11-19 22:17:28 +00003423 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
3424#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3425 typename add_rvalue_reference<_Tp>::type>
3426#else
3427 typename add_lvalue_reference<_Tp>::type>
3428#endif
3429 {};
3430
Marshall Clow6455d852015-11-07 17:44:36 +00003431#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3432template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v
3433 = is_trivially_move_assignable<_Tp>::value;
3434#endif
3435
Howard Hinnant1468b662010-11-19 22:17:28 +00003436// is_trivially_destructible
3437
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003438#if __has_feature(has_trivial_destructor) || (_GNUC_VER >= 403)
Howard Hinnant1468b662010-11-19 22:17:28 +00003439
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003440template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible
Marshall Clowe33e03e2014-09-02 16:19:38 +00003441 : public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {};
Howard Hinnant1468b662010-11-19 22:17:28 +00003442
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003443#else
Howard Hinnant1468b662010-11-19 22:17:28 +00003444
3445template <class _Tp> struct __libcpp_trivial_destructor
3446 : public integral_constant<bool, is_scalar<_Tp>::value ||
3447 is_reference<_Tp>::value> {};
3448
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003449template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible
Howard Hinnant1468b662010-11-19 22:17:28 +00003450 : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
3451
Eric Fiselier12c6d9c2015-07-18 16:43:58 +00003452template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible<_Tp[]>
3453 : public false_type {};
3454
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003455#endif
Howard Hinnant1468b662010-11-19 22:17:28 +00003456
Marshall Clow6455d852015-11-07 17:44:36 +00003457#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3458template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_destructible_v
3459 = is_trivially_destructible<_Tp>::value;
3460#endif
3461
Howard Hinnant1468b662010-11-19 22:17:28 +00003462// is_nothrow_constructible
3463
Marshall Clow4f3368e2014-05-29 01:10:28 +00003464#if 0
3465template <class _Tp, class... _Args>
3466struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
3467 : public integral_constant<bool, __is_nothrow_constructible(_Tp(_Args...))>
3468{
3469};
3470
3471#else
3472
Howard Hinnant1468b662010-11-19 22:17:28 +00003473#ifndef _LIBCPP_HAS_NO_VARIADICS
3474
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003475#if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
Howard Hinnant5d37fb32011-05-11 20:19:40 +00003476
Marshall Clowdf9722e2014-10-07 21:42:12 +00003477template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;
Howard Hinnant5d37fb32011-05-11 20:19:40 +00003478
3479template <class _Tp, class... _Args>
Marshall Clowdf9722e2014-10-07 21:42:12 +00003480struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...>
Howard Hinnant5d37fb32011-05-11 20:19:40 +00003481 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
3482{
3483};
3484
Marshall Clowdf9722e2014-10-07 21:42:12 +00003485template <class _Tp>
3486void __implicit_conversion_to(_Tp) noexcept { }
3487
3488template <class _Tp, class _Arg>
3489struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg>
3490 : public integral_constant<bool, noexcept(__implicit_conversion_to<_Tp>(declval<_Arg>()))>
3491{
3492};
3493
3494template <class _Tp, bool _IsReference, class... _Args>
3495struct __libcpp_is_nothrow_constructible</*is constructible*/false, _IsReference, _Tp, _Args...>
Howard Hinnant5d37fb32011-05-11 20:19:40 +00003496 : public false_type
3497{
3498};
3499
3500template <class _Tp, class... _Args>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003501struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
Marshall Clowdf9722e2014-10-07 21:42:12 +00003502 : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...>
Howard Hinnant5d37fb32011-05-11 20:19:40 +00003503{
3504};
3505
Howard Hinnant6063ec12011-05-13 14:08:16 +00003506template <class _Tp, size_t _Ns>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003507struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp[_Ns]>
Marshall Clowdf9722e2014-10-07 21:42:12 +00003508 : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp>
Howard Hinnant6063ec12011-05-13 14:08:16 +00003509{
3510};
3511
Howard Hinnant5d37fb32011-05-11 20:19:40 +00003512#else // __has_feature(cxx_noexcept)
3513
Howard Hinnant1468b662010-11-19 22:17:28 +00003514template <class _Tp, class... _Args>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003515struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
Howard Hinnant1468b662010-11-19 22:17:28 +00003516 : false_type
3517{
3518};
3519
3520template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003521struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp>
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003522#if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
Howard Hinnant1468b662010-11-19 22:17:28 +00003523 : integral_constant<bool, __has_nothrow_constructor(_Tp)>
3524#else
3525 : integral_constant<bool, is_scalar<_Tp>::value>
3526#endif
3527{
3528};
3529
3530template <class _Tp>
3531#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003532struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&&>
Howard Hinnant1468b662010-11-19 22:17:28 +00003533#else
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003534struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp>
Howard Hinnant1468b662010-11-19 22:17:28 +00003535#endif
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003536#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
Howard Hinnant1468b662010-11-19 22:17:28 +00003537 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3538#else
3539 : integral_constant<bool, is_scalar<_Tp>::value>
3540#endif
3541{
3542};
3543
3544template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003545struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&>
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003546#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
Howard Hinnant1468b662010-11-19 22:17:28 +00003547 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3548#else
3549 : integral_constant<bool, is_scalar<_Tp>::value>
3550#endif
3551{
3552};
3553
3554template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003555struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&>
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003556#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
Howard Hinnant1468b662010-11-19 22:17:28 +00003557 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3558#else
3559 : integral_constant<bool, is_scalar<_Tp>::value>
3560#endif
3561{
3562};
3563
Howard Hinnant5d37fb32011-05-11 20:19:40 +00003564#endif // __has_feature(cxx_noexcept)
3565
Howard Hinnant1468b662010-11-19 22:17:28 +00003566#else // _LIBCPP_HAS_NO_VARIADICS
3567
3568template <class _Tp, class _A0 = __is_construct::__nat,
3569 class _A1 = __is_construct::__nat>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003570struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
Howard Hinnant1468b662010-11-19 22:17:28 +00003571 : false_type
3572{
3573};
3574
3575template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003576struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, __is_construct::__nat,
Howard Hinnant1468b662010-11-19 22:17:28 +00003577 __is_construct::__nat>
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003578#if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
Howard Hinnant1468b662010-11-19 22:17:28 +00003579 : integral_constant<bool, __has_nothrow_constructor(_Tp)>
3580#else
3581 : integral_constant<bool, is_scalar<_Tp>::value>
3582#endif
3583{
3584};
3585
3586template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003587struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp,
Howard Hinnant1468b662010-11-19 22:17:28 +00003588 __is_construct::__nat>
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003589#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
Howard Hinnant1468b662010-11-19 22:17:28 +00003590 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3591#else
3592 : integral_constant<bool, is_scalar<_Tp>::value>
3593#endif
3594{
3595};
3596
3597template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003598struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&,
Howard Hinnant1468b662010-11-19 22:17:28 +00003599 __is_construct::__nat>
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003600#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
Howard Hinnant1468b662010-11-19 22:17:28 +00003601 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3602#else
3603 : integral_constant<bool, is_scalar<_Tp>::value>
3604#endif
3605{
3606};
3607
3608template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003609struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&,
Howard Hinnant1468b662010-11-19 22:17:28 +00003610 __is_construct::__nat>
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003611#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
Howard Hinnant1468b662010-11-19 22:17:28 +00003612 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3613#else
3614 : integral_constant<bool, is_scalar<_Tp>::value>
3615#endif
3616{
3617};
3618
3619#endif // _LIBCPP_HAS_NO_VARIADICS
Marshall Clow4f3368e2014-05-29 01:10:28 +00003620#endif // __has_feature(is_nothrow_constructible)
Howard Hinnant1468b662010-11-19 22:17:28 +00003621
Marshall Clow6455d852015-11-07 17:44:36 +00003622#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
3623template <class _Tp, class ..._Args> _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v
3624 = is_nothrow_constructible<_Tp, _Args...>::value;
3625#endif
3626
Howard Hinnant1468b662010-11-19 22:17:28 +00003627// is_nothrow_default_constructible
3628
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003629template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_default_constructible
Howard Hinnant1468b662010-11-19 22:17:28 +00003630 : public is_nothrow_constructible<_Tp>
3631 {};
3632
Marshall Clow6455d852015-11-07 17:44:36 +00003633#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3634template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v
3635 = is_nothrow_default_constructible<_Tp>::value;
3636#endif
3637
Howard Hinnant1468b662010-11-19 22:17:28 +00003638// is_nothrow_copy_constructible
3639
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003640template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_constructible
Marshall Clowd132bf42014-09-22 23:58:00 +00003641 : public is_nothrow_constructible<_Tp,
3642 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
Howard Hinnant1468b662010-11-19 22:17:28 +00003643
Marshall Clow6455d852015-11-07 17:44:36 +00003644#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3645template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v
3646 = is_nothrow_copy_constructible<_Tp>::value;
3647#endif
3648
Howard Hinnant1468b662010-11-19 22:17:28 +00003649// is_nothrow_move_constructible
3650
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003651template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_constructible
Howard Hinnant1468b662010-11-19 22:17:28 +00003652#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3653 : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3654#else
3655 : public is_nothrow_copy_constructible<_Tp>
3656#endif
3657 {};
3658
Marshall Clow6455d852015-11-07 17:44:36 +00003659#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3660template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v
3661 = is_nothrow_move_constructible<_Tp>::value;
3662#endif
3663
Howard Hinnant1468b662010-11-19 22:17:28 +00003664// is_nothrow_assignable
3665
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003666#if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
Howard Hinnant5d37fb32011-05-11 20:19:40 +00003667
Marshall Clow708dd842014-01-24 15:27:41 +00003668template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable;
Howard Hinnant5d37fb32011-05-11 20:19:40 +00003669
Howard Hinnant1468b662010-11-19 22:17:28 +00003670template <class _Tp, class _Arg>
Marshall Clow708dd842014-01-24 15:27:41 +00003671struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg>
Howard Hinnant5d37fb32011-05-11 20:19:40 +00003672 : public false_type
3673{
3674};
3675
3676template <class _Tp, class _Arg>
Marshall Clow708dd842014-01-24 15:27:41 +00003677struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg>
Howard Hinnant0949eed2011-06-30 21:18:19 +00003678 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) >
Howard Hinnant5d37fb32011-05-11 20:19:40 +00003679{
3680};
3681
3682template <class _Tp, class _Arg>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003683struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable
Marshall Clow708dd842014-01-24 15:27:41 +00003684 : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
Howard Hinnant5d37fb32011-05-11 20:19:40 +00003685{
3686};
3687
3688#else // __has_feature(cxx_noexcept)
3689
3690template <class _Tp, class _Arg>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003691struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable
Howard Hinnant1468b662010-11-19 22:17:28 +00003692 : public false_type {};
3693
3694template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003695struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp>
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003696#if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
Howard Hinnant1468b662010-11-19 22:17:28 +00003697 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3698#else
3699 : integral_constant<bool, is_scalar<_Tp>::value> {};
3700#endif
3701
3702template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003703struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp&>
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003704#if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
Howard Hinnant1468b662010-11-19 22:17:28 +00003705 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3706#else
3707 : integral_constant<bool, is_scalar<_Tp>::value> {};
3708#endif
3709
3710template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003711struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, const _Tp&>
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003712#if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
Howard Hinnant1468b662010-11-19 22:17:28 +00003713 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3714#else
3715 : integral_constant<bool, is_scalar<_Tp>::value> {};
3716#endif
3717
3718#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3719
3720template <class _Tp>
3721struct is_nothrow_assignable<_Tp&, _Tp&&>
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003722#if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
Howard Hinnant1468b662010-11-19 22:17:28 +00003723 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3724#else
3725 : integral_constant<bool, is_scalar<_Tp>::value> {};
3726#endif
3727
3728#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3729
Howard Hinnant5d37fb32011-05-11 20:19:40 +00003730#endif // __has_feature(cxx_noexcept)
3731
Marshall Clow6455d852015-11-07 17:44:36 +00003732#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3733template <class _Tp, class _Arg> _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v
3734 = is_nothrow_assignable<_Tp, _Arg>::value;
3735#endif
3736
Howard Hinnant1468b662010-11-19 22:17:28 +00003737// is_nothrow_copy_assignable
3738
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003739template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_assignable
Howard Hinnant1468b662010-11-19 22:17:28 +00003740 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
Marshall Clowd132bf42014-09-22 23:58:00 +00003741 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
Howard Hinnant1468b662010-11-19 22:17:28 +00003742
Marshall Clow55d741c2015-11-10 15:48:23 +00003743#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3744template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v
3745 = is_nothrow_copy_assignable<_Tp>::value;
3746#endif
3747
Howard Hinnant1468b662010-11-19 22:17:28 +00003748// is_nothrow_move_assignable
3749
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003750template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_assignable
Howard Hinnant1468b662010-11-19 22:17:28 +00003751 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3752#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3753 typename add_rvalue_reference<_Tp>::type>
3754#else
3755 typename add_lvalue_reference<_Tp>::type>
3756#endif
3757 {};
3758
Marshall Clow6455d852015-11-07 17:44:36 +00003759#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
Marshall Clow55d741c2015-11-10 15:48:23 +00003760template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v
3761 = is_nothrow_move_assignable<_Tp>::value;
Marshall Clow6455d852015-11-07 17:44:36 +00003762#endif
3763
Howard Hinnant1468b662010-11-19 22:17:28 +00003764// is_nothrow_destructible
3765
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003766#if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
Howard Hinnant5d37fb32011-05-11 20:19:40 +00003767
Marshall Clow708dd842014-01-24 15:27:41 +00003768template <bool, class _Tp> struct __libcpp_is_nothrow_destructible;
Howard Hinnant5d37fb32011-05-11 20:19:40 +00003769
3770template <class _Tp>
Marshall Clow708dd842014-01-24 15:27:41 +00003771struct __libcpp_is_nothrow_destructible<false, _Tp>
Howard Hinnant5d37fb32011-05-11 20:19:40 +00003772 : public false_type
3773{
3774};
3775
3776template <class _Tp>
Marshall Clow708dd842014-01-24 15:27:41 +00003777struct __libcpp_is_nothrow_destructible<true, _Tp>
Howard Hinnant0949eed2011-06-30 21:18:19 +00003778 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) >
Howard Hinnant5d37fb32011-05-11 20:19:40 +00003779{
3780};
3781
3782template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003783struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible
Marshall Clow708dd842014-01-24 15:27:41 +00003784 : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
Howard Hinnant5d37fb32011-05-11 20:19:40 +00003785{
3786};
3787
Howard Hinnant6063ec12011-05-13 14:08:16 +00003788template <class _Tp, size_t _Ns>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003789struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp[_Ns]>
Howard Hinnant6063ec12011-05-13 14:08:16 +00003790 : public is_nothrow_destructible<_Tp>
3791{
3792};
3793
3794template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003795struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&>
Howard Hinnant6063ec12011-05-13 14:08:16 +00003796 : public true_type
3797{
3798};
3799
3800#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3801
3802template <class _Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003803struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&&>
Howard Hinnant6063ec12011-05-13 14:08:16 +00003804 : public true_type
3805{
3806};
3807
3808#endif
3809
Howard Hinnant5d37fb32011-05-11 20:19:40 +00003810#else
3811
Howard Hinnant1468b662010-11-19 22:17:28 +00003812template <class _Tp> struct __libcpp_nothrow_destructor
3813 : public integral_constant<bool, is_scalar<_Tp>::value ||
3814 is_reference<_Tp>::value> {};
3815
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003816template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible
Howard Hinnant1468b662010-11-19 22:17:28 +00003817 : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
3818
Eric Fiselier12c6d9c2015-07-18 16:43:58 +00003819template <class _Tp>
3820struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp[]>
3821 : public false_type {};
3822
Howard Hinnant5d37fb32011-05-11 20:19:40 +00003823#endif
3824
Marshall Clow6455d852015-11-07 17:44:36 +00003825#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3826template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v
3827 = is_nothrow_destructible<_Tp>::value;
3828#endif
3829
Howard Hinnant1468b662010-11-19 22:17:28 +00003830// is_pod
3831
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003832#if __has_feature(is_pod) || (_GNUC_VER >= 403)
Howard Hinnant1468b662010-11-19 22:17:28 +00003833
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003834template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod
Howard Hinnant1468b662010-11-19 22:17:28 +00003835 : public integral_constant<bool, __is_pod(_Tp)> {};
3836
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003837#else
Howard Hinnant1468b662010-11-19 22:17:28 +00003838
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003839template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod
Howard Hinnant1468b662010-11-19 22:17:28 +00003840 : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value &&
3841 is_trivially_copy_constructible<_Tp>::value &&
3842 is_trivially_copy_assignable<_Tp>::value &&
3843 is_trivially_destructible<_Tp>::value> {};
3844
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003845#endif
Howard Hinnant954b3662010-09-07 23:11:28 +00003846
Marshall Clow94611a82015-11-01 20:24:59 +00003847#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3848template <class _Tp> _LIBCPP_CONSTEXPR bool is_pod_v
3849 = is_pod<_Tp>::value;
3850#endif
3851
Howard Hinnant36666952011-05-09 19:21:17 +00003852// is_literal_type;
3853
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003854template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_literal_type
Marshall Clow81aa3a72014-06-26 01:07:56 +00003855#ifdef _LIBCPP_IS_LITERAL
3856 : public integral_constant<bool, _LIBCPP_IS_LITERAL(_Tp)>
Howard Hinnant36666952011-05-09 19:21:17 +00003857#else
3858 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value ||
3859 is_reference<typename remove_all_extents<_Tp>::type>::value>
3860#endif
3861 {};
3862
Marshall Clow94611a82015-11-01 20:24:59 +00003863#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3864template <class _Tp> _LIBCPP_CONSTEXPR bool is_literal_type_v
3865 = is_literal_type<_Tp>::value;
3866#endif
3867
Howard Hinnant6063ec12011-05-13 14:08:16 +00003868// is_standard_layout;
3869
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003870template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_standard_layout
Marshall Clow48e7e9f2014-07-10 15:38:20 +00003871#if __has_feature(is_standard_layout) || (_GNUC_VER >= 407)
Howard Hinnant6063ec12011-05-13 14:08:16 +00003872 : public integral_constant<bool, __is_standard_layout(_Tp)>
3873#else
3874 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
3875#endif
3876 {};
3877
Marshall Clow94611a82015-11-01 20:24:59 +00003878#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3879template <class _Tp> _LIBCPP_CONSTEXPR bool is_standard_layout_v
3880 = is_standard_layout<_Tp>::value;
3881#endif
3882
Howard Hinnant6063ec12011-05-13 14:08:16 +00003883// is_trivially_copyable;
3884
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003885template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copyable
Howard Hinnant6063ec12011-05-13 14:08:16 +00003886#if __has_feature(is_trivially_copyable)
3887 : public integral_constant<bool, __is_trivially_copyable(_Tp)>
Eric Fiseliereeeada12015-06-13 02:18:44 +00003888#elif _GNUC_VER >= 501
3889 : public integral_constant<bool, !is_volatile<_Tp>::value && __is_trivially_copyable(_Tp)>
Howard Hinnant6063ec12011-05-13 14:08:16 +00003890#else
3891 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
3892#endif
3893 {};
3894
Marshall Clow94611a82015-11-01 20:24:59 +00003895#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3896template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copyable_v
3897 = is_trivially_copyable<_Tp>::value;
3898#endif
3899
Howard Hinnant6063ec12011-05-13 14:08:16 +00003900// is_trivial;
3901
Howard Hinnant0f678bd2013-08-12 18:38:34 +00003902template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivial
Eric Fiseliereeeada12015-06-13 02:18:44 +00003903#if __has_feature(is_trivial) || _GNUC_VER >= 407
Howard Hinnant6063ec12011-05-13 14:08:16 +00003904 : public integral_constant<bool, __is_trivial(_Tp)>
3905#else
3906 : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
Howard Hinnant5ec7f5a2011-05-14 18:20:45 +00003907 is_trivially_default_constructible<_Tp>::value>
Howard Hinnant6063ec12011-05-13 14:08:16 +00003908#endif
3909 {};
Howard Hinnant57cff292011-05-19 15:05:04 +00003910
Marshall Clow94611a82015-11-01 20:24:59 +00003911#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3912template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivial_v
3913 = is_trivial<_Tp>::value;
3914#endif
3915
Eric Fiselier134ff652016-04-18 06:17:30 +00003916template <class _Tp> struct __is_reference_wrapper_impl : public false_type {};
3917template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {};
3918template <class _Tp> struct __is_reference_wrapper
3919 : public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {};
3920
Eric Fiselier8d5cbd72016-04-20 00:14:32 +00003921#ifndef _LIBCPP_CXX03_LANG
Howard Hinnant57cff292011-05-19 15:05:04 +00003922
Howard Hinnante003ce42011-05-22 00:09:02 +00003923// Check for complete types
3924
Howard Hinnant99968442011-11-29 18:15:50 +00003925template <class ..._Tp> struct __check_complete;
Howard Hinnante003ce42011-05-22 00:09:02 +00003926
3927template <>
3928struct __check_complete<>
3929{
3930};
3931
Howard Hinnant99968442011-11-29 18:15:50 +00003932template <class _Hp, class _T0, class ..._Tp>
3933struct __check_complete<_Hp, _T0, _Tp...>
3934 : private __check_complete<_Hp>,
3935 private __check_complete<_T0, _Tp...>
Howard Hinnante003ce42011-05-22 00:09:02 +00003936{
3937};
3938
Howard Hinnant99968442011-11-29 18:15:50 +00003939template <class _Hp>
3940struct __check_complete<_Hp, _Hp>
3941 : private __check_complete<_Hp>
Howard Hinnante003ce42011-05-22 00:09:02 +00003942{
3943};
3944
Howard Hinnant99968442011-11-29 18:15:50 +00003945template <class _Tp>
3946struct __check_complete<_Tp>
Howard Hinnante003ce42011-05-22 00:09:02 +00003947{
Howard Hinnant99968442011-11-29 18:15:50 +00003948 static_assert(sizeof(_Tp) > 0, "Type must be complete.");
Howard Hinnante003ce42011-05-22 00:09:02 +00003949};
3950
Howard Hinnant99968442011-11-29 18:15:50 +00003951template <class _Tp>
3952struct __check_complete<_Tp&>
3953 : private __check_complete<_Tp>
Howard Hinnante003ce42011-05-22 00:09:02 +00003954{
3955};
3956
Howard Hinnant99968442011-11-29 18:15:50 +00003957template <class _Tp>
3958struct __check_complete<_Tp&&>
3959 : private __check_complete<_Tp>
Howard Hinnante003ce42011-05-22 00:09:02 +00003960{
3961};
3962
Howard Hinnant99968442011-11-29 18:15:50 +00003963template <class _Rp, class ..._Param>
3964struct __check_complete<_Rp (*)(_Param...)>
Howard Hinnante41f4752012-07-20 18:56:07 +00003965 : private __check_complete<_Rp>
Howard Hinnante003ce42011-05-22 00:09:02 +00003966{
3967};
3968
Howard Hinnantde8fc6b2013-08-14 21:28:31 +00003969template <class ..._Param>
3970struct __check_complete<void (*)(_Param...)>
3971{
3972};
3973
Howard Hinnant99968442011-11-29 18:15:50 +00003974template <class _Rp, class ..._Param>
3975struct __check_complete<_Rp (_Param...)>
Howard Hinnante41f4752012-07-20 18:56:07 +00003976 : private __check_complete<_Rp>
Howard Hinnante003ce42011-05-22 00:09:02 +00003977{
3978};
3979
Howard Hinnantde8fc6b2013-08-14 21:28:31 +00003980template <class ..._Param>
3981struct __check_complete<void (_Param...)>
3982{
3983};
3984
Howard Hinnant99968442011-11-29 18:15:50 +00003985template <class _Rp, class _Class, class ..._Param>
3986struct __check_complete<_Rp (_Class::*)(_Param...)>
Howard Hinnante41f4752012-07-20 18:56:07 +00003987 : private __check_complete<_Class>
Howard Hinnante003ce42011-05-22 00:09:02 +00003988{
3989};
3990
Howard Hinnant99968442011-11-29 18:15:50 +00003991template <class _Rp, class _Class, class ..._Param>
3992struct __check_complete<_Rp (_Class::*)(_Param...) const>
Howard Hinnante41f4752012-07-20 18:56:07 +00003993 : private __check_complete<_Class>
Howard Hinnante003ce42011-05-22 00:09:02 +00003994{
3995};
3996
Howard Hinnant99968442011-11-29 18:15:50 +00003997template <class _Rp, class _Class, class ..._Param>
3998struct __check_complete<_Rp (_Class::*)(_Param...) volatile>
Howard Hinnante41f4752012-07-20 18:56:07 +00003999 : private __check_complete<_Class>
Howard Hinnante003ce42011-05-22 00:09:02 +00004000{
4001};
4002
Howard Hinnant99968442011-11-29 18:15:50 +00004003template <class _Rp, class _Class, class ..._Param>
4004struct __check_complete<_Rp (_Class::*)(_Param...) const volatile>
Howard Hinnante41f4752012-07-20 18:56:07 +00004005 : private __check_complete<_Class>
Howard Hinnante003ce42011-05-22 00:09:02 +00004006{
4007};
4008
Howard Hinnant99968442011-11-29 18:15:50 +00004009template <class _Rp, class _Class, class ..._Param>
4010struct __check_complete<_Rp (_Class::*)(_Param...) &>
Howard Hinnante41f4752012-07-20 18:56:07 +00004011 : private __check_complete<_Class>
Howard Hinnante003ce42011-05-22 00:09:02 +00004012{
4013};
4014
Howard Hinnant99968442011-11-29 18:15:50 +00004015template <class _Rp, class _Class, class ..._Param>
4016struct __check_complete<_Rp (_Class::*)(_Param...) const&>
Howard Hinnante41f4752012-07-20 18:56:07 +00004017 : private __check_complete<_Class>
Howard Hinnante003ce42011-05-22 00:09:02 +00004018{
4019};
4020
Howard Hinnant99968442011-11-29 18:15:50 +00004021template <class _Rp, class _Class, class ..._Param>
4022struct __check_complete<_Rp (_Class::*)(_Param...) volatile&>
Howard Hinnante41f4752012-07-20 18:56:07 +00004023 : private __check_complete<_Class>
Howard Hinnante003ce42011-05-22 00:09:02 +00004024{
4025};
4026
Howard Hinnant99968442011-11-29 18:15:50 +00004027template <class _Rp, class _Class, class ..._Param>
4028struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&>
Howard Hinnante41f4752012-07-20 18:56:07 +00004029 : private __check_complete<_Class>
Howard Hinnante003ce42011-05-22 00:09:02 +00004030{
4031};
4032
Howard Hinnant99968442011-11-29 18:15:50 +00004033template <class _Rp, class _Class, class ..._Param>
4034struct __check_complete<_Rp (_Class::*)(_Param...) &&>
Howard Hinnante41f4752012-07-20 18:56:07 +00004035 : private __check_complete<_Class>
Howard Hinnante003ce42011-05-22 00:09:02 +00004036{
4037};
4038
Howard Hinnant99968442011-11-29 18:15:50 +00004039template <class _Rp, class _Class, class ..._Param>
4040struct __check_complete<_Rp (_Class::*)(_Param...) const&&>
Howard Hinnante41f4752012-07-20 18:56:07 +00004041 : private __check_complete<_Class>
Howard Hinnante003ce42011-05-22 00:09:02 +00004042{
4043};
4044
Howard Hinnant99968442011-11-29 18:15:50 +00004045template <class _Rp, class _Class, class ..._Param>
4046struct __check_complete<_Rp (_Class::*)(_Param...) volatile&&>
Howard Hinnante41f4752012-07-20 18:56:07 +00004047 : private __check_complete<_Class>
Howard Hinnante003ce42011-05-22 00:09:02 +00004048{
4049};
4050
Howard Hinnant99968442011-11-29 18:15:50 +00004051template <class _Rp, class _Class, class ..._Param>
4052struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&&>
Howard Hinnante41f4752012-07-20 18:56:07 +00004053 : private __check_complete<_Class>
Howard Hinnante003ce42011-05-22 00:09:02 +00004054{
4055};
4056
Howard Hinnant99968442011-11-29 18:15:50 +00004057template <class _Rp, class _Class>
4058struct __check_complete<_Rp _Class::*>
Howard Hinnante003ce42011-05-22 00:09:02 +00004059 : private __check_complete<_Class>
4060{
4061};
4062
Eric Fiselier134ff652016-04-18 06:17:30 +00004063
Eric Fiselier8d5cbd72016-04-20 00:14:32 +00004064template <class _Fp, class _A0,
4065 class _DecayFp = typename decay<_Fp>::type,
4066 class _DecayA0 = typename decay<_A0>::type,
4067 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
4068using __enable_if_bullet1 = typename enable_if
4069 <
4070 is_member_function_pointer<_DecayFp>::value
4071 && is_base_of<_ClassT, _DecayA0>::value
4072 >::type;
Eric Fiselier134ff652016-04-18 06:17:30 +00004073
Eric Fiselier8d5cbd72016-04-20 00:14:32 +00004074template <class _Fp, class _A0,
4075 class _DecayFp = typename decay<_Fp>::type,
4076 class _DecayA0 = typename decay<_A0>::type>
4077using __enable_if_bullet2 = typename enable_if
4078 <
4079 is_member_function_pointer<_DecayFp>::value
4080 && __is_reference_wrapper<_DecayA0>::value
4081 >::type;
4082
4083template <class _Fp, class _A0,
4084 class _DecayFp = typename decay<_Fp>::type,
4085 class _DecayA0 = typename decay<_A0>::type,
4086 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
4087using __enable_if_bullet3 = typename enable_if
4088 <
4089 is_member_function_pointer<_DecayFp>::value
4090 && !is_base_of<_ClassT, _DecayA0>::value
4091 && !__is_reference_wrapper<_DecayA0>::value
4092 >::type;
4093
4094template <class _Fp, class _A0,
4095 class _DecayFp = typename decay<_Fp>::type,
4096 class _DecayA0 = typename decay<_A0>::type,
4097 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
4098using __enable_if_bullet4 = typename enable_if
4099 <
4100 is_member_object_pointer<_DecayFp>::value
4101 && is_base_of<_ClassT, _DecayA0>::value
4102 >::type;
4103
4104template <class _Fp, class _A0,
4105 class _DecayFp = typename decay<_Fp>::type,
4106 class _DecayA0 = typename decay<_A0>::type>
4107using __enable_if_bullet5 = typename enable_if
4108 <
4109 is_member_object_pointer<_DecayFp>::value
4110 && __is_reference_wrapper<_DecayA0>::value
4111 >::type;
4112
4113template <class _Fp, class _A0,
4114 class _DecayFp = typename decay<_Fp>::type,
4115 class _DecayA0 = typename decay<_A0>::type,
4116 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
4117using __enable_if_bullet6 = typename enable_if
4118 <
4119 is_member_object_pointer<_DecayFp>::value
4120 && !is_base_of<_ClassT, _DecayA0>::value
4121 && !__is_reference_wrapper<_DecayA0>::value
4122 >::type;
Eric Fiselier134ff652016-04-18 06:17:30 +00004123
Howard Hinnantbd89e4b2011-05-20 22:02:53 +00004124// __invoke forward declarations
Howard Hinnant57cff292011-05-19 15:05:04 +00004125
Howard Hinnantbd89e4b2011-05-20 22:02:53 +00004126// fall back - none of the bullets
Howard Hinnant57cff292011-05-19 15:05:04 +00004127
Eric Fiselier8d5cbd72016-04-20 00:14:32 +00004128#define _LIBCPP_INVOKE_RETURN(...) \
4129 noexcept(noexcept(__VA_ARGS__)) -> decltype(__VA_ARGS__) \
4130 { return __VA_ARGS__; }
4131
Howard Hinnant57cff292011-05-19 15:05:04 +00004132template <class ..._Args>
Eric Fiselier8d5cbd72016-04-20 00:14:32 +00004133auto __invoke(__any, _Args&& ...__args) -> __nat;
4134
4135template <class ..._Args>
4136auto __invoke_constexpr(__any, _Args&& ...__args) -> __nat;
Howard Hinnant57cff292011-05-19 15:05:04 +00004137
Eric Fiselier134ff652016-04-18 06:17:30 +00004138// bullets 1, 2 and 3
Howard Hinnantbd89e4b2011-05-20 22:02:53 +00004139
Howard Hinnantecc97422013-05-07 23:40:12 +00004140template <class _Fp, class _A0, class ..._Args,
Eric Fiselier8d5cbd72016-04-20 00:14:32 +00004141 class = __enable_if_bullet1<_Fp, _A0>>
4142inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbd89e4b2011-05-20 22:02:53 +00004143auto
Howard Hinnant99968442011-11-29 18:15:50 +00004144__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
Eric Fiselier8d5cbd72016-04-20 00:14:32 +00004145_LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
Eric Fiselier134ff652016-04-18 06:17:30 +00004146
Howard Hinnantecc97422013-05-07 23:40:12 +00004147template <class _Fp, class _A0, class ..._Args,
Eric Fiselier8d5cbd72016-04-20 00:14:32 +00004148 class = __enable_if_bullet1<_Fp, _A0>>
4149inline _LIBCPP_INLINE_VISIBILITY
4150_LIBCPP_CONSTEXPR auto
4151__invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4152_LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
Eric Fiselier134ff652016-04-18 06:17:30 +00004153
4154template <class _Fp, class _A0, class ..._Args,
Eric Fiselier8d5cbd72016-04-20 00:14:32 +00004155 class = __enable_if_bullet2<_Fp, _A0>>
4156inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbd89e4b2011-05-20 22:02:53 +00004157auto
Howard Hinnant99968442011-11-29 18:15:50 +00004158__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
Eric Fiselier8d5cbd72016-04-20 00:14:32 +00004159_LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
4160
4161template <class _Fp, class _A0, class ..._Args,
4162 class = __enable_if_bullet2<_Fp, _A0>>
4163inline _LIBCPP_INLINE_VISIBILITY
4164_LIBCPP_CONSTEXPR auto
4165__invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4166_LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
4167
4168template <class _Fp, class _A0, class ..._Args,
4169 class = __enable_if_bullet3<_Fp, _A0>>
4170inline _LIBCPP_INLINE_VISIBILITY
4171auto
4172__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4173_LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
4174
4175template <class _Fp, class _A0, class ..._Args,
4176 class = __enable_if_bullet3<_Fp, _A0>>
4177inline _LIBCPP_INLINE_VISIBILITY
4178_LIBCPP_CONSTEXPR auto
4179__invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4180_LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
Howard Hinnantbd89e4b2011-05-20 22:02:53 +00004181
Eric Fiselier134ff652016-04-18 06:17:30 +00004182// bullets 4, 5 and 6
Howard Hinnantbd89e4b2011-05-20 22:02:53 +00004183
Howard Hinnantecc97422013-05-07 23:40:12 +00004184template <class _Fp, class _A0,
Eric Fiselier8d5cbd72016-04-20 00:14:32 +00004185 class = __enable_if_bullet4<_Fp, _A0>>
4186inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbd89e4b2011-05-20 22:02:53 +00004187auto
Howard Hinnant99968442011-11-29 18:15:50 +00004188__invoke(_Fp&& __f, _A0&& __a0)
Eric Fiselier8d5cbd72016-04-20 00:14:32 +00004189_LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
Eric Fiselier134ff652016-04-18 06:17:30 +00004190
Howard Hinnantecc97422013-05-07 23:40:12 +00004191template <class _Fp, class _A0,
Eric Fiselier8d5cbd72016-04-20 00:14:32 +00004192 class = __enable_if_bullet4<_Fp, _A0>>
4193inline _LIBCPP_INLINE_VISIBILITY
4194_LIBCPP_CONSTEXPR auto
4195__invoke_constexpr(_Fp&& __f, _A0&& __a0)
4196_LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
Eric Fiselier134ff652016-04-18 06:17:30 +00004197
4198template <class _Fp, class _A0,
Eric Fiselier8d5cbd72016-04-20 00:14:32 +00004199 class = __enable_if_bullet5<_Fp, _A0>>
4200inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbd89e4b2011-05-20 22:02:53 +00004201auto
Howard Hinnant99968442011-11-29 18:15:50 +00004202__invoke(_Fp&& __f, _A0&& __a0)
Eric Fiselier8d5cbd72016-04-20 00:14:32 +00004203_LIBCPP_INVOKE_RETURN(__a0.get().*__f)
4204
4205template <class _Fp, class _A0,
4206 class = __enable_if_bullet5<_Fp, _A0>>
4207inline _LIBCPP_INLINE_VISIBILITY
4208_LIBCPP_CONSTEXPR auto
4209__invoke_constexpr(_Fp&& __f, _A0&& __a0)
4210_LIBCPP_INVOKE_RETURN(__a0.get().*__f)
4211
4212template <class _Fp, class _A0,
4213 class = __enable_if_bullet6<_Fp, _A0>>
4214inline _LIBCPP_INLINE_VISIBILITY
4215auto
4216__invoke(_Fp&& __f, _A0&& __a0)
4217_LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
4218
4219template <class _Fp, class _A0,
4220 class = __enable_if_bullet6<_Fp, _A0>>
4221inline _LIBCPP_INLINE_VISIBILITY
4222_LIBCPP_CONSTEXPR auto
4223__invoke_constexpr(_Fp&& __f, _A0&& __a0)
4224_LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
Howard Hinnantbd89e4b2011-05-20 22:02:53 +00004225
Eric Fiselier134ff652016-04-18 06:17:30 +00004226// bullet 7
Howard Hinnantbd89e4b2011-05-20 22:02:53 +00004227
Howard Hinnant99968442011-11-29 18:15:50 +00004228template <class _Fp, class ..._Args>
Eric Fiselier8d5cbd72016-04-20 00:14:32 +00004229inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbd89e4b2011-05-20 22:02:53 +00004230auto
Howard Hinnant99968442011-11-29 18:15:50 +00004231__invoke(_Fp&& __f, _Args&& ...__args)
Eric Fiselier8d5cbd72016-04-20 00:14:32 +00004232_LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
4233
4234template <class _Fp, class ..._Args>
4235inline _LIBCPP_INLINE_VISIBILITY
4236_LIBCPP_CONSTEXPR auto
4237__invoke_constexpr(_Fp&& __f, _Args&& ...__args)
4238_LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
4239
4240#undef _LIBCPP_INVOKE_RETURN
Howard Hinnantbd89e4b2011-05-20 22:02:53 +00004241
4242// __invokable
4243
Eric Fiselier8d5cbd72016-04-20 00:14:32 +00004244template <class _Ret, class _Fp, class ..._Args>
4245struct __invokable_r
Howard Hinnantc4253072012-07-16 16:17:34 +00004246 : private __check_complete<_Fp>
Howard Hinnant57cff292011-05-19 15:05:04 +00004247{
Eric Fiselier8d5cbd72016-04-20 00:14:32 +00004248 using _Result = decltype(
4249 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
4250
4251 static const bool value =
4252 conditional<
4253 !is_same<_Result, __nat>::value,
4254 typename conditional<
4255 is_void<_Ret>::value,
4256 true_type,
4257 is_convertible<_Result, _Ret>
4258 >::type,
4259 false_type
4260 >::type::value;
Howard Hinnant57cff292011-05-19 15:05:04 +00004261};
4262
Howard Hinnant99968442011-11-29 18:15:50 +00004263template <class _Fp, class ..._Args>
Eric Fiselier8d5cbd72016-04-20 00:14:32 +00004264using __invokable = __invokable_r<void, _Fp, _Args...>;
4265
4266template <bool _IsInvokable, bool _IsCVVoid, class _Ret, class _Fp, class ..._Args>
4267struct __nothrow_invokable_r_imp {
4268 static const bool value = false;
Howard Hinnant57cff292011-05-19 15:05:04 +00004269};
4270
Eric Fiselier8d5cbd72016-04-20 00:14:32 +00004271template <class _Ret, class _Fp, class ..._Args>
4272struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
Howard Hinnant57cff292011-05-19 15:05:04 +00004273{
Eric Fiselier8d5cbd72016-04-20 00:14:32 +00004274 typedef __nothrow_invokable_r_imp _ThisT;
4275
4276 template <class _Tp>
4277 static void __test_noexcept(_Tp) noexcept;
4278
4279 static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>(
4280 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)));
Howard Hinnant57cff292011-05-19 15:05:04 +00004281};
4282
Eric Fiselier8d5cbd72016-04-20 00:14:32 +00004283template <class _Ret, class _Fp, class ..._Args>
4284struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...>
Howard Hinnant57cff292011-05-19 15:05:04 +00004285{
Eric Fiselier8d5cbd72016-04-20 00:14:32 +00004286 static const bool value = noexcept(
4287 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
Howard Hinnant57cff292011-05-19 15:05:04 +00004288};
4289
Eric Fiselier8d5cbd72016-04-20 00:14:32 +00004290template <class _Ret, class _Fp, class ..._Args>
4291using __nothrow_invokable_r =
4292 __nothrow_invokable_r_imp<
4293 __invokable_r<_Ret, _Fp, _Args...>::value,
4294 is_void<_Ret>::value,
4295 _Ret, _Fp, _Args...
4296 >;
4297
Howard Hinnant99968442011-11-29 18:15:50 +00004298template <class _Fp, class ..._Args>
Howard Hinnant57cff292011-05-19 15:05:04 +00004299struct __invoke_of
Eric Fiselier8d5cbd72016-04-20 00:14:32 +00004300 : public enable_if<
4301 __invokable<_Fp, _Args...>::value,
4302 typename __invokable_r<void, _Fp, _Args...>::_Result>
Howard Hinnant57cff292011-05-19 15:05:04 +00004303{
4304};
4305
Eric Fiselier8d5cbd72016-04-20 00:14:32 +00004306// result_of
4307
Howard Hinnant2d622292012-06-26 17:37:15 +00004308template <class _Fp, class ..._Args>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00004309class _LIBCPP_TYPE_VIS_ONLY result_of<_Fp(_Args...)>
Howard Hinnant2d622292012-06-26 17:37:15 +00004310 : public __invoke_of<_Fp, _Args...>
4311{
4312};
4313
Marshall Clow933afa92013-07-04 00:10:01 +00004314#if _LIBCPP_STD_VER > 11
4315template <class _Tp> using result_of_t = typename result_of<_Tp>::type;
4316#endif
4317
Eric Fiselier8d5cbd72016-04-20 00:14:32 +00004318#if _LIBCPP_STD_VER > 14
4319
4320// is_callable
4321
4322template <class _Fn, class _Ret = void>
4323struct _LIBCPP_TYPE_VIS_ONLY is_callable;
4324
4325template <class _Fn, class ..._Args, class _Ret>
4326struct _LIBCPP_TYPE_VIS_ONLY is_callable<_Fn(_Args...), _Ret>
4327 : integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value> {};
4328
4329template <class _Fn, class _Ret = void>
4330constexpr bool is_callable_v = is_callable<_Fn, _Ret>::value;
4331
4332// is_nothrow_callable
4333
4334template <class _Fn, class _Ret = void>
4335struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_callable;
4336
4337template <class _Fn, class ..._Args, class _Ret>
4338struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_callable<_Fn(_Args...), _Ret>
4339 : integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value>
4340{};
4341
4342template <class _Fn, class _Ret = void>
4343constexpr bool is_nothrow_callable_v = is_nothrow_callable<_Fn, _Ret>::value;
4344
4345#endif // _LIBCPP_STD_VER > 14
4346
4347#endif // !defined(_LIBCPP_CXX03_LANG)
Howard Hinnant57cff292011-05-19 15:05:04 +00004348
Eric Fiselier8f1e73d2016-04-21 23:38:59 +00004349template <class _Tp> struct __is_swappable;
4350template <class _Tp> struct __is_nothrow_swappable;
4351
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004352template <class _Tp>
4353inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantd36369d2011-07-27 18:34:06 +00004354#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
Howard Hinnant1694d232011-05-28 14:41:13 +00004355typename enable_if
4356<
4357 is_move_constructible<_Tp>::value &&
4358 is_move_assignable<_Tp>::value
4359>::type
Howard Hinnantd36369d2011-07-27 18:34:06 +00004360#else
4361void
4362#endif
Howard Hinnante9b2c2d2011-05-27 15:04:19 +00004363swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
4364 is_nothrow_move_assignable<_Tp>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004365{
Howard Hinnant0949eed2011-06-30 21:18:19 +00004366 _Tp __t(_VSTD::move(__x));
4367 __x = _VSTD::move(__y);
4368 __y = _VSTD::move(__t);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004369}
4370
Eric Fiselier8f1e73d2016-04-21 23:38:59 +00004371template<class _Tp, size_t _Np>
4372inline _LIBCPP_INLINE_VISIBILITY
4373typename enable_if<
4374 __is_swappable<_Tp>::value
4375>::type
4376swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value);
4377
Howard Hinnante9b2c2d2011-05-27 15:04:19 +00004378template <class _ForwardIterator1, class _ForwardIterator2>
4379inline _LIBCPP_INLINE_VISIBILITY
4380void
4381iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
4382 // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
Howard Hinnant0949eed2011-06-30 21:18:19 +00004383 _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(),
4384 *_VSTD::declval<_ForwardIterator2>())))
Howard Hinnante9b2c2d2011-05-27 15:04:19 +00004385{
4386 swap(*__a, *__b);
4387}
4388
Howard Hinnanta5e01212011-05-27 19:08:18 +00004389// __swappable
4390
Howard Hinnant1694d232011-05-28 14:41:13 +00004391namespace __detail
4392{
Eric Fiselier8f1e73d2016-04-21 23:38:59 +00004393// ALL generic swap overloads MUST already have a declaration available at this point.
Howard Hinnanta5e01212011-05-27 19:08:18 +00004394
Eric Fiselier8f1e73d2016-04-21 23:38:59 +00004395template <class _Tp, class _Up = _Tp,
4396 bool _NotVoid = !is_void<_Tp>::value && !is_void<_Up>::value>
4397struct __swappable_with
Howard Hinnanta5e01212011-05-27 19:08:18 +00004398{
Eric Fiselier45e9a932016-07-11 19:57:13 +00004399 template <class _LHS, class _RHS>
4400 static decltype(swap(_VSTD::declval<_LHS>(), _VSTD::declval<_RHS>()))
4401 __test_swap(int);
4402 template <class, class>
4403 static __nat __test_swap(long);
4404
4405 // Extra parens are needed for the C++03 definition of decltype.
4406 typedef decltype((__test_swap<_Tp, _Up>(0))) __swap1;
4407 typedef decltype((__test_swap<_Up, _Tp>(0))) __swap2;
Eric Fiselier8f1e73d2016-04-21 23:38:59 +00004408
4409 static const bool value = !is_same<__swap1, __nat>::value
4410 && !is_same<__swap2, __nat>::value;
Howard Hinnanta5e01212011-05-27 19:08:18 +00004411};
4412
Eric Fiselier8f1e73d2016-04-21 23:38:59 +00004413template <class _Tp, class _Up>
4414struct __swappable_with<_Tp, _Up, false> : false_type {};
4415
4416template <class _Tp, class _Up = _Tp, bool _Swappable = __swappable_with<_Tp, _Up>::value>
4417struct __nothrow_swappable_with {
4418 static const bool value =
4419#ifndef _LIBCPP_HAS_NO_NOEXCEPT
4420 noexcept(swap(_VSTD::declval<_Tp>(), _VSTD::declval<_Up>()))
4421 && noexcept(swap(_VSTD::declval<_Up>(), _VSTD::declval<_Tp>()));
4422#else
4423 false;
4424#endif
4425};
4426
4427template <class _Tp, class _Up>
4428struct __nothrow_swappable_with<_Tp, _Up, false> : false_type {};
4429
Howard Hinnant1694d232011-05-28 14:41:13 +00004430} // __detail
4431
Howard Hinnanta5e01212011-05-27 19:08:18 +00004432template <class _Tp>
4433struct __is_swappable
Eric Fiselier8f1e73d2016-04-21 23:38:59 +00004434 : public integral_constant<bool, __detail::__swappable_with<_Tp&>::value>
Howard Hinnanta5e01212011-05-27 19:08:18 +00004435{
4436};
4437
4438template <class _Tp>
4439struct __is_nothrow_swappable
Eric Fiselier8f1e73d2016-04-21 23:38:59 +00004440 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp&>::value>
Howard Hinnanta5e01212011-05-27 19:08:18 +00004441{
4442};
4443
Eric Fiselier8f1e73d2016-04-21 23:38:59 +00004444#if _LIBCPP_STD_VER > 14
4445
4446template <class _Tp, class _Up>
4447struct _LIBCPP_TYPE_VIS_ONLY is_swappable_with
4448 : public integral_constant<bool, __detail::__swappable_with<_Tp, _Up>::value>
4449{
4450};
Howard Hinnanta5e01212011-05-27 19:08:18 +00004451
4452template <class _Tp>
Eric Fiselier8f1e73d2016-04-21 23:38:59 +00004453struct _LIBCPP_TYPE_VIS_ONLY is_swappable
4454 : public conditional<
4455 __is_referenceable<_Tp>::value,
4456 is_swappable_with<
4457 typename add_lvalue_reference<_Tp>::type,
4458 typename add_lvalue_reference<_Tp>::type>,
4459 false_type
4460 >::type
Howard Hinnanta5e01212011-05-27 19:08:18 +00004461{
4462};
4463
Eric Fiselier8f1e73d2016-04-21 23:38:59 +00004464template <class _Tp, class _Up>
4465struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_swappable_with
4466 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp, _Up>::value>
4467{
4468};
4469
4470template <class _Tp>
4471struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_swappable
4472 : public conditional<
4473 __is_referenceable<_Tp>::value,
4474 is_nothrow_swappable_with<
4475 typename add_lvalue_reference<_Tp>::type,
4476 typename add_lvalue_reference<_Tp>::type>,
4477 false_type
4478 >::type
4479{
4480};
4481
4482template <class _Tp, class _Up>
4483constexpr bool is_swappable_with_v = is_swappable_with<_Tp, _Up>::value;
4484
4485template <class _Tp>
4486constexpr bool is_swappable_v = is_swappable<_Tp>::value;
4487
4488template <class _Tp, class _Up>
4489constexpr bool is_nothrow_swappable_with_v = is_nothrow_swappable_with<_Tp, _Up>::value;
4490
4491template <class _Tp>
4492constexpr bool is_nothrow_swappable_v = is_nothrow_swappable<_Tp>::value;
4493
4494#endif // _LIBCPP_STD_VER > 14
Howard Hinnanta5e01212011-05-27 19:08:18 +00004495
Marshall Clow81aa3a72014-06-26 01:07:56 +00004496#ifdef _LIBCPP_UNDERLYING_TYPE
Sean Hunt737a3512011-07-18 18:37:21 +00004497
4498template <class _Tp>
4499struct underlying_type
4500{
Marshall Clow81aa3a72014-06-26 01:07:56 +00004501 typedef _LIBCPP_UNDERLYING_TYPE(_Tp) type;
Sean Hunt737a3512011-07-18 18:37:21 +00004502};
4503
Marshall Clow933afa92013-07-04 00:10:01 +00004504#if _LIBCPP_STD_VER > 11
4505template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
4506#endif
4507
Marshall Clow81aa3a72014-06-26 01:07:56 +00004508#else // _LIBCPP_UNDERLYING_TYPE
Sean Hunt737a3512011-07-18 18:37:21 +00004509
4510template <class _Tp, bool _Support = false>
4511struct underlying_type
4512{
4513 static_assert(_Support, "The underyling_type trait requires compiler "
4514 "support. Either no such support exists or "
4515 "libc++ does not know how to use it.");
4516};
4517
Marshall Clow81aa3a72014-06-26 01:07:56 +00004518#endif // _LIBCPP_UNDERLYING_TYPE
Sean Hunt737a3512011-07-18 18:37:21 +00004519
Eric Fiselier31cb7fe2015-02-10 16:46:42 +00004520
Eric Fiselier14273e82016-05-18 23:09:24 +00004521template <class _Tp, bool = is_enum<_Tp>::value>
Eric Fiselier31cb7fe2015-02-10 16:46:42 +00004522struct __sfinae_underlying_type
4523{
4524 typedef typename underlying_type<_Tp>::type type;
4525 typedef decltype(((type)1) + 0) __promoted_type;
4526};
4527
4528template <class _Tp>
4529struct __sfinae_underlying_type<_Tp, false> {};
4530
Eric Fiselierbbca1742015-12-10 00:43:37 +00004531inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier31cb7fe2015-02-10 16:46:42 +00004532int __convert_to_integral(int __val) { return __val; }
4533
Eric Fiselierbbca1742015-12-10 00:43:37 +00004534inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier31cb7fe2015-02-10 16:46:42 +00004535unsigned __convert_to_integral(unsigned __val) { return __val; }
4536
Eric Fiselierbbca1742015-12-10 00:43:37 +00004537inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier31cb7fe2015-02-10 16:46:42 +00004538long __convert_to_integral(long __val) { return __val; }
4539
Eric Fiselierbbca1742015-12-10 00:43:37 +00004540inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier31cb7fe2015-02-10 16:46:42 +00004541unsigned long __convert_to_integral(unsigned long __val) { return __val; }
4542
Eric Fiselierbbca1742015-12-10 00:43:37 +00004543inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier31cb7fe2015-02-10 16:46:42 +00004544long long __convert_to_integral(long long __val) { return __val; }
4545
Eric Fiselierbbca1742015-12-10 00:43:37 +00004546inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier31cb7fe2015-02-10 16:46:42 +00004547unsigned long long __convert_to_integral(unsigned long long __val) {return __val; }
4548
4549#ifndef _LIBCPP_HAS_NO_INT128
Eric Fiselierbbca1742015-12-10 00:43:37 +00004550inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier31cb7fe2015-02-10 16:46:42 +00004551__int128_t __convert_to_integral(__int128_t __val) { return __val; }
4552
Eric Fiselierbbca1742015-12-10 00:43:37 +00004553inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier31cb7fe2015-02-10 16:46:42 +00004554__uint128_t __convert_to_integral(__uint128_t __val) { return __val; }
4555#endif
4556
4557template <class _Tp>
Eric Fiselierbbca1742015-12-10 00:43:37 +00004558inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier31cb7fe2015-02-10 16:46:42 +00004559typename __sfinae_underlying_type<_Tp>::__promoted_type
4560__convert_to_integral(_Tp __val) { return __val; }
4561
Howard Hinnant01afa5c2013-09-02 20:30:37 +00004562#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
4563
4564template <class _Tp>
Eric Fiselier341b5902014-11-05 20:59:18 +00004565struct __has_operator_addressof_member_imp
Howard Hinnant01afa5c2013-09-02 20:30:37 +00004566{
Howard Hinnant01afa5c2013-09-02 20:30:37 +00004567 template <class _Up>
Eric Fiselierb6e0ef22014-11-05 21:20:10 +00004568 static auto __test(int)
4569 -> typename __select_2nd<decltype(_VSTD::declval<_Up>().operator&()), true_type>::type;
4570 template <class>
4571 static auto __test(long) -> false_type;
Howard Hinnant01afa5c2013-09-02 20:30:37 +00004572
Eric Fiselierb6e0ef22014-11-05 21:20:10 +00004573 static const bool value = decltype(__test<_Tp>(0))::value;
Howard Hinnant01afa5c2013-09-02 20:30:37 +00004574};
4575
4576template <class _Tp>
Eric Fiselier341b5902014-11-05 20:59:18 +00004577struct __has_operator_addressof_free_imp
4578{
Eric Fiselier341b5902014-11-05 20:59:18 +00004579 template <class _Up>
Eric Fiselierb6e0ef22014-11-05 21:20:10 +00004580 static auto __test(int)
4581 -> typename __select_2nd<decltype(operator&(_VSTD::declval<_Up>())), true_type>::type;
4582 template <class>
4583 static auto __test(long) -> false_type;
Eric Fiselier341b5902014-11-05 20:59:18 +00004584
Eric Fiselierb6e0ef22014-11-05 21:20:10 +00004585 static const bool value = decltype(__test<_Tp>(0))::value;
Eric Fiselier341b5902014-11-05 20:59:18 +00004586};
4587
4588template <class _Tp>
Howard Hinnant01afa5c2013-09-02 20:30:37 +00004589struct __has_operator_addressof
Eric Fiselier341b5902014-11-05 20:59:18 +00004590 : public integral_constant<bool, __has_operator_addressof_member_imp<_Tp>::value
4591 || __has_operator_addressof_free_imp<_Tp>::value>
Howard Hinnant01afa5c2013-09-02 20:30:37 +00004592{};
4593
4594#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
4595
Marshall Clow88aae922014-11-17 15:50:08 +00004596#if _LIBCPP_STD_VER > 14
4597template <class...> using void_t = void;
Marshall Clowfe99a302015-11-16 15:54:13 +00004598
4599# ifndef _LIBCPP_HAS_NO_VARIADICS
4600template <class... _Args>
4601struct conjunction : __and_<_Args...> {};
4602template<class... _Args> constexpr bool conjunction_v = conjunction<_Args...>::value;
4603
4604template <class... _Args>
4605struct disjunction : __or_<_Args...> {};
4606template<class... _Args> constexpr bool disjunction_v = disjunction<_Args...>::value;
4607
4608template <class _Tp>
4609struct negation : __not_<_Tp> {};
4610template<class _Tp> constexpr bool negation_v = negation<_Tp>::value;
4611# endif // _LIBCPP_HAS_NO_VARIADICS
4612#endif // _LIBCPP_STD_VER > 14
Marshall Clow88aae922014-11-17 15:50:08 +00004613
Eric Fiselier83c9dc12016-04-15 23:27:27 +00004614// These traits are used in __tree and __hash_table
4615#ifndef _LIBCPP_CXX03_LANG
4616struct __extract_key_fail_tag {};
4617struct __extract_key_self_tag {};
4618struct __extract_key_first_tag {};
4619
4620template <class _ValTy, class _Key,
4621 class _RawValTy = typename __unconstref<_ValTy>::type>
4622struct __can_extract_key
4623 : conditional<is_same<_RawValTy, _Key>::value, __extract_key_self_tag,
4624 __extract_key_fail_tag>::type {};
4625
4626template <class _Pair, class _Key, class _First, class _Second>
4627struct __can_extract_key<_Pair, _Key, pair<_First, _Second>>
4628 : conditional<is_same<typename remove_const<_First>::type, _Key>::value,
4629 __extract_key_first_tag, __extract_key_fail_tag>::type {};
Eric Fiselierdc414cd2016-04-16 00:23:12 +00004630
4631// __can_extract_map_key uses true_type/false_type instead of the tags.
4632// It returns true if _Key != _ContainerValueTy (the container is a map not a set)
4633// and _ValTy == _Key.
4634template <class _ValTy, class _Key, class _ContainerValueTy,
4635 class _RawValTy = typename __unconstref<_ValTy>::type>
4636struct __can_extract_map_key
4637 : integral_constant<bool, is_same<_RawValTy, _Key>::value> {};
4638
4639// This specialization returns __extract_key_fail_tag for non-map containers
4640// because _Key == _ContainerValueTy
4641template <class _ValTy, class _Key, class _RawValTy>
4642struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy>
4643 : false_type {};
4644
Eric Fiselier83c9dc12016-04-15 23:27:27 +00004645#endif
4646
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004647_LIBCPP_END_NAMESPACE_STD
4648
4649#endif // _LIBCPP_TYPE_TRAITS