type_traits revision 227825
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
151227825Stheraventemplate <bool _B, 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
744227825Stheraventemplate <class _Tp>
745227825Stheravenstruct __is_empty1
746227825Stheraven    : public _Tp
747227825Stheraven{
748227825Stheraven    double _;
749227825Stheraven};
750227825Stheraven
751227825Stheravenstruct __is_empty2
752227825Stheraven{
753227825Stheraven    double _;
754227825Stheraven};
755227825Stheraven
756227825Stheraventemplate <class _Tp, bool = is_class<_Tp>::value>
757227825Stheravenstruct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {};
758227825Stheraven
759227825Stheraventemplate <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {};
760227825Stheraven
761227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_empty : public __libcpp_empty<_Tp> {};
762227825Stheraven
763227825Stheraven// is_polymorphic
764227825Stheraven
765227825Stheraventemplate <class _Tp> struct __is_polymorphic1 : public _Tp {};
766227825Stheraventemplate <class _Tp> struct __is_polymorphic2 : public _Tp {virtual ~__is_polymorphic2() throw();};
767227825Stheraven
768227825Stheraventemplate <class _Tp, bool = is_class<_Tp>::value>
769227825Stheravenstruct __libcpp_polymorphic
770227825Stheraven    : public integral_constant<bool, sizeof(__is_polymorphic1<_Tp>) == sizeof(__is_polymorphic2<_Tp>)> {};
771227825Stheraven
772227825Stheraventemplate <class _Tp> struct __libcpp_polymorphic<_Tp, false> : public false_type {};
773227825Stheraven
774227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_polymorphic
775227825Stheraven    : public __libcpp_polymorphic<_Tp> {};
776227825Stheraven
777227825Stheraven// has_virtual_destructor
778227825Stheraven
779227825Stheraven#if __has_feature(has_virtual_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
780227825Stheraven
781227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE has_virtual_destructor
782227825Stheraven    : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
783227825Stheraven
784227825Stheraven#else  // _LIBCPP_HAS_TYPE_TRAITS
785227825Stheraven
786227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE has_virtual_destructor
787227825Stheraven    : public false_type {};
788227825Stheraven
789227825Stheraven#endif  // _LIBCPP_HAS_TYPE_TRAITS
790227825Stheraven
791227825Stheraven// alignment_of
792227825Stheraven
793227825Stheraventemplate <class _Tp> struct __alignment_of {_Tp _;};
794227825Stheraven
795227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE alignment_of
796227825Stheraven    : public integral_constant<size_t, __alignof__(__alignment_of<typename remove_all_extents<_Tp>::type>)> {};
797227825Stheraven
798227825Stheraven// aligned_storage
799227825Stheraven
800227825Stheraventemplate <class _Hp, class _Tp>
801227825Stheravenstruct __type_list
802227825Stheraven{
803227825Stheraven    typedef _Hp _Head;
804227825Stheraven    typedef _Tp _Tail;
805227825Stheraven};
806227825Stheraven
807227825Stheravenstruct __nat
808227825Stheraven{
809227825Stheraven#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
810227825Stheraven    __nat() = delete;
811227825Stheraven    __nat(const __nat&) = delete;
812227825Stheraven    __nat& operator=(const __nat&) = delete;
813227825Stheraven    ~__nat() = delete;
814227825Stheraven#endif
815227825Stheraven};
816227825Stheraven
817227825Stheraventemplate <class _Tp>
818227825Stheravenstruct __align_type
819227825Stheraven{
820227825Stheraven    static const size_t value = alignment_of<_Tp>::value;
821227825Stheraven    typedef _Tp type;
822227825Stheraven};
823227825Stheraven
824227825Stheravenstruct __struct_double {long double _;};
825227825Stheravenstruct __struct_double4 {double _[4];};
826227825Stheraven
827227825Stheraventypedef
828227825Stheraven    __type_list<__align_type<unsigned char>,
829227825Stheraven    __type_list<__align_type<unsigned short>,
830227825Stheraven    __type_list<__align_type<unsigned int>,
831227825Stheraven    __type_list<__align_type<unsigned long>,
832227825Stheraven    __type_list<__align_type<unsigned long long>,
833227825Stheraven    __type_list<__align_type<double>,
834227825Stheraven    __type_list<__align_type<long double>,
835227825Stheraven    __type_list<__align_type<__struct_double>,
836227825Stheraven    __type_list<__align_type<__struct_double4>,
837227825Stheraven    __type_list<__align_type<int*>,
838227825Stheraven    __nat
839227825Stheraven    > > > > > > > > > > __all_types;
840227825Stheraven
841227825Stheraventemplate <class _TL, size_t _Align> struct __find_pod;
842227825Stheraven
843227825Stheraventemplate <class _Hp, size_t _Align>
844227825Stheravenstruct __find_pod<__type_list<_Hp, __nat>, _Align>
845227825Stheraven{
846227825Stheraven    typedef typename conditional<
847227825Stheraven                             _Align == _Hp::value,
848227825Stheraven                             typename _Hp::type,
849227825Stheraven                             void
850227825Stheraven                         >::type type;
851227825Stheraven};
852227825Stheraven
853227825Stheraventemplate <class _Hp, class _Tp, size_t _Align>
854227825Stheravenstruct __find_pod<__type_list<_Hp, _Tp>, _Align>
855227825Stheraven{
856227825Stheraven    typedef typename conditional<
857227825Stheraven                             _Align == _Hp::value,
858227825Stheraven                             typename _Hp::type,
859227825Stheraven                             typename __find_pod<_Tp, _Align>::type
860227825Stheraven                         >::type type;
861227825Stheraven};
862227825Stheraven
863227825Stheraventemplate <class _TL, size_t _Len> struct __find_max_align;
864227825Stheraven
865227825Stheraventemplate <class _Hp, size_t _Len>
866227825Stheravenstruct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
867227825Stheraven
868227825Stheraventemplate <size_t _Len, size_t _A1, size_t _A2>
869227825Stheravenstruct __select_align
870227825Stheraven{
871227825Stheravenprivate:
872227825Stheraven    static const size_t __min = _A2 < _A1 ? _A2 : _A1;
873227825Stheraven    static const size_t __max = _A1 < _A2 ? _A2 : _A1;
874227825Stheravenpublic:
875227825Stheraven    static const size_t value = _Len < __max ? __min : __max;
876227825Stheraven};
877227825Stheraven
878227825Stheraventemplate <class _Hp, class _Tp, size_t _Len>
879227825Stheravenstruct __find_max_align<__type_list<_Hp, _Tp>, _Len>
880227825Stheraven    : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
881227825Stheraven
882227825Stheraventemplate <size_t _Len, const size_t _Align = __find_max_align<__all_types, _Len>::value>
883227825Stheravenstruct _LIBCPP_VISIBLE aligned_storage
884227825Stheraven{
885227825Stheraven    typedef typename __find_pod<__all_types, _Align>::type _Aligner;
886227825Stheraven    static_assert(!is_void<_Aligner>::value, "");
887227825Stheraven    union type
888227825Stheraven    {
889227825Stheraven        _Aligner __align;
890227825Stheraven        unsigned char __data[_Len];
891227825Stheraven    };
892227825Stheraven};
893227825Stheraven
894227825Stheraven#define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
895227825Stheraventemplate <size_t _Len>\
896227825Stheravenstruct _LIBCPP_VISIBLE aligned_storage<_Len, n>\
897227825Stheraven{\
898227825Stheraven    struct _ALIGNAS(n) type\
899227825Stheraven    {\
900227825Stheraven        unsigned char _[_Len];\
901227825Stheraven    };\
902227825Stheraven}
903227825Stheraven
904227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
905227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
906227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
907227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
908227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
909227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
910227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
911227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
912227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
913227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
914227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
915227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
916227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
917227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
918227825Stheraven// MSDN says that MSVC does not support alignment beyond 8192 (=0x2000)
919227825Stheraven#if !defined(_MSC_VER)
920227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
921227825Stheraven#endif // !_MSC_VER
922227825Stheraven
923227825Stheraven#undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
924227825Stheraven
925227825Stheraven// __promote
926227825Stheraven
927227825Stheraventemplate <class _A1, class _A2 = void, class _A3 = void,
928227825Stheraven          bool = (is_arithmetic<_A1>::value || is_void<_A1>::value) &&
929227825Stheraven                 (is_arithmetic<_A2>::value || is_void<_A2>::value) &&
930227825Stheraven                 (is_arithmetic<_A3>::value || is_void<_A3>::value)>
931227825Stheravenclass __promote {};
932227825Stheraven
933227825Stheraventemplate <class _A1, class _A2, class _A3>
934227825Stheravenclass __promote<_A1, _A2, _A3, true>
935227825Stheraven{
936227825Stheravenprivate:
937227825Stheraven    typedef typename __promote<_A1>::type __type1;
938227825Stheraven    typedef typename __promote<_A2>::type __type2;
939227825Stheraven    typedef typename __promote<_A3>::type __type3;
940227825Stheravenpublic:
941227825Stheraven    typedef decltype(__type1() + __type2() + __type3()) type;
942227825Stheraven};
943227825Stheraven
944227825Stheraventemplate <class _A1, class _A2>
945227825Stheravenclass __promote<_A1, _A2, void, true>
946227825Stheraven{
947227825Stheravenprivate:
948227825Stheraven    typedef typename __promote<_A1>::type __type1;
949227825Stheraven    typedef typename __promote<_A2>::type __type2;
950227825Stheravenpublic:
951227825Stheraven    typedef decltype(__type1() + __type2()) type;
952227825Stheraven};
953227825Stheraven
954227825Stheraventemplate <class _A1>
955227825Stheravenclass __promote<_A1, void, void, true>
956227825Stheraven{
957227825Stheravenpublic:
958227825Stheraven    typedef typename conditional<is_arithmetic<_A1>::value,
959227825Stheraven                     typename conditional<is_integral<_A1>::value, double, _A1>::type,
960227825Stheraven                     void
961227825Stheraven            >::type type;
962227825Stheraven};
963227825Stheraven
964227825Stheraven#ifdef _LIBCPP_STORE_AS_OPTIMIZATION
965227825Stheraven
966227825Stheraven// __transform
967227825Stheraven
968227825Stheraventemplate <class _Tp, size_t = sizeof(_Tp), bool = is_scalar<_Tp>::value> struct __transform {typedef _Tp type;};
969227825Stheraventemplate <class _Tp> struct __transform<_Tp, 1, true> {typedef unsigned char      type;};
970227825Stheraventemplate <class _Tp> struct __transform<_Tp, 2, true> {typedef unsigned short     type;};
971227825Stheraventemplate <class _Tp> struct __transform<_Tp, 4, true> {typedef unsigned int       type;};
972227825Stheraventemplate <class _Tp> struct __transform<_Tp, 8, true> {typedef unsigned long long type;};
973227825Stheraven
974227825Stheraven#endif  // _LIBCPP_STORE_AS_OPTIMIZATION
975227825Stheraven
976227825Stheraven// make_signed / make_unsigned
977227825Stheraven
978227825Stheraventypedef
979227825Stheraven    __type_list<signed char,
980227825Stheraven    __type_list<signed short,
981227825Stheraven    __type_list<signed int,
982227825Stheraven    __type_list<signed long,
983227825Stheraven    __type_list<signed long long,
984227825Stheraven    __nat
985227825Stheraven    > > > > > __signed_types;
986227825Stheraven
987227825Stheraventypedef
988227825Stheraven    __type_list<unsigned char,
989227825Stheraven    __type_list<unsigned short,
990227825Stheraven    __type_list<unsigned int,
991227825Stheraven    __type_list<unsigned long,
992227825Stheraven    __type_list<unsigned long long,
993227825Stheraven    __nat
994227825Stheraven    > > > > > __unsigned_types;
995227825Stheraven
996227825Stheraventemplate <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
997227825Stheraven
998227825Stheraventemplate <class _Hp, class _Tp, size_t _Size>
999227825Stheravenstruct __find_first<__type_list<_Hp, _Tp>, _Size, true>
1000227825Stheraven{
1001227825Stheraven    typedef _Hp type;
1002227825Stheraven};
1003227825Stheraven
1004227825Stheraventemplate <class _Hp, class _Tp, size_t _Size>
1005227825Stheravenstruct __find_first<__type_list<_Hp, _Tp>, _Size, false>
1006227825Stheraven{
1007227825Stheraven    typedef typename __find_first<_Tp, _Size>::type type;
1008227825Stheraven};
1009227825Stheraven
1010227825Stheraventemplate <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
1011227825Stheraven                             bool = is_volatile<typename remove_reference<_Tp>::type>::value>
1012227825Stheravenstruct __apply_cv
1013227825Stheraven{
1014227825Stheraven    typedef _Up type;
1015227825Stheraven};
1016227825Stheraven
1017227825Stheraventemplate <class _Tp, class _Up>
1018227825Stheravenstruct __apply_cv<_Tp, _Up, true, false>
1019227825Stheraven{
1020227825Stheraven    typedef const _Up type;
1021227825Stheraven};
1022227825Stheraven
1023227825Stheraventemplate <class _Tp, class _Up>
1024227825Stheravenstruct __apply_cv<_Tp, _Up, false, true>
1025227825Stheraven{
1026227825Stheraven    typedef volatile _Up type;
1027227825Stheraven};
1028227825Stheraven
1029227825Stheraventemplate <class _Tp, class _Up>
1030227825Stheravenstruct __apply_cv<_Tp, _Up, true, true>
1031227825Stheraven{
1032227825Stheraven    typedef const volatile _Up type;
1033227825Stheraven};
1034227825Stheraven
1035227825Stheraventemplate <class _Tp, class _Up>
1036227825Stheravenstruct __apply_cv<_Tp&, _Up, false, false>
1037227825Stheraven{
1038227825Stheraven    typedef _Up& type;
1039227825Stheraven};
1040227825Stheraven
1041227825Stheraventemplate <class _Tp, class _Up>
1042227825Stheravenstruct __apply_cv<_Tp&, _Up, true, false>
1043227825Stheraven{
1044227825Stheraven    typedef const _Up& type;
1045227825Stheraven};
1046227825Stheraven
1047227825Stheraventemplate <class _Tp, class _Up>
1048227825Stheravenstruct __apply_cv<_Tp&, _Up, false, true>
1049227825Stheraven{
1050227825Stheraven    typedef volatile _Up& type;
1051227825Stheraven};
1052227825Stheraven
1053227825Stheraventemplate <class _Tp, class _Up>
1054227825Stheravenstruct __apply_cv<_Tp&, _Up, true, true>
1055227825Stheraven{
1056227825Stheraven    typedef const volatile _Up& type;
1057227825Stheraven};
1058227825Stheraven
1059227825Stheraventemplate <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1060227825Stheravenstruct __make_signed {};
1061227825Stheraven
1062227825Stheraventemplate <class _Tp>
1063227825Stheravenstruct __make_signed<_Tp, true>
1064227825Stheraven{
1065227825Stheraven    typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
1066227825Stheraven};
1067227825Stheraven
1068227825Stheraventemplate <> struct __make_signed<bool,               true> {};
1069227825Stheraventemplate <> struct __make_signed<  signed short,     true> {typedef short     type;};
1070227825Stheraventemplate <> struct __make_signed<unsigned short,     true> {typedef short     type;};
1071227825Stheraventemplate <> struct __make_signed<  signed int,       true> {typedef int       type;};
1072227825Stheraventemplate <> struct __make_signed<unsigned int,       true> {typedef int       type;};
1073227825Stheraventemplate <> struct __make_signed<  signed long,      true> {typedef long      type;};
1074227825Stheraventemplate <> struct __make_signed<unsigned long,      true> {typedef long      type;};
1075227825Stheraventemplate <> struct __make_signed<  signed long long, true> {typedef long long type;};
1076227825Stheraventemplate <> struct __make_signed<unsigned long long, true> {typedef long long type;};
1077227825Stheraven
1078227825Stheraventemplate <class _Tp>
1079227825Stheravenstruct _LIBCPP_VISIBLE make_signed
1080227825Stheraven{
1081227825Stheraven    typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
1082227825Stheraven};
1083227825Stheraven
1084227825Stheraventemplate <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1085227825Stheravenstruct __make_unsigned {};
1086227825Stheraven
1087227825Stheraventemplate <class _Tp>
1088227825Stheravenstruct __make_unsigned<_Tp, true>
1089227825Stheraven{
1090227825Stheraven    typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
1091227825Stheraven};
1092227825Stheraven
1093227825Stheraventemplate <> struct __make_unsigned<bool,               true> {};
1094227825Stheraventemplate <> struct __make_unsigned<  signed short,     true> {typedef unsigned short     type;};
1095227825Stheraventemplate <> struct __make_unsigned<unsigned short,     true> {typedef unsigned short     type;};
1096227825Stheraventemplate <> struct __make_unsigned<  signed int,       true> {typedef unsigned int       type;};
1097227825Stheraventemplate <> struct __make_unsigned<unsigned int,       true> {typedef unsigned int       type;};
1098227825Stheraventemplate <> struct __make_unsigned<  signed long,      true> {typedef unsigned long      type;};
1099227825Stheraventemplate <> struct __make_unsigned<unsigned long,      true> {typedef unsigned long      type;};
1100227825Stheraventemplate <> struct __make_unsigned<  signed long long, true> {typedef unsigned long long type;};
1101227825Stheraventemplate <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
1102227825Stheraven
1103227825Stheraventemplate <class _Tp>
1104227825Stheravenstruct _LIBCPP_VISIBLE make_unsigned
1105227825Stheraven{
1106227825Stheraven    typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
1107227825Stheraven};
1108227825Stheraven
1109227825Stheraven#ifdef _LIBCPP_HAS_NO_VARIADICS
1110227825Stheraven
1111227825Stheraventemplate <class _Tp, class _Up = void, class V = void>
1112227825Stheravenstruct _LIBCPP_VISIBLE common_type
1113227825Stheraven{
1114227825Stheravenpublic:
1115227825Stheraven    typedef typename common_type<typename common_type<_Tp, _Up>::type, V>::type type;
1116227825Stheraven};
1117227825Stheraven
1118227825Stheraventemplate <class _Tp>
1119227825Stheravenstruct _LIBCPP_VISIBLE common_type<_Tp, void, void>
1120227825Stheraven{
1121227825Stheravenpublic:
1122227825Stheraven    typedef _Tp type;
1123227825Stheraven};
1124227825Stheraven
1125227825Stheraventemplate <class _Tp, class _Up>
1126227825Stheravenstruct _LIBCPP_VISIBLE common_type<_Tp, _Up, void>
1127227825Stheraven{
1128227825Stheravenprivate:
1129227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1130227825Stheraven    static _Tp&& __t();
1131227825Stheraven    static _Up&& __u();
1132227825Stheraven#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1133227825Stheraven    static _Tp __t();
1134227825Stheraven    static _Up __u();
1135227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1136227825Stheravenpublic:
1137227825Stheraven    typedef decltype(true ? __t() : __u()) type;
1138227825Stheraven};
1139227825Stheraven
1140227825Stheraven#else  // _LIBCPP_HAS_NO_VARIADICS
1141227825Stheraven
1142227825Stheraventemplate <class ..._Tp> struct common_type;
1143227825Stheraven
1144227825Stheraventemplate <class _Tp>
1145227825Stheravenstruct _LIBCPP_VISIBLE common_type<_Tp>
1146227825Stheraven{
1147227825Stheraven    typedef _Tp type;
1148227825Stheraven};
1149227825Stheraven
1150227825Stheraventemplate <class _Tp, class _Up>
1151227825Stheravenstruct _LIBCPP_VISIBLE common_type<_Tp, _Up>
1152227825Stheraven{
1153227825Stheravenprivate:
1154227825Stheraven    static _Tp&& __t();
1155227825Stheraven    static _Up&& __u();
1156227825Stheraven    static bool __f();
1157227825Stheravenpublic:
1158227825Stheraven    typedef decltype(__f() ? __t() : __u()) type;
1159227825Stheraven};
1160227825Stheraven
1161227825Stheraventemplate <class _Tp, class _Up, class ..._Vp>
1162227825Stheravenstruct _LIBCPP_VISIBLE common_type<_Tp, _Up, _Vp...>
1163227825Stheraven{
1164227825Stheraven    typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp...>::type type;
1165227825Stheraven};
1166227825Stheraven
1167227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
1168227825Stheraven
1169227825Stheraven// is_assignable
1170227825Stheraven
1171227825Stheraventemplate <class _Tp, class _Arg>
1172227825Stheravendecltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>(), true_type()))
1173227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1174227825Stheraven__is_assignable_test(_Tp&&, _Arg&&);
1175227825Stheraven#else
1176227825Stheraven__is_assignable_test(_Tp, _Arg&);
1177227825Stheraven#endif
1178227825Stheraven
1179227825Stheraventemplate <class _Arg>
1180227825Stheravenfalse_type
1181227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1182227825Stheraven__is_assignable_test(__any, _Arg&&);
1183227825Stheraven#else
1184227825Stheraven__is_assignable_test(__any, _Arg&);
1185227825Stheraven#endif
1186227825Stheraven
1187227825Stheraventemplate <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
1188227825Stheravenstruct __is_assignable_imp
1189227825Stheraven    : public common_type
1190227825Stheraven        <
1191227825Stheraven            decltype(__is_assignable_test(declval<_Tp>(), declval<_Arg>()))
1192227825Stheraven        >::type {};
1193227825Stheraven
1194227825Stheraventemplate <class _Tp, class _Arg>
1195227825Stheravenstruct __is_assignable_imp<_Tp, _Arg, true>
1196227825Stheraven    : public false_type
1197227825Stheraven{
1198227825Stheraven};
1199227825Stheraven
1200227825Stheraventemplate <class _Tp, class _Arg>
1201227825Stheravenstruct is_assignable
1202227825Stheraven    : public __is_assignable_imp<_Tp, _Arg> {};
1203227825Stheraven
1204227825Stheraven// is_copy_assignable
1205227825Stheraven
1206227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_copy_assignable
1207227825Stheraven    : public is_assignable<typename add_lvalue_reference<_Tp>::type,
1208227825Stheraven                     const typename add_lvalue_reference<_Tp>::type> {};
1209227825Stheraven
1210227825Stheraven// is_move_assignable
1211227825Stheraven
1212227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_move_assignable
1213227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1214227825Stheraven    : public is_assignable<typename add_lvalue_reference<_Tp>::type,
1215227825Stheraven                     const typename add_rvalue_reference<_Tp>::type> {};
1216227825Stheraven#else
1217227825Stheraven    : public is_copy_assignable<_Tp> {};
1218227825Stheraven#endif
1219227825Stheraven
1220227825Stheraven// is_destructible
1221227825Stheraven
1222227825Stheraventemplate <class _Tp>
1223227825Stheravenstruct __destructible_test
1224227825Stheraven{
1225227825Stheraven    _Tp __t;
1226227825Stheraven};
1227227825Stheraven
1228227825Stheraventemplate <class _Tp>
1229227825Stheravendecltype((_VSTD::declval<__destructible_test<_Tp> >().~__destructible_test<_Tp>(), true_type()))
1230227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1231227825Stheraven__is_destructible_test(_Tp&&);
1232227825Stheraven#else
1233227825Stheraven__is_destructible_test(_Tp&);
1234227825Stheraven#endif
1235227825Stheraven
1236227825Stheravenfalse_type
1237227825Stheraven__is_destructible_test(__any);
1238227825Stheraven
1239227825Stheraventemplate <class _Tp, bool = is_void<_Tp>::value || is_abstract<_Tp>::value>
1240227825Stheravenstruct __destructible_imp
1241227825Stheraven    : public common_type
1242227825Stheraven        <
1243227825Stheraven            decltype(__is_destructible_test(declval<_Tp>()))
1244227825Stheraven        >::type {};
1245227825Stheraven
1246227825Stheraventemplate <class _Tp>
1247227825Stheravenstruct __destructible_imp<_Tp, true>
1248227825Stheraven    : public false_type {};
1249227825Stheraven
1250227825Stheraventemplate <class _Tp>
1251227825Stheravenstruct is_destructible
1252227825Stheraven    : public __destructible_imp<_Tp> {};
1253227825Stheraven
1254227825Stheraven// move
1255227825Stheraven
1256227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1257227825Stheraven
1258227825Stheraventemplate <class _Tp>
1259227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1260227825Stheraventypename remove_reference<_Tp>::type&&
1261227825Stheravenmove(_Tp&& __t) _NOEXCEPT
1262227825Stheraven{
1263227825Stheraven    typedef typename remove_reference<_Tp>::type _Up;
1264227825Stheraven    return static_cast<_Up&&>(__t);
1265227825Stheraven}
1266227825Stheraven
1267227825Stheraventemplate <class _Tp>
1268227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1269227825Stheraven_Tp&&
1270227825Stheravenforward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
1271227825Stheraven{
1272227825Stheraven    return static_cast<_Tp&&>(__t);
1273227825Stheraven}
1274227825Stheraven
1275227825Stheraventemplate <class _Tp>
1276227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1277227825Stheraven_Tp&&
1278227825Stheravenforward(typename std::remove_reference<_Tp>::type&& __t) _NOEXCEPT
1279227825Stheraven{
1280227825Stheraven    static_assert(!std::is_lvalue_reference<_Tp>::value,
1281227825Stheraven                  "Can not forward an rvalue as an lvalue.");
1282227825Stheraven    return static_cast<_Tp&&>(__t);
1283227825Stheraven}
1284227825Stheraven
1285227825Stheraven#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1286227825Stheraven
1287227825Stheraventemplate <class _Tp>
1288227825Stheravenclass __rv
1289227825Stheraven{
1290227825Stheraven    typedef typename remove_reference<_Tp>::type _Trr;
1291227825Stheraven    _Trr& t_;
1292227825Stheravenpublic:
1293227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1294227825Stheraven    _Trr* operator->() {return &t_;}
1295227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1296227825Stheraven    explicit __rv(_Trr& __t) : t_(__t) {}
1297227825Stheraven};
1298227825Stheraven
1299227825Stheraventemplate <class _Tp>
1300227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1301227825Stheraventypename enable_if
1302227825Stheraven<
1303227825Stheraven    !is_convertible<_Tp, __rv<_Tp> >::value,
1304227825Stheraven    _Tp&
1305227825Stheraven>::type
1306227825Stheravenmove(_Tp& __t)
1307227825Stheraven{
1308227825Stheraven    return __t;
1309227825Stheraven}
1310227825Stheraven
1311227825Stheraventemplate <class _Tp>
1312227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1313227825Stheraventypename enable_if
1314227825Stheraven<
1315227825Stheraven    is_convertible<_Tp, __rv<_Tp> >::value,
1316227825Stheraven    _Tp
1317227825Stheraven>::type
1318227825Stheravenmove(_Tp& __t)
1319227825Stheraven{
1320227825Stheraven    return _Tp(__rv<_Tp>(__t));
1321227825Stheraven}
1322227825Stheraven
1323227825Stheraventemplate <class _Tp, class _Up>
1324227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1325227825Stheraventypename enable_if
1326227825Stheraven<
1327227825Stheraven    !is_convertible<_Tp, __rv<_Tp> >::value,
1328227825Stheraven    typename add_lvalue_reference<_Tp>::type
1329227825Stheraven>::type
1330227825Stheravenforward(_Up& __t)
1331227825Stheraven{
1332227825Stheraven    return __t;
1333227825Stheraven}
1334227825Stheraven
1335227825Stheraventemplate <class _Tp, class _Up>
1336227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1337227825Stheraventypename enable_if
1338227825Stheraven<
1339227825Stheraven    !is_convertible<_Tp, __rv<_Tp> >::value,
1340227825Stheraven    typename add_lvalue_reference<_Tp>::type
1341227825Stheraven>::type
1342227825Stheravenforward(const _Up& __t)
1343227825Stheraven{
1344227825Stheraven    return __t;
1345227825Stheraven}
1346227825Stheraven
1347227825Stheraventemplate <class _Tp, class _Up>
1348227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1349227825Stheraventypename enable_if
1350227825Stheraven<
1351227825Stheraven    is_convertible<_Tp, __rv<_Tp> >::value,
1352227825Stheraven    _Tp
1353227825Stheraven>::type
1354227825Stheravenforward(_Up& __t)
1355227825Stheraven{
1356227825Stheraven    return _Tp(__rv<_Tp>(__t));
1357227825Stheraven}
1358227825Stheraven
1359227825Stheraventemplate <class _Tp, class _Up>
1360227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1361227825Stheraventypename enable_if
1362227825Stheraven<
1363227825Stheraven    is_convertible<_Tp, __rv<_Tp> >::value,
1364227825Stheraven    _Tp
1365227825Stheraven>::type
1366227825Stheravenforward(const _Up& __t)
1367227825Stheraven{
1368227825Stheraven    return _Tp(__rv<_Tp>(__t));
1369227825Stheraven}
1370227825Stheraven
1371227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1372227825Stheraven
1373227825Stheraventemplate <class _Tp>
1374227825Stheravenstruct _LIBCPP_VISIBLE decay
1375227825Stheraven{
1376227825Stheravenprivate:
1377227825Stheraven    typedef typename remove_reference<_Tp>::type _Up;
1378227825Stheravenpublic:
1379227825Stheraven    typedef typename conditional
1380227825Stheraven                     <
1381227825Stheraven                         is_array<_Up>::value,
1382227825Stheraven                         typename remove_extent<_Up>::type*,
1383227825Stheraven                         typename conditional
1384227825Stheraven                         <
1385227825Stheraven                              is_function<_Up>::value,
1386227825Stheraven                              typename add_pointer<_Up>::type,
1387227825Stheraven                              typename remove_cv<_Up>::type
1388227825Stheraven                         >::type
1389227825Stheraven                     >::type type;
1390227825Stheraven};
1391227825Stheraven
1392227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1393227825Stheraven
1394227825Stheraventemplate <class _Tp>
1395227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1396227825Stheraventypename decay<_Tp>::type
1397227825Stheraven__decay_copy(_Tp&& __t)
1398227825Stheraven{
1399227825Stheraven    return _VSTD::forward<_Tp>(__t);
1400227825Stheraven}
1401227825Stheraven
1402227825Stheraven#else
1403227825Stheraven
1404227825Stheraventemplate <class _Tp>
1405227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1406227825Stheraventypename decay<_Tp>::type
1407227825Stheraven__decay_copy(const _Tp& __t)
1408227825Stheraven{
1409227825Stheraven    return _VSTD::forward<_Tp>(__t);
1410227825Stheraven}
1411227825Stheraven
1412227825Stheraven#endif
1413227825Stheraven
1414227825Stheraventemplate <class _MP, bool _IsMemberFuctionPtr, bool _IsMemberObjectPtr>
1415227825Stheravenstruct __member_pointer_traits_imp
1416227825Stheraven{
1417227825Stheraven};
1418227825Stheraven
1419227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
1420227825Stheraven
1421227825Stheraventemplate <class _R, class _Class, class ..._Param>
1422227825Stheravenstruct __member_pointer_traits_imp<_R (_Class::*)(_Param...), true, false>
1423227825Stheraven{
1424227825Stheraven    typedef _Class _ClassType;
1425227825Stheraven    typedef _R _ReturnType;
1426227825Stheraven};
1427227825Stheraven
1428227825Stheraventemplate <class _R, class _Class, class ..._Param>
1429227825Stheravenstruct __member_pointer_traits_imp<_R (_Class::*)(_Param...) const, true, false>
1430227825Stheraven{
1431227825Stheraven    typedef _Class const _ClassType;
1432227825Stheraven    typedef _R _ReturnType;
1433227825Stheraven};
1434227825Stheraven
1435227825Stheraventemplate <class _R, class _Class, class ..._Param>
1436227825Stheravenstruct __member_pointer_traits_imp<_R (_Class::*)(_Param...) volatile, true, false>
1437227825Stheraven{
1438227825Stheraven    typedef _Class volatile _ClassType;
1439227825Stheraven    typedef _R _ReturnType;
1440227825Stheraven};
1441227825Stheraven
1442227825Stheraventemplate <class _R, class _Class, class ..._Param>
1443227825Stheravenstruct __member_pointer_traits_imp<_R (_Class::*)(_Param...) const volatile, true, false>
1444227825Stheraven{
1445227825Stheraven    typedef _Class const volatile _ClassType;
1446227825Stheraven    typedef _R _ReturnType;
1447227825Stheraven};
1448227825Stheraven
1449227825Stheraven#if __has_feature(cxx_reference_qualified_functions)
1450227825Stheraven
1451227825Stheraventemplate <class _R, class _Class, class ..._Param>
1452227825Stheravenstruct __member_pointer_traits_imp<_R (_Class::*)(_Param...) &, true, false>
1453227825Stheraven{
1454227825Stheraven    typedef _Class& _ClassType;
1455227825Stheraven    typedef _R _ReturnType;
1456227825Stheraven};
1457227825Stheraven
1458227825Stheraventemplate <class _R, class _Class, class ..._Param>
1459227825Stheravenstruct __member_pointer_traits_imp<_R (_Class::*)(_Param...) const&, true, false>
1460227825Stheraven{
1461227825Stheraven    typedef _Class const& _ClassType;
1462227825Stheraven    typedef _R _ReturnType;
1463227825Stheraven};
1464227825Stheraven
1465227825Stheraventemplate <class _R, class _Class, class ..._Param>
1466227825Stheravenstruct __member_pointer_traits_imp<_R (_Class::*)(_Param...) volatile&, true, false>
1467227825Stheraven{
1468227825Stheraven    typedef _Class volatile& _ClassType;
1469227825Stheraven    typedef _R _ReturnType;
1470227825Stheraven};
1471227825Stheraven
1472227825Stheraventemplate <class _R, class _Class, class ..._Param>
1473227825Stheravenstruct __member_pointer_traits_imp<_R (_Class::*)(_Param...) const volatile&, true, false>
1474227825Stheraven{
1475227825Stheraven    typedef _Class const volatile& _ClassType;
1476227825Stheraven    typedef _R _ReturnType;
1477227825Stheraven};
1478227825Stheraven
1479227825Stheraventemplate <class _R, class _Class, class ..._Param>
1480227825Stheravenstruct __member_pointer_traits_imp<_R (_Class::*)(_Param...) &&, true, false>
1481227825Stheraven{
1482227825Stheraven    typedef _Class&& _ClassType;
1483227825Stheraven    typedef _R _ReturnType;
1484227825Stheraven};
1485227825Stheraven
1486227825Stheraventemplate <class _R, class _Class, class ..._Param>
1487227825Stheravenstruct __member_pointer_traits_imp<_R (_Class::*)(_Param...) const&&, true, false>
1488227825Stheraven{
1489227825Stheraven    typedef _Class const&& _ClassType;
1490227825Stheraven    typedef _R _ReturnType;
1491227825Stheraven};
1492227825Stheraven
1493227825Stheraventemplate <class _R, class _Class, class ..._Param>
1494227825Stheravenstruct __member_pointer_traits_imp<_R (_Class::*)(_Param...) volatile&&, true, false>
1495227825Stheraven{
1496227825Stheraven    typedef _Class volatile&& _ClassType;
1497227825Stheraven    typedef _R _ReturnType;
1498227825Stheraven};
1499227825Stheraven
1500227825Stheraventemplate <class _R, class _Class, class ..._Param>
1501227825Stheravenstruct __member_pointer_traits_imp<_R (_Class::*)(_Param...) const volatile&&, true, false>
1502227825Stheraven{
1503227825Stheraven    typedef _Class const volatile&& _ClassType;
1504227825Stheraven    typedef _R _ReturnType;
1505227825Stheraven};
1506227825Stheraven
1507227825Stheraven#endif  // __has_feature(cxx_reference_qualified_functions)
1508227825Stheraven
1509227825Stheraven#else  // _LIBCPP_HAS_NO_VARIADICS
1510227825Stheraven
1511227825Stheraventemplate <class _R, class _Class>
1512227825Stheravenstruct __member_pointer_traits_imp<_R (_Class::*)(), true, false>
1513227825Stheraven{
1514227825Stheraven    typedef _Class _ClassType;
1515227825Stheraven    typedef _R _ReturnType;
1516227825Stheraven};
1517227825Stheraven
1518227825Stheraventemplate <class _R, class _Class, class _P0>
1519227825Stheravenstruct __member_pointer_traits_imp<_R (_Class::*)(_P0), true, false>
1520227825Stheraven{
1521227825Stheraven    typedef _Class _ClassType;
1522227825Stheraven    typedef _R _ReturnType;
1523227825Stheraven};
1524227825Stheraven
1525227825Stheraventemplate <class _R, class _Class, class _P0, class _P1>
1526227825Stheravenstruct __member_pointer_traits_imp<_R (_Class::*)(_P0, _P1), true, false>
1527227825Stheraven{
1528227825Stheraven    typedef _Class _ClassType;
1529227825Stheraven    typedef _R _ReturnType;
1530227825Stheraven};
1531227825Stheraven
1532227825Stheraventemplate <class _R, class _Class, class _P0, class _P1, class _P2>
1533227825Stheravenstruct __member_pointer_traits_imp<_R (_Class::*)(_P0, _P1, _P2), true, false>
1534227825Stheraven{
1535227825Stheraven    typedef _Class _ClassType;
1536227825Stheraven    typedef _R _ReturnType;
1537227825Stheraven};
1538227825Stheraven
1539227825Stheraventemplate <class _R, class _Class>
1540227825Stheravenstruct __member_pointer_traits_imp<_R (_Class::*)() const, true, false>
1541227825Stheraven{
1542227825Stheraven    typedef _Class const _ClassType;
1543227825Stheraven    typedef _R _ReturnType;
1544227825Stheraven};
1545227825Stheraven
1546227825Stheraventemplate <class _R, class _Class, class _P0>
1547227825Stheravenstruct __member_pointer_traits_imp<_R (_Class::*)(_P0) const, true, false>
1548227825Stheraven{
1549227825Stheraven    typedef _Class const _ClassType;
1550227825Stheraven    typedef _R _ReturnType;
1551227825Stheraven};
1552227825Stheraven
1553227825Stheraventemplate <class _R, class _Class, class _P0, class _P1>
1554227825Stheravenstruct __member_pointer_traits_imp<_R (_Class::*)(_P0, _P1) const, true, false>
1555227825Stheraven{
1556227825Stheraven    typedef _Class const _ClassType;
1557227825Stheraven    typedef _R _ReturnType;
1558227825Stheraven};
1559227825Stheraven
1560227825Stheraventemplate <class _R, class _Class, class _P0, class _P1, class _P2>
1561227825Stheravenstruct __member_pointer_traits_imp<_R (_Class::*)(_P0, _P1, _P2) const, true, false>
1562227825Stheraven{
1563227825Stheraven    typedef _Class const _ClassType;
1564227825Stheraven    typedef _R _ReturnType;
1565227825Stheraven};
1566227825Stheraven
1567227825Stheraventemplate <class _R, class _Class>
1568227825Stheravenstruct __member_pointer_traits_imp<_R (_Class::*)() volatile, true, false>
1569227825Stheraven{
1570227825Stheraven    typedef _Class volatile _ClassType;
1571227825Stheraven    typedef _R _ReturnType;
1572227825Stheraven};
1573227825Stheraven
1574227825Stheraventemplate <class _R, class _Class, class _P0>
1575227825Stheravenstruct __member_pointer_traits_imp<_R (_Class::*)(_P0) volatile, true, false>
1576227825Stheraven{
1577227825Stheraven    typedef _Class volatile _ClassType;
1578227825Stheraven    typedef _R _ReturnType;
1579227825Stheraven};
1580227825Stheraven
1581227825Stheraventemplate <class _R, class _Class, class _P0, class _P1>
1582227825Stheravenstruct __member_pointer_traits_imp<_R (_Class::*)(_P0, _P1) volatile, true, false>
1583227825Stheraven{
1584227825Stheraven    typedef _Class volatile _ClassType;
1585227825Stheraven    typedef _R _ReturnType;
1586227825Stheraven};
1587227825Stheraven
1588227825Stheraventemplate <class _R, class _Class, class _P0, class _P1, class _P2>
1589227825Stheravenstruct __member_pointer_traits_imp<_R (_Class::*)(_P0, _P1, _P2) volatile, true, false>
1590227825Stheraven{
1591227825Stheraven    typedef _Class volatile _ClassType;
1592227825Stheraven    typedef _R _ReturnType;
1593227825Stheraven};
1594227825Stheraven
1595227825Stheraventemplate <class _R, class _Class>
1596227825Stheravenstruct __member_pointer_traits_imp<_R (_Class::*)() const volatile, true, false>
1597227825Stheraven{
1598227825Stheraven    typedef _Class const volatile _ClassType;
1599227825Stheraven    typedef _R _ReturnType;
1600227825Stheraven};
1601227825Stheraven
1602227825Stheraventemplate <class _R, class _Class, class _P0>
1603227825Stheravenstruct __member_pointer_traits_imp<_R (_Class::*)(_P0) const volatile, true, false>
1604227825Stheraven{
1605227825Stheraven    typedef _Class const volatile _ClassType;
1606227825Stheraven    typedef _R _ReturnType;
1607227825Stheraven};
1608227825Stheraven
1609227825Stheraventemplate <class _R, class _Class, class _P0, class _P1>
1610227825Stheravenstruct __member_pointer_traits_imp<_R (_Class::*)(_P0, _P1) const volatile, true, false>
1611227825Stheraven{
1612227825Stheraven    typedef _Class const volatile _ClassType;
1613227825Stheraven    typedef _R _ReturnType;
1614227825Stheraven};
1615227825Stheraven
1616227825Stheraventemplate <class _R, class _Class, class _P0, class _P1, class _P2>
1617227825Stheravenstruct __member_pointer_traits_imp<_R (_Class::*)(_P0, _P1, _P2) const volatile, true, false>
1618227825Stheraven{
1619227825Stheraven    typedef _Class const volatile _ClassType;
1620227825Stheraven    typedef _R _ReturnType;
1621227825Stheraven};
1622227825Stheraven
1623227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
1624227825Stheraven
1625227825Stheraventemplate <class _R, class _Class>
1626227825Stheravenstruct __member_pointer_traits_imp<_R _Class::*, false, true>
1627227825Stheraven{
1628227825Stheraven    typedef _Class _ClassType;
1629227825Stheraven    typedef _R _ReturnType;
1630227825Stheraven};
1631227825Stheraven
1632227825Stheraventemplate <class _MP>
1633227825Stheravenstruct __member_pointer_traits
1634227825Stheraven    : public __member_pointer_traits_imp<_MP,
1635227825Stheraven                    is_member_function_pointer<_MP>::value,
1636227825Stheraven                    is_member_object_pointer<_MP>::value>
1637227825Stheraven{
1638227825Stheraven//     typedef ... _ClassType;
1639227825Stheraven//     typedef ... _ReturnType;
1640227825Stheraven};
1641227825Stheraven
1642227825Stheraven// result_of
1643227825Stheraven
1644227825Stheraventemplate <class _Callable> class result_of;
1645227825Stheraven
1646227825Stheraventemplate <class _Fn, bool, bool>
1647227825Stheravenclass __result_of
1648227825Stheraven{
1649227825Stheraven};
1650227825Stheraven
1651227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
1652227825Stheraven
1653227825Stheraventemplate <class _Fn, class ..._ArgTypes>
1654227825Stheravenclass __result_of<_Fn(_ArgTypes...), true, false>
1655227825Stheraven{
1656227825Stheravenpublic:
1657227825Stheraven    typedef decltype(declval<_Fn>()(declval<_ArgTypes>()...)) type;
1658227825Stheraven};
1659227825Stheraven
1660227825Stheraventemplate <class _MP, class _Tp, bool _IsMemberFunctionPtr>
1661227825Stheravenstruct __result_of_mp;
1662227825Stheraven
1663227825Stheraven// member function pointer
1664227825Stheraven
1665227825Stheraventemplate <class _MP, class _Tp>
1666227825Stheravenstruct __result_of_mp<_MP, _Tp, true>
1667227825Stheraven    : public common_type<typename __member_pointer_traits<_MP>::_ReturnType>
1668227825Stheraven{
1669227825Stheraven};
1670227825Stheraven
1671227825Stheraven// member data pointer
1672227825Stheraven
1673227825Stheraventemplate <class _MP, class _Tp, bool>
1674227825Stheravenstruct __result_of_mdp;
1675227825Stheraven
1676227825Stheraventemplate <class _R, class _Class, class _Tp>
1677227825Stheravenstruct __result_of_mdp<_R _Class::*, _Tp, false>
1678227825Stheraven{
1679227825Stheraven    typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _R>::type&& type;
1680227825Stheraven};
1681227825Stheraven
1682227825Stheraventemplate <class _R, class _Class, class _Tp>
1683227825Stheravenstruct __result_of_mdp<_R _Class::*, _Tp, true>
1684227825Stheraven{
1685227825Stheraven    typedef typename __apply_cv<_Tp, _R>::type&& type;
1686227825Stheraven};
1687227825Stheraven
1688227825Stheraventemplate <class _R, class _Class, class _Tp>
1689227825Stheravenstruct __result_of_mp<_R _Class::*, _Tp, false>
1690227825Stheraven    : public __result_of_mdp<_R _Class::*, _Tp,
1691227825Stheraven            is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
1692227825Stheraven{
1693227825Stheraven};
1694227825Stheraven
1695227825Stheraventemplate <class _Fn, class _Tp, class ..._ArgTypes>
1696227825Stheravenclass __result_of<_Fn(_Tp, _ArgTypes...), false, true>  // _Fn must be member pointer
1697227825Stheraven    : public __result_of_mp<typename remove_reference<_Fn>::type,
1698227825Stheraven                            _Tp,
1699227825Stheraven                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1700227825Stheraven{
1701227825Stheraven};
1702227825Stheraven
1703227825Stheraven// result_of
1704227825Stheraven
1705227825Stheraventemplate <class _Fn, class ..._ArgTypes>
1706227825Stheravenclass _LIBCPP_VISIBLE result_of<_Fn(_ArgTypes...)>
1707227825Stheraven    : public __result_of<_Fn(_ArgTypes...),
1708227825Stheraven                         is_class<typename remove_reference<_Fn>::type>::value ||
1709227825Stheraven                         is_function<typename remove_reference<_Fn>::type>::value,
1710227825Stheraven                         is_member_pointer<typename remove_reference<_Fn>::type>::value
1711227825Stheraven                        >
1712227825Stheraven{
1713227825Stheraven};
1714227825Stheraven
1715227825Stheraven#else  // _LIBCPP_HAS_NO_VARIADICS
1716227825Stheraven
1717227825Stheraventemplate <class _Fn>
1718227825Stheravenclass __result_of<_Fn(), true, false>
1719227825Stheraven{
1720227825Stheravenpublic:
1721227825Stheraven    typedef decltype(declval<_Fn>()()) type;
1722227825Stheraven};
1723227825Stheraven
1724227825Stheraventemplate <class _Fn, class _A0>
1725227825Stheravenclass __result_of<_Fn(_A0), true, false>
1726227825Stheraven{
1727227825Stheravenpublic:
1728227825Stheraven    typedef decltype(declval<_Fn>()(declval<_A0>())) type;
1729227825Stheraven};
1730227825Stheraven
1731227825Stheraventemplate <class _Fn, class _A0, class _A1>
1732227825Stheravenclass __result_of<_Fn(_A0, _A1), true, false>
1733227825Stheraven{
1734227825Stheravenpublic:
1735227825Stheraven    typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type;
1736227825Stheraven};
1737227825Stheraven
1738227825Stheraventemplate <class _Fn, class _A0, class _A1, class _A2>
1739227825Stheravenclass __result_of<_Fn(_A0, _A1, _A2), true, false>
1740227825Stheraven{
1741227825Stheravenpublic:
1742227825Stheraven    typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type;
1743227825Stheraven};
1744227825Stheraven
1745227825Stheraventemplate <class _MP, class _Tp, bool _IsMemberFunctionPtr>
1746227825Stheravenstruct __result_of_mp;
1747227825Stheraven
1748227825Stheraven// member function pointer
1749227825Stheraven
1750227825Stheraventemplate <class _MP, class _Tp>
1751227825Stheravenstruct __result_of_mp<_MP, _Tp, true>
1752227825Stheraven    : public common_type<typename __member_pointer_traits<_MP>::_ReturnType>
1753227825Stheraven{
1754227825Stheraven};
1755227825Stheraven
1756227825Stheraven// member data pointer
1757227825Stheraven
1758227825Stheraventemplate <class _MP, class _Tp, bool>
1759227825Stheravenstruct __result_of_mdp;
1760227825Stheraven
1761227825Stheraventemplate <class _R, class _Class, class _Tp>
1762227825Stheravenstruct __result_of_mdp<_R _Class::*, _Tp, false>
1763227825Stheraven{
1764227825Stheraven    typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _R>::type& type;
1765227825Stheraven};
1766227825Stheraven
1767227825Stheraventemplate <class _R, class _Class, class _Tp>
1768227825Stheravenstruct __result_of_mdp<_R _Class::*, _Tp, true>
1769227825Stheraven{
1770227825Stheraven    typedef typename __apply_cv<_Tp, _R>::type& type;
1771227825Stheraven};
1772227825Stheraven
1773227825Stheraventemplate <class _R, class _Class, class _Tp>
1774227825Stheravenstruct __result_of_mp<_R _Class::*, _Tp, false>
1775227825Stheraven    : public __result_of_mdp<_R _Class::*, _Tp,
1776227825Stheraven            is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
1777227825Stheraven{
1778227825Stheraven};
1779227825Stheraven
1780227825Stheraven
1781227825Stheraven
1782227825Stheraventemplate <class _Fn, class _Tp>
1783227825Stheravenclass __result_of<_Fn(_Tp), false, true>  // _Fn must be member pointer
1784227825Stheraven    : public __result_of_mp<typename remove_reference<_Fn>::type,
1785227825Stheraven                            _Tp,
1786227825Stheraven                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1787227825Stheraven{
1788227825Stheraven};
1789227825Stheraven
1790227825Stheraventemplate <class _Fn, class _Tp, class _A0>
1791227825Stheravenclass __result_of<_Fn(_Tp, _A0), false, true>  // _Fn must be member pointer
1792227825Stheraven    : public __result_of_mp<typename remove_reference<_Fn>::type,
1793227825Stheraven                            _Tp,
1794227825Stheraven                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1795227825Stheraven{
1796227825Stheraven};
1797227825Stheraven
1798227825Stheraventemplate <class _Fn, class _Tp, class _A0, class _A1>
1799227825Stheravenclass __result_of<_Fn(_Tp, _A0, _A1), false, true>  // _Fn must be member pointer
1800227825Stheraven    : public __result_of_mp<typename remove_reference<_Fn>::type,
1801227825Stheraven                            _Tp,
1802227825Stheraven                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1803227825Stheraven{
1804227825Stheraven};
1805227825Stheraven
1806227825Stheraventemplate <class _Fn, class _Tp, class _A0, class _A1, class _A2>
1807227825Stheravenclass __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true>  // _Fn must be member pointer
1808227825Stheraven    : public __result_of_mp<typename remove_reference<_Fn>::type,
1809227825Stheraven                            _Tp,
1810227825Stheraven                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1811227825Stheraven{
1812227825Stheraven};
1813227825Stheraven
1814227825Stheraven// result_of
1815227825Stheraven
1816227825Stheraventemplate <class _Fn>
1817227825Stheravenclass _LIBCPP_VISIBLE result_of<_Fn()>
1818227825Stheraven    : public __result_of<_Fn(),
1819227825Stheraven                         is_class<typename remove_reference<_Fn>::type>::value ||
1820227825Stheraven                         is_function<typename remove_reference<_Fn>::type>::value,
1821227825Stheraven                         is_member_pointer<typename remove_reference<_Fn>::type>::value
1822227825Stheraven                        >
1823227825Stheraven{
1824227825Stheraven};
1825227825Stheraven
1826227825Stheraventemplate <class _Fn, class _A0>
1827227825Stheravenclass _LIBCPP_VISIBLE result_of<_Fn(_A0)>
1828227825Stheraven    : public __result_of<_Fn(_A0),
1829227825Stheraven                         is_class<typename remove_reference<_Fn>::type>::value ||
1830227825Stheraven                         is_function<typename remove_reference<_Fn>::type>::value,
1831227825Stheraven                         is_member_pointer<typename remove_reference<_Fn>::type>::value
1832227825Stheraven                        >
1833227825Stheraven{
1834227825Stheraven};
1835227825Stheraven
1836227825Stheraventemplate <class _Fn, class _A0, class _A1>
1837227825Stheravenclass _LIBCPP_VISIBLE result_of<_Fn(_A0, _A1)>
1838227825Stheraven    : public __result_of<_Fn(_A0, _A1),
1839227825Stheraven                         is_class<typename remove_reference<_Fn>::type>::value ||
1840227825Stheraven                         is_function<typename remove_reference<_Fn>::type>::value,
1841227825Stheraven                         is_member_pointer<typename remove_reference<_Fn>::type>::value
1842227825Stheraven                        >
1843227825Stheraven{
1844227825Stheraven};
1845227825Stheraven
1846227825Stheraventemplate <class _Fn, class _A0, class _A1, class _A2>
1847227825Stheravenclass _LIBCPP_VISIBLE result_of<_Fn(_A0, _A1, _A2)>
1848227825Stheraven    : public __result_of<_Fn(_A0, _A1, _A2),
1849227825Stheraven                         is_class<typename remove_reference<_Fn>::type>::value ||
1850227825Stheraven                         is_function<typename remove_reference<_Fn>::type>::value,
1851227825Stheraven                         is_member_pointer<typename remove_reference<_Fn>::type>::value
1852227825Stheraven                        >
1853227825Stheraven{
1854227825Stheraven};
1855227825Stheraven
1856227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
1857227825Stheraven
1858227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
1859227825Stheraven
1860227825Stheraven// template <class T, class... Args> struct is_constructible;
1861227825Stheraven
1862227825Stheraven//      main is_constructible test
1863227825Stheraven
1864227825Stheraventemplate <class _Tp, class ..._Args>
1865227825Stheravendecltype(_VSTD::move(_Tp(_VSTD::declval<_Args>()...)), true_type())
1866227825Stheraven__is_constructible_test(_Tp&&, _Args&& ...);
1867227825Stheraven
1868227825Stheraventemplate <class ..._Args>
1869227825Stheravenfalse_type
1870227825Stheraven__is_constructible_test(__any, _Args&& ...);
1871227825Stheraven
1872227825Stheraventemplate <bool, class _Tp, class... _Args>
1873227825Stheravenstruct __is_constructible // false, _Tp is not a scalar
1874227825Stheraven    : public common_type
1875227825Stheraven             <
1876227825Stheraven                 decltype(__is_constructible_test(declval<_Tp>(), declval<_Args>()...))
1877227825Stheraven             >::type
1878227825Stheraven    {};
1879227825Stheraven
1880227825Stheraven//      function types are not constructible
1881227825Stheraven
1882227825Stheraventemplate <class _R, class... _A1, class... _A2>
1883227825Stheravenstruct __is_constructible<false, _R(_A1...), _A2...>
1884227825Stheraven    : public false_type
1885227825Stheraven    {};
1886227825Stheraven
1887227825Stheraven//      handle scalars and reference types
1888227825Stheraven
1889227825Stheraven//      Scalars are default constructible, references are not
1890227825Stheraven
1891227825Stheraventemplate <class _Tp>
1892227825Stheravenstruct __is_constructible<true, _Tp>
1893227825Stheraven    : public is_scalar<_Tp>
1894227825Stheraven    {};
1895227825Stheraven
1896227825Stheraven//      Scalars and references are constructible from one arg if that arg is
1897227825Stheraven//          implicitly convertible to the scalar or reference.
1898227825Stheraven
1899227825Stheraventemplate <class _Tp>
1900227825Stheravenstruct __is_constructible_ref
1901227825Stheraven{
1902227825Stheraven    true_type static __(_Tp);
1903227825Stheraven    false_type static __(...);
1904227825Stheraven};
1905227825Stheraven
1906227825Stheraventemplate <class _Tp, class _A0>
1907227825Stheravenstruct __is_constructible<true, _Tp, _A0>
1908227825Stheraven    : public common_type
1909227825Stheraven             <
1910227825Stheraven                 decltype(__is_constructible_ref<_Tp>::__(declval<_A0>()))
1911227825Stheraven             >::type
1912227825Stheraven    {};
1913227825Stheraven
1914227825Stheraven//      Scalars and references are not constructible from multiple args.
1915227825Stheraven
1916227825Stheraventemplate <class _Tp, class _A0, class ..._Args>
1917227825Stheravenstruct __is_constructible<true, _Tp, _A0, _Args...>
1918227825Stheraven    : public false_type
1919227825Stheraven    {};
1920227825Stheraven
1921227825Stheraven//      Treat scalars and reference types separately
1922227825Stheraven
1923227825Stheraventemplate <bool, class _Tp, class... _Args>
1924227825Stheravenstruct __is_constructible_void_check
1925227825Stheraven    : public __is_constructible<is_scalar<_Tp>::value || is_reference<_Tp>::value,
1926227825Stheraven                                _Tp, _Args...>
1927227825Stheraven    {};
1928227825Stheraven
1929227825Stheraven//      If any of T or Args is void, is_constructible should be false
1930227825Stheraven
1931227825Stheraventemplate <class _Tp, class... _Args>
1932227825Stheravenstruct __is_constructible_void_check<true, _Tp, _Args...>
1933227825Stheraven    : public false_type
1934227825Stheraven    {};
1935227825Stheraven
1936227825Stheraventemplate <class ..._Args> struct __contains_void;
1937227825Stheraven
1938227825Stheraventemplate <> struct __contains_void<> : false_type {};
1939227825Stheraven
1940227825Stheraventemplate <class _A0, class ..._Args>
1941227825Stheravenstruct __contains_void<_A0, _Args...>
1942227825Stheraven{
1943227825Stheraven    static const bool value = is_void<_A0>::value ||
1944227825Stheraven                              __contains_void<_Args...>::value;
1945227825Stheraven};
1946227825Stheraven
1947227825Stheraven//      is_constructible entry point
1948227825Stheraven
1949227825Stheraventemplate <class _Tp, class... _Args>
1950227825Stheravenstruct _LIBCPP_VISIBLE is_constructible
1951227825Stheraven    : public __is_constructible_void_check<__contains_void<_Tp, _Args...>::value
1952227825Stheraven                                        || is_abstract<_Tp>::value,
1953227825Stheraven                                           _Tp, _Args...>
1954227825Stheraven    {};
1955227825Stheraven
1956227825Stheraven//      Array types are default constructible if their element type
1957227825Stheraven//      is default constructible
1958227825Stheraven
1959227825Stheraventemplate <class _A, size_t _N>
1960227825Stheravenstruct __is_constructible<false, _A[_N]>
1961227825Stheraven    : public is_constructible<typename remove_all_extents<_A>::type>
1962227825Stheraven    {};
1963227825Stheraven
1964227825Stheraven//      Otherwise array types are not constructible by this syntax
1965227825Stheraven
1966227825Stheraventemplate <class _A, size_t _N, class ..._Args>
1967227825Stheravenstruct __is_constructible<false, _A[_N], _Args...>
1968227825Stheraven    : public false_type
1969227825Stheraven    {};
1970227825Stheraven
1971227825Stheraven//      Incomplete array types are not constructible
1972227825Stheraven
1973227825Stheraventemplate <class _A, class ..._Args>
1974227825Stheravenstruct __is_constructible<false, _A[], _Args...>
1975227825Stheraven    : public false_type
1976227825Stheraven    {};
1977227825Stheraven
1978227825Stheraven#else  // _LIBCPP_HAS_NO_VARIADICS
1979227825Stheraven
1980227825Stheraven// template <class T> struct is_constructible0;
1981227825Stheraven
1982227825Stheraven//      main is_constructible0 test
1983227825Stheraven
1984227825Stheraventemplate <class _Tp>
1985227825Stheravendecltype((_Tp(), true_type()))
1986227825Stheraven__is_constructible0_test(_Tp&);
1987227825Stheraven
1988227825Stheravenfalse_type
1989227825Stheraven__is_constructible0_test(__any);
1990227825Stheraven
1991227825Stheraventemplate <class _Tp, class _A0>
1992227825Stheravendecltype((_Tp(_VSTD::declval<_A0>()), true_type()))
1993227825Stheraven__is_constructible1_test(_Tp&, _A0&);
1994227825Stheraven
1995227825Stheraventemplate <class _A0>
1996227825Stheravenfalse_type
1997227825Stheraven__is_constructible1_test(__any, _A0&);
1998227825Stheraven
1999227825Stheraventemplate <class _Tp, class _A0, class _A1>
2000227825Stheravendecltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>()), true_type()))
2001227825Stheraven__is_constructible2_test(_Tp&, _A0&, _A1&);
2002227825Stheraven
2003227825Stheraventemplate <class _A0, class _A1>
2004227825Stheravenfalse_type
2005227825Stheraven__is_constructible2_test(__any, _A0&, _A1&);
2006227825Stheraven
2007227825Stheraventemplate <bool, class _Tp>
2008227825Stheravenstruct __is_constructible0_imp // false, _Tp is not a scalar
2009227825Stheraven    : public common_type
2010227825Stheraven             <
2011227825Stheraven                 decltype(__is_constructible0_test(declval<_Tp&>()))
2012227825Stheraven             >::type
2013227825Stheraven    {};
2014227825Stheraven
2015227825Stheraventemplate <bool, class _Tp, class _A0>
2016227825Stheravenstruct __is_constructible1_imp // false, _Tp is not a scalar
2017227825Stheraven    : public common_type
2018227825Stheraven             <
2019227825Stheraven                 decltype(__is_constructible1_test(declval<_Tp&>(), declval<_A0&>()))
2020227825Stheraven             >::type
2021227825Stheraven    {};
2022227825Stheraven
2023227825Stheraventemplate <bool, class _Tp, class _A0, class _A1>
2024227825Stheravenstruct __is_constructible2_imp // false, _Tp is not a scalar
2025227825Stheraven    : public common_type
2026227825Stheraven             <
2027227825Stheraven                 decltype(__is_constructible2_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>()))
2028227825Stheraven             >::type
2029227825Stheraven    {};
2030227825Stheraven
2031227825Stheraven//      handle scalars and reference types
2032227825Stheraven
2033227825Stheraven//      Scalars are default constructible, references are not
2034227825Stheraven
2035227825Stheraventemplate <class _Tp>
2036227825Stheravenstruct __is_constructible0_imp<true, _Tp>
2037227825Stheraven    : public is_scalar<_Tp>
2038227825Stheraven    {};
2039227825Stheraven
2040227825Stheraventemplate <class _Tp, class _A0>
2041227825Stheravenstruct __is_constructible1_imp<true, _Tp, _A0>
2042227825Stheraven    : public is_convertible<_A0, _Tp>
2043227825Stheraven    {};
2044227825Stheraven
2045227825Stheraventemplate <class _Tp, class _A0, class _A1>
2046227825Stheravenstruct __is_constructible2_imp<true, _Tp, _A0, _A1>
2047227825Stheraven    : public false_type
2048227825Stheraven    {};
2049227825Stheraven
2050227825Stheraven//      Treat scalars and reference types separately
2051227825Stheraven
2052227825Stheraventemplate <bool, class _Tp>
2053227825Stheravenstruct __is_constructible0_void_check
2054227825Stheraven    : public __is_constructible0_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2055227825Stheraven                                _Tp>
2056227825Stheraven    {};
2057227825Stheraven
2058227825Stheraventemplate <bool, class _Tp, class _A0>
2059227825Stheravenstruct __is_constructible1_void_check
2060227825Stheraven    : public __is_constructible1_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2061227825Stheraven                                _Tp, _A0>
2062227825Stheraven    {};
2063227825Stheraven
2064227825Stheraventemplate <bool, class _Tp, class _A0, class _A1>
2065227825Stheravenstruct __is_constructible2_void_check
2066227825Stheraven    : public __is_constructible2_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2067227825Stheraven                                _Tp, _A0, _A1>
2068227825Stheraven    {};
2069227825Stheraven
2070227825Stheraven//      If any of T or Args is void, is_constructible should be false
2071227825Stheraven
2072227825Stheraventemplate <class _Tp>
2073227825Stheravenstruct __is_constructible0_void_check<true, _Tp>
2074227825Stheraven    : public false_type
2075227825Stheraven    {};
2076227825Stheraven
2077227825Stheraventemplate <class _Tp, class _A0>
2078227825Stheravenstruct __is_constructible1_void_check<true, _Tp, _A0>
2079227825Stheraven    : public false_type
2080227825Stheraven    {};
2081227825Stheraven
2082227825Stheraventemplate <class _Tp, class _A0, class _A1>
2083227825Stheravenstruct __is_constructible2_void_check<true, _Tp, _A0, _A1>
2084227825Stheraven    : public false_type
2085227825Stheraven    {};
2086227825Stheraven
2087227825Stheraven//      is_constructible entry point
2088227825Stheraven
2089227825Stheravennamespace __is_construct
2090227825Stheraven{
2091227825Stheraven
2092227825Stheravenstruct __nat {};
2093227825Stheraven
2094227825Stheraven}
2095227825Stheraven
2096227825Stheraventemplate <class _Tp, class _A0 = __is_construct::__nat,
2097227825Stheraven                     class _A1 = __is_construct::__nat>
2098227825Stheravenstruct _LIBCPP_VISIBLE is_constructible
2099227825Stheraven    : public __is_constructible2_void_check<is_void<_Tp>::value
2100227825Stheraven                                        || is_abstract<_Tp>::value
2101227825Stheraven                                        || is_function<_Tp>::value
2102227825Stheraven                                        || is_void<_A0>::value
2103227825Stheraven                                        || is_void<_A1>::value,
2104227825Stheraven                                           _Tp, _A0, _A1>
2105227825Stheraven    {};
2106227825Stheraven
2107227825Stheraventemplate <class _Tp>
2108227825Stheravenstruct _LIBCPP_VISIBLE is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat>
2109227825Stheraven    : public __is_constructible0_void_check<is_void<_Tp>::value
2110227825Stheraven                                        || is_abstract<_Tp>::value
2111227825Stheraven                                        || is_function<_Tp>::value,
2112227825Stheraven                                           _Tp>
2113227825Stheraven    {};
2114227825Stheraven
2115227825Stheraventemplate <class _Tp, class _A0>
2116227825Stheravenstruct _LIBCPP_VISIBLE is_constructible<_Tp, _A0, __is_construct::__nat>
2117227825Stheraven    : public __is_constructible1_void_check<is_void<_Tp>::value
2118227825Stheraven                                        || is_abstract<_Tp>::value
2119227825Stheraven                                        || is_function<_Tp>::value
2120227825Stheraven                                        || is_void<_A0>::value,
2121227825Stheraven                                           _Tp, _A0>
2122227825Stheraven    {};
2123227825Stheraven
2124227825Stheraven//      Array types are default constructible if their element type
2125227825Stheraven//      is default constructible
2126227825Stheraven
2127227825Stheraventemplate <class _A, size_t _N>
2128227825Stheravenstruct __is_constructible0_imp<false, _A[_N]>
2129227825Stheraven    : public is_constructible<typename remove_all_extents<_A>::type>
2130227825Stheraven    {};
2131227825Stheraven
2132227825Stheraventemplate <class _A, size_t _N, class _A0>
2133227825Stheravenstruct __is_constructible1_imp<false, _A[_N], _A0>
2134227825Stheraven    : public false_type
2135227825Stheraven    {};
2136227825Stheraven
2137227825Stheraventemplate <class _A, size_t _N, class _A0, class _A1>
2138227825Stheravenstruct __is_constructible2_imp<false, _A[_N], _A0, _A1>
2139227825Stheraven    : public false_type
2140227825Stheraven    {};
2141227825Stheraven
2142227825Stheraven//      Incomplete array types are not constructible
2143227825Stheraven
2144227825Stheraventemplate <class _A>
2145227825Stheravenstruct __is_constructible0_imp<false, _A[]>
2146227825Stheraven    : public false_type
2147227825Stheraven    {};
2148227825Stheraven
2149227825Stheraventemplate <class _A, class _A0>
2150227825Stheravenstruct __is_constructible1_imp<false, _A[], _A0>
2151227825Stheraven    : public false_type
2152227825Stheraven    {};
2153227825Stheraven
2154227825Stheraventemplate <class _A, class _A0, class _A1>
2155227825Stheravenstruct __is_constructible2_imp<false, _A[], _A0, _A1>
2156227825Stheraven    : public false_type
2157227825Stheraven    {};
2158227825Stheraven
2159227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
2160227825Stheraven
2161227825Stheraven// is_default_constructible
2162227825Stheraven
2163227825Stheraventemplate <class _Tp>
2164227825Stheravenstruct _LIBCPP_VISIBLE is_default_constructible
2165227825Stheraven    : public is_constructible<_Tp>
2166227825Stheraven    {};
2167227825Stheraven
2168227825Stheraven// is_copy_constructible
2169227825Stheraven
2170227825Stheraventemplate <class _Tp>
2171227825Stheravenstruct _LIBCPP_VISIBLE is_copy_constructible
2172227825Stheraven    : public is_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type>
2173227825Stheraven    {};
2174227825Stheraven
2175227825Stheraven// is_move_constructible
2176227825Stheraven
2177227825Stheraventemplate <class _Tp>
2178227825Stheravenstruct _LIBCPP_VISIBLE is_move_constructible
2179227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2180227825Stheraven    : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2181227825Stheraven#else
2182227825Stheraven    : public is_copy_constructible<_Tp>
2183227825Stheraven#endif
2184227825Stheraven    {};
2185227825Stheraven
2186227825Stheraven// is_trivially_constructible
2187227825Stheraven
2188227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
2189227825Stheraven
2190227825Stheraventemplate <class _Tp, class... _Args>
2191227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible
2192227825Stheraven    : false_type
2193227825Stheraven{
2194227825Stheraven};
2195227825Stheraven
2196227825Stheraventemplate <class _Tp>
2197227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp>
2198227825Stheraven#if __has_feature(has_trivial_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2199227825Stheraven    : integral_constant<bool, __has_trivial_constructor(_Tp)>
2200227825Stheraven#else
2201227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2202227825Stheraven#endif
2203227825Stheraven{
2204227825Stheraven};
2205227825Stheraven
2206227825Stheraventemplate <class _Tp>
2207227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2208227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp&&>
2209227825Stheraven#else
2210227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp>
2211227825Stheraven#endif
2212227825Stheraven#if __has_feature(has_trivial_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2213227825Stheraven    : integral_constant<bool, __has_trivial_copy(_Tp)>
2214227825Stheraven#else
2215227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2216227825Stheraven#endif
2217227825Stheraven{
2218227825Stheraven};
2219227825Stheraven
2220227825Stheraventemplate <class _Tp>
2221227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, const _Tp&>
2222227825Stheraven#if __has_feature(has_trivial_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2223227825Stheraven    : integral_constant<bool, __has_trivial_copy(_Tp)>
2224227825Stheraven#else
2225227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2226227825Stheraven#endif
2227227825Stheraven{
2228227825Stheraven};
2229227825Stheraven
2230227825Stheraventemplate <class _Tp>
2231227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp&>
2232227825Stheraven#if __has_feature(has_trivial_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2233227825Stheraven    : integral_constant<bool, __has_trivial_copy(_Tp)>
2234227825Stheraven#else
2235227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2236227825Stheraven#endif
2237227825Stheraven{
2238227825Stheraven};
2239227825Stheraven
2240227825Stheraven#else  // _LIBCPP_HAS_NO_VARIADICS
2241227825Stheraven
2242227825Stheraventemplate <class _Tp, class _A0 = __is_construct::__nat,
2243227825Stheraven                     class _A1 = __is_construct::__nat>
2244227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible
2245227825Stheraven    : false_type
2246227825Stheraven{
2247227825Stheraven};
2248227825Stheraven
2249227825Stheraventemplate <class _Tp>
2250227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, __is_construct::__nat,
2251227825Stheraven                                                       __is_construct::__nat>
2252227825Stheraven#if __has_feature(has_trivial_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2253227825Stheraven    : integral_constant<bool, __has_trivial_constructor(_Tp)>
2254227825Stheraven#else
2255227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2256227825Stheraven#endif
2257227825Stheraven{
2258227825Stheraven};
2259227825Stheraven
2260227825Stheraventemplate <class _Tp>
2261227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp,
2262227825Stheraven                                                       __is_construct::__nat>
2263227825Stheraven#if __has_feature(has_trivial_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2264227825Stheraven    : integral_constant<bool, __has_trivial_copy(_Tp)>
2265227825Stheraven#else
2266227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2267227825Stheraven#endif
2268227825Stheraven{
2269227825Stheraven};
2270227825Stheraven
2271227825Stheraventemplate <class _Tp>
2272227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, const _Tp&,
2273227825Stheraven                                                       __is_construct::__nat>
2274227825Stheraven#if __has_feature(has_trivial_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2275227825Stheraven    : integral_constant<bool, __has_trivial_copy(_Tp)>
2276227825Stheraven#else
2277227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2278227825Stheraven#endif
2279227825Stheraven{
2280227825Stheraven};
2281227825Stheraven
2282227825Stheraventemplate <class _Tp>
2283227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp&,
2284227825Stheraven                                                       __is_construct::__nat>
2285227825Stheraven#if __has_feature(has_trivial_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2286227825Stheraven    : integral_constant<bool, __has_trivial_copy(_Tp)>
2287227825Stheraven#else
2288227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2289227825Stheraven#endif
2290227825Stheraven{
2291227825Stheraven};
2292227825Stheraven
2293227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
2294227825Stheraven
2295227825Stheraven// is_trivially_default_constructible
2296227825Stheraven
2297227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivially_default_constructible
2298227825Stheraven    : public is_trivially_constructible<_Tp>
2299227825Stheraven    {};
2300227825Stheraven
2301227825Stheraven// is_trivially_copy_constructible
2302227825Stheraven
2303227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivially_copy_constructible
2304227825Stheraven    : public is_trivially_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type>
2305227825Stheraven    {};
2306227825Stheraven
2307227825Stheraven// is_trivially_move_constructible
2308227825Stheraven
2309227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivially_move_constructible
2310227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2311227825Stheraven    : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2312227825Stheraven#else
2313227825Stheraven    : public is_trivially_copy_constructible<_Tp>
2314227825Stheraven#endif
2315227825Stheraven    {};
2316227825Stheraven
2317227825Stheraven// is_trivially_assignable
2318227825Stheraven
2319227825Stheraventemplate <class _Tp, class _Arg>
2320227825Stheravenstruct is_trivially_assignable
2321227825Stheraven    : public false_type {};
2322227825Stheraven
2323227825Stheraventemplate <class _Tp>
2324227825Stheravenstruct is_trivially_assignable<_Tp&, _Tp>
2325227825Stheraven#if __has_feature(has_trivial_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2326227825Stheraven    : integral_constant<bool, __has_trivial_assign(_Tp)> {};
2327227825Stheraven#else
2328227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2329227825Stheraven#endif
2330227825Stheraven
2331227825Stheraventemplate <class _Tp>
2332227825Stheravenstruct is_trivially_assignable<_Tp&, _Tp&>
2333227825Stheraven#if __has_feature(has_trivial_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2334227825Stheraven    : integral_constant<bool, __has_trivial_assign(_Tp)> {};
2335227825Stheraven#else
2336227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2337227825Stheraven#endif
2338227825Stheraven
2339227825Stheraventemplate <class _Tp>
2340227825Stheravenstruct is_trivially_assignable<_Tp&, const _Tp&>
2341227825Stheraven#if __has_feature(has_trivial_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2342227825Stheraven    : integral_constant<bool, __has_trivial_assign(_Tp)> {};
2343227825Stheraven#else
2344227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2345227825Stheraven#endif
2346227825Stheraven
2347227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2348227825Stheraven
2349227825Stheraventemplate <class _Tp>
2350227825Stheravenstruct is_trivially_assignable<_Tp&, _Tp&&>
2351227825Stheraven#if __has_feature(has_trivial_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2352227825Stheraven    : integral_constant<bool, __has_trivial_assign(_Tp)> {};
2353227825Stheraven#else
2354227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2355227825Stheraven#endif
2356227825Stheraven
2357227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2358227825Stheraven
2359227825Stheraven// is_trivially_copy_assignable
2360227825Stheraven
2361227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivially_copy_assignable
2362227825Stheraven    : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
2363227825Stheraven                               const typename add_lvalue_reference<_Tp>::type>
2364227825Stheraven    {};
2365227825Stheraven
2366227825Stheraven// is_trivially_move_assignable
2367227825Stheraven
2368227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivially_move_assignable
2369227825Stheraven    : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
2370227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2371227825Stheraven                                     typename add_rvalue_reference<_Tp>::type>
2372227825Stheraven#else
2373227825Stheraven                                     typename add_lvalue_reference<_Tp>::type>
2374227825Stheraven#endif
2375227825Stheraven    {};
2376227825Stheraven
2377227825Stheraven// is_trivially_destructible
2378227825Stheraven
2379227825Stheraven#if __has_feature(has_trivial_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2380227825Stheraven
2381227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivially_destructible
2382227825Stheraven    : public integral_constant<bool, __has_trivial_destructor(_Tp)> {};
2383227825Stheraven
2384227825Stheraven#else  // _LIBCPP_HAS_TYPE_TRAITS
2385227825Stheraven
2386227825Stheraventemplate <class _Tp> struct __libcpp_trivial_destructor
2387227825Stheraven    : public integral_constant<bool, is_scalar<_Tp>::value ||
2388227825Stheraven                                     is_reference<_Tp>::value> {};
2389227825Stheraven
2390227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivially_destructible
2391227825Stheraven    : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
2392227825Stheraven
2393227825Stheraven#endif  // _LIBCPP_HAS_TYPE_TRAITS
2394227825Stheraven
2395227825Stheraven// is_nothrow_constructible
2396227825Stheraven
2397227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
2398227825Stheraven
2399227825Stheraven#if __has_feature(cxx_noexcept)
2400227825Stheraven
2401227825Stheraventemplate <bool, class _Tp, class... _Args> struct __is_nothrow_constructible;
2402227825Stheraven
2403227825Stheraventemplate <class _Tp, class... _Args>
2404227825Stheravenstruct __is_nothrow_constructible<true, _Tp, _Args...>
2405227825Stheraven    : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
2406227825Stheraven{
2407227825Stheraven};
2408227825Stheraven
2409227825Stheraventemplate <class _Tp, class... _Args>
2410227825Stheravenstruct __is_nothrow_constructible<false, _Tp, _Args...>
2411227825Stheraven    : public false_type
2412227825Stheraven{
2413227825Stheraven};
2414227825Stheraven
2415227825Stheraventemplate <class _Tp, class... _Args>
2416227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible
2417227825Stheraven    : __is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, _Tp, _Args...>
2418227825Stheraven{
2419227825Stheraven};
2420227825Stheraven
2421227825Stheraventemplate <class _Tp, size_t _Ns>
2422227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp[_Ns]>
2423227825Stheraven    : __is_nothrow_constructible<is_constructible<_Tp>::value, _Tp>
2424227825Stheraven{
2425227825Stheraven};
2426227825Stheraven
2427227825Stheraven#else  // __has_feature(cxx_noexcept)
2428227825Stheraven
2429227825Stheraventemplate <class _Tp, class... _Args>
2430227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible
2431227825Stheraven    : false_type
2432227825Stheraven{
2433227825Stheraven};
2434227825Stheraven
2435227825Stheraventemplate <class _Tp>
2436227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp>
2437227825Stheraven#if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2438227825Stheraven    : integral_constant<bool, __has_nothrow_constructor(_Tp)>
2439227825Stheraven#else
2440227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2441227825Stheraven#endif
2442227825Stheraven{
2443227825Stheraven};
2444227825Stheraven
2445227825Stheraventemplate <class _Tp>
2446227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2447227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, _Tp&&>
2448227825Stheraven#else
2449227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, _Tp>
2450227825Stheraven#endif
2451227825Stheraven#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2452227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
2453227825Stheraven#else
2454227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2455227825Stheraven#endif
2456227825Stheraven{
2457227825Stheraven};
2458227825Stheraven
2459227825Stheraventemplate <class _Tp>
2460227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, const _Tp&>
2461227825Stheraven#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2462227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
2463227825Stheraven#else
2464227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2465227825Stheraven#endif
2466227825Stheraven{
2467227825Stheraven};
2468227825Stheraven
2469227825Stheraventemplate <class _Tp>
2470227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, _Tp&>
2471227825Stheraven#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2472227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
2473227825Stheraven#else
2474227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2475227825Stheraven#endif
2476227825Stheraven{
2477227825Stheraven};
2478227825Stheraven
2479227825Stheraven#endif  // __has_feature(cxx_noexcept)
2480227825Stheraven
2481227825Stheraven#else  // _LIBCPP_HAS_NO_VARIADICS
2482227825Stheraven
2483227825Stheraventemplate <class _Tp, class _A0 = __is_construct::__nat,
2484227825Stheraven                     class _A1 = __is_construct::__nat>
2485227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible
2486227825Stheraven    : false_type
2487227825Stheraven{
2488227825Stheraven};
2489227825Stheraven
2490227825Stheraventemplate <class _Tp>
2491227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, __is_construct::__nat,
2492227825Stheraven                                                       __is_construct::__nat>
2493227825Stheraven#if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2494227825Stheraven    : integral_constant<bool, __has_nothrow_constructor(_Tp)>
2495227825Stheraven#else
2496227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2497227825Stheraven#endif
2498227825Stheraven{
2499227825Stheraven};
2500227825Stheraven
2501227825Stheraventemplate <class _Tp>
2502227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, _Tp,
2503227825Stheraven                                                       __is_construct::__nat>
2504227825Stheraven#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2505227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
2506227825Stheraven#else
2507227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2508227825Stheraven#endif
2509227825Stheraven{
2510227825Stheraven};
2511227825Stheraven
2512227825Stheraventemplate <class _Tp>
2513227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, const _Tp&,
2514227825Stheraven                                                       __is_construct::__nat>
2515227825Stheraven#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2516227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
2517227825Stheraven#else
2518227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2519227825Stheraven#endif
2520227825Stheraven{
2521227825Stheraven};
2522227825Stheraven
2523227825Stheraventemplate <class _Tp>
2524227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, _Tp&,
2525227825Stheraven                                                       __is_construct::__nat>
2526227825Stheraven#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2527227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
2528227825Stheraven#else
2529227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2530227825Stheraven#endif
2531227825Stheraven{
2532227825Stheraven};
2533227825Stheraven
2534227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
2535227825Stheraven
2536227825Stheraven// is_nothrow_default_constructible
2537227825Stheraven
2538227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_default_constructible
2539227825Stheraven    : public is_nothrow_constructible<_Tp>
2540227825Stheraven    {};
2541227825Stheraven
2542227825Stheraven// is_nothrow_copy_constructible
2543227825Stheraven
2544227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_copy_constructible
2545227825Stheraven    : public is_nothrow_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type>
2546227825Stheraven    {};
2547227825Stheraven
2548227825Stheraven// is_nothrow_move_constructible
2549227825Stheraven
2550227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_move_constructible
2551227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2552227825Stheraven    : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2553227825Stheraven#else
2554227825Stheraven    : public is_nothrow_copy_constructible<_Tp>
2555227825Stheraven#endif
2556227825Stheraven    {};
2557227825Stheraven
2558227825Stheraven// is_nothrow_assignable
2559227825Stheraven
2560227825Stheraven#if __has_feature(cxx_noexcept)
2561227825Stheraven
2562227825Stheraventemplate <bool, class _Tp, class _Arg> struct __is_nothrow_assignable;
2563227825Stheraven
2564227825Stheraventemplate <class _Tp, class _Arg>
2565227825Stheravenstruct __is_nothrow_assignable<false, _Tp, _Arg>
2566227825Stheraven    : public false_type
2567227825Stheraven{
2568227825Stheraven};
2569227825Stheraven
2570227825Stheraventemplate <class _Tp, class _Arg>
2571227825Stheravenstruct __is_nothrow_assignable<true, _Tp, _Arg>
2572227825Stheraven    : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) >
2573227825Stheraven{
2574227825Stheraven};
2575227825Stheraven
2576227825Stheraventemplate <class _Tp, class _Arg>
2577227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_assignable
2578227825Stheraven    : public __is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
2579227825Stheraven{
2580227825Stheraven};
2581227825Stheraven
2582227825Stheraven#else  // __has_feature(cxx_noexcept)
2583227825Stheraven
2584227825Stheraventemplate <class _Tp, class _Arg>
2585227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_assignable
2586227825Stheraven    : public false_type {};
2587227825Stheraven
2588227825Stheraventemplate <class _Tp>
2589227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_assignable<_Tp&, _Tp>
2590227825Stheraven#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2591227825Stheraven    : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
2592227825Stheraven#else
2593227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2594227825Stheraven#endif
2595227825Stheraven
2596227825Stheraventemplate <class _Tp>
2597227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_assignable<_Tp&, _Tp&>
2598227825Stheraven#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2599227825Stheraven    : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
2600227825Stheraven#else
2601227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2602227825Stheraven#endif
2603227825Stheraven
2604227825Stheraventemplate <class _Tp>
2605227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_assignable<_Tp&, const _Tp&>
2606227825Stheraven#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2607227825Stheraven    : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
2608227825Stheraven#else
2609227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2610227825Stheraven#endif
2611227825Stheraven
2612227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2613227825Stheraven
2614227825Stheraventemplate <class _Tp>
2615227825Stheravenstruct is_nothrow_assignable<_Tp&, _Tp&&>
2616227825Stheraven#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2617227825Stheraven    : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
2618227825Stheraven#else
2619227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2620227825Stheraven#endif
2621227825Stheraven
2622227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2623227825Stheraven
2624227825Stheraven#endif  // __has_feature(cxx_noexcept)
2625227825Stheraven
2626227825Stheraven// is_nothrow_copy_assignable
2627227825Stheraven
2628227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_copy_assignable
2629227825Stheraven    : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
2630227825Stheraven                               const typename add_lvalue_reference<_Tp>::type>
2631227825Stheraven    {};
2632227825Stheraven
2633227825Stheraven// is_nothrow_move_assignable
2634227825Stheraven
2635227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_move_assignable
2636227825Stheraven    : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
2637227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2638227825Stheraven                                     typename add_rvalue_reference<_Tp>::type>
2639227825Stheraven#else
2640227825Stheraven                                     typename add_lvalue_reference<_Tp>::type>
2641227825Stheraven#endif
2642227825Stheraven    {};
2643227825Stheraven
2644227825Stheraven// is_nothrow_destructible
2645227825Stheraven
2646227825Stheraven#if __has_feature(cxx_noexcept)
2647227825Stheraven
2648227825Stheraventemplate <bool, class _Tp> struct __is_nothrow_destructible;
2649227825Stheraven
2650227825Stheraventemplate <class _Tp>
2651227825Stheravenstruct __is_nothrow_destructible<false, _Tp>
2652227825Stheraven    : public false_type
2653227825Stheraven{
2654227825Stheraven};
2655227825Stheraven
2656227825Stheraventemplate <class _Tp>
2657227825Stheravenstruct __is_nothrow_destructible<true, _Tp>
2658227825Stheraven    : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) >
2659227825Stheraven{
2660227825Stheraven};
2661227825Stheraven
2662227825Stheraventemplate <class _Tp>
2663227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_destructible
2664227825Stheraven    : public __is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
2665227825Stheraven{
2666227825Stheraven};
2667227825Stheraven
2668227825Stheraventemplate <class _Tp, size_t _Ns>
2669227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_destructible<_Tp[_Ns]>
2670227825Stheraven    : public is_nothrow_destructible<_Tp>
2671227825Stheraven{
2672227825Stheraven};
2673227825Stheraven
2674227825Stheraventemplate <class _Tp>
2675227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_destructible<_Tp&>
2676227825Stheraven    : public true_type
2677227825Stheraven{
2678227825Stheraven};
2679227825Stheraven
2680227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2681227825Stheraven
2682227825Stheraventemplate <class _Tp>
2683227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_destructible<_Tp&&>
2684227825Stheraven    : public true_type
2685227825Stheraven{
2686227825Stheraven};
2687227825Stheraven
2688227825Stheraven#endif
2689227825Stheraven
2690227825Stheraven#else
2691227825Stheraven
2692227825Stheraventemplate <class _Tp> struct __libcpp_nothrow_destructor
2693227825Stheraven    : public integral_constant<bool, is_scalar<_Tp>::value ||
2694227825Stheraven                                     is_reference<_Tp>::value> {};
2695227825Stheraven
2696227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_destructible
2697227825Stheraven    : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
2698227825Stheraven
2699227825Stheraven#endif
2700227825Stheraven
2701227825Stheraven// is_pod
2702227825Stheraven
2703227825Stheraven#if __has_feature(is_pod) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2704227825Stheraven
2705227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_pod
2706227825Stheraven    : public integral_constant<bool, __is_pod(_Tp)> {};
2707227825Stheraven
2708227825Stheraven#else  // _LIBCPP_HAS_TYPE_TRAITS
2709227825Stheraven
2710227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_pod
2711227825Stheraven    : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value   &&
2712227825Stheraven                                     is_trivially_copy_constructible<_Tp>::value      &&
2713227825Stheraven                                     is_trivially_copy_assignable<_Tp>::value    &&
2714227825Stheraven                                     is_trivially_destructible<_Tp>::value> {};
2715227825Stheraven
2716227825Stheraven#endif  // _LIBCPP_HAS_TYPE_TRAITS
2717227825Stheraven
2718227825Stheraven// is_literal_type;
2719227825Stheraven
2720227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_literal_type
2721227825Stheraven#if __has_feature(is_literal)
2722227825Stheraven    : public integral_constant<bool, __is_literal(_Tp)>
2723227825Stheraven#else
2724227825Stheraven    : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value ||
2725227825Stheraven                              is_reference<typename remove_all_extents<_Tp>::type>::value>
2726227825Stheraven#endif
2727227825Stheraven    {};
2728227825Stheraven    
2729227825Stheraven// is_standard_layout;
2730227825Stheraven
2731227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_standard_layout
2732227825Stheraven#if __has_feature(is_standard_layout)
2733227825Stheraven    : public integral_constant<bool, __is_standard_layout(_Tp)>
2734227825Stheraven#else
2735227825Stheraven    : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
2736227825Stheraven#endif
2737227825Stheraven    {};
2738227825Stheraven    
2739227825Stheraven// is_trivially_copyable;
2740227825Stheraven
2741227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivially_copyable
2742227825Stheraven#if __has_feature(is_trivially_copyable)
2743227825Stheraven    : public integral_constant<bool, __is_trivially_copyable(_Tp)>
2744227825Stheraven#else
2745227825Stheraven    : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
2746227825Stheraven#endif
2747227825Stheraven    {};
2748227825Stheraven    
2749227825Stheraven// is_trivial;
2750227825Stheraven
2751227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivial
2752227825Stheraven#if __has_feature(is_trivial)
2753227825Stheraven    : public integral_constant<bool, __is_trivial(_Tp)>
2754227825Stheraven#else
2755227825Stheraven    : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
2756227825Stheraven                                 is_trivially_default_constructible<_Tp>::value>
2757227825Stheraven#endif
2758227825Stheraven    {};
2759227825Stheraven
2760227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
2761227825Stheraven
2762227825Stheraven// Check for complete types
2763227825Stheraven
2764227825Stheraventemplate <class ..._T> struct __check_complete;
2765227825Stheraven
2766227825Stheraventemplate <>
2767227825Stheravenstruct __check_complete<>
2768227825Stheraven{
2769227825Stheraven};
2770227825Stheraven
2771227825Stheraventemplate <class _H, class _T0, class ..._T>
2772227825Stheravenstruct __check_complete<_H, _T0, _T...>
2773227825Stheraven    : private __check_complete<_H>,
2774227825Stheraven      private __check_complete<_T0, _T...>
2775227825Stheraven{
2776227825Stheraven};
2777227825Stheraven
2778227825Stheraventemplate <class _H>
2779227825Stheravenstruct __check_complete<_H, _H>
2780227825Stheraven    : private __check_complete<_H>
2781227825Stheraven{
2782227825Stheraven};
2783227825Stheraven
2784227825Stheraventemplate <class _T>
2785227825Stheravenstruct __check_complete<_T>
2786227825Stheraven{
2787227825Stheraven    static_assert(sizeof(_T) > 0, "Type must be complete.");
2788227825Stheraven};
2789227825Stheraven
2790227825Stheraventemplate <class _T>
2791227825Stheravenstruct __check_complete<_T&>
2792227825Stheraven    : private __check_complete<_T>
2793227825Stheraven{
2794227825Stheraven};
2795227825Stheraven
2796227825Stheraventemplate <class _T>
2797227825Stheravenstruct __check_complete<_T&&>
2798227825Stheraven    : private __check_complete<_T>
2799227825Stheraven{
2800227825Stheraven};
2801227825Stheraven
2802227825Stheraventemplate <class _R, class ..._Param>
2803227825Stheravenstruct __check_complete<_R (*)(_Param...)>
2804227825Stheraven    : private __check_complete<_Param...>
2805227825Stheraven{
2806227825Stheraven};
2807227825Stheraven
2808227825Stheraventemplate <class _R, class ..._Param>
2809227825Stheravenstruct __check_complete<_R (_Param...)>
2810227825Stheraven    : private __check_complete<_Param...>
2811227825Stheraven{
2812227825Stheraven};
2813227825Stheraven
2814227825Stheraventemplate <class _R, class _Class, class ..._Param>
2815227825Stheravenstruct __check_complete<_R (_Class::*)(_Param...)>
2816227825Stheraven    : private __check_complete<_Class, _Param...>
2817227825Stheraven{
2818227825Stheraven};
2819227825Stheraven
2820227825Stheraventemplate <class _R, class _Class, class ..._Param>
2821227825Stheravenstruct __check_complete<_R (_Class::*)(_Param...) const>
2822227825Stheraven    : private __check_complete<_Class, _Param...>
2823227825Stheraven{
2824227825Stheraven};
2825227825Stheraven
2826227825Stheraventemplate <class _R, class _Class, class ..._Param>
2827227825Stheravenstruct __check_complete<_R (_Class::*)(_Param...) volatile>
2828227825Stheraven    : private __check_complete<_Class, _Param...>
2829227825Stheraven{
2830227825Stheraven};
2831227825Stheraven
2832227825Stheraventemplate <class _R, class _Class, class ..._Param>
2833227825Stheravenstruct __check_complete<_R (_Class::*)(_Param...) const volatile>
2834227825Stheraven    : private __check_complete<_Class, _Param...>
2835227825Stheraven{
2836227825Stheraven};
2837227825Stheraven
2838227825Stheraven#if __has_feature(cxx_reference_qualified_functions)
2839227825Stheraven
2840227825Stheraventemplate <class _R, class _Class, class ..._Param>
2841227825Stheravenstruct __check_complete<_R (_Class::*)(_Param...) &>
2842227825Stheraven    : private __check_complete<_Class, _Param...>
2843227825Stheraven{
2844227825Stheraven};
2845227825Stheraven
2846227825Stheraventemplate <class _R, class _Class, class ..._Param>
2847227825Stheravenstruct __check_complete<_R (_Class::*)(_Param...) const&>
2848227825Stheraven    : private __check_complete<_Class, _Param...>
2849227825Stheraven{
2850227825Stheraven};
2851227825Stheraven
2852227825Stheraventemplate <class _R, class _Class, class ..._Param>
2853227825Stheravenstruct __check_complete<_R (_Class::*)(_Param...) volatile&>
2854227825Stheraven    : private __check_complete<_Class, _Param...>
2855227825Stheraven{
2856227825Stheraven};
2857227825Stheraven
2858227825Stheraventemplate <class _R, class _Class, class ..._Param>
2859227825Stheravenstruct __check_complete<_R (_Class::*)(_Param...) const volatile&>
2860227825Stheraven    : private __check_complete<_Class, _Param...>
2861227825Stheraven{
2862227825Stheraven};
2863227825Stheraven
2864227825Stheraventemplate <class _R, class _Class, class ..._Param>
2865227825Stheravenstruct __check_complete<_R (_Class::*)(_Param...) &&>
2866227825Stheraven    : private __check_complete<_Class, _Param...>
2867227825Stheraven{
2868227825Stheraven};
2869227825Stheraven
2870227825Stheraventemplate <class _R, class _Class, class ..._Param>
2871227825Stheravenstruct __check_complete<_R (_Class::*)(_Param...) const&&>
2872227825Stheraven    : private __check_complete<_Class, _Param...>
2873227825Stheraven{
2874227825Stheraven};
2875227825Stheraven
2876227825Stheraventemplate <class _R, class _Class, class ..._Param>
2877227825Stheravenstruct __check_complete<_R (_Class::*)(_Param...) volatile&&>
2878227825Stheraven    : private __check_complete<_Class, _Param...>
2879227825Stheraven{
2880227825Stheraven};
2881227825Stheraven
2882227825Stheraventemplate <class _R, class _Class, class ..._Param>
2883227825Stheravenstruct __check_complete<_R (_Class::*)(_Param...) const volatile&&>
2884227825Stheraven    : private __check_complete<_Class, _Param...>
2885227825Stheraven{
2886227825Stheraven};
2887227825Stheraven
2888227825Stheraven#endif
2889227825Stheraven
2890227825Stheraventemplate <class _R, class _Class>
2891227825Stheravenstruct __check_complete<_R _Class::*>
2892227825Stheraven    : private __check_complete<_Class>
2893227825Stheraven{
2894227825Stheraven};
2895227825Stheraven
2896227825Stheraven// __invoke forward declarations
2897227825Stheraven
2898227825Stheraven// fall back - none of the bullets
2899227825Stheraven
2900227825Stheraventemplate <class ..._Args>
2901227825Stheravenauto
2902227825Stheraven__invoke(__any, _Args&& ...__args)
2903227825Stheraven    -> __nat;
2904227825Stheraven
2905227825Stheraven// bullets 1 and 2
2906227825Stheraven
2907227825Stheraventemplate <class _F, class _A0, class ..._Args>
2908227825Stheravenauto
2909227825Stheraven__invoke(_F&& __f, _A0&& __a0, _Args&& ...__args)
2910227825Stheraven    -> decltype((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...));
2911227825Stheraven
2912227825Stheraventemplate <class _F, class _A0, class ..._Args>
2913227825Stheravenauto
2914227825Stheraven__invoke(_F&& __f, _A0&& __a0, _Args&& ...__args)
2915227825Stheraven    -> decltype(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...));
2916227825Stheraven
2917227825Stheraven// bullets 3 and 4
2918227825Stheraven
2919227825Stheraventemplate <class _F, class _A0>
2920227825Stheravenauto
2921227825Stheraven__invoke(_F&& __f, _A0&& __a0)
2922227825Stheraven    -> decltype(_VSTD::forward<_A0>(__a0).*__f);
2923227825Stheraven
2924227825Stheraventemplate <class _F, class _A0>
2925227825Stheravenauto
2926227825Stheraven__invoke(_F&& __f, _A0&& __a0)
2927227825Stheraven    -> decltype((*_VSTD::forward<_A0>(__a0)).*__f);
2928227825Stheraven
2929227825Stheraven// bullet 5
2930227825Stheraven
2931227825Stheraventemplate <class _F, class ..._Args>
2932227825Stheravenauto
2933227825Stheraven__invoke(_F&& __f, _Args&& ...__args)
2934227825Stheraven    -> decltype(_VSTD::forward<_F>(__f)(_VSTD::forward<_Args>(__args)...));
2935227825Stheraven
2936227825Stheraven// __invokable
2937227825Stheraven
2938227825Stheraventemplate <class _F, class ..._Args>
2939227825Stheravenstruct __invokable_imp
2940227825Stheraven    : private __check_complete<_F, _Args...>
2941227825Stheraven{
2942227825Stheraven    typedef decltype(
2943227825Stheraven            __invoke(_VSTD::declval<_F>(), _VSTD::declval<_Args>()...)
2944227825Stheraven                    ) type;
2945227825Stheraven    static const bool value = !is_same<type, __nat>::value;
2946227825Stheraven};
2947227825Stheraven
2948227825Stheraventemplate <class _F, class ..._Args>
2949227825Stheravenstruct __invokable
2950227825Stheraven    : public integral_constant<bool,
2951227825Stheraven          __invokable_imp<_F, _Args...>::value>
2952227825Stheraven{
2953227825Stheraven};
2954227825Stheraven
2955227825Stheraven// __invoke_of
2956227825Stheraven
2957227825Stheraventemplate <bool _Invokable, class _F, class ..._Args>
2958227825Stheravenstruct __invoke_of_imp  // false
2959227825Stheraven{
2960227825Stheraven};
2961227825Stheraven
2962227825Stheraventemplate <class _F, class ..._Args>
2963227825Stheravenstruct __invoke_of_imp<true, _F, _Args...>
2964227825Stheraven{
2965227825Stheraven    typedef typename __invokable_imp<_F, _Args...>::type type;
2966227825Stheraven};
2967227825Stheraven
2968227825Stheraventemplate <class _F, class ..._Args>
2969227825Stheravenstruct __invoke_of
2970227825Stheraven    : public __invoke_of_imp<__invokable<_F, _Args...>::value, _F, _Args...>
2971227825Stheraven{
2972227825Stheraven};
2973227825Stheraven
2974227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
2975227825Stheraven
2976227825Stheraventemplate <class _Tp>
2977227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
2978227825Stheraven#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
2979227825Stheraventypename enable_if
2980227825Stheraven<
2981227825Stheraven    is_move_constructible<_Tp>::value &&
2982227825Stheraven    is_move_assignable<_Tp>::value
2983227825Stheraven>::type
2984227825Stheraven#else
2985227825Stheravenvoid
2986227825Stheraven#endif
2987227825Stheravenswap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
2988227825Stheraven                                    is_nothrow_move_assignable<_Tp>::value)
2989227825Stheraven{
2990227825Stheraven    _Tp __t(_VSTD::move(__x));
2991227825Stheraven    __x = _VSTD::move(__y);
2992227825Stheraven    __y = _VSTD::move(__t);
2993227825Stheraven}
2994227825Stheraven
2995227825Stheraventemplate <class _ForwardIterator1, class _ForwardIterator2>
2996227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
2997227825Stheravenvoid
2998227825Stheraveniter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
2999227825Stheraven    //                                  _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
3000227825Stheraven               _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(),
3001227825Stheraven                                          *_VSTD::declval<_ForwardIterator2>())))
3002227825Stheraven{
3003227825Stheraven    swap(*__a, *__b);
3004227825Stheraven}
3005227825Stheraven
3006227825Stheraven// __swappable
3007227825Stheraven
3008227825Stheravennamespace __detail
3009227825Stheraven{
3010227825Stheraven
3011227825Stheravenusing _VSTD::swap;
3012227825Stheraven__nat swap(__any, __any);
3013227825Stheraven
3014227825Stheraventemplate <class _Tp>
3015227825Stheravenstruct __swappable
3016227825Stheraven{
3017227825Stheraven    typedef decltype(swap(_VSTD::declval<_Tp&>(), _VSTD::declval<_Tp&>())) type;
3018227825Stheraven    static const bool value = !is_same<type, __nat>::value;
3019227825Stheraven};
3020227825Stheraven
3021227825Stheraven}  // __detail
3022227825Stheraven
3023227825Stheraventemplate <class _Tp>
3024227825Stheravenstruct __is_swappable
3025227825Stheraven    : public integral_constant<bool, __detail::__swappable<_Tp>::value>
3026227825Stheraven{
3027227825Stheraven};
3028227825Stheraven
3029227825Stheraven#if __has_feature(cxx_noexcept)
3030227825Stheraven
3031227825Stheraventemplate <bool, class _Tp>
3032227825Stheravenstruct __is_nothrow_swappable_imp
3033227825Stheraven    : public integral_constant<bool, noexcept(swap(_VSTD::declval<_Tp&>(),
3034227825Stheraven                                                   _VSTD::declval<_Tp&>()))>
3035227825Stheraven{
3036227825Stheraven};
3037227825Stheraven
3038227825Stheraventemplate <class _Tp>
3039227825Stheravenstruct __is_nothrow_swappable_imp<false, _Tp>
3040227825Stheraven    : public false_type
3041227825Stheraven{
3042227825Stheraven};
3043227825Stheraven
3044227825Stheraventemplate <class _Tp>
3045227825Stheravenstruct __is_nothrow_swappable
3046227825Stheraven    : public __is_nothrow_swappable_imp<__is_swappable<_Tp>::value, _Tp>
3047227825Stheraven{
3048227825Stheraven};
3049227825Stheraven
3050227825Stheraven#else  // __has_feature(cxx_noexcept)
3051227825Stheraven
3052227825Stheraventemplate <class _Tp>
3053227825Stheravenstruct __is_nothrow_swappable
3054227825Stheraven    : public false_type
3055227825Stheraven{
3056227825Stheraven};
3057227825Stheraven
3058227825Stheraven#endif  // __has_feature(cxx_noexcept)
3059227825Stheraven
3060227825Stheraven#ifdef _LIBCXX_UNDERLYING_TYPE
3061227825Stheraven
3062227825Stheraventemplate <class _Tp>
3063227825Stheravenstruct underlying_type
3064227825Stheraven{
3065227825Stheraven    typedef _LIBCXX_UNDERLYING_TYPE(_Tp) type;
3066227825Stheraven};
3067227825Stheraven
3068227825Stheraven#else  // _LIBCXX_UNDERLYING_TYPE
3069227825Stheraven
3070227825Stheraventemplate <class _Tp, bool _Support = false>
3071227825Stheravenstruct underlying_type
3072227825Stheraven{
3073227825Stheraven    static_assert(_Support, "The underyling_type trait requires compiler "
3074227825Stheraven                            "support. Either no such support exists or "
3075227825Stheraven                            "libc++ does not know how to use it.");
3076227825Stheraven};
3077227825Stheraven
3078227825Stheraven#endif // _LIBCXX_UNDERLYING_TYPE
3079227825Stheraven
3080227825Stheraven_LIBCPP_END_NAMESPACE_STD
3081227825Stheraven
3082227825Stheraven#endif  // _LIBCPP_TYPE_TRAITS
3083