type_traits revision 232950
1227825Stheraven// -*- C++ -*-
2227825Stheraven//===------------------------ type_traits ---------------------------------===//
3227825Stheraven//
4227825Stheraven//                     The LLVM Compiler Infrastructure
5227825Stheraven//
6227825Stheraven// This file is dual licensed under the MIT and the University of Illinois Open
7227825Stheraven// Source Licenses. See LICENSE.TXT for details.
8227825Stheraven//
9227825Stheraven//===----------------------------------------------------------------------===//
10227825Stheraven
11227825Stheraven#ifndef _LIBCPP_TYPE_TRAITS
12227825Stheraven#define _LIBCPP_TYPE_TRAITS
13227825Stheraven
14227825Stheraven/*
15227825Stheraven    type_traits synopsis
16227825Stheraven
17227825Stheravennamespace std
18227825Stheraven{
19227825Stheraven
20227825Stheraven    // helper class:
21227825Stheraven    template <class T, T v> struct integral_constant;
22227825Stheraven    typedef integral_constant<bool, true>  true_type;
23227825Stheraven    typedef integral_constant<bool, false> false_type;
24227825Stheraven
25227825Stheraven    // helper traits
26227825Stheraven    template <bool, class T = void> struct enable_if;
27227825Stheraven    template <bool, class T, class F> struct conditional;
28227825Stheraven
29227825Stheraven    // Primary classification traits:
30227825Stheraven    template <class T> struct is_void;
31227825Stheraven    template <class T> struct is_integral;
32227825Stheraven    template <class T> struct is_floating_point;
33227825Stheraven    template <class T> struct is_array;
34227825Stheraven    template <class T> struct is_pointer;
35227825Stheraven    template <class T> struct is_lvalue_reference;
36227825Stheraven    template <class T> struct is_rvalue_reference;
37227825Stheraven    template <class T> struct is_member_object_pointer;
38227825Stheraven    template <class T> struct is_member_function_pointer;
39227825Stheraven    template <class T> struct is_enum;
40227825Stheraven    template <class T> struct is_union;
41227825Stheraven    template <class T> struct is_class;
42227825Stheraven    template <class T> struct is_function;
43227825Stheraven
44227825Stheraven    // Secondary classification traits:
45227825Stheraven    template <class T> struct is_reference;
46227825Stheraven    template <class T> struct is_arithmetic;
47227825Stheraven    template <class T> struct is_fundamental;
48227825Stheraven    template <class T> struct is_member_pointer;
49227825Stheraven    template <class T> struct is_scalar;
50227825Stheraven    template <class T> struct is_object;
51227825Stheraven    template <class T> struct is_compound;
52227825Stheraven
53227825Stheraven    // Const-volatile properties and transformations:
54227825Stheraven    template <class T> struct is_const;
55227825Stheraven    template <class T> struct is_volatile;
56227825Stheraven    template <class T> struct remove_const;
57227825Stheraven    template <class T> struct remove_volatile;
58227825Stheraven    template <class T> struct remove_cv;
59227825Stheraven    template <class T> struct add_const;
60227825Stheraven    template <class T> struct add_volatile;
61227825Stheraven    template <class T> struct add_cv;
62227825Stheraven
63227825Stheraven    // Reference transformations:
64227825Stheraven    template <class T> struct remove_reference;
65227825Stheraven    template <class T> struct add_lvalue_reference;
66227825Stheraven    template <class T> struct add_rvalue_reference;
67227825Stheraven
68227825Stheraven    // Pointer transformations:
69227825Stheraven    template <class T> struct remove_pointer;
70227825Stheraven    template <class T> struct add_pointer;
71227825Stheraven
72227825Stheraven    // Integral properties:
73227825Stheraven    template <class T> struct is_signed;
74227825Stheraven    template <class T> struct is_unsigned;
75227825Stheraven    template <class T> struct make_signed;
76227825Stheraven    template <class T> struct make_unsigned;
77227825Stheraven
78227825Stheraven    // Array properties and transformations:
79227825Stheraven    template <class T> struct rank;
80227825Stheraven    template <class T, unsigned I = 0> struct extent;
81227825Stheraven    template <class T> struct remove_extent;
82227825Stheraven    template <class T> struct remove_all_extents;
83227825Stheraven
84227825Stheraven    // Member introspection:
85227825Stheraven    template <class T> struct is_pod;
86227825Stheraven    template <class T> struct is_trivial;
87227825Stheraven    template <class T> struct is_trivially_copyable;
88227825Stheraven    template <class T> struct is_standard_layout;
89227825Stheraven    template <class T> struct is_literal_type;
90227825Stheraven    template <class T> struct is_empty;
91227825Stheraven    template <class T> struct is_polymorphic;
92227825Stheraven    template <class T> struct is_abstract;
93227825Stheraven
94227825Stheraven    template <class T, class... Args> struct is_constructible;
95227825Stheraven    template <class T>                struct is_default_constructible;
96227825Stheraven    template <class T>                struct is_copy_constructible;
97227825Stheraven    template <class T>                struct is_move_constructible;
98227825Stheraven    template <class T, class U>       struct is_assignable;
99227825Stheraven    template <class T>                struct is_copy_assignable;
100227825Stheraven    template <class T>                struct is_move_assignable;
101227825Stheraven    template <class T>                struct is_destructible;
102227825Stheraven
103227825Stheraven    template <class T, class... Args> struct is_trivially_constructible;
104227825Stheraven    template <class T>                struct is_trivially_default_constructible;
105227825Stheraven    template <class T>                struct is_trivially_copy_constructible;
106227825Stheraven    template <class T>                struct is_trivially_move_constructible;
107227825Stheraven    template <class T, class U>       struct is_trivially_assignable;
108227825Stheraven    template <class T>                struct is_trivially_copy_assignable;
109227825Stheraven    template <class T>                struct is_trivially_move_assignable;
110227825Stheraven    template <class T>                struct is_trivially_destructible;
111227825Stheraven
112227825Stheraven    template <class T, class... Args> struct is_nothrow_constructible;
113227825Stheraven    template <class T>                struct is_nothrow_default_constructible;
114227825Stheraven    template <class T>                struct is_nothrow_copy_constructible;
115227825Stheraven    template <class T>                struct is_nothrow_move_constructible;
116227825Stheraven    template <class T, class U>       struct is_nothrow_assignable;
117227825Stheraven    template <class T>                struct is_nothrow_copy_assignable;
118227825Stheraven    template <class T>                struct is_nothrow_move_assignable;
119227825Stheraven    template <class T>                struct is_nothrow_destructible;
120227825Stheraven
121227825Stheraven    template <class T> struct has_virtual_destructor;
122227825Stheraven
123227825Stheraven    // Relationships between types:
124227825Stheraven    template <class T, class U> struct is_same;
125227825Stheraven    template <class Base, class Derived> struct is_base_of;
126227825Stheraven    template <class From, class To> struct is_convertible;
127227825Stheraven
128227825Stheraven    // Alignment properties and transformations:
129227825Stheraven    template <class T> struct alignment_of;
130227825Stheraven    template <size_t Len, size_t Align = most_stringent_alignment_requirement>
131227825Stheraven        struct aligned_storage;
132227825Stheraven
133227825Stheraven    template <class T> struct decay;
134227825Stheraven    template <class... T> struct common_type;
135227825Stheraven    template <class T> struct underlying_type;
136227825Stheraven    template <class> class result_of; // undefined
137227825Stheraven    template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>;
138227825Stheraven
139227825Stheraven}  // std
140227825Stheraven
141227825Stheraven*/
142227825Stheraven#include <__config>
143227825Stheraven#include <cstddef>
144227825Stheraven
145227825Stheraven#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
146227825Stheraven#pragma GCC system_header
147227825Stheraven#endif
148227825Stheraven
149227825Stheraven_LIBCPP_BEGIN_NAMESPACE_STD
150227825Stheraven
151232950Stheraventemplate <bool _Bp, class _If, class _Then>
152227825Stheraven    struct _LIBCPP_VISIBLE conditional {typedef _If type;};
153227825Stheraventemplate <class _If, class _Then>
154227825Stheraven    struct _LIBCPP_VISIBLE conditional<false, _If, _Then> {typedef _Then type;};
155227825Stheraven
156227825Stheraventemplate <bool, class _Tp = void> struct _LIBCPP_VISIBLE enable_if {};
157227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE enable_if<true, _Tp> {typedef _Tp type;};
158227825Stheraven
159227825Stheravenstruct __two {char _[2];};
160227825Stheraven
161227825Stheraven// helper class:
162227825Stheraven
163227825Stheraventemplate <class _Tp, _Tp __v>
164227825Stheravenstruct _LIBCPP_VISIBLE integral_constant
165227825Stheraven{
166227825Stheraven    static constexpr _Tp      value = __v;
167227825Stheraven    typedef _Tp               value_type;
168227825Stheraven    typedef integral_constant type;
169227825Stheraven    _LIBCPP_INLINE_VISIBILITY
170227825Stheraven#ifndef _LIBCPP_HAS_NO_CONSTEXPR
171227825Stheraven    constexpr
172227825Stheraven#endif
173227825Stheraven         operator value_type()
174227825Stheraven#ifdef _LIBCPP_HAS_NO_CONSTEXPR
175227825Stheraven                               const
176227825Stheraven#endif
177227825Stheraven                                     {return value;}
178227825Stheraven};
179227825Stheraven
180227825Stheraventemplate <class _Tp, _Tp __v>
181227825Stheravenconstexpr _Tp integral_constant<_Tp, __v>::value;
182227825Stheraven
183227825Stheraventypedef integral_constant<bool, true>  true_type;
184227825Stheraventypedef integral_constant<bool, false> false_type;
185227825Stheraven
186227825Stheraven// is_const
187227825Stheraven
188227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_const            : public false_type {};
189227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_const<_Tp const> : public true_type {};
190227825Stheraven
191227825Stheraven// is_volatile
192227825Stheraven
193227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_volatile               : public false_type {};
194227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_volatile<_Tp volatile> : public true_type {};
195227825Stheraven
196227825Stheraven// remove_const
197227825Stheraven
198227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE remove_const            {typedef _Tp type;};
199227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE remove_const<const _Tp> {typedef _Tp type;};
200227825Stheraven
201227825Stheraven// remove_volatile
202227825Stheraven
203227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE remove_volatile               {typedef _Tp type;};
204227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE remove_volatile<volatile _Tp> {typedef _Tp type;};
205227825Stheraven
206227825Stheraven// remove_cv
207227825Stheraven
208227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE remove_cv
209227825Stheraven{typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
210227825Stheraven
211227825Stheraven// is_void
212227825Stheraven
213227825Stheraventemplate <class _Tp> struct __is_void       : public false_type {};
214227825Stheraventemplate <>          struct __is_void<void> : public true_type {};
215227825Stheraven
216227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_void
217227825Stheraven    : public __is_void<typename remove_cv<_Tp>::type> {};
218227825Stheraven
219227825Stheraven// __is_nullptr_t
220227825Stheraven
221227825Stheraventemplate <class _Tp> struct ____is_nullptr_t       : public false_type {};
222227825Stheraventemplate <>          struct ____is_nullptr_t<nullptr_t> : public true_type {};
223227825Stheraven
224227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE __is_nullptr_t
225227825Stheraven    : public ____is_nullptr_t<typename remove_cv<_Tp>::type> {};
226227825Stheraven
227227825Stheraven// is_integral
228227825Stheraven
229227825Stheraventemplate <class _Tp> struct __is_integral                     : public false_type {};
230227825Stheraventemplate <>          struct __is_integral<bool>               : public true_type {};
231227825Stheraventemplate <>          struct __is_integral<char>               : public true_type {};
232227825Stheraventemplate <>          struct __is_integral<signed char>        : public true_type {};
233227825Stheraventemplate <>          struct __is_integral<unsigned char>      : public true_type {};
234227825Stheraventemplate <>          struct __is_integral<wchar_t>            : public true_type {};
235227825Stheraven#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
236227825Stheraventemplate <>          struct __is_integral<char16_t>           : public true_type {};
237227825Stheraventemplate <>          struct __is_integral<char32_t>           : public true_type {};
238227825Stheraven#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
239227825Stheraventemplate <>          struct __is_integral<short>              : public true_type {};
240227825Stheraventemplate <>          struct __is_integral<unsigned short>     : public true_type {};
241227825Stheraventemplate <>          struct __is_integral<int>                : public true_type {};
242227825Stheraventemplate <>          struct __is_integral<unsigned int>       : public true_type {};
243227825Stheraventemplate <>          struct __is_integral<long>               : public true_type {};
244227825Stheraventemplate <>          struct __is_integral<unsigned long>      : public true_type {};
245227825Stheraventemplate <>          struct __is_integral<long long>          : public true_type {};
246227825Stheraventemplate <>          struct __is_integral<unsigned long long> : public true_type {};
247227825Stheraven
248227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_integral
249227825Stheraven    : public __is_integral<typename remove_cv<_Tp>::type> {};
250227825Stheraven
251227825Stheraven// is_floating_point
252227825Stheraven
253227825Stheraventemplate <class _Tp> struct __is_floating_point              : public false_type {};
254227825Stheraventemplate <>          struct __is_floating_point<float>       : public true_type {};
255227825Stheraventemplate <>          struct __is_floating_point<double>      : public true_type {};
256227825Stheraventemplate <>          struct __is_floating_point<long double> : public true_type {};
257227825Stheraven
258227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_floating_point
259227825Stheraven    : public __is_floating_point<typename remove_cv<_Tp>::type> {};
260227825Stheraven
261227825Stheraven// is_array
262227825Stheraven
263227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_array
264227825Stheraven    : public false_type {};
265227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_array<_Tp[]>
266227825Stheraven    : public true_type {};
267227825Stheraventemplate <class _Tp, size_t _Np> struct _LIBCPP_VISIBLE is_array<_Tp[_Np]>
268227825Stheraven    : public true_type {};
269227825Stheraven
270227825Stheraven// is_pointer
271227825Stheraven
272227825Stheraventemplate <class _Tp> struct __is_pointer       : public false_type {};
273227825Stheraventemplate <class _Tp> struct __is_pointer<_Tp*> : public true_type {};
274227825Stheraven
275227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_pointer
276227825Stheraven    : public __is_pointer<typename remove_cv<_Tp>::type> {};
277227825Stheraven
278227825Stheraven// is_reference
279227825Stheraven
280227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_lvalue_reference       : public false_type {};
281227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_lvalue_reference<_Tp&> : public true_type {};
282227825Stheraven
283227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_rvalue_reference        : public false_type {};
284227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
285227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_rvalue_reference<_Tp&&> : public true_type {};
286227825Stheraven#endif
287227825Stheraven
288227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_reference        : public false_type {};
289227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_reference<_Tp&>  : public true_type {};
290227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
291227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_reference<_Tp&&> : public true_type {};
292227825Stheraven#endif
293227825Stheraven
294227825Stheraven#if defined(__clang__) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
295227825Stheraven#define _LIBCPP_HAS_TYPE_TRAITS
296227825Stheraven#endif
297227825Stheraven
298227825Stheraven// is_union
299227825Stheraven
300227825Stheraven#if __has_feature(is_union) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
301227825Stheraven
302227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_union
303227825Stheraven    : public integral_constant<bool, __is_union(_Tp)> {};
304227825Stheraven
305227825Stheraven#else
306227825Stheraven
307227825Stheraventemplate <class _Tp> struct __libcpp_union : public false_type {};
308227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_union
309227825Stheraven    : public __libcpp_union<typename remove_cv<_Tp>::type> {};
310227825Stheraven
311227825Stheraven#endif
312227825Stheraven
313227825Stheraven// is_class
314227825Stheraven
315227825Stheraven#if __has_feature(is_class) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
316227825Stheraven
317227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_class
318227825Stheraven    : public integral_constant<bool, __is_class(_Tp)> {};
319227825Stheraven
320227825Stheraven#else
321227825Stheraven
322227825Stheravennamespace __is_class_imp
323227825Stheraven{
324227825Stheraventemplate <class _Tp> char  __test(int _Tp::*);
325227825Stheraventemplate <class _Tp> __two __test(...);
326227825Stheraven}
327227825Stheraven
328227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_class
329227825Stheraven    : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {};
330227825Stheraven
331227825Stheraven#endif
332227825Stheraven
333227825Stheraven// is_same
334227825Stheraven
335227825Stheraventemplate <class _Tp, class _Up> struct _LIBCPP_VISIBLE is_same           : public false_type {};
336227825Stheraventemplate <class _Tp>            struct _LIBCPP_VISIBLE is_same<_Tp, _Tp> : public true_type {};
337227825Stheraven
338227825Stheraven// is_function
339227825Stheraven
340227825Stheravennamespace __is_function_imp
341227825Stheraven{
342227825Stheraventemplate <class _Tp> char  __test(_Tp*);
343227825Stheraventemplate <class _Tp> __two __test(...);
344227825Stheraventemplate <class _Tp> _Tp&  __source();
345227825Stheraven}
346227825Stheraven
347227825Stheraventemplate <class _Tp, bool = is_class<_Tp>::value ||
348227825Stheraven                            is_union<_Tp>::value ||
349227825Stheraven                            is_void<_Tp>::value  ||
350227825Stheraven                            is_reference<_Tp>::value ||
351227825Stheraven                            is_same<_Tp, nullptr_t>::value >
352227825Stheravenstruct __is_function
353227825Stheraven    : public integral_constant<bool, sizeof(__is_function_imp::__test<_Tp>(__is_function_imp::__source<_Tp>())) == 1>
354227825Stheraven    {};
355227825Stheraventemplate <class _Tp> struct __is_function<_Tp, true> : public false_type {};
356227825Stheraven
357227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_function
358227825Stheraven    : public __is_function<_Tp> {};
359227825Stheraven
360227825Stheraven// is_member_function_pointer
361227825Stheraven
362227825Stheraventemplate <class _Tp> struct            __is_member_function_pointer             : public false_type {};
363227825Stheraventemplate <class _Tp, class _Up> struct __is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {};
364227825Stheraven
365227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_member_function_pointer
366227825Stheraven    : public __is_member_function_pointer<typename remove_cv<_Tp>::type> {};
367227825Stheraven
368227825Stheraven// is_member_pointer
369227825Stheraven
370227825Stheraventemplate <class _Tp>            struct __is_member_pointer             : public false_type {};
371227825Stheraventemplate <class _Tp, class _Up> struct __is_member_pointer<_Tp _Up::*> : public true_type {};
372227825Stheraven
373227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_member_pointer
374227825Stheraven    : public __is_member_pointer<typename remove_cv<_Tp>::type> {};
375227825Stheraven
376227825Stheraven// is_member_object_pointer
377227825Stheraven
378227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_member_object_pointer
379227825Stheraven    : public integral_constant<bool, is_member_pointer<_Tp>::value &&
380227825Stheraven                                    !is_member_function_pointer<_Tp>::value> {};
381227825Stheraven
382227825Stheraven// is_enum
383227825Stheraven
384227825Stheraven#if __has_feature(is_enum) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
385227825Stheraven
386227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_enum
387227825Stheraven    : public integral_constant<bool, __is_enum(_Tp)> {};
388227825Stheraven
389227825Stheraven#else
390227825Stheraven
391227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_enum
392227825Stheraven    : public integral_constant<bool, !is_void<_Tp>::value             &&
393227825Stheraven                                     !is_integral<_Tp>::value         &&
394227825Stheraven                                     !is_floating_point<_Tp>::value   &&
395227825Stheraven                                     !is_array<_Tp>::value            &&
396227825Stheraven                                     !is_pointer<_Tp>::value          &&
397227825Stheraven                                     !is_reference<_Tp>::value        &&
398227825Stheraven                                     !is_member_pointer<_Tp>::value   &&
399227825Stheraven                                     !is_union<_Tp>::value            &&
400227825Stheraven                                     !is_class<_Tp>::value            &&
401227825Stheraven                                     !is_function<_Tp>::value         > {};
402227825Stheraven
403227825Stheraven#endif
404227825Stheraven
405227825Stheraven// is_arithmetic
406227825Stheraven
407227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_arithmetic
408227825Stheraven    : public integral_constant<bool, is_integral<_Tp>::value      ||
409227825Stheraven                                     is_floating_point<_Tp>::value> {};
410227825Stheraven
411227825Stheraven// is_fundamental
412227825Stheraven
413227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_fundamental
414227825Stheraven    : public integral_constant<bool, is_void<_Tp>::value        ||
415227825Stheraven                                     __is_nullptr_t<_Tp>::value ||
416227825Stheraven                                     is_arithmetic<_Tp>::value> {};
417227825Stheraven
418227825Stheraven// is_scalar
419227825Stheraven
420227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_scalar
421227825Stheraven    : public integral_constant<bool, is_arithmetic<_Tp>::value     ||
422227825Stheraven                                     is_member_pointer<_Tp>::value ||
423227825Stheraven                                     is_pointer<_Tp>::value        ||
424227825Stheraven                                     __is_nullptr_t<_Tp>::value    ||
425227825Stheraven                                     is_enum<_Tp>::value           > {};
426227825Stheraven
427227825Stheraventemplate <> struct _LIBCPP_VISIBLE is_scalar<nullptr_t> : public true_type {};
428227825Stheraven
429227825Stheraven// is_object
430227825Stheraven
431227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_object
432227825Stheraven    : public integral_constant<bool, is_scalar<_Tp>::value ||
433227825Stheraven                                     is_array<_Tp>::value  ||
434227825Stheraven                                     is_union<_Tp>::value  ||
435227825Stheraven                                     is_class<_Tp>::value  > {};
436227825Stheraven
437227825Stheraven// is_compound
438227825Stheraven
439227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_compound
440227825Stheraven    : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
441227825Stheraven
442227825Stheraven// add_const
443227825Stheraven
444227825Stheraventemplate <class _Tp, bool = is_reference<_Tp>::value ||
445227825Stheraven                            is_function<_Tp>::value  ||
446227825Stheraven                            is_const<_Tp>::value     >
447227825Stheravenstruct __add_const             {typedef _Tp type;};
448227825Stheraven
449227825Stheraventemplate <class _Tp>
450227825Stheravenstruct __add_const<_Tp, false> {typedef const _Tp type;};
451227825Stheraven
452227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE add_const
453227825Stheraven    {typedef typename __add_const<_Tp>::type type;};
454227825Stheraven
455227825Stheraven// add_volatile
456227825Stheraven
457227825Stheraventemplate <class _Tp, bool = is_reference<_Tp>::value ||
458227825Stheraven                            is_function<_Tp>::value  ||
459227825Stheraven                            is_volatile<_Tp>::value  >
460227825Stheravenstruct __add_volatile             {typedef _Tp type;};
461227825Stheraven
462227825Stheraventemplate <class _Tp>
463227825Stheravenstruct __add_volatile<_Tp, false> {typedef volatile _Tp type;};
464227825Stheraven
465227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE add_volatile
466227825Stheraven    {typedef typename __add_volatile<_Tp>::type type;};
467227825Stheraven
468227825Stheraven// add_cv
469227825Stheraven
470227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE add_cv
471227825Stheraven    {typedef typename add_const<typename add_volatile<_Tp>::type>::type type;};
472227825Stheraven
473227825Stheraven// remove_reference
474227825Stheraven
475227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE remove_reference        {typedef _Tp type;};
476227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE remove_reference<_Tp&>  {typedef _Tp type;};
477227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
478227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE remove_reference<_Tp&&> {typedef _Tp type;};
479227825Stheraven#endif
480227825Stheraven
481227825Stheraven// add_lvalue_reference
482227825Stheraven
483227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE add_lvalue_reference                      {typedef _Tp& type;};
484227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE add_lvalue_reference<_Tp&>                {typedef _Tp& type;};  // for older compiler
485227825Stheraventemplate <>          struct _LIBCPP_VISIBLE add_lvalue_reference<void>                {typedef void type;};
486227825Stheraventemplate <>          struct _LIBCPP_VISIBLE add_lvalue_reference<const void>          {typedef const void type;};
487227825Stheraventemplate <>          struct _LIBCPP_VISIBLE add_lvalue_reference<volatile void>       {typedef volatile void type;};
488227825Stheraventemplate <>          struct _LIBCPP_VISIBLE add_lvalue_reference<const volatile void> {typedef const volatile void type;};
489227825Stheraven
490227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
491227825Stheraven
492227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE  add_rvalue_reference                     {typedef _Tp&& type;};
493227825Stheraventemplate <>          struct _LIBCPP_VISIBLE add_rvalue_reference<void>                {typedef void type;};
494227825Stheraventemplate <>          struct _LIBCPP_VISIBLE add_rvalue_reference<const void>          {typedef const void type;};
495227825Stheraventemplate <>          struct _LIBCPP_VISIBLE add_rvalue_reference<volatile void>       {typedef volatile void type;};
496227825Stheraventemplate <>          struct _LIBCPP_VISIBLE add_rvalue_reference<const volatile void> {typedef const volatile void type;};
497227825Stheraven
498227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
499227825Stheraven
500227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
501227825Stheraven
502227825Stheraventemplate <class _Tp>
503227825Stheraventypename add_rvalue_reference<_Tp>::type
504227825Stheravendeclval() _NOEXCEPT;
505227825Stheraven
506227825Stheraven#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
507227825Stheraven
508227825Stheraventemplate <class _Tp>
509227825Stheraventypename add_lvalue_reference<_Tp>::type
510227825Stheravendeclval();
511227825Stheraven
512227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
513227825Stheraven
514227825Stheravenstruct __any
515227825Stheraven{
516227825Stheraven    __any(...);
517227825Stheraven};
518227825Stheraven
519227825Stheraven// remove_pointer
520227825Stheraven
521227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE remove_pointer                      {typedef _Tp type;};
522227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE remove_pointer<_Tp*>                {typedef _Tp type;};
523227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE remove_pointer<_Tp* const>          {typedef _Tp type;};
524227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE remove_pointer<_Tp* volatile>       {typedef _Tp type;};
525227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE remove_pointer<_Tp* const volatile> {typedef _Tp type;};
526227825Stheraven
527227825Stheraven// add_pointer
528227825Stheraven
529227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE add_pointer
530227825Stheraven    {typedef typename remove_reference<_Tp>::type* type;};
531227825Stheraven
532227825Stheraven// is_signed
533227825Stheraven
534227825Stheraventemplate <class _Tp, bool = is_integral<_Tp>::value>
535227825Stheravenstruct ___is_signed : public integral_constant<bool, _Tp(-1) < _Tp(0)> {};
536227825Stheraven
537227825Stheraventemplate <class _Tp>
538227825Stheravenstruct ___is_signed<_Tp, false> : public true_type {};  // floating point
539227825Stheraven
540227825Stheraventemplate <class _Tp, bool = is_arithmetic<_Tp>::value>
541227825Stheravenstruct __is_signed : public ___is_signed<_Tp> {};
542227825Stheraven
543227825Stheraventemplate <class _Tp> struct __is_signed<_Tp, false> : public false_type {};
544227825Stheraven
545227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_signed : public __is_signed<_Tp> {};
546227825Stheraven
547227825Stheraven// is_unsigned
548227825Stheraven
549227825Stheraventemplate <class _Tp, bool = is_integral<_Tp>::value>
550227825Stheravenstruct ___is_unsigned : public integral_constant<bool, _Tp(0) < _Tp(-1)> {};
551227825Stheraven
552227825Stheraventemplate <class _Tp>
553227825Stheravenstruct ___is_unsigned<_Tp, false> : public false_type {};  // floating point
554227825Stheraven
555227825Stheraventemplate <class _Tp, bool = is_arithmetic<_Tp>::value>
556227825Stheravenstruct __is_unsigned : public ___is_unsigned<_Tp> {};
557227825Stheraven
558227825Stheraventemplate <class _Tp> struct __is_unsigned<_Tp, false> : public false_type {};
559227825Stheraven
560227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_unsigned : public __is_unsigned<_Tp> {};
561227825Stheraven
562227825Stheraven// rank
563227825Stheraven
564227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE rank
565227825Stheraven    : public integral_constant<size_t, 0> {};
566227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE rank<_Tp[]>
567227825Stheraven    : public integral_constant<size_t, rank<_Tp>::value + 1> {};
568227825Stheraventemplate <class _Tp, size_t _Np> struct _LIBCPP_VISIBLE rank<_Tp[_Np]>
569227825Stheraven    : public integral_constant<size_t, rank<_Tp>::value + 1> {};
570227825Stheraven
571227825Stheraven// extent
572227825Stheraven
573227825Stheraventemplate <class _Tp, unsigned _Ip = 0> struct _LIBCPP_VISIBLE extent
574227825Stheraven    : public integral_constant<size_t, 0> {};
575227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE extent<_Tp[], 0>
576227825Stheraven    : public integral_constant<size_t, 0> {};
577227825Stheraventemplate <class _Tp, unsigned _Ip> struct _LIBCPP_VISIBLE extent<_Tp[], _Ip>
578227825Stheraven    : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
579227825Stheraventemplate <class _Tp, size_t _Np> struct _LIBCPP_VISIBLE extent<_Tp[_Np], 0>
580227825Stheraven    : public integral_constant<size_t, _Np> {};
581227825Stheraventemplate <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_VISIBLE extent<_Tp[_Np], _Ip>
582227825Stheraven    : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
583227825Stheraven
584227825Stheraven// remove_extent
585227825Stheraven
586227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE remove_extent
587227825Stheraven    {typedef _Tp type;};
588227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE remove_extent<_Tp[]>
589227825Stheraven    {typedef _Tp type;};
590227825Stheraventemplate <class _Tp, size_t _Np> struct _LIBCPP_VISIBLE remove_extent<_Tp[_Np]>
591227825Stheraven    {typedef _Tp type;};
592227825Stheraven
593227825Stheraven// remove_all_extents
594227825Stheraven
595227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE remove_all_extents
596227825Stheraven    {typedef _Tp type;};
597227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE remove_all_extents<_Tp[]>
598227825Stheraven    {typedef typename remove_all_extents<_Tp>::type type;};
599227825Stheraventemplate <class _Tp, size_t _Np> struct _LIBCPP_VISIBLE remove_all_extents<_Tp[_Np]>
600227825Stheraven    {typedef typename remove_all_extents<_Tp>::type type;};
601227825Stheraven
602227825Stheraven// is_abstract
603227825Stheraven
604227825Stheravennamespace __is_abstract_imp
605227825Stheraven{
606227825Stheraventemplate <class _Tp> char  __test(_Tp (*)[1]);
607227825Stheraventemplate <class _Tp> __two __test(...);
608227825Stheraven}
609227825Stheraven
610227825Stheraventemplate <class _Tp, bool = is_class<_Tp>::value>
611227825Stheravenstruct __libcpp_abstract : public integral_constant<bool, sizeof(__is_abstract_imp::__test<_Tp>(0)) != 1> {};
612227825Stheraven
613227825Stheraventemplate <class _Tp> struct __libcpp_abstract<_Tp, false> : public false_type {};
614227825Stheraven
615227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_abstract : public __libcpp_abstract<_Tp> {};
616227825Stheraven
617227825Stheraven// is_convertible
618227825Stheraven
619227825Stheraven#if __has_feature(is_convertible_to)
620227825Stheraven
621227825Stheraventemplate <class _T1, class _T2> struct _LIBCPP_VISIBLE is_convertible
622227825Stheraven    : public integral_constant<bool, __is_convertible_to(_T1, _T2)> {};
623227825Stheraven
624227825Stheraven#else  // __has_feature(is_convertible_to)
625227825Stheraven
626227825Stheravennamespace __is_convertible_imp
627227825Stheraven{
628227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
629227825Stheraventemplate <class _Tp> char  __test(const volatile typename remove_reference<_Tp>::type&&);
630227825Stheraven#else
631227825Stheraventemplate <class _Tp> char  __test(_Tp);
632227825Stheraven#endif
633227825Stheraventemplate <class _Tp> __two __test(...);
634227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
635227825Stheraventemplate <class _Tp> _Tp&& __source();
636227825Stheraven#else
637227825Stheraventemplate <class _Tp> typename remove_reference<_Tp>::type& __source();
638227825Stheraven#endif
639227825Stheraven
640227825Stheraventemplate <class _Tp, bool _IsArray =    is_array<_Tp>::value,
641227825Stheraven                     bool _IsFunction = is_function<_Tp>::value,
642227825Stheraven                     bool _IsVoid =     is_void<_Tp>::value>
643227825Stheraven                     struct __is_array_function_or_void                          {enum {value = 0};};
644227825Stheraventemplate <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};};
645227825Stheraventemplate <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};};
646227825Stheraventemplate <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};};
647227825Stheraven}
648227825Stheraven
649227825Stheraventemplate <class _Tp,
650227825Stheraven    unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
651227825Stheravenstruct __is_convertible_check
652227825Stheraven{
653227825Stheraven    static const size_t __v = 0;
654227825Stheraven};
655227825Stheraven
656227825Stheraventemplate <class _Tp>
657227825Stheravenstruct __is_convertible_check<_Tp, 0>
658227825Stheraven{
659227825Stheraven    static const size_t __v = sizeof(_Tp);
660227825Stheraven};
661227825Stheraven
662227825Stheraventemplate <class _T1, class _T2,
663227825Stheraven    unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value,
664227825Stheraven    unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
665227825Stheravenstruct __is_convertible
666227825Stheraven    : public integral_constant<bool,
667227825Stheraven        sizeof(__is_convertible_imp::__test<_T2>(__is_convertible_imp::__source<_T1>())) == 1
668227825Stheraven    >
669227825Stheraven{};
670227825Stheraven
671227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 0> : false_type {};
672227825Stheraven
673227825Stheraventemplate <class _T1> struct __is_convertible<_T1, const _T1&, 1, 0> : true_type {};
674227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
675227825Stheraventemplate <class _T1> struct __is_convertible<_T1, _T1&&, 1, 0> : true_type {};
676227825Stheraventemplate <class _T1> struct __is_convertible<_T1, const _T1&&, 1, 0> : true_type {};
677227825Stheraventemplate <class _T1> struct __is_convertible<_T1, volatile _T1&&, 1, 0> : true_type {};
678227825Stheraventemplate <class _T1> struct __is_convertible<_T1, const volatile _T1&&, 1, 0> : true_type {};
679227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
680227825Stheraven
681227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2*, 1, 0>
682227825Stheraven    : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*>::value> {};
683227825Stheraven
684227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2* const, 1, 0>
685227825Stheraven    : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const>::value> {};
686227825Stheraven
687227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2* volatile, 1, 0>
688227825Stheraven    : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*volatile>::value> {};
689227825Stheraven
690227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2* const volatile, 1, 0>
691227825Stheraven    : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const volatile>::value> {};
692227825Stheraven
693227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 0>                : public false_type {};
694227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
695227825Stheraventemplate <class _T1>            struct __is_convertible<_T1, _T1&&, 2, 0>               : public true_type {};
696227825Stheraven#endif
697227825Stheraventemplate <class _T1>            struct __is_convertible<_T1, _T1*, 2, 0>               : public true_type {};
698227825Stheraventemplate <class _T1>            struct __is_convertible<_T1, _T1*const, 2, 0>          : public true_type {};
699227825Stheraventemplate <class _T1>            struct __is_convertible<_T1, _T1*volatile, 2, 0>       : public true_type {};
700227825Stheraventemplate <class _T1>            struct __is_convertible<_T1, _T1*const volatile, 2, 0> : public true_type {};
701227825Stheraven
702227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 0> : public false_type {};
703227825Stheraven
704227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
705227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
706227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
707227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {};
708227825Stheraven
709227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {};
710227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {};
711227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {};
712227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {};
713227825Stheraven
714227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {};
715227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {};
716227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {};
717227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {};
718227825Stheraven
719227825Stheraventemplate <class _T1, class _T2> struct _LIBCPP_VISIBLE is_convertible
720227825Stheraven    : public __is_convertible<_T1, _T2>
721227825Stheraven{
722227825Stheraven    static const size_t __complete_check1 = __is_convertible_check<_T1>::__v;
723227825Stheraven    static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
724227825Stheraven};
725227825Stheraven
726227825Stheraven#endif  // __has_feature(is_convertible_to)
727227825Stheraven
728227825Stheraven// is_base_of
729227825Stheraven
730227825Stheraven#ifdef _LIBCP_HAS_IS_BASE_OF
731227825Stheraven
732227825Stheraventemplate <class _Bp, class _Dp>
733227825Stheravenstruct _LIBCPP_VISIBLE is_base_of
734227825Stheraven    : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
735227825Stheraven
736227825Stheraven#else  // __has_feature(is_base_of)
737227825Stheraven
738227825Stheraven#error is_base_of not implemented.
739227825Stheraven
740227825Stheraven#endif  // __has_feature(is_base_of)
741227825Stheraven
742227825Stheraven// is_empty
743227825Stheraven
744232950Stheraven#if __has_feature(is_empty)
745232950Stheraven
746227825Stheraventemplate <class _Tp>
747232950Stheravenstruct _LIBCPP_VISIBLE is_empty
748232950Stheraven    : public integral_constant<bool, __is_empty(_Tp)> {};
749232950Stheraven
750232950Stheraven#else  // __has_feature(is_empty)
751232950Stheraven
752232950Stheraventemplate <class _Tp>
753227825Stheravenstruct __is_empty1
754227825Stheraven    : public _Tp
755227825Stheraven{
756227825Stheraven    double _;
757227825Stheraven};
758227825Stheraven
759227825Stheravenstruct __is_empty2
760227825Stheraven{
761227825Stheraven    double _;
762227825Stheraven};
763227825Stheraven
764227825Stheraventemplate <class _Tp, bool = is_class<_Tp>::value>
765227825Stheravenstruct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {};
766227825Stheraven
767227825Stheraventemplate <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {};
768227825Stheraven
769227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_empty : public __libcpp_empty<_Tp> {};
770227825Stheraven
771232950Stheraven#endif  // __has_feature(is_empty)
772232950Stheraven
773227825Stheraven// is_polymorphic
774227825Stheraven
775232950Stheraven#if __has_feature(is_polymorphic)
776232950Stheraven
777232950Stheraventemplate <class _Tp>
778232950Stheravenstruct _LIBCPP_VISIBLE is_polymorphic
779232950Stheraven    : public integral_constant<bool, __is_polymorphic(_Tp)> {};
780232950Stheraven
781232950Stheraven#else
782232950Stheraven
783227825Stheraventemplate <class _Tp> struct __is_polymorphic1 : public _Tp {};
784227825Stheraventemplate <class _Tp> struct __is_polymorphic2 : public _Tp {virtual ~__is_polymorphic2() throw();};
785227825Stheraven
786227825Stheraventemplate <class _Tp, bool = is_class<_Tp>::value>
787227825Stheravenstruct __libcpp_polymorphic
788227825Stheraven    : public integral_constant<bool, sizeof(__is_polymorphic1<_Tp>) == sizeof(__is_polymorphic2<_Tp>)> {};
789227825Stheraven
790227825Stheraventemplate <class _Tp> struct __libcpp_polymorphic<_Tp, false> : public false_type {};
791227825Stheraven
792227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_polymorphic
793227825Stheraven    : public __libcpp_polymorphic<_Tp> {};
794227825Stheraven
795232950Stheraven#endif // __has_feature(is_polymorphic)
796232950Stheraven
797227825Stheraven// has_virtual_destructor
798227825Stheraven
799227825Stheraven#if __has_feature(has_virtual_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
800227825Stheraven
801227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE has_virtual_destructor
802227825Stheraven    : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
803227825Stheraven
804227825Stheraven#else  // _LIBCPP_HAS_TYPE_TRAITS
805227825Stheraven
806227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE has_virtual_destructor
807227825Stheraven    : public false_type {};
808227825Stheraven
809227825Stheraven#endif  // _LIBCPP_HAS_TYPE_TRAITS
810227825Stheraven
811227825Stheraven// alignment_of
812227825Stheraven
813227825Stheraventemplate <class _Tp> struct __alignment_of {_Tp _;};
814227825Stheraven
815227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE alignment_of
816227825Stheraven    : public integral_constant<size_t, __alignof__(__alignment_of<typename remove_all_extents<_Tp>::type>)> {};
817227825Stheraven
818227825Stheraven// aligned_storage
819227825Stheraven
820227825Stheraventemplate <class _Hp, class _Tp>
821227825Stheravenstruct __type_list
822227825Stheraven{
823227825Stheraven    typedef _Hp _Head;
824227825Stheraven    typedef _Tp _Tail;
825227825Stheraven};
826227825Stheraven
827227825Stheravenstruct __nat
828227825Stheraven{
829227825Stheraven#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
830227825Stheraven    __nat() = delete;
831227825Stheraven    __nat(const __nat&) = delete;
832227825Stheraven    __nat& operator=(const __nat&) = delete;
833227825Stheraven    ~__nat() = delete;
834227825Stheraven#endif
835227825Stheraven};
836227825Stheraven
837227825Stheraventemplate <class _Tp>
838227825Stheravenstruct __align_type
839227825Stheraven{
840227825Stheraven    static const size_t value = alignment_of<_Tp>::value;
841227825Stheraven    typedef _Tp type;
842227825Stheraven};
843227825Stheraven
844227825Stheravenstruct __struct_double {long double _;};
845227825Stheravenstruct __struct_double4 {double _[4];};
846227825Stheraven
847227825Stheraventypedef
848227825Stheraven    __type_list<__align_type<unsigned char>,
849227825Stheraven    __type_list<__align_type<unsigned short>,
850227825Stheraven    __type_list<__align_type<unsigned int>,
851227825Stheraven    __type_list<__align_type<unsigned long>,
852227825Stheraven    __type_list<__align_type<unsigned long long>,
853227825Stheraven    __type_list<__align_type<double>,
854227825Stheraven    __type_list<__align_type<long double>,
855227825Stheraven    __type_list<__align_type<__struct_double>,
856227825Stheraven    __type_list<__align_type<__struct_double4>,
857227825Stheraven    __type_list<__align_type<int*>,
858227825Stheraven    __nat
859227825Stheraven    > > > > > > > > > > __all_types;
860227825Stheraven
861227825Stheraventemplate <class _TL, size_t _Align> struct __find_pod;
862227825Stheraven
863227825Stheraventemplate <class _Hp, size_t _Align>
864227825Stheravenstruct __find_pod<__type_list<_Hp, __nat>, _Align>
865227825Stheraven{
866227825Stheraven    typedef typename conditional<
867227825Stheraven                             _Align == _Hp::value,
868227825Stheraven                             typename _Hp::type,
869227825Stheraven                             void
870227825Stheraven                         >::type type;
871227825Stheraven};
872227825Stheraven
873227825Stheraventemplate <class _Hp, class _Tp, size_t _Align>
874227825Stheravenstruct __find_pod<__type_list<_Hp, _Tp>, _Align>
875227825Stheraven{
876227825Stheraven    typedef typename conditional<
877227825Stheraven                             _Align == _Hp::value,
878227825Stheraven                             typename _Hp::type,
879227825Stheraven                             typename __find_pod<_Tp, _Align>::type
880227825Stheraven                         >::type type;
881227825Stheraven};
882227825Stheraven
883227825Stheraventemplate <class _TL, size_t _Len> struct __find_max_align;
884227825Stheraven
885227825Stheraventemplate <class _Hp, size_t _Len>
886227825Stheravenstruct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
887227825Stheraven
888227825Stheraventemplate <size_t _Len, size_t _A1, size_t _A2>
889227825Stheravenstruct __select_align
890227825Stheraven{
891227825Stheravenprivate:
892227825Stheraven    static const size_t __min = _A2 < _A1 ? _A2 : _A1;
893227825Stheraven    static const size_t __max = _A1 < _A2 ? _A2 : _A1;
894227825Stheravenpublic:
895227825Stheraven    static const size_t value = _Len < __max ? __min : __max;
896227825Stheraven};
897227825Stheraven
898227825Stheraventemplate <class _Hp, class _Tp, size_t _Len>
899227825Stheravenstruct __find_max_align<__type_list<_Hp, _Tp>, _Len>
900227825Stheraven    : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
901227825Stheraven
902227825Stheraventemplate <size_t _Len, const size_t _Align = __find_max_align<__all_types, _Len>::value>
903227825Stheravenstruct _LIBCPP_VISIBLE aligned_storage
904227825Stheraven{
905227825Stheraven    typedef typename __find_pod<__all_types, _Align>::type _Aligner;
906227825Stheraven    static_assert(!is_void<_Aligner>::value, "");
907227825Stheraven    union type
908227825Stheraven    {
909227825Stheraven        _Aligner __align;
910227825Stheraven        unsigned char __data[_Len];
911227825Stheraven    };
912227825Stheraven};
913227825Stheraven
914227825Stheraven#define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
915227825Stheraventemplate <size_t _Len>\
916227825Stheravenstruct _LIBCPP_VISIBLE aligned_storage<_Len, n>\
917227825Stheraven{\
918227825Stheraven    struct _ALIGNAS(n) type\
919227825Stheraven    {\
920227825Stheraven        unsigned char _[_Len];\
921227825Stheraven    };\
922227825Stheraven}
923227825Stheraven
924227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
925227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
926227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
927227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
928227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
929227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
930227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
931227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
932227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
933227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
934227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
935227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
936227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
937227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
938227825Stheraven// MSDN says that MSVC does not support alignment beyond 8192 (=0x2000)
939227825Stheraven#if !defined(_MSC_VER)
940227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
941227825Stheraven#endif // !_MSC_VER
942227825Stheraven
943227825Stheraven#undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
944227825Stheraven
945227825Stheraven// __promote
946227825Stheraven
947227825Stheraventemplate <class _A1, class _A2 = void, class _A3 = void,
948227825Stheraven          bool = (is_arithmetic<_A1>::value || is_void<_A1>::value) &&
949227825Stheraven                 (is_arithmetic<_A2>::value || is_void<_A2>::value) &&
950227825Stheraven                 (is_arithmetic<_A3>::value || is_void<_A3>::value)>
951227825Stheravenclass __promote {};
952227825Stheraven
953227825Stheraventemplate <class _A1, class _A2, class _A3>
954227825Stheravenclass __promote<_A1, _A2, _A3, true>
955227825Stheraven{
956227825Stheravenprivate:
957227825Stheraven    typedef typename __promote<_A1>::type __type1;
958227825Stheraven    typedef typename __promote<_A2>::type __type2;
959227825Stheraven    typedef typename __promote<_A3>::type __type3;
960227825Stheravenpublic:
961227825Stheraven    typedef decltype(__type1() + __type2() + __type3()) type;
962227825Stheraven};
963227825Stheraven
964227825Stheraventemplate <class _A1, class _A2>
965227825Stheravenclass __promote<_A1, _A2, void, true>
966227825Stheraven{
967227825Stheravenprivate:
968227825Stheraven    typedef typename __promote<_A1>::type __type1;
969227825Stheraven    typedef typename __promote<_A2>::type __type2;
970227825Stheravenpublic:
971227825Stheraven    typedef decltype(__type1() + __type2()) type;
972227825Stheraven};
973227825Stheraven
974227825Stheraventemplate <class _A1>
975227825Stheravenclass __promote<_A1, void, void, true>
976227825Stheraven{
977227825Stheravenpublic:
978227825Stheraven    typedef typename conditional<is_arithmetic<_A1>::value,
979227825Stheraven                     typename conditional<is_integral<_A1>::value, double, _A1>::type,
980227825Stheraven                     void
981227825Stheraven            >::type type;
982227825Stheraven};
983227825Stheraven
984227825Stheraven#ifdef _LIBCPP_STORE_AS_OPTIMIZATION
985227825Stheraven
986227825Stheraven// __transform
987227825Stheraven
988227825Stheraventemplate <class _Tp, size_t = sizeof(_Tp), bool = is_scalar<_Tp>::value> struct __transform {typedef _Tp type;};
989227825Stheraventemplate <class _Tp> struct __transform<_Tp, 1, true> {typedef unsigned char      type;};
990227825Stheraventemplate <class _Tp> struct __transform<_Tp, 2, true> {typedef unsigned short     type;};
991227825Stheraventemplate <class _Tp> struct __transform<_Tp, 4, true> {typedef unsigned int       type;};
992227825Stheraventemplate <class _Tp> struct __transform<_Tp, 8, true> {typedef unsigned long long type;};
993227825Stheraven
994227825Stheraven#endif  // _LIBCPP_STORE_AS_OPTIMIZATION
995227825Stheraven
996227825Stheraven// make_signed / make_unsigned
997227825Stheraven
998227825Stheraventypedef
999227825Stheraven    __type_list<signed char,
1000227825Stheraven    __type_list<signed short,
1001227825Stheraven    __type_list<signed int,
1002227825Stheraven    __type_list<signed long,
1003227825Stheraven    __type_list<signed long long,
1004227825Stheraven    __nat
1005227825Stheraven    > > > > > __signed_types;
1006227825Stheraven
1007227825Stheraventypedef
1008227825Stheraven    __type_list<unsigned char,
1009227825Stheraven    __type_list<unsigned short,
1010227825Stheraven    __type_list<unsigned int,
1011227825Stheraven    __type_list<unsigned long,
1012227825Stheraven    __type_list<unsigned long long,
1013227825Stheraven    __nat
1014227825Stheraven    > > > > > __unsigned_types;
1015227825Stheraven
1016227825Stheraventemplate <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
1017227825Stheraven
1018227825Stheraventemplate <class _Hp, class _Tp, size_t _Size>
1019227825Stheravenstruct __find_first<__type_list<_Hp, _Tp>, _Size, true>
1020227825Stheraven{
1021227825Stheraven    typedef _Hp type;
1022227825Stheraven};
1023227825Stheraven
1024227825Stheraventemplate <class _Hp, class _Tp, size_t _Size>
1025227825Stheravenstruct __find_first<__type_list<_Hp, _Tp>, _Size, false>
1026227825Stheraven{
1027227825Stheraven    typedef typename __find_first<_Tp, _Size>::type type;
1028227825Stheraven};
1029227825Stheraven
1030227825Stheraventemplate <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
1031227825Stheraven                             bool = is_volatile<typename remove_reference<_Tp>::type>::value>
1032227825Stheravenstruct __apply_cv
1033227825Stheraven{
1034227825Stheraven    typedef _Up type;
1035227825Stheraven};
1036227825Stheraven
1037227825Stheraventemplate <class _Tp, class _Up>
1038227825Stheravenstruct __apply_cv<_Tp, _Up, true, false>
1039227825Stheraven{
1040227825Stheraven    typedef const _Up type;
1041227825Stheraven};
1042227825Stheraven
1043227825Stheraventemplate <class _Tp, class _Up>
1044227825Stheravenstruct __apply_cv<_Tp, _Up, false, true>
1045227825Stheraven{
1046227825Stheraven    typedef volatile _Up type;
1047227825Stheraven};
1048227825Stheraven
1049227825Stheraventemplate <class _Tp, class _Up>
1050227825Stheravenstruct __apply_cv<_Tp, _Up, true, true>
1051227825Stheraven{
1052227825Stheraven    typedef const volatile _Up type;
1053227825Stheraven};
1054227825Stheraven
1055227825Stheraventemplate <class _Tp, class _Up>
1056227825Stheravenstruct __apply_cv<_Tp&, _Up, false, false>
1057227825Stheraven{
1058227825Stheraven    typedef _Up& type;
1059227825Stheraven};
1060227825Stheraven
1061227825Stheraventemplate <class _Tp, class _Up>
1062227825Stheravenstruct __apply_cv<_Tp&, _Up, true, false>
1063227825Stheraven{
1064227825Stheraven    typedef const _Up& type;
1065227825Stheraven};
1066227825Stheraven
1067227825Stheraventemplate <class _Tp, class _Up>
1068227825Stheravenstruct __apply_cv<_Tp&, _Up, false, true>
1069227825Stheraven{
1070227825Stheraven    typedef volatile _Up& type;
1071227825Stheraven};
1072227825Stheraven
1073227825Stheraventemplate <class _Tp, class _Up>
1074227825Stheravenstruct __apply_cv<_Tp&, _Up, true, true>
1075227825Stheraven{
1076227825Stheraven    typedef const volatile _Up& type;
1077227825Stheraven};
1078227825Stheraven
1079227825Stheraventemplate <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1080227825Stheravenstruct __make_signed {};
1081227825Stheraven
1082227825Stheraventemplate <class _Tp>
1083227825Stheravenstruct __make_signed<_Tp, true>
1084227825Stheraven{
1085227825Stheraven    typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
1086227825Stheraven};
1087227825Stheraven
1088227825Stheraventemplate <> struct __make_signed<bool,               true> {};
1089227825Stheraventemplate <> struct __make_signed<  signed short,     true> {typedef short     type;};
1090227825Stheraventemplate <> struct __make_signed<unsigned short,     true> {typedef short     type;};
1091227825Stheraventemplate <> struct __make_signed<  signed int,       true> {typedef int       type;};
1092227825Stheraventemplate <> struct __make_signed<unsigned int,       true> {typedef int       type;};
1093227825Stheraventemplate <> struct __make_signed<  signed long,      true> {typedef long      type;};
1094227825Stheraventemplate <> struct __make_signed<unsigned long,      true> {typedef long      type;};
1095227825Stheraventemplate <> struct __make_signed<  signed long long, true> {typedef long long type;};
1096227825Stheraventemplate <> struct __make_signed<unsigned long long, true> {typedef long long type;};
1097227825Stheraven
1098227825Stheraventemplate <class _Tp>
1099227825Stheravenstruct _LIBCPP_VISIBLE make_signed
1100227825Stheraven{
1101227825Stheraven    typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
1102227825Stheraven};
1103227825Stheraven
1104227825Stheraventemplate <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1105227825Stheravenstruct __make_unsigned {};
1106227825Stheraven
1107227825Stheraventemplate <class _Tp>
1108227825Stheravenstruct __make_unsigned<_Tp, true>
1109227825Stheraven{
1110227825Stheraven    typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
1111227825Stheraven};
1112227825Stheraven
1113227825Stheraventemplate <> struct __make_unsigned<bool,               true> {};
1114227825Stheraventemplate <> struct __make_unsigned<  signed short,     true> {typedef unsigned short     type;};
1115227825Stheraventemplate <> struct __make_unsigned<unsigned short,     true> {typedef unsigned short     type;};
1116227825Stheraventemplate <> struct __make_unsigned<  signed int,       true> {typedef unsigned int       type;};
1117227825Stheraventemplate <> struct __make_unsigned<unsigned int,       true> {typedef unsigned int       type;};
1118227825Stheraventemplate <> struct __make_unsigned<  signed long,      true> {typedef unsigned long      type;};
1119227825Stheraventemplate <> struct __make_unsigned<unsigned long,      true> {typedef unsigned long      type;};
1120227825Stheraventemplate <> struct __make_unsigned<  signed long long, true> {typedef unsigned long long type;};
1121227825Stheraventemplate <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
1122227825Stheraven
1123227825Stheraventemplate <class _Tp>
1124227825Stheravenstruct _LIBCPP_VISIBLE make_unsigned
1125227825Stheraven{
1126227825Stheraven    typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
1127227825Stheraven};
1128227825Stheraven
1129227825Stheraven#ifdef _LIBCPP_HAS_NO_VARIADICS
1130227825Stheraven
1131227825Stheraventemplate <class _Tp, class _Up = void, class V = void>
1132227825Stheravenstruct _LIBCPP_VISIBLE common_type
1133227825Stheraven{
1134227825Stheravenpublic:
1135227825Stheraven    typedef typename common_type<typename common_type<_Tp, _Up>::type, V>::type type;
1136227825Stheraven};
1137227825Stheraven
1138227825Stheraventemplate <class _Tp>
1139227825Stheravenstruct _LIBCPP_VISIBLE common_type<_Tp, void, void>
1140227825Stheraven{
1141227825Stheravenpublic:
1142227825Stheraven    typedef _Tp type;
1143227825Stheraven};
1144227825Stheraven
1145227825Stheraventemplate <class _Tp, class _Up>
1146227825Stheravenstruct _LIBCPP_VISIBLE common_type<_Tp, _Up, void>
1147227825Stheraven{
1148227825Stheravenprivate:
1149227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1150227825Stheraven    static _Tp&& __t();
1151227825Stheraven    static _Up&& __u();
1152227825Stheraven#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1153227825Stheraven    static _Tp __t();
1154227825Stheraven    static _Up __u();
1155227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1156227825Stheravenpublic:
1157232950Stheraven    typedef typename remove_reference<decltype(true ? __t() : __u())>::type type;
1158227825Stheraven};
1159227825Stheraven
1160227825Stheraven#else  // _LIBCPP_HAS_NO_VARIADICS
1161227825Stheraven
1162227825Stheraventemplate <class ..._Tp> struct common_type;
1163227825Stheraven
1164227825Stheraventemplate <class _Tp>
1165227825Stheravenstruct _LIBCPP_VISIBLE common_type<_Tp>
1166227825Stheraven{
1167227825Stheraven    typedef _Tp type;
1168227825Stheraven};
1169227825Stheraven
1170227825Stheraventemplate <class _Tp, class _Up>
1171227825Stheravenstruct _LIBCPP_VISIBLE common_type<_Tp, _Up>
1172227825Stheraven{
1173227825Stheravenprivate:
1174227825Stheraven    static _Tp&& __t();
1175227825Stheraven    static _Up&& __u();
1176227825Stheraven    static bool __f();
1177227825Stheravenpublic:
1178232950Stheraven    typedef typename remove_reference<decltype(__f() ? __t() : __u())>::type type;
1179227825Stheraven};
1180227825Stheraven
1181227825Stheraventemplate <class _Tp, class _Up, class ..._Vp>
1182227825Stheravenstruct _LIBCPP_VISIBLE common_type<_Tp, _Up, _Vp...>
1183227825Stheraven{
1184227825Stheraven    typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp...>::type type;
1185227825Stheraven};
1186227825Stheraven
1187227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
1188227825Stheraven
1189227825Stheraven// is_assignable
1190227825Stheraven
1191227825Stheraventemplate <class _Tp, class _Arg>
1192227825Stheravendecltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>(), true_type()))
1193227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1194227825Stheraven__is_assignable_test(_Tp&&, _Arg&&);
1195227825Stheraven#else
1196227825Stheraven__is_assignable_test(_Tp, _Arg&);
1197227825Stheraven#endif
1198227825Stheraven
1199227825Stheraventemplate <class _Arg>
1200227825Stheravenfalse_type
1201227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1202227825Stheraven__is_assignable_test(__any, _Arg&&);
1203227825Stheraven#else
1204227825Stheraven__is_assignable_test(__any, _Arg&);
1205227825Stheraven#endif
1206227825Stheraven
1207227825Stheraventemplate <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
1208227825Stheravenstruct __is_assignable_imp
1209227825Stheraven    : public common_type
1210227825Stheraven        <
1211227825Stheraven            decltype(__is_assignable_test(declval<_Tp>(), declval<_Arg>()))
1212227825Stheraven        >::type {};
1213227825Stheraven
1214227825Stheraventemplate <class _Tp, class _Arg>
1215227825Stheravenstruct __is_assignable_imp<_Tp, _Arg, true>
1216227825Stheraven    : public false_type
1217227825Stheraven{
1218227825Stheraven};
1219227825Stheraven
1220227825Stheraventemplate <class _Tp, class _Arg>
1221227825Stheravenstruct is_assignable
1222227825Stheraven    : public __is_assignable_imp<_Tp, _Arg> {};
1223227825Stheraven
1224227825Stheraven// is_copy_assignable
1225227825Stheraven
1226227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_copy_assignable
1227227825Stheraven    : public is_assignable<typename add_lvalue_reference<_Tp>::type,
1228227825Stheraven                     const typename add_lvalue_reference<_Tp>::type> {};
1229227825Stheraven
1230227825Stheraven// is_move_assignable
1231227825Stheraven
1232227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_move_assignable
1233227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1234227825Stheraven    : public is_assignable<typename add_lvalue_reference<_Tp>::type,
1235227825Stheraven                     const typename add_rvalue_reference<_Tp>::type> {};
1236227825Stheraven#else
1237227825Stheraven    : public is_copy_assignable<_Tp> {};
1238227825Stheraven#endif
1239227825Stheraven
1240227825Stheraven// is_destructible
1241227825Stheraven
1242227825Stheraventemplate <class _Tp>
1243227825Stheravenstruct __destructible_test
1244227825Stheraven{
1245227825Stheraven    _Tp __t;
1246227825Stheraven};
1247227825Stheraven
1248227825Stheraventemplate <class _Tp>
1249227825Stheravendecltype((_VSTD::declval<__destructible_test<_Tp> >().~__destructible_test<_Tp>(), true_type()))
1250227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1251227825Stheraven__is_destructible_test(_Tp&&);
1252227825Stheraven#else
1253227825Stheraven__is_destructible_test(_Tp&);
1254227825Stheraven#endif
1255227825Stheraven
1256227825Stheravenfalse_type
1257227825Stheraven__is_destructible_test(__any);
1258227825Stheraven
1259227825Stheraventemplate <class _Tp, bool = is_void<_Tp>::value || is_abstract<_Tp>::value>
1260227825Stheravenstruct __destructible_imp
1261227825Stheraven    : public common_type
1262227825Stheraven        <
1263227825Stheraven            decltype(__is_destructible_test(declval<_Tp>()))
1264227825Stheraven        >::type {};
1265227825Stheraven
1266227825Stheraventemplate <class _Tp>
1267227825Stheravenstruct __destructible_imp<_Tp, true>
1268227825Stheraven    : public false_type {};
1269227825Stheraven
1270227825Stheraventemplate <class _Tp>
1271227825Stheravenstruct is_destructible
1272227825Stheraven    : public __destructible_imp<_Tp> {};
1273227825Stheraven
1274227825Stheraven// move
1275227825Stheraven
1276227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1277227825Stheraven
1278227825Stheraventemplate <class _Tp>
1279227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1280227825Stheraventypename remove_reference<_Tp>::type&&
1281227825Stheravenmove(_Tp&& __t) _NOEXCEPT
1282227825Stheraven{
1283227825Stheraven    typedef typename remove_reference<_Tp>::type _Up;
1284227825Stheraven    return static_cast<_Up&&>(__t);
1285227825Stheraven}
1286227825Stheraven
1287227825Stheraventemplate <class _Tp>
1288227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1289227825Stheraven_Tp&&
1290227825Stheravenforward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
1291227825Stheraven{
1292227825Stheraven    return static_cast<_Tp&&>(__t);
1293227825Stheraven}
1294227825Stheraven
1295227825Stheraventemplate <class _Tp>
1296227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1297227825Stheraven_Tp&&
1298227825Stheravenforward(typename std::remove_reference<_Tp>::type&& __t) _NOEXCEPT
1299227825Stheraven{
1300227825Stheraven    static_assert(!std::is_lvalue_reference<_Tp>::value,
1301227825Stheraven                  "Can not forward an rvalue as an lvalue.");
1302227825Stheraven    return static_cast<_Tp&&>(__t);
1303227825Stheraven}
1304227825Stheraven
1305227825Stheraven#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1306227825Stheraven
1307227825Stheraventemplate <class _Tp>
1308227825Stheravenclass __rv
1309227825Stheraven{
1310227825Stheraven    typedef typename remove_reference<_Tp>::type _Trr;
1311227825Stheraven    _Trr& t_;
1312227825Stheravenpublic:
1313227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1314227825Stheraven    _Trr* operator->() {return &t_;}
1315227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1316227825Stheraven    explicit __rv(_Trr& __t) : t_(__t) {}
1317227825Stheraven};
1318227825Stheraven
1319227825Stheraventemplate <class _Tp>
1320227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1321227825Stheraventypename enable_if
1322227825Stheraven<
1323227825Stheraven    !is_convertible<_Tp, __rv<_Tp> >::value,
1324227825Stheraven    _Tp&
1325227825Stheraven>::type
1326227825Stheravenmove(_Tp& __t)
1327227825Stheraven{
1328227825Stheraven    return __t;
1329227825Stheraven}
1330227825Stheraven
1331227825Stheraventemplate <class _Tp>
1332227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1333227825Stheraventypename enable_if
1334227825Stheraven<
1335232950Stheraven    !is_convertible<_Tp, __rv<_Tp> >::value,
1336232950Stheraven    const _Tp&
1337232950Stheraven>::type
1338232950Stheravenmove(const _Tp& __t)
1339232950Stheraven{
1340232950Stheraven    return __t;
1341232950Stheraven}
1342232950Stheraven
1343232950Stheraventemplate <class _Tp>
1344232950Stheraveninline _LIBCPP_INLINE_VISIBILITY
1345232950Stheraventypename enable_if
1346232950Stheraven<
1347227825Stheraven    is_convertible<_Tp, __rv<_Tp> >::value,
1348227825Stheraven    _Tp
1349227825Stheraven>::type
1350227825Stheravenmove(_Tp& __t)
1351227825Stheraven{
1352227825Stheraven    return _Tp(__rv<_Tp>(__t));
1353227825Stheraven}
1354227825Stheraven
1355227825Stheraventemplate <class _Tp, class _Up>
1356227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1357227825Stheraventypename enable_if
1358227825Stheraven<
1359227825Stheraven    !is_convertible<_Tp, __rv<_Tp> >::value,
1360227825Stheraven    typename add_lvalue_reference<_Tp>::type
1361227825Stheraven>::type
1362227825Stheravenforward(_Up& __t)
1363227825Stheraven{
1364227825Stheraven    return __t;
1365227825Stheraven}
1366227825Stheraven
1367227825Stheraventemplate <class _Tp, class _Up>
1368227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1369227825Stheraventypename enable_if
1370227825Stheraven<
1371227825Stheraven    !is_convertible<_Tp, __rv<_Tp> >::value,
1372227825Stheraven    typename add_lvalue_reference<_Tp>::type
1373227825Stheraven>::type
1374227825Stheravenforward(const _Up& __t)
1375227825Stheraven{
1376227825Stheraven    return __t;
1377227825Stheraven}
1378227825Stheraven
1379227825Stheraventemplate <class _Tp, class _Up>
1380227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1381227825Stheraventypename enable_if
1382227825Stheraven<
1383227825Stheraven    is_convertible<_Tp, __rv<_Tp> >::value,
1384227825Stheraven    _Tp
1385227825Stheraven>::type
1386227825Stheravenforward(_Up& __t)
1387227825Stheraven{
1388227825Stheraven    return _Tp(__rv<_Tp>(__t));
1389227825Stheraven}
1390227825Stheraven
1391227825Stheraventemplate <class _Tp, class _Up>
1392227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1393227825Stheraventypename enable_if
1394227825Stheraven<
1395227825Stheraven    is_convertible<_Tp, __rv<_Tp> >::value,
1396227825Stheraven    _Tp
1397227825Stheraven>::type
1398227825Stheravenforward(const _Up& __t)
1399227825Stheraven{
1400227825Stheraven    return _Tp(__rv<_Tp>(__t));
1401227825Stheraven}
1402227825Stheraven
1403227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1404227825Stheraven
1405227825Stheraventemplate <class _Tp>
1406227825Stheravenstruct _LIBCPP_VISIBLE decay
1407227825Stheraven{
1408227825Stheravenprivate:
1409227825Stheraven    typedef typename remove_reference<_Tp>::type _Up;
1410227825Stheravenpublic:
1411227825Stheraven    typedef typename conditional
1412227825Stheraven                     <
1413227825Stheraven                         is_array<_Up>::value,
1414227825Stheraven                         typename remove_extent<_Up>::type*,
1415227825Stheraven                         typename conditional
1416227825Stheraven                         <
1417227825Stheraven                              is_function<_Up>::value,
1418227825Stheraven                              typename add_pointer<_Up>::type,
1419227825Stheraven                              typename remove_cv<_Up>::type
1420227825Stheraven                         >::type
1421227825Stheraven                     >::type type;
1422227825Stheraven};
1423227825Stheraven
1424227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1425227825Stheraven
1426227825Stheraventemplate <class _Tp>
1427227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1428227825Stheraventypename decay<_Tp>::type
1429227825Stheraven__decay_copy(_Tp&& __t)
1430227825Stheraven{
1431227825Stheraven    return _VSTD::forward<_Tp>(__t);
1432227825Stheraven}
1433227825Stheraven
1434227825Stheraven#else
1435227825Stheraven
1436227825Stheraventemplate <class _Tp>
1437227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1438227825Stheraventypename decay<_Tp>::type
1439227825Stheraven__decay_copy(const _Tp& __t)
1440227825Stheraven{
1441227825Stheraven    return _VSTD::forward<_Tp>(__t);
1442227825Stheraven}
1443227825Stheraven
1444227825Stheraven#endif
1445227825Stheraven
1446227825Stheraventemplate <class _MP, bool _IsMemberFuctionPtr, bool _IsMemberObjectPtr>
1447227825Stheravenstruct __member_pointer_traits_imp
1448227825Stheraven{
1449227825Stheraven};
1450227825Stheraven
1451227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
1452227825Stheraven
1453232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1454232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
1455227825Stheraven{
1456227825Stheraven    typedef _Class _ClassType;
1457232950Stheraven    typedef _Rp _ReturnType;
1458227825Stheraven};
1459227825Stheraven
1460232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1461232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
1462227825Stheraven{
1463227825Stheraven    typedef _Class const _ClassType;
1464232950Stheraven    typedef _Rp _ReturnType;
1465227825Stheraven};
1466227825Stheraven
1467232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1468232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
1469227825Stheraven{
1470227825Stheraven    typedef _Class volatile _ClassType;
1471232950Stheraven    typedef _Rp _ReturnType;
1472227825Stheraven};
1473227825Stheraven
1474232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1475232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
1476227825Stheraven{
1477227825Stheraven    typedef _Class const volatile _ClassType;
1478232950Stheraven    typedef _Rp _ReturnType;
1479227825Stheraven};
1480227825Stheraven
1481227825Stheraven#if __has_feature(cxx_reference_qualified_functions)
1482227825Stheraven
1483232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1484232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
1485227825Stheraven{
1486227825Stheraven    typedef _Class& _ClassType;
1487232950Stheraven    typedef _Rp _ReturnType;
1488227825Stheraven};
1489227825Stheraven
1490232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1491232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
1492227825Stheraven{
1493227825Stheraven    typedef _Class const& _ClassType;
1494232950Stheraven    typedef _Rp _ReturnType;
1495227825Stheraven};
1496227825Stheraven
1497232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1498232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
1499227825Stheraven{
1500227825Stheraven    typedef _Class volatile& _ClassType;
1501232950Stheraven    typedef _Rp _ReturnType;
1502227825Stheraven};
1503227825Stheraven
1504232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1505232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
1506227825Stheraven{
1507227825Stheraven    typedef _Class const volatile& _ClassType;
1508232950Stheraven    typedef _Rp _ReturnType;
1509227825Stheraven};
1510227825Stheraven
1511232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1512232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
1513227825Stheraven{
1514227825Stheraven    typedef _Class&& _ClassType;
1515232950Stheraven    typedef _Rp _ReturnType;
1516227825Stheraven};
1517227825Stheraven
1518232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1519232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
1520227825Stheraven{
1521227825Stheraven    typedef _Class const&& _ClassType;
1522232950Stheraven    typedef _Rp _ReturnType;
1523227825Stheraven};
1524227825Stheraven
1525232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1526232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
1527227825Stheraven{
1528227825Stheraven    typedef _Class volatile&& _ClassType;
1529232950Stheraven    typedef _Rp _ReturnType;
1530227825Stheraven};
1531227825Stheraven
1532232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1533232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
1534227825Stheraven{
1535227825Stheraven    typedef _Class const volatile&& _ClassType;
1536232950Stheraven    typedef _Rp _ReturnType;
1537227825Stheraven};
1538227825Stheraven
1539227825Stheraven#endif  // __has_feature(cxx_reference_qualified_functions)
1540227825Stheraven
1541227825Stheraven#else  // _LIBCPP_HAS_NO_VARIADICS
1542227825Stheraven
1543232950Stheraventemplate <class _Rp, class _Class>
1544232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(), true, false>
1545227825Stheraven{
1546227825Stheraven    typedef _Class _ClassType;
1547232950Stheraven    typedef _Rp _ReturnType;
1548227825Stheraven};
1549227825Stheraven
1550232950Stheraventemplate <class _Rp, class _Class, class _P0>
1551232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false>
1552227825Stheraven{
1553227825Stheraven    typedef _Class _ClassType;
1554232950Stheraven    typedef _Rp _ReturnType;
1555227825Stheraven};
1556227825Stheraven
1557232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1>
1558232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false>
1559227825Stheraven{
1560227825Stheraven    typedef _Class _ClassType;
1561232950Stheraven    typedef _Rp _ReturnType;
1562227825Stheraven};
1563227825Stheraven
1564232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1, class _P2>
1565232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false>
1566227825Stheraven{
1567227825Stheraven    typedef _Class _ClassType;
1568232950Stheraven    typedef _Rp _ReturnType;
1569227825Stheraven};
1570227825Stheraven
1571232950Stheraventemplate <class _Rp, class _Class>
1572232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false>
1573227825Stheraven{
1574227825Stheraven    typedef _Class const _ClassType;
1575232950Stheraven    typedef _Rp _ReturnType;
1576227825Stheraven};
1577227825Stheraven
1578232950Stheraventemplate <class _Rp, class _Class, class _P0>
1579232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false>
1580227825Stheraven{
1581227825Stheraven    typedef _Class const _ClassType;
1582232950Stheraven    typedef _Rp _ReturnType;
1583227825Stheraven};
1584227825Stheraven
1585232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1>
1586232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false>
1587227825Stheraven{
1588227825Stheraven    typedef _Class const _ClassType;
1589232950Stheraven    typedef _Rp _ReturnType;
1590227825Stheraven};
1591227825Stheraven
1592232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1, class _P2>
1593232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, false>
1594227825Stheraven{
1595227825Stheraven    typedef _Class const _ClassType;
1596232950Stheraven    typedef _Rp _ReturnType;
1597227825Stheraven};
1598227825Stheraven
1599232950Stheraventemplate <class _Rp, class _Class>
1600232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false>
1601227825Stheraven{
1602227825Stheraven    typedef _Class volatile _ClassType;
1603232950Stheraven    typedef _Rp _ReturnType;
1604227825Stheraven};
1605227825Stheraven
1606232950Stheraventemplate <class _Rp, class _Class, class _P0>
1607232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false>
1608227825Stheraven{
1609227825Stheraven    typedef _Class volatile _ClassType;
1610232950Stheraven    typedef _Rp _ReturnType;
1611227825Stheraven};
1612227825Stheraven
1613232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1>
1614232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, false>
1615227825Stheraven{
1616227825Stheraven    typedef _Class volatile _ClassType;
1617232950Stheraven    typedef _Rp _ReturnType;
1618227825Stheraven};
1619227825Stheraven
1620232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1, class _P2>
1621232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true, false>
1622227825Stheraven{
1623227825Stheraven    typedef _Class volatile _ClassType;
1624232950Stheraven    typedef _Rp _ReturnType;
1625227825Stheraven};
1626227825Stheraven
1627232950Stheraventemplate <class _Rp, class _Class>
1628232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false>
1629227825Stheraven{
1630227825Stheraven    typedef _Class const volatile _ClassType;
1631232950Stheraven    typedef _Rp _ReturnType;
1632227825Stheraven};
1633227825Stheraven
1634232950Stheraventemplate <class _Rp, class _Class, class _P0>
1635232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, false>
1636227825Stheraven{
1637227825Stheraven    typedef _Class const volatile _ClassType;
1638232950Stheraven    typedef _Rp _ReturnType;
1639227825Stheraven};
1640227825Stheraven
1641232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1>
1642232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, true, false>
1643227825Stheraven{
1644227825Stheraven    typedef _Class const volatile _ClassType;
1645232950Stheraven    typedef _Rp _ReturnType;
1646227825Stheraven};
1647227825Stheraven
1648232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1, class _P2>
1649232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile, true, false>
1650227825Stheraven{
1651227825Stheraven    typedef _Class const volatile _ClassType;
1652232950Stheraven    typedef _Rp _ReturnType;
1653227825Stheraven};
1654227825Stheraven
1655227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
1656227825Stheraven
1657232950Stheraventemplate <class _Rp, class _Class>
1658232950Stheravenstruct __member_pointer_traits_imp<_Rp _Class::*, false, true>
1659227825Stheraven{
1660227825Stheraven    typedef _Class _ClassType;
1661232950Stheraven    typedef _Rp _ReturnType;
1662227825Stheraven};
1663227825Stheraven
1664227825Stheraventemplate <class _MP>
1665227825Stheravenstruct __member_pointer_traits
1666227825Stheraven    : public __member_pointer_traits_imp<_MP,
1667227825Stheraven                    is_member_function_pointer<_MP>::value,
1668227825Stheraven                    is_member_object_pointer<_MP>::value>
1669227825Stheraven{
1670227825Stheraven//     typedef ... _ClassType;
1671227825Stheraven//     typedef ... _ReturnType;
1672227825Stheraven};
1673227825Stheraven
1674227825Stheraven// result_of
1675227825Stheraven
1676227825Stheraventemplate <class _Callable> class result_of;
1677227825Stheraven
1678227825Stheraventemplate <class _Fn, bool, bool>
1679227825Stheravenclass __result_of
1680227825Stheraven{
1681227825Stheraven};
1682227825Stheraven
1683227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
1684227825Stheraven
1685227825Stheraventemplate <class _Fn, class ..._ArgTypes>
1686227825Stheravenclass __result_of<_Fn(_ArgTypes...), true, false>
1687227825Stheraven{
1688227825Stheravenpublic:
1689227825Stheraven    typedef decltype(declval<_Fn>()(declval<_ArgTypes>()...)) type;
1690227825Stheraven};
1691227825Stheraven
1692227825Stheraventemplate <class _MP, class _Tp, bool _IsMemberFunctionPtr>
1693227825Stheravenstruct __result_of_mp;
1694227825Stheraven
1695227825Stheraven// member function pointer
1696227825Stheraven
1697227825Stheraventemplate <class _MP, class _Tp>
1698227825Stheravenstruct __result_of_mp<_MP, _Tp, true>
1699227825Stheraven    : public common_type<typename __member_pointer_traits<_MP>::_ReturnType>
1700227825Stheraven{
1701227825Stheraven};
1702227825Stheraven
1703227825Stheraven// member data pointer
1704227825Stheraven
1705227825Stheraventemplate <class _MP, class _Tp, bool>
1706227825Stheravenstruct __result_of_mdp;
1707227825Stheraven
1708232950Stheraventemplate <class _Rp, class _Class, class _Tp>
1709232950Stheravenstruct __result_of_mdp<_Rp _Class::*, _Tp, false>
1710227825Stheraven{
1711232950Stheraven    typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type&& type;
1712227825Stheraven};
1713227825Stheraven
1714232950Stheraventemplate <class _Rp, class _Class, class _Tp>
1715232950Stheravenstruct __result_of_mdp<_Rp _Class::*, _Tp, true>
1716227825Stheraven{
1717232950Stheraven    typedef typename __apply_cv<_Tp, _Rp>::type&& type;
1718227825Stheraven};
1719227825Stheraven
1720232950Stheraventemplate <class _Rp, class _Class, class _Tp>
1721232950Stheravenstruct __result_of_mp<_Rp _Class::*, _Tp, false>
1722232950Stheraven    : public __result_of_mdp<_Rp _Class::*, _Tp,
1723227825Stheraven            is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
1724227825Stheraven{
1725227825Stheraven};
1726227825Stheraven
1727227825Stheraventemplate <class _Fn, class _Tp, class ..._ArgTypes>
1728227825Stheravenclass __result_of<_Fn(_Tp, _ArgTypes...), false, true>  // _Fn must be member pointer
1729227825Stheraven    : public __result_of_mp<typename remove_reference<_Fn>::type,
1730227825Stheraven                            _Tp,
1731227825Stheraven                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1732227825Stheraven{
1733227825Stheraven};
1734227825Stheraven
1735227825Stheraven// result_of
1736227825Stheraven
1737227825Stheraventemplate <class _Fn, class ..._ArgTypes>
1738227825Stheravenclass _LIBCPP_VISIBLE result_of<_Fn(_ArgTypes...)>
1739227825Stheraven    : public __result_of<_Fn(_ArgTypes...),
1740227825Stheraven                         is_class<typename remove_reference<_Fn>::type>::value ||
1741227825Stheraven                         is_function<typename remove_reference<_Fn>::type>::value,
1742227825Stheraven                         is_member_pointer<typename remove_reference<_Fn>::type>::value
1743227825Stheraven                        >
1744227825Stheraven{
1745227825Stheraven};
1746227825Stheraven
1747227825Stheraven#else  // _LIBCPP_HAS_NO_VARIADICS
1748227825Stheraven
1749227825Stheraventemplate <class _Fn>
1750227825Stheravenclass __result_of<_Fn(), true, false>
1751227825Stheraven{
1752227825Stheravenpublic:
1753227825Stheraven    typedef decltype(declval<_Fn>()()) type;
1754227825Stheraven};
1755227825Stheraven
1756227825Stheraventemplate <class _Fn, class _A0>
1757227825Stheravenclass __result_of<_Fn(_A0), true, false>
1758227825Stheraven{
1759227825Stheravenpublic:
1760227825Stheraven    typedef decltype(declval<_Fn>()(declval<_A0>())) type;
1761227825Stheraven};
1762227825Stheraven
1763227825Stheraventemplate <class _Fn, class _A0, class _A1>
1764227825Stheravenclass __result_of<_Fn(_A0, _A1), true, false>
1765227825Stheraven{
1766227825Stheravenpublic:
1767227825Stheraven    typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type;
1768227825Stheraven};
1769227825Stheraven
1770227825Stheraventemplate <class _Fn, class _A0, class _A1, class _A2>
1771227825Stheravenclass __result_of<_Fn(_A0, _A1, _A2), true, false>
1772227825Stheraven{
1773227825Stheravenpublic:
1774227825Stheraven    typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type;
1775227825Stheraven};
1776227825Stheraven
1777227825Stheraventemplate <class _MP, class _Tp, bool _IsMemberFunctionPtr>
1778227825Stheravenstruct __result_of_mp;
1779227825Stheraven
1780227825Stheraven// member function pointer
1781227825Stheraven
1782227825Stheraventemplate <class _MP, class _Tp>
1783227825Stheravenstruct __result_of_mp<_MP, _Tp, true>
1784227825Stheraven    : public common_type<typename __member_pointer_traits<_MP>::_ReturnType>
1785227825Stheraven{
1786227825Stheraven};
1787227825Stheraven
1788227825Stheraven// member data pointer
1789227825Stheraven
1790227825Stheraventemplate <class _MP, class _Tp, bool>
1791227825Stheravenstruct __result_of_mdp;
1792227825Stheraven
1793232950Stheraventemplate <class _Rp, class _Class, class _Tp>
1794232950Stheravenstruct __result_of_mdp<_Rp _Class::*, _Tp, false>
1795227825Stheraven{
1796232950Stheraven    typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type;
1797227825Stheraven};
1798227825Stheraven
1799232950Stheraventemplate <class _Rp, class _Class, class _Tp>
1800232950Stheravenstruct __result_of_mdp<_Rp _Class::*, _Tp, true>
1801227825Stheraven{
1802232950Stheraven    typedef typename __apply_cv<_Tp, _Rp>::type& type;
1803227825Stheraven};
1804227825Stheraven
1805232950Stheraventemplate <class _Rp, class _Class, class _Tp>
1806232950Stheravenstruct __result_of_mp<_Rp _Class::*, _Tp, false>
1807232950Stheraven    : public __result_of_mdp<_Rp _Class::*, _Tp,
1808227825Stheraven            is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
1809227825Stheraven{
1810227825Stheraven};
1811227825Stheraven
1812227825Stheraven
1813227825Stheraven
1814227825Stheraventemplate <class _Fn, class _Tp>
1815227825Stheravenclass __result_of<_Fn(_Tp), false, true>  // _Fn must be member pointer
1816227825Stheraven    : public __result_of_mp<typename remove_reference<_Fn>::type,
1817227825Stheraven                            _Tp,
1818227825Stheraven                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1819227825Stheraven{
1820227825Stheraven};
1821227825Stheraven
1822227825Stheraventemplate <class _Fn, class _Tp, class _A0>
1823227825Stheravenclass __result_of<_Fn(_Tp, _A0), false, true>  // _Fn must be member pointer
1824227825Stheraven    : public __result_of_mp<typename remove_reference<_Fn>::type,
1825227825Stheraven                            _Tp,
1826227825Stheraven                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1827227825Stheraven{
1828227825Stheraven};
1829227825Stheraven
1830227825Stheraventemplate <class _Fn, class _Tp, class _A0, class _A1>
1831227825Stheravenclass __result_of<_Fn(_Tp, _A0, _A1), false, true>  // _Fn must be member pointer
1832227825Stheraven    : public __result_of_mp<typename remove_reference<_Fn>::type,
1833227825Stheraven                            _Tp,
1834227825Stheraven                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1835227825Stheraven{
1836227825Stheraven};
1837227825Stheraven
1838227825Stheraventemplate <class _Fn, class _Tp, class _A0, class _A1, class _A2>
1839227825Stheravenclass __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true>  // _Fn must be member pointer
1840227825Stheraven    : public __result_of_mp<typename remove_reference<_Fn>::type,
1841227825Stheraven                            _Tp,
1842227825Stheraven                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1843227825Stheraven{
1844227825Stheraven};
1845227825Stheraven
1846227825Stheraven// result_of
1847227825Stheraven
1848227825Stheraventemplate <class _Fn>
1849227825Stheravenclass _LIBCPP_VISIBLE result_of<_Fn()>
1850227825Stheraven    : public __result_of<_Fn(),
1851227825Stheraven                         is_class<typename remove_reference<_Fn>::type>::value ||
1852227825Stheraven                         is_function<typename remove_reference<_Fn>::type>::value,
1853227825Stheraven                         is_member_pointer<typename remove_reference<_Fn>::type>::value
1854227825Stheraven                        >
1855227825Stheraven{
1856227825Stheraven};
1857227825Stheraven
1858227825Stheraventemplate <class _Fn, class _A0>
1859227825Stheravenclass _LIBCPP_VISIBLE result_of<_Fn(_A0)>
1860227825Stheraven    : public __result_of<_Fn(_A0),
1861227825Stheraven                         is_class<typename remove_reference<_Fn>::type>::value ||
1862227825Stheraven                         is_function<typename remove_reference<_Fn>::type>::value,
1863227825Stheraven                         is_member_pointer<typename remove_reference<_Fn>::type>::value
1864227825Stheraven                        >
1865227825Stheraven{
1866227825Stheraven};
1867227825Stheraven
1868227825Stheraventemplate <class _Fn, class _A0, class _A1>
1869227825Stheravenclass _LIBCPP_VISIBLE result_of<_Fn(_A0, _A1)>
1870227825Stheraven    : public __result_of<_Fn(_A0, _A1),
1871227825Stheraven                         is_class<typename remove_reference<_Fn>::type>::value ||
1872227825Stheraven                         is_function<typename remove_reference<_Fn>::type>::value,
1873227825Stheraven                         is_member_pointer<typename remove_reference<_Fn>::type>::value
1874227825Stheraven                        >
1875227825Stheraven{
1876227825Stheraven};
1877227825Stheraven
1878227825Stheraventemplate <class _Fn, class _A0, class _A1, class _A2>
1879227825Stheravenclass _LIBCPP_VISIBLE result_of<_Fn(_A0, _A1, _A2)>
1880227825Stheraven    : public __result_of<_Fn(_A0, _A1, _A2),
1881227825Stheraven                         is_class<typename remove_reference<_Fn>::type>::value ||
1882227825Stheraven                         is_function<typename remove_reference<_Fn>::type>::value,
1883227825Stheraven                         is_member_pointer<typename remove_reference<_Fn>::type>::value
1884227825Stheraven                        >
1885227825Stheraven{
1886227825Stheraven};
1887227825Stheraven
1888227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
1889227825Stheraven
1890227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
1891227825Stheraven
1892227825Stheraven// template <class T, class... Args> struct is_constructible;
1893227825Stheraven
1894227825Stheraven//      main is_constructible test
1895227825Stheraven
1896227825Stheraventemplate <class _Tp, class ..._Args>
1897227825Stheravendecltype(_VSTD::move(_Tp(_VSTD::declval<_Args>()...)), true_type())
1898227825Stheraven__is_constructible_test(_Tp&&, _Args&& ...);
1899227825Stheraven
1900227825Stheraventemplate <class ..._Args>
1901227825Stheravenfalse_type
1902227825Stheraven__is_constructible_test(__any, _Args&& ...);
1903227825Stheraven
1904227825Stheraventemplate <bool, class _Tp, class... _Args>
1905227825Stheravenstruct __is_constructible // false, _Tp is not a scalar
1906227825Stheraven    : public common_type
1907227825Stheraven             <
1908227825Stheraven                 decltype(__is_constructible_test(declval<_Tp>(), declval<_Args>()...))
1909227825Stheraven             >::type
1910227825Stheraven    {};
1911227825Stheraven
1912227825Stheraven//      function types are not constructible
1913227825Stheraven
1914232950Stheraventemplate <class _Rp, class... _A1, class... _A2>
1915232950Stheravenstruct __is_constructible<false, _Rp(_A1...), _A2...>
1916227825Stheraven    : public false_type
1917227825Stheraven    {};
1918227825Stheraven
1919227825Stheraven//      handle scalars and reference types
1920227825Stheraven
1921227825Stheraven//      Scalars are default constructible, references are not
1922227825Stheraven
1923227825Stheraventemplate <class _Tp>
1924227825Stheravenstruct __is_constructible<true, _Tp>
1925227825Stheraven    : public is_scalar<_Tp>
1926227825Stheraven    {};
1927227825Stheraven
1928227825Stheraven//      Scalars and references are constructible from one arg if that arg is
1929227825Stheraven//          implicitly convertible to the scalar or reference.
1930227825Stheraven
1931227825Stheraventemplate <class _Tp>
1932227825Stheravenstruct __is_constructible_ref
1933227825Stheraven{
1934227825Stheraven    true_type static __(_Tp);
1935227825Stheraven    false_type static __(...);
1936227825Stheraven};
1937227825Stheraven
1938227825Stheraventemplate <class _Tp, class _A0>
1939227825Stheravenstruct __is_constructible<true, _Tp, _A0>
1940227825Stheraven    : public common_type
1941227825Stheraven             <
1942227825Stheraven                 decltype(__is_constructible_ref<_Tp>::__(declval<_A0>()))
1943227825Stheraven             >::type
1944227825Stheraven    {};
1945227825Stheraven
1946227825Stheraven//      Scalars and references are not constructible from multiple args.
1947227825Stheraven
1948227825Stheraventemplate <class _Tp, class _A0, class ..._Args>
1949227825Stheravenstruct __is_constructible<true, _Tp, _A0, _Args...>
1950227825Stheraven    : public false_type
1951227825Stheraven    {};
1952227825Stheraven
1953227825Stheraven//      Treat scalars and reference types separately
1954227825Stheraven
1955227825Stheraventemplate <bool, class _Tp, class... _Args>
1956227825Stheravenstruct __is_constructible_void_check
1957227825Stheraven    : public __is_constructible<is_scalar<_Tp>::value || is_reference<_Tp>::value,
1958227825Stheraven                                _Tp, _Args...>
1959227825Stheraven    {};
1960227825Stheraven
1961227825Stheraven//      If any of T or Args is void, is_constructible should be false
1962227825Stheraven
1963227825Stheraventemplate <class _Tp, class... _Args>
1964227825Stheravenstruct __is_constructible_void_check<true, _Tp, _Args...>
1965227825Stheraven    : public false_type
1966227825Stheraven    {};
1967227825Stheraven
1968227825Stheraventemplate <class ..._Args> struct __contains_void;
1969227825Stheraven
1970227825Stheraventemplate <> struct __contains_void<> : false_type {};
1971227825Stheraven
1972227825Stheraventemplate <class _A0, class ..._Args>
1973227825Stheravenstruct __contains_void<_A0, _Args...>
1974227825Stheraven{
1975227825Stheraven    static const bool value = is_void<_A0>::value ||
1976227825Stheraven                              __contains_void<_Args...>::value;
1977227825Stheraven};
1978227825Stheraven
1979227825Stheraven//      is_constructible entry point
1980227825Stheraven
1981227825Stheraventemplate <class _Tp, class... _Args>
1982227825Stheravenstruct _LIBCPP_VISIBLE is_constructible
1983227825Stheraven    : public __is_constructible_void_check<__contains_void<_Tp, _Args...>::value
1984227825Stheraven                                        || is_abstract<_Tp>::value,
1985227825Stheraven                                           _Tp, _Args...>
1986227825Stheraven    {};
1987227825Stheraven
1988227825Stheraven//      Array types are default constructible if their element type
1989227825Stheraven//      is default constructible
1990227825Stheraven
1991232950Stheraventemplate <class _Ap, size_t _Np>
1992232950Stheravenstruct __is_constructible<false, _Ap[_Np]>
1993232950Stheraven    : public is_constructible<typename remove_all_extents<_Ap>::type>
1994227825Stheraven    {};
1995227825Stheraven
1996227825Stheraven//      Otherwise array types are not constructible by this syntax
1997227825Stheraven
1998232950Stheraventemplate <class _Ap, size_t _Np, class ..._Args>
1999232950Stheravenstruct __is_constructible<false, _Ap[_Np], _Args...>
2000227825Stheraven    : public false_type
2001227825Stheraven    {};
2002227825Stheraven
2003227825Stheraven//      Incomplete array types are not constructible
2004227825Stheraven
2005232950Stheraventemplate <class _Ap, class ..._Args>
2006232950Stheravenstruct __is_constructible<false, _Ap[], _Args...>
2007227825Stheraven    : public false_type
2008227825Stheraven    {};
2009227825Stheraven
2010227825Stheraven#else  // _LIBCPP_HAS_NO_VARIADICS
2011227825Stheraven
2012227825Stheraven// template <class T> struct is_constructible0;
2013227825Stheraven
2014227825Stheraven//      main is_constructible0 test
2015227825Stheraven
2016227825Stheraventemplate <class _Tp>
2017227825Stheravendecltype((_Tp(), true_type()))
2018227825Stheraven__is_constructible0_test(_Tp&);
2019227825Stheraven
2020227825Stheravenfalse_type
2021227825Stheraven__is_constructible0_test(__any);
2022227825Stheraven
2023227825Stheraventemplate <class _Tp, class _A0>
2024227825Stheravendecltype((_Tp(_VSTD::declval<_A0>()), true_type()))
2025227825Stheraven__is_constructible1_test(_Tp&, _A0&);
2026227825Stheraven
2027227825Stheraventemplate <class _A0>
2028227825Stheravenfalse_type
2029227825Stheraven__is_constructible1_test(__any, _A0&);
2030227825Stheraven
2031227825Stheraventemplate <class _Tp, class _A0, class _A1>
2032227825Stheravendecltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>()), true_type()))
2033227825Stheraven__is_constructible2_test(_Tp&, _A0&, _A1&);
2034227825Stheraven
2035227825Stheraventemplate <class _A0, class _A1>
2036227825Stheravenfalse_type
2037227825Stheraven__is_constructible2_test(__any, _A0&, _A1&);
2038227825Stheraven
2039227825Stheraventemplate <bool, class _Tp>
2040227825Stheravenstruct __is_constructible0_imp // false, _Tp is not a scalar
2041227825Stheraven    : public common_type
2042227825Stheraven             <
2043227825Stheraven                 decltype(__is_constructible0_test(declval<_Tp&>()))
2044227825Stheraven             >::type
2045227825Stheraven    {};
2046227825Stheraven
2047227825Stheraventemplate <bool, class _Tp, class _A0>
2048227825Stheravenstruct __is_constructible1_imp // false, _Tp is not a scalar
2049227825Stheraven    : public common_type
2050227825Stheraven             <
2051227825Stheraven                 decltype(__is_constructible1_test(declval<_Tp&>(), declval<_A0&>()))
2052227825Stheraven             >::type
2053227825Stheraven    {};
2054227825Stheraven
2055227825Stheraventemplate <bool, class _Tp, class _A0, class _A1>
2056227825Stheravenstruct __is_constructible2_imp // false, _Tp is not a scalar
2057227825Stheraven    : public common_type
2058227825Stheraven             <
2059227825Stheraven                 decltype(__is_constructible2_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>()))
2060227825Stheraven             >::type
2061227825Stheraven    {};
2062227825Stheraven
2063227825Stheraven//      handle scalars and reference types
2064227825Stheraven
2065227825Stheraven//      Scalars are default constructible, references are not
2066227825Stheraven
2067227825Stheraventemplate <class _Tp>
2068227825Stheravenstruct __is_constructible0_imp<true, _Tp>
2069227825Stheraven    : public is_scalar<_Tp>
2070227825Stheraven    {};
2071227825Stheraven
2072227825Stheraventemplate <class _Tp, class _A0>
2073227825Stheravenstruct __is_constructible1_imp<true, _Tp, _A0>
2074227825Stheraven    : public is_convertible<_A0, _Tp>
2075227825Stheraven    {};
2076227825Stheraven
2077227825Stheraventemplate <class _Tp, class _A0, class _A1>
2078227825Stheravenstruct __is_constructible2_imp<true, _Tp, _A0, _A1>
2079227825Stheraven    : public false_type
2080227825Stheraven    {};
2081227825Stheraven
2082227825Stheraven//      Treat scalars and reference types separately
2083227825Stheraven
2084227825Stheraventemplate <bool, class _Tp>
2085227825Stheravenstruct __is_constructible0_void_check
2086227825Stheraven    : public __is_constructible0_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2087227825Stheraven                                _Tp>
2088227825Stheraven    {};
2089227825Stheraven
2090227825Stheraventemplate <bool, class _Tp, class _A0>
2091227825Stheravenstruct __is_constructible1_void_check
2092227825Stheraven    : public __is_constructible1_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2093227825Stheraven                                _Tp, _A0>
2094227825Stheraven    {};
2095227825Stheraven
2096227825Stheraventemplate <bool, class _Tp, class _A0, class _A1>
2097227825Stheravenstruct __is_constructible2_void_check
2098227825Stheraven    : public __is_constructible2_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2099227825Stheraven                                _Tp, _A0, _A1>
2100227825Stheraven    {};
2101227825Stheraven
2102227825Stheraven//      If any of T or Args is void, is_constructible should be false
2103227825Stheraven
2104227825Stheraventemplate <class _Tp>
2105227825Stheravenstruct __is_constructible0_void_check<true, _Tp>
2106227825Stheraven    : public false_type
2107227825Stheraven    {};
2108227825Stheraven
2109227825Stheraventemplate <class _Tp, class _A0>
2110227825Stheravenstruct __is_constructible1_void_check<true, _Tp, _A0>
2111227825Stheraven    : public false_type
2112227825Stheraven    {};
2113227825Stheraven
2114227825Stheraventemplate <class _Tp, class _A0, class _A1>
2115227825Stheravenstruct __is_constructible2_void_check<true, _Tp, _A0, _A1>
2116227825Stheraven    : public false_type
2117227825Stheraven    {};
2118227825Stheraven
2119227825Stheraven//      is_constructible entry point
2120227825Stheraven
2121227825Stheravennamespace __is_construct
2122227825Stheraven{
2123227825Stheraven
2124227825Stheravenstruct __nat {};
2125227825Stheraven
2126227825Stheraven}
2127227825Stheraven
2128227825Stheraventemplate <class _Tp, class _A0 = __is_construct::__nat,
2129227825Stheraven                     class _A1 = __is_construct::__nat>
2130227825Stheravenstruct _LIBCPP_VISIBLE is_constructible
2131227825Stheraven    : public __is_constructible2_void_check<is_void<_Tp>::value
2132227825Stheraven                                        || is_abstract<_Tp>::value
2133227825Stheraven                                        || is_function<_Tp>::value
2134227825Stheraven                                        || is_void<_A0>::value
2135227825Stheraven                                        || is_void<_A1>::value,
2136227825Stheraven                                           _Tp, _A0, _A1>
2137227825Stheraven    {};
2138227825Stheraven
2139227825Stheraventemplate <class _Tp>
2140227825Stheravenstruct _LIBCPP_VISIBLE is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat>
2141227825Stheraven    : public __is_constructible0_void_check<is_void<_Tp>::value
2142227825Stheraven                                        || is_abstract<_Tp>::value
2143227825Stheraven                                        || is_function<_Tp>::value,
2144227825Stheraven                                           _Tp>
2145227825Stheraven    {};
2146227825Stheraven
2147227825Stheraventemplate <class _Tp, class _A0>
2148227825Stheravenstruct _LIBCPP_VISIBLE is_constructible<_Tp, _A0, __is_construct::__nat>
2149227825Stheraven    : public __is_constructible1_void_check<is_void<_Tp>::value
2150227825Stheraven                                        || is_abstract<_Tp>::value
2151227825Stheraven                                        || is_function<_Tp>::value
2152227825Stheraven                                        || is_void<_A0>::value,
2153227825Stheraven                                           _Tp, _A0>
2154227825Stheraven    {};
2155227825Stheraven
2156227825Stheraven//      Array types are default constructible if their element type
2157227825Stheraven//      is default constructible
2158227825Stheraven
2159232950Stheraventemplate <class _Ap, size_t _Np>
2160232950Stheravenstruct __is_constructible0_imp<false, _Ap[_Np]>
2161232950Stheraven    : public is_constructible<typename remove_all_extents<_Ap>::type>
2162227825Stheraven    {};
2163227825Stheraven
2164232950Stheraventemplate <class _Ap, size_t _Np, class _A0>
2165232950Stheravenstruct __is_constructible1_imp<false, _Ap[_Np], _A0>
2166227825Stheraven    : public false_type
2167227825Stheraven    {};
2168227825Stheraven
2169232950Stheraventemplate <class _Ap, size_t _Np, class _A0, class _A1>
2170232950Stheravenstruct __is_constructible2_imp<false, _Ap[_Np], _A0, _A1>
2171227825Stheraven    : public false_type
2172227825Stheraven    {};
2173227825Stheraven
2174227825Stheraven//      Incomplete array types are not constructible
2175227825Stheraven
2176232950Stheraventemplate <class _Ap>
2177232950Stheravenstruct __is_constructible0_imp<false, _Ap[]>
2178227825Stheraven    : public false_type
2179227825Stheraven    {};
2180227825Stheraven
2181232950Stheraventemplate <class _Ap, class _A0>
2182232950Stheravenstruct __is_constructible1_imp<false, _Ap[], _A0>
2183227825Stheraven    : public false_type
2184227825Stheraven    {};
2185227825Stheraven
2186232950Stheraventemplate <class _Ap, class _A0, class _A1>
2187232950Stheravenstruct __is_constructible2_imp<false, _Ap[], _A0, _A1>
2188227825Stheraven    : public false_type
2189227825Stheraven    {};
2190227825Stheraven
2191227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
2192227825Stheraven
2193227825Stheraven// is_default_constructible
2194227825Stheraven
2195227825Stheraventemplate <class _Tp>
2196227825Stheravenstruct _LIBCPP_VISIBLE is_default_constructible
2197227825Stheraven    : public is_constructible<_Tp>
2198227825Stheraven    {};
2199227825Stheraven
2200227825Stheraven// is_copy_constructible
2201227825Stheraven
2202227825Stheraventemplate <class _Tp>
2203227825Stheravenstruct _LIBCPP_VISIBLE is_copy_constructible
2204227825Stheraven    : public is_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type>
2205227825Stheraven    {};
2206227825Stheraven
2207227825Stheraven// is_move_constructible
2208227825Stheraven
2209227825Stheraventemplate <class _Tp>
2210227825Stheravenstruct _LIBCPP_VISIBLE is_move_constructible
2211227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2212227825Stheraven    : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2213227825Stheraven#else
2214227825Stheraven    : public is_copy_constructible<_Tp>
2215227825Stheraven#endif
2216227825Stheraven    {};
2217227825Stheraven
2218227825Stheraven// is_trivially_constructible
2219227825Stheraven
2220227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
2221227825Stheraven
2222232950Stheraven#if __has_feature(is_trivially_constructible)
2223232950Stheraven
2224227825Stheraventemplate <class _Tp, class... _Args>
2225227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible
2226232950Stheraven    : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
2227232950Stheraven{
2228232950Stheraven};
2229232950Stheraven
2230232950Stheraven#else  // !__has_feature(is_trivially_constructible)
2231232950Stheraven
2232232950Stheraventemplate <class _Tp, class... _Args>
2233232950Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible
2234227825Stheraven    : false_type
2235227825Stheraven{
2236227825Stheraven};
2237227825Stheraven
2238227825Stheraventemplate <class _Tp>
2239227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp>
2240227825Stheraven#if __has_feature(has_trivial_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2241227825Stheraven    : integral_constant<bool, __has_trivial_constructor(_Tp)>
2242227825Stheraven#else
2243227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2244227825Stheraven#endif
2245227825Stheraven{
2246227825Stheraven};
2247227825Stheraven
2248227825Stheraventemplate <class _Tp>
2249227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2250227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp&&>
2251227825Stheraven#else
2252227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp>
2253227825Stheraven#endif
2254227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2255227825Stheraven{
2256227825Stheraven};
2257227825Stheraven
2258227825Stheraventemplate <class _Tp>
2259227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, const _Tp&>
2260227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2261227825Stheraven{
2262227825Stheraven};
2263227825Stheraven
2264227825Stheraventemplate <class _Tp>
2265227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp&>
2266227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2267227825Stheraven{
2268227825Stheraven};
2269227825Stheraven
2270232950Stheraven#endif  // !__has_feature(is_trivially_constructible)
2271232950Stheraven
2272227825Stheraven#else  // _LIBCPP_HAS_NO_VARIADICS
2273227825Stheraven
2274227825Stheraventemplate <class _Tp, class _A0 = __is_construct::__nat,
2275227825Stheraven                     class _A1 = __is_construct::__nat>
2276227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible
2277227825Stheraven    : false_type
2278227825Stheraven{
2279227825Stheraven};
2280227825Stheraven
2281232950Stheraven#if __has_feature(is_trivially_constructible)
2282232950Stheraven
2283227825Stheraventemplate <class _Tp>
2284227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, __is_construct::__nat,
2285227825Stheraven                                                       __is_construct::__nat>
2286232950Stheraven    : integral_constant<bool, __is_trivially_constructible(_Tp)>
2287232950Stheraven{
2288232950Stheraven};
2289232950Stheraven
2290232950Stheraventemplate <class _Tp>
2291232950Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp,
2292232950Stheraven                                                       __is_construct::__nat>
2293232950Stheraven    : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp)>
2294232950Stheraven{
2295232950Stheraven};
2296232950Stheraven
2297232950Stheraventemplate <class _Tp>
2298232950Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, const _Tp&,
2299232950Stheraven                                                       __is_construct::__nat>
2300232950Stheraven    : integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)>
2301232950Stheraven{
2302232950Stheraven};
2303232950Stheraven
2304232950Stheraventemplate <class _Tp>
2305232950Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp&,
2306232950Stheraven                                                       __is_construct::__nat>
2307232950Stheraven    : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&)>
2308232950Stheraven{
2309232950Stheraven};
2310232950Stheraven
2311232950Stheraven#else  // !__has_feature(is_trivially_constructible)
2312232950Stheraven
2313232950Stheraventemplate <class _Tp>
2314232950Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, __is_construct::__nat,
2315232950Stheraven                                                       __is_construct::__nat>
2316227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2317227825Stheraven{
2318227825Stheraven};
2319227825Stheraven
2320227825Stheraventemplate <class _Tp>
2321227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp,
2322227825Stheraven                                                       __is_construct::__nat>
2323227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2324227825Stheraven{
2325227825Stheraven};
2326227825Stheraven
2327227825Stheraventemplate <class _Tp>
2328227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, const _Tp&,
2329227825Stheraven                                                       __is_construct::__nat>
2330227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2331227825Stheraven{
2332227825Stheraven};
2333227825Stheraven
2334227825Stheraventemplate <class _Tp>
2335227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp&,
2336227825Stheraven                                                       __is_construct::__nat>
2337227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2338227825Stheraven{
2339227825Stheraven};
2340227825Stheraven
2341232950Stheraven#endif  // !__has_feature(is_trivially_constructible)
2342232950Stheraven
2343227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
2344227825Stheraven
2345227825Stheraven// is_trivially_default_constructible
2346227825Stheraven
2347227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivially_default_constructible
2348227825Stheraven    : public is_trivially_constructible<_Tp>
2349227825Stheraven    {};
2350227825Stheraven
2351227825Stheraven// is_trivially_copy_constructible
2352227825Stheraven
2353227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivially_copy_constructible
2354227825Stheraven    : public is_trivially_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type>
2355227825Stheraven    {};
2356227825Stheraven
2357227825Stheraven// is_trivially_move_constructible
2358227825Stheraven
2359227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivially_move_constructible
2360227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2361227825Stheraven    : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2362227825Stheraven#else
2363227825Stheraven    : public is_trivially_copy_constructible<_Tp>
2364227825Stheraven#endif
2365227825Stheraven    {};
2366227825Stheraven
2367227825Stheraven// is_trivially_assignable
2368227825Stheraven
2369232950Stheraven#if __has_feature(is_trivially_constructible)
2370232950Stheraven
2371227825Stheraventemplate <class _Tp, class _Arg>
2372227825Stheravenstruct is_trivially_assignable
2373232950Stheraven    : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
2374232950Stheraven{
2375232950Stheraven};
2376232950Stheraven
2377232950Stheraven#else  // !__has_feature(is_trivially_constructible)
2378232950Stheraven
2379232950Stheraventemplate <class _Tp, class _Arg>
2380232950Stheravenstruct is_trivially_assignable
2381227825Stheraven    : public false_type {};
2382227825Stheraven
2383227825Stheraventemplate <class _Tp>
2384227825Stheravenstruct is_trivially_assignable<_Tp&, _Tp>
2385227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2386227825Stheraven
2387227825Stheraventemplate <class _Tp>
2388227825Stheravenstruct is_trivially_assignable<_Tp&, _Tp&>
2389227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2390227825Stheraven
2391227825Stheraventemplate <class _Tp>
2392227825Stheravenstruct is_trivially_assignable<_Tp&, const _Tp&>
2393227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2394227825Stheraven
2395227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2396227825Stheraven
2397227825Stheraventemplate <class _Tp>
2398227825Stheravenstruct is_trivially_assignable<_Tp&, _Tp&&>
2399227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2400227825Stheraven
2401227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2402227825Stheraven
2403232950Stheraven#endif  // !__has_feature(is_trivially_constructible)
2404232950Stheraven
2405227825Stheraven// is_trivially_copy_assignable
2406227825Stheraven
2407227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivially_copy_assignable
2408227825Stheraven    : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
2409227825Stheraven                               const typename add_lvalue_reference<_Tp>::type>
2410227825Stheraven    {};
2411227825Stheraven
2412227825Stheraven// is_trivially_move_assignable
2413227825Stheraven
2414227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivially_move_assignable
2415227825Stheraven    : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
2416227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2417227825Stheraven                                     typename add_rvalue_reference<_Tp>::type>
2418227825Stheraven#else
2419227825Stheraven                                     typename add_lvalue_reference<_Tp>::type>
2420227825Stheraven#endif
2421227825Stheraven    {};
2422227825Stheraven
2423227825Stheraven// is_trivially_destructible
2424227825Stheraven
2425227825Stheraven#if __has_feature(has_trivial_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2426227825Stheraven
2427227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivially_destructible
2428227825Stheraven    : public integral_constant<bool, __has_trivial_destructor(_Tp)> {};
2429227825Stheraven
2430227825Stheraven#else  // _LIBCPP_HAS_TYPE_TRAITS
2431227825Stheraven
2432227825Stheraventemplate <class _Tp> struct __libcpp_trivial_destructor
2433227825Stheraven    : public integral_constant<bool, is_scalar<_Tp>::value ||
2434227825Stheraven                                     is_reference<_Tp>::value> {};
2435227825Stheraven
2436227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivially_destructible
2437227825Stheraven    : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
2438227825Stheraven
2439227825Stheraven#endif  // _LIBCPP_HAS_TYPE_TRAITS
2440227825Stheraven
2441227825Stheraven// is_nothrow_constructible
2442227825Stheraven
2443227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
2444227825Stheraven
2445227825Stheraven#if __has_feature(cxx_noexcept)
2446227825Stheraven
2447227825Stheraventemplate <bool, class _Tp, class... _Args> struct __is_nothrow_constructible;
2448227825Stheraven
2449227825Stheraventemplate <class _Tp, class... _Args>
2450227825Stheravenstruct __is_nothrow_constructible<true, _Tp, _Args...>
2451227825Stheraven    : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
2452227825Stheraven{
2453227825Stheraven};
2454227825Stheraven
2455227825Stheraventemplate <class _Tp, class... _Args>
2456227825Stheravenstruct __is_nothrow_constructible<false, _Tp, _Args...>
2457227825Stheraven    : public false_type
2458227825Stheraven{
2459227825Stheraven};
2460227825Stheraven
2461227825Stheraventemplate <class _Tp, class... _Args>
2462227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible
2463227825Stheraven    : __is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, _Tp, _Args...>
2464227825Stheraven{
2465227825Stheraven};
2466227825Stheraven
2467227825Stheraventemplate <class _Tp, size_t _Ns>
2468227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp[_Ns]>
2469227825Stheraven    : __is_nothrow_constructible<is_constructible<_Tp>::value, _Tp>
2470227825Stheraven{
2471227825Stheraven};
2472227825Stheraven
2473227825Stheraven#else  // __has_feature(cxx_noexcept)
2474227825Stheraven
2475227825Stheraventemplate <class _Tp, class... _Args>
2476227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible
2477227825Stheraven    : false_type
2478227825Stheraven{
2479227825Stheraven};
2480227825Stheraven
2481227825Stheraventemplate <class _Tp>
2482227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp>
2483227825Stheraven#if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2484227825Stheraven    : integral_constant<bool, __has_nothrow_constructor(_Tp)>
2485227825Stheraven#else
2486227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2487227825Stheraven#endif
2488227825Stheraven{
2489227825Stheraven};
2490227825Stheraven
2491227825Stheraventemplate <class _Tp>
2492227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2493227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, _Tp&&>
2494227825Stheraven#else
2495227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, _Tp>
2496227825Stheraven#endif
2497227825Stheraven#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2498227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
2499227825Stheraven#else
2500227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2501227825Stheraven#endif
2502227825Stheraven{
2503227825Stheraven};
2504227825Stheraven
2505227825Stheraventemplate <class _Tp>
2506227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, const _Tp&>
2507227825Stheraven#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2508227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
2509227825Stheraven#else
2510227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2511227825Stheraven#endif
2512227825Stheraven{
2513227825Stheraven};
2514227825Stheraven
2515227825Stheraventemplate <class _Tp>
2516227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, _Tp&>
2517227825Stheraven#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2518227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
2519227825Stheraven#else
2520227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2521227825Stheraven#endif
2522227825Stheraven{
2523227825Stheraven};
2524227825Stheraven
2525227825Stheraven#endif  // __has_feature(cxx_noexcept)
2526227825Stheraven
2527227825Stheraven#else  // _LIBCPP_HAS_NO_VARIADICS
2528227825Stheraven
2529227825Stheraventemplate <class _Tp, class _A0 = __is_construct::__nat,
2530227825Stheraven                     class _A1 = __is_construct::__nat>
2531227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible
2532227825Stheraven    : false_type
2533227825Stheraven{
2534227825Stheraven};
2535227825Stheraven
2536227825Stheraventemplate <class _Tp>
2537227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, __is_construct::__nat,
2538227825Stheraven                                                       __is_construct::__nat>
2539227825Stheraven#if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2540227825Stheraven    : integral_constant<bool, __has_nothrow_constructor(_Tp)>
2541227825Stheraven#else
2542227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2543227825Stheraven#endif
2544227825Stheraven{
2545227825Stheraven};
2546227825Stheraven
2547227825Stheraventemplate <class _Tp>
2548227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, _Tp,
2549227825Stheraven                                                       __is_construct::__nat>
2550227825Stheraven#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2551227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
2552227825Stheraven#else
2553227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2554227825Stheraven#endif
2555227825Stheraven{
2556227825Stheraven};
2557227825Stheraven
2558227825Stheraventemplate <class _Tp>
2559227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, const _Tp&,
2560227825Stheraven                                                       __is_construct::__nat>
2561227825Stheraven#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2562227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
2563227825Stheraven#else
2564227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2565227825Stheraven#endif
2566227825Stheraven{
2567227825Stheraven};
2568227825Stheraven
2569227825Stheraventemplate <class _Tp>
2570227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, _Tp&,
2571227825Stheraven                                                       __is_construct::__nat>
2572227825Stheraven#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2573227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
2574227825Stheraven#else
2575227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2576227825Stheraven#endif
2577227825Stheraven{
2578227825Stheraven};
2579227825Stheraven
2580227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
2581227825Stheraven
2582227825Stheraven// is_nothrow_default_constructible
2583227825Stheraven
2584227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_default_constructible
2585227825Stheraven    : public is_nothrow_constructible<_Tp>
2586227825Stheraven    {};
2587227825Stheraven
2588227825Stheraven// is_nothrow_copy_constructible
2589227825Stheraven
2590227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_copy_constructible
2591227825Stheraven    : public is_nothrow_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type>
2592227825Stheraven    {};
2593227825Stheraven
2594227825Stheraven// is_nothrow_move_constructible
2595227825Stheraven
2596227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_move_constructible
2597227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2598227825Stheraven    : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2599227825Stheraven#else
2600227825Stheraven    : public is_nothrow_copy_constructible<_Tp>
2601227825Stheraven#endif
2602227825Stheraven    {};
2603227825Stheraven
2604227825Stheraven// is_nothrow_assignable
2605227825Stheraven
2606227825Stheraven#if __has_feature(cxx_noexcept)
2607227825Stheraven
2608227825Stheraventemplate <bool, class _Tp, class _Arg> struct __is_nothrow_assignable;
2609227825Stheraven
2610227825Stheraventemplate <class _Tp, class _Arg>
2611227825Stheravenstruct __is_nothrow_assignable<false, _Tp, _Arg>
2612227825Stheraven    : public false_type
2613227825Stheraven{
2614227825Stheraven};
2615227825Stheraven
2616227825Stheraventemplate <class _Tp, class _Arg>
2617227825Stheravenstruct __is_nothrow_assignable<true, _Tp, _Arg>
2618227825Stheraven    : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) >
2619227825Stheraven{
2620227825Stheraven};
2621227825Stheraven
2622227825Stheraventemplate <class _Tp, class _Arg>
2623227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_assignable
2624227825Stheraven    : public __is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
2625227825Stheraven{
2626227825Stheraven};
2627227825Stheraven
2628227825Stheraven#else  // __has_feature(cxx_noexcept)
2629227825Stheraven
2630227825Stheraventemplate <class _Tp, class _Arg>
2631227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_assignable
2632227825Stheraven    : public false_type {};
2633227825Stheraven
2634227825Stheraventemplate <class _Tp>
2635227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_assignable<_Tp&, _Tp>
2636227825Stheraven#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2637227825Stheraven    : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
2638227825Stheraven#else
2639227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2640227825Stheraven#endif
2641227825Stheraven
2642227825Stheraventemplate <class _Tp>
2643227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_assignable<_Tp&, _Tp&>
2644227825Stheraven#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2645227825Stheraven    : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
2646227825Stheraven#else
2647227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2648227825Stheraven#endif
2649227825Stheraven
2650227825Stheraventemplate <class _Tp>
2651227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_assignable<_Tp&, const _Tp&>
2652227825Stheraven#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2653227825Stheraven    : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
2654227825Stheraven#else
2655227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2656227825Stheraven#endif
2657227825Stheraven
2658227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2659227825Stheraven
2660227825Stheraventemplate <class _Tp>
2661227825Stheravenstruct is_nothrow_assignable<_Tp&, _Tp&&>
2662227825Stheraven#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2663227825Stheraven    : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
2664227825Stheraven#else
2665227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2666227825Stheraven#endif
2667227825Stheraven
2668227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2669227825Stheraven
2670227825Stheraven#endif  // __has_feature(cxx_noexcept)
2671227825Stheraven
2672227825Stheraven// is_nothrow_copy_assignable
2673227825Stheraven
2674227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_copy_assignable
2675227825Stheraven    : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
2676227825Stheraven                               const typename add_lvalue_reference<_Tp>::type>
2677227825Stheraven    {};
2678227825Stheraven
2679227825Stheraven// is_nothrow_move_assignable
2680227825Stheraven
2681227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_move_assignable
2682227825Stheraven    : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
2683227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2684227825Stheraven                                     typename add_rvalue_reference<_Tp>::type>
2685227825Stheraven#else
2686227825Stheraven                                     typename add_lvalue_reference<_Tp>::type>
2687227825Stheraven#endif
2688227825Stheraven    {};
2689227825Stheraven
2690227825Stheraven// is_nothrow_destructible
2691227825Stheraven
2692227825Stheraven#if __has_feature(cxx_noexcept)
2693227825Stheraven
2694227825Stheraventemplate <bool, class _Tp> struct __is_nothrow_destructible;
2695227825Stheraven
2696227825Stheraventemplate <class _Tp>
2697227825Stheravenstruct __is_nothrow_destructible<false, _Tp>
2698227825Stheraven    : public false_type
2699227825Stheraven{
2700227825Stheraven};
2701227825Stheraven
2702227825Stheraventemplate <class _Tp>
2703227825Stheravenstruct __is_nothrow_destructible<true, _Tp>
2704227825Stheraven    : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) >
2705227825Stheraven{
2706227825Stheraven};
2707227825Stheraven
2708227825Stheraventemplate <class _Tp>
2709227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_destructible
2710227825Stheraven    : public __is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
2711227825Stheraven{
2712227825Stheraven};
2713227825Stheraven
2714227825Stheraventemplate <class _Tp, size_t _Ns>
2715227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_destructible<_Tp[_Ns]>
2716227825Stheraven    : public is_nothrow_destructible<_Tp>
2717227825Stheraven{
2718227825Stheraven};
2719227825Stheraven
2720227825Stheraventemplate <class _Tp>
2721227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_destructible<_Tp&>
2722227825Stheraven    : public true_type
2723227825Stheraven{
2724227825Stheraven};
2725227825Stheraven
2726227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2727227825Stheraven
2728227825Stheraventemplate <class _Tp>
2729227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_destructible<_Tp&&>
2730227825Stheraven    : public true_type
2731227825Stheraven{
2732227825Stheraven};
2733227825Stheraven
2734227825Stheraven#endif
2735227825Stheraven
2736227825Stheraven#else
2737227825Stheraven
2738227825Stheraventemplate <class _Tp> struct __libcpp_nothrow_destructor
2739227825Stheraven    : public integral_constant<bool, is_scalar<_Tp>::value ||
2740227825Stheraven                                     is_reference<_Tp>::value> {};
2741227825Stheraven
2742227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_destructible
2743227825Stheraven    : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
2744227825Stheraven
2745227825Stheraven#endif
2746227825Stheraven
2747227825Stheraven// is_pod
2748227825Stheraven
2749227825Stheraven#if __has_feature(is_pod) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2750227825Stheraven
2751227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_pod
2752227825Stheraven    : public integral_constant<bool, __is_pod(_Tp)> {};
2753227825Stheraven
2754227825Stheraven#else  // _LIBCPP_HAS_TYPE_TRAITS
2755227825Stheraven
2756227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_pod
2757227825Stheraven    : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value   &&
2758227825Stheraven                                     is_trivially_copy_constructible<_Tp>::value      &&
2759227825Stheraven                                     is_trivially_copy_assignable<_Tp>::value    &&
2760227825Stheraven                                     is_trivially_destructible<_Tp>::value> {};
2761227825Stheraven
2762227825Stheraven#endif  // _LIBCPP_HAS_TYPE_TRAITS
2763227825Stheraven
2764227825Stheraven// is_literal_type;
2765227825Stheraven
2766227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_literal_type
2767227825Stheraven#if __has_feature(is_literal)
2768227825Stheraven    : public integral_constant<bool, __is_literal(_Tp)>
2769227825Stheraven#else
2770227825Stheraven    : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value ||
2771227825Stheraven                              is_reference<typename remove_all_extents<_Tp>::type>::value>
2772227825Stheraven#endif
2773227825Stheraven    {};
2774227825Stheraven    
2775227825Stheraven// is_standard_layout;
2776227825Stheraven
2777227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_standard_layout
2778227825Stheraven#if __has_feature(is_standard_layout)
2779227825Stheraven    : public integral_constant<bool, __is_standard_layout(_Tp)>
2780227825Stheraven#else
2781227825Stheraven    : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
2782227825Stheraven#endif
2783227825Stheraven    {};
2784227825Stheraven    
2785227825Stheraven// is_trivially_copyable;
2786227825Stheraven
2787227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivially_copyable
2788227825Stheraven#if __has_feature(is_trivially_copyable)
2789227825Stheraven    : public integral_constant<bool, __is_trivially_copyable(_Tp)>
2790227825Stheraven#else
2791227825Stheraven    : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
2792227825Stheraven#endif
2793227825Stheraven    {};
2794227825Stheraven    
2795227825Stheraven// is_trivial;
2796227825Stheraven
2797227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivial
2798227825Stheraven#if __has_feature(is_trivial)
2799227825Stheraven    : public integral_constant<bool, __is_trivial(_Tp)>
2800227825Stheraven#else
2801227825Stheraven    : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
2802227825Stheraven                                 is_trivially_default_constructible<_Tp>::value>
2803227825Stheraven#endif
2804227825Stheraven    {};
2805227825Stheraven
2806227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
2807227825Stheraven
2808227825Stheraven// Check for complete types
2809227825Stheraven
2810232950Stheraventemplate <class ..._Tp> struct __check_complete;
2811227825Stheraven
2812227825Stheraventemplate <>
2813227825Stheravenstruct __check_complete<>
2814227825Stheraven{
2815227825Stheraven};
2816227825Stheraven
2817232950Stheraventemplate <class _Hp, class _T0, class ..._Tp>
2818232950Stheravenstruct __check_complete<_Hp, _T0, _Tp...>
2819232950Stheraven    : private __check_complete<_Hp>,
2820232950Stheraven      private __check_complete<_T0, _Tp...>
2821227825Stheraven{
2822227825Stheraven};
2823227825Stheraven
2824232950Stheraventemplate <class _Hp>
2825232950Stheravenstruct __check_complete<_Hp, _Hp>
2826232950Stheraven    : private __check_complete<_Hp>
2827227825Stheraven{
2828227825Stheraven};
2829227825Stheraven
2830232950Stheraventemplate <class _Tp>
2831232950Stheravenstruct __check_complete<_Tp>
2832227825Stheraven{
2833232950Stheraven    static_assert(sizeof(_Tp) > 0, "Type must be complete.");
2834227825Stheraven};
2835227825Stheraven
2836232950Stheraventemplate <class _Tp>
2837232950Stheravenstruct __check_complete<_Tp&>
2838232950Stheraven    : private __check_complete<_Tp>
2839227825Stheraven{
2840227825Stheraven};
2841227825Stheraven
2842232950Stheraventemplate <class _Tp>
2843232950Stheravenstruct __check_complete<_Tp&&>
2844232950Stheraven    : private __check_complete<_Tp>
2845227825Stheraven{
2846227825Stheraven};
2847227825Stheraven
2848232950Stheraventemplate <class _Rp, class ..._Param>
2849232950Stheravenstruct __check_complete<_Rp (*)(_Param...)>
2850227825Stheraven    : private __check_complete<_Param...>
2851227825Stheraven{
2852227825Stheraven};
2853227825Stheraven
2854232950Stheraventemplate <class _Rp, class ..._Param>
2855232950Stheravenstruct __check_complete<_Rp (_Param...)>
2856227825Stheraven    : private __check_complete<_Param...>
2857227825Stheraven{
2858227825Stheraven};
2859227825Stheraven
2860232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2861232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...)>
2862227825Stheraven    : private __check_complete<_Class, _Param...>
2863227825Stheraven{
2864227825Stheraven};
2865227825Stheraven
2866232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2867232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) const>
2868227825Stheraven    : private __check_complete<_Class, _Param...>
2869227825Stheraven{
2870227825Stheraven};
2871227825Stheraven
2872232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2873232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) volatile>
2874227825Stheraven    : private __check_complete<_Class, _Param...>
2875227825Stheraven{
2876227825Stheraven};
2877227825Stheraven
2878232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2879232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) const volatile>
2880227825Stheraven    : private __check_complete<_Class, _Param...>
2881227825Stheraven{
2882227825Stheraven};
2883227825Stheraven
2884227825Stheraven#if __has_feature(cxx_reference_qualified_functions)
2885227825Stheraven
2886232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2887232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) &>
2888227825Stheraven    : private __check_complete<_Class, _Param...>
2889227825Stheraven{
2890227825Stheraven};
2891227825Stheraven
2892232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2893232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) const&>
2894227825Stheraven    : private __check_complete<_Class, _Param...>
2895227825Stheraven{
2896227825Stheraven};
2897227825Stheraven
2898232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2899232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) volatile&>
2900227825Stheraven    : private __check_complete<_Class, _Param...>
2901227825Stheraven{
2902227825Stheraven};
2903227825Stheraven
2904232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2905232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) const volatile&>
2906227825Stheraven    : private __check_complete<_Class, _Param...>
2907227825Stheraven{
2908227825Stheraven};
2909227825Stheraven
2910232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2911232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) &&>
2912227825Stheraven    : private __check_complete<_Class, _Param...>
2913227825Stheraven{
2914227825Stheraven};
2915227825Stheraven
2916232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2917232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) const&&>
2918227825Stheraven    : private __check_complete<_Class, _Param...>
2919227825Stheraven{
2920227825Stheraven};
2921227825Stheraven
2922232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2923232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) volatile&&>
2924227825Stheraven    : private __check_complete<_Class, _Param...>
2925227825Stheraven{
2926227825Stheraven};
2927227825Stheraven
2928232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2929232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) const volatile&&>
2930227825Stheraven    : private __check_complete<_Class, _Param...>
2931227825Stheraven{
2932227825Stheraven};
2933227825Stheraven
2934227825Stheraven#endif
2935227825Stheraven
2936232950Stheraventemplate <class _Rp, class _Class>
2937232950Stheravenstruct __check_complete<_Rp _Class::*>
2938227825Stheraven    : private __check_complete<_Class>
2939227825Stheraven{
2940227825Stheraven};
2941227825Stheraven
2942227825Stheraven// __invoke forward declarations
2943227825Stheraven
2944227825Stheraven// fall back - none of the bullets
2945227825Stheraven
2946227825Stheraventemplate <class ..._Args>
2947227825Stheravenauto
2948227825Stheraven__invoke(__any, _Args&& ...__args)
2949227825Stheraven    -> __nat;
2950227825Stheraven
2951227825Stheraven// bullets 1 and 2
2952227825Stheraven
2953232950Stheraventemplate <class _Fp, class _A0, class ..._Args>
2954227825Stheravenauto
2955232950Stheraven__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
2956227825Stheraven    -> decltype((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...));
2957227825Stheraven
2958232950Stheraventemplate <class _Fp, class _A0, class ..._Args>
2959227825Stheravenauto
2960232950Stheraven__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
2961227825Stheraven    -> decltype(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...));
2962227825Stheraven
2963227825Stheraven// bullets 3 and 4
2964227825Stheraven
2965232950Stheraventemplate <class _Fp, class _A0>
2966227825Stheravenauto
2967232950Stheraven__invoke(_Fp&& __f, _A0&& __a0)
2968227825Stheraven    -> decltype(_VSTD::forward<_A0>(__a0).*__f);
2969227825Stheraven
2970232950Stheraventemplate <class _Fp, class _A0>
2971227825Stheravenauto
2972232950Stheraven__invoke(_Fp&& __f, _A0&& __a0)
2973227825Stheraven    -> decltype((*_VSTD::forward<_A0>(__a0)).*__f);
2974227825Stheraven
2975227825Stheraven// bullet 5
2976227825Stheraven
2977232950Stheraventemplate <class _Fp, class ..._Args>
2978227825Stheravenauto
2979232950Stheraven__invoke(_Fp&& __f, _Args&& ...__args)
2980232950Stheraven    -> decltype(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...));
2981227825Stheraven
2982227825Stheraven// __invokable
2983227825Stheraven
2984232950Stheraventemplate <class _Fp, class ..._Args>
2985227825Stheravenstruct __invokable_imp
2986232950Stheraven    : private __check_complete<_Fp, _Args...>
2987227825Stheraven{
2988227825Stheraven    typedef decltype(
2989232950Stheraven            __invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)
2990227825Stheraven                    ) type;
2991227825Stheraven    static const bool value = !is_same<type, __nat>::value;
2992227825Stheraven};
2993227825Stheraven
2994232950Stheraventemplate <class _Fp, class ..._Args>
2995227825Stheravenstruct __invokable
2996227825Stheraven    : public integral_constant<bool,
2997232950Stheraven          __invokable_imp<_Fp, _Args...>::value>
2998227825Stheraven{
2999227825Stheraven};
3000227825Stheraven
3001227825Stheraven// __invoke_of
3002227825Stheraven
3003232950Stheraventemplate <bool _Invokable, class _Fp, class ..._Args>
3004227825Stheravenstruct __invoke_of_imp  // false
3005227825Stheraven{
3006227825Stheraven};
3007227825Stheraven
3008232950Stheraventemplate <class _Fp, class ..._Args>
3009232950Stheravenstruct __invoke_of_imp<true, _Fp, _Args...>
3010227825Stheraven{
3011232950Stheraven    typedef typename __invokable_imp<_Fp, _Args...>::type type;
3012227825Stheraven};
3013227825Stheraven
3014232950Stheraventemplate <class _Fp, class ..._Args>
3015227825Stheravenstruct __invoke_of
3016232950Stheraven    : public __invoke_of_imp<__invokable<_Fp, _Args...>::value, _Fp, _Args...>
3017227825Stheraven{
3018227825Stheraven};
3019227825Stheraven
3020227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
3021227825Stheraven
3022227825Stheraventemplate <class _Tp>
3023227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
3024227825Stheraven#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
3025227825Stheraventypename enable_if
3026227825Stheraven<
3027227825Stheraven    is_move_constructible<_Tp>::value &&
3028227825Stheraven    is_move_assignable<_Tp>::value
3029227825Stheraven>::type
3030227825Stheraven#else
3031227825Stheravenvoid
3032227825Stheraven#endif
3033227825Stheravenswap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
3034227825Stheraven                                    is_nothrow_move_assignable<_Tp>::value)
3035227825Stheraven{
3036227825Stheraven    _Tp __t(_VSTD::move(__x));
3037227825Stheraven    __x = _VSTD::move(__y);
3038227825Stheraven    __y = _VSTD::move(__t);
3039227825Stheraven}
3040227825Stheraven
3041227825Stheraventemplate <class _ForwardIterator1, class _ForwardIterator2>
3042227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
3043227825Stheravenvoid
3044227825Stheraveniter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
3045227825Stheraven    //                                  _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
3046227825Stheraven               _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(),
3047227825Stheraven                                          *_VSTD::declval<_ForwardIterator2>())))
3048227825Stheraven{
3049227825Stheraven    swap(*__a, *__b);
3050227825Stheraven}
3051227825Stheraven
3052227825Stheraven// __swappable
3053227825Stheraven
3054227825Stheravennamespace __detail
3055227825Stheraven{
3056227825Stheraven
3057227825Stheravenusing _VSTD::swap;
3058227825Stheraven__nat swap(__any, __any);
3059227825Stheraven
3060227825Stheraventemplate <class _Tp>
3061227825Stheravenstruct __swappable
3062227825Stheraven{
3063227825Stheraven    typedef decltype(swap(_VSTD::declval<_Tp&>(), _VSTD::declval<_Tp&>())) type;
3064227825Stheraven    static const bool value = !is_same<type, __nat>::value;
3065227825Stheraven};
3066227825Stheraven
3067227825Stheraven}  // __detail
3068227825Stheraven
3069227825Stheraventemplate <class _Tp>
3070227825Stheravenstruct __is_swappable
3071227825Stheraven    : public integral_constant<bool, __detail::__swappable<_Tp>::value>
3072227825Stheraven{
3073227825Stheraven};
3074227825Stheraven
3075227825Stheraven#if __has_feature(cxx_noexcept)
3076227825Stheraven
3077227825Stheraventemplate <bool, class _Tp>
3078227825Stheravenstruct __is_nothrow_swappable_imp
3079227825Stheraven    : public integral_constant<bool, noexcept(swap(_VSTD::declval<_Tp&>(),
3080227825Stheraven                                                   _VSTD::declval<_Tp&>()))>
3081227825Stheraven{
3082227825Stheraven};
3083227825Stheraven
3084227825Stheraventemplate <class _Tp>
3085227825Stheravenstruct __is_nothrow_swappable_imp<false, _Tp>
3086227825Stheraven    : public false_type
3087227825Stheraven{
3088227825Stheraven};
3089227825Stheraven
3090227825Stheraventemplate <class _Tp>
3091227825Stheravenstruct __is_nothrow_swappable
3092227825Stheraven    : public __is_nothrow_swappable_imp<__is_swappable<_Tp>::value, _Tp>
3093227825Stheraven{
3094227825Stheraven};
3095227825Stheraven
3096227825Stheraven#else  // __has_feature(cxx_noexcept)
3097227825Stheraven
3098227825Stheraventemplate <class _Tp>
3099227825Stheravenstruct __is_nothrow_swappable
3100227825Stheraven    : public false_type
3101227825Stheraven{
3102227825Stheraven};
3103227825Stheraven
3104227825Stheraven#endif  // __has_feature(cxx_noexcept)
3105227825Stheraven
3106227825Stheraven#ifdef _LIBCXX_UNDERLYING_TYPE
3107227825Stheraven
3108227825Stheraventemplate <class _Tp>
3109227825Stheravenstruct underlying_type
3110227825Stheraven{
3111227825Stheraven    typedef _LIBCXX_UNDERLYING_TYPE(_Tp) type;
3112227825Stheraven};
3113227825Stheraven
3114227825Stheraven#else  // _LIBCXX_UNDERLYING_TYPE
3115227825Stheraven
3116227825Stheraventemplate <class _Tp, bool _Support = false>
3117227825Stheravenstruct underlying_type
3118227825Stheraven{
3119227825Stheraven    static_assert(_Support, "The underyling_type trait requires compiler "
3120227825Stheraven                            "support. Either no such support exists or "
3121227825Stheraven                            "libc++ does not know how to use it.");
3122227825Stheraven};
3123227825Stheraven
3124227825Stheraven#endif // _LIBCXX_UNDERLYING_TYPE
3125227825Stheraven
3126227825Stheraven_LIBCPP_END_NAMESPACE_STD
3127227825Stheraven
3128227825Stheraven#endif  // _LIBCPP_TYPE_TRAITS
3129