type_traits revision 249998
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;
132249998Sdim    template <size_t Len, class... Types> struct aligned_union;
133227825Stheraven
134227825Stheraven    template <class T> struct decay;
135227825Stheraven    template <class... T> struct common_type;
136227825Stheraven    template <class T> struct underlying_type;
137227825Stheraven    template <class> class result_of; // undefined
138227825Stheraven    template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>;
139227825Stheraven
140227825Stheraven}  // std
141227825Stheraven
142227825Stheraven*/
143227825Stheraven#include <__config>
144227825Stheraven#include <cstddef>
145227825Stheraven
146227825Stheraven#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
147227825Stheraven#pragma GCC system_header
148227825Stheraven#endif
149227825Stheraven
150227825Stheraven_LIBCPP_BEGIN_NAMESPACE_STD
151227825Stheraven
152232950Stheraventemplate <bool _Bp, class _If, class _Then>
153249998Sdim    struct _LIBCPP_TYPE_VIS conditional {typedef _If type;};
154227825Stheraventemplate <class _If, class _Then>
155249998Sdim    struct _LIBCPP_TYPE_VIS conditional<false, _If, _Then> {typedef _Then type;};
156227825Stheraven
157249998Sdimtemplate <bool, class _Tp = void> struct _LIBCPP_TYPE_VIS enable_if {};
158249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS enable_if<true, _Tp> {typedef _Tp type;};
159227825Stheraven
160242945Stheravenstruct __two {char __lx[2];};
161227825Stheraven
162227825Stheraven// helper class:
163227825Stheraven
164227825Stheraventemplate <class _Tp, _Tp __v>
165249998Sdimstruct _LIBCPP_TYPE_VIS integral_constant
166227825Stheraven{
167234976Stheraven    static _LIBCPP_CONSTEXPR const _Tp      value = __v;
168227825Stheraven    typedef _Tp               value_type;
169227825Stheraven    typedef integral_constant type;
170227825Stheraven    _LIBCPP_INLINE_VISIBILITY
171234976Stheraven        _LIBCPP_CONSTEXPR operator value_type() const {return value;}
172227825Stheraven};
173227825Stheraven
174227825Stheraventemplate <class _Tp, _Tp __v>
175234976Stheraven_LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
176227825Stheraven
177227825Stheraventypedef integral_constant<bool, true>  true_type;
178227825Stheraventypedef integral_constant<bool, false> false_type;
179227825Stheraven
180227825Stheraven// is_const
181227825Stheraven
182249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_const            : public false_type {};
183249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_const<_Tp const> : public true_type {};
184227825Stheraven
185227825Stheraven// is_volatile
186227825Stheraven
187249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_volatile               : public false_type {};
188249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_volatile<_Tp volatile> : public true_type {};
189227825Stheraven
190227825Stheraven// remove_const
191227825Stheraven
192249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS remove_const            {typedef _Tp type;};
193249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS remove_const<const _Tp> {typedef _Tp type;};
194227825Stheraven
195227825Stheraven// remove_volatile
196227825Stheraven
197249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS remove_volatile               {typedef _Tp type;};
198249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS remove_volatile<volatile _Tp> {typedef _Tp type;};
199227825Stheraven
200227825Stheraven// remove_cv
201227825Stheraven
202249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS remove_cv
203227825Stheraven{typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
204227825Stheraven
205227825Stheraven// is_void
206227825Stheraven
207227825Stheraventemplate <class _Tp> struct __is_void       : public false_type {};
208227825Stheraventemplate <>          struct __is_void<void> : public true_type {};
209227825Stheraven
210249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_void
211227825Stheraven    : public __is_void<typename remove_cv<_Tp>::type> {};
212227825Stheraven
213227825Stheraven// __is_nullptr_t
214227825Stheraven
215227825Stheraventemplate <class _Tp> struct ____is_nullptr_t       : public false_type {};
216227825Stheraventemplate <>          struct ____is_nullptr_t<nullptr_t> : public true_type {};
217227825Stheraven
218249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS __is_nullptr_t
219227825Stheraven    : public ____is_nullptr_t<typename remove_cv<_Tp>::type> {};
220227825Stheraven
221227825Stheraven// is_integral
222227825Stheraven
223227825Stheraventemplate <class _Tp> struct __is_integral                     : public false_type {};
224227825Stheraventemplate <>          struct __is_integral<bool>               : public true_type {};
225227825Stheraventemplate <>          struct __is_integral<char>               : public true_type {};
226227825Stheraventemplate <>          struct __is_integral<signed char>        : public true_type {};
227227825Stheraventemplate <>          struct __is_integral<unsigned char>      : public true_type {};
228227825Stheraventemplate <>          struct __is_integral<wchar_t>            : public true_type {};
229227825Stheraven#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
230227825Stheraventemplate <>          struct __is_integral<char16_t>           : public true_type {};
231227825Stheraventemplate <>          struct __is_integral<char32_t>           : public true_type {};
232227825Stheraven#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
233227825Stheraventemplate <>          struct __is_integral<short>              : public true_type {};
234227825Stheraventemplate <>          struct __is_integral<unsigned short>     : public true_type {};
235227825Stheraventemplate <>          struct __is_integral<int>                : public true_type {};
236227825Stheraventemplate <>          struct __is_integral<unsigned int>       : public true_type {};
237227825Stheraventemplate <>          struct __is_integral<long>               : public true_type {};
238227825Stheraventemplate <>          struct __is_integral<unsigned long>      : public true_type {};
239227825Stheraventemplate <>          struct __is_integral<long long>          : public true_type {};
240227825Stheraventemplate <>          struct __is_integral<unsigned long long> : public true_type {};
241227825Stheraven
242249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_integral
243227825Stheraven    : public __is_integral<typename remove_cv<_Tp>::type> {};
244227825Stheraven
245227825Stheraven// is_floating_point
246227825Stheraven
247227825Stheraventemplate <class _Tp> struct __is_floating_point              : public false_type {};
248227825Stheraventemplate <>          struct __is_floating_point<float>       : public true_type {};
249227825Stheraventemplate <>          struct __is_floating_point<double>      : public true_type {};
250227825Stheraventemplate <>          struct __is_floating_point<long double> : public true_type {};
251227825Stheraven
252249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_floating_point
253227825Stheraven    : public __is_floating_point<typename remove_cv<_Tp>::type> {};
254227825Stheraven
255227825Stheraven// is_array
256227825Stheraven
257249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_array
258227825Stheraven    : public false_type {};
259249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_array<_Tp[]>
260227825Stheraven    : public true_type {};
261249998Sdimtemplate <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS is_array<_Tp[_Np]>
262227825Stheraven    : public true_type {};
263227825Stheraven
264227825Stheraven// is_pointer
265227825Stheraven
266227825Stheraventemplate <class _Tp> struct __is_pointer       : public false_type {};
267227825Stheraventemplate <class _Tp> struct __is_pointer<_Tp*> : public true_type {};
268227825Stheraven
269249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_pointer
270227825Stheraven    : public __is_pointer<typename remove_cv<_Tp>::type> {};
271227825Stheraven
272227825Stheraven// is_reference
273227825Stheraven
274249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_lvalue_reference       : public false_type {};
275249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_lvalue_reference<_Tp&> : public true_type {};
276227825Stheraven
277249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_rvalue_reference        : public false_type {};
278227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
279249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_rvalue_reference<_Tp&&> : public true_type {};
280227825Stheraven#endif
281227825Stheraven
282249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_reference        : public false_type {};
283249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_reference<_Tp&>  : public true_type {};
284227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
285249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_reference<_Tp&&> : public true_type {};
286227825Stheraven#endif
287227825Stheraven
288227825Stheraven#if defined(__clang__) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
289227825Stheraven#define _LIBCPP_HAS_TYPE_TRAITS
290227825Stheraven#endif
291227825Stheraven
292227825Stheraven// is_union
293227825Stheraven
294227825Stheraven#if __has_feature(is_union) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
295227825Stheraven
296249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_union
297227825Stheraven    : public integral_constant<bool, __is_union(_Tp)> {};
298227825Stheraven
299227825Stheraven#else
300227825Stheraven
301227825Stheraventemplate <class _Tp> struct __libcpp_union : public false_type {};
302249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_union
303227825Stheraven    : public __libcpp_union<typename remove_cv<_Tp>::type> {};
304227825Stheraven
305227825Stheraven#endif
306227825Stheraven
307227825Stheraven// is_class
308227825Stheraven
309227825Stheraven#if __has_feature(is_class) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
310227825Stheraven
311249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_class
312227825Stheraven    : public integral_constant<bool, __is_class(_Tp)> {};
313227825Stheraven
314227825Stheraven#else
315227825Stheraven
316227825Stheravennamespace __is_class_imp
317227825Stheraven{
318227825Stheraventemplate <class _Tp> char  __test(int _Tp::*);
319227825Stheraventemplate <class _Tp> __two __test(...);
320227825Stheraven}
321227825Stheraven
322249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_class
323227825Stheraven    : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {};
324227825Stheraven
325227825Stheraven#endif
326227825Stheraven
327227825Stheraven// is_same
328227825Stheraven
329249998Sdimtemplate <class _Tp, class _Up> struct _LIBCPP_TYPE_VIS is_same           : public false_type {};
330249998Sdimtemplate <class _Tp>            struct _LIBCPP_TYPE_VIS is_same<_Tp, _Tp> : public true_type {};
331227825Stheraven
332227825Stheraven// is_function
333227825Stheraven
334227825Stheravennamespace __is_function_imp
335227825Stheraven{
336227825Stheraventemplate <class _Tp> char  __test(_Tp*);
337227825Stheraventemplate <class _Tp> __two __test(...);
338227825Stheraventemplate <class _Tp> _Tp&  __source();
339227825Stheraven}
340227825Stheraven
341227825Stheraventemplate <class _Tp, bool = is_class<_Tp>::value ||
342227825Stheraven                            is_union<_Tp>::value ||
343227825Stheraven                            is_void<_Tp>::value  ||
344227825Stheraven                            is_reference<_Tp>::value ||
345227825Stheraven                            is_same<_Tp, nullptr_t>::value >
346227825Stheravenstruct __is_function
347227825Stheraven    : public integral_constant<bool, sizeof(__is_function_imp::__test<_Tp>(__is_function_imp::__source<_Tp>())) == 1>
348227825Stheraven    {};
349227825Stheraventemplate <class _Tp> struct __is_function<_Tp, true> : public false_type {};
350227825Stheraven
351249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_function
352227825Stheraven    : public __is_function<_Tp> {};
353227825Stheraven
354227825Stheraven// is_member_function_pointer
355227825Stheraven
356227825Stheraventemplate <class _Tp> struct            __is_member_function_pointer             : public false_type {};
357227825Stheraventemplate <class _Tp, class _Up> struct __is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {};
358227825Stheraven
359249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_member_function_pointer
360227825Stheraven    : public __is_member_function_pointer<typename remove_cv<_Tp>::type> {};
361227825Stheraven
362227825Stheraven// is_member_pointer
363227825Stheraven
364227825Stheraventemplate <class _Tp>            struct __is_member_pointer             : public false_type {};
365227825Stheraventemplate <class _Tp, class _Up> struct __is_member_pointer<_Tp _Up::*> : public true_type {};
366227825Stheraven
367249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_member_pointer
368227825Stheraven    : public __is_member_pointer<typename remove_cv<_Tp>::type> {};
369227825Stheraven
370227825Stheraven// is_member_object_pointer
371227825Stheraven
372249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_member_object_pointer
373227825Stheraven    : public integral_constant<bool, is_member_pointer<_Tp>::value &&
374227825Stheraven                                    !is_member_function_pointer<_Tp>::value> {};
375227825Stheraven
376227825Stheraven// is_enum
377227825Stheraven
378227825Stheraven#if __has_feature(is_enum) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
379227825Stheraven
380249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_enum
381227825Stheraven    : public integral_constant<bool, __is_enum(_Tp)> {};
382227825Stheraven
383227825Stheraven#else
384227825Stheraven
385249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_enum
386227825Stheraven    : public integral_constant<bool, !is_void<_Tp>::value             &&
387227825Stheraven                                     !is_integral<_Tp>::value         &&
388227825Stheraven                                     !is_floating_point<_Tp>::value   &&
389227825Stheraven                                     !is_array<_Tp>::value            &&
390227825Stheraven                                     !is_pointer<_Tp>::value          &&
391227825Stheraven                                     !is_reference<_Tp>::value        &&
392227825Stheraven                                     !is_member_pointer<_Tp>::value   &&
393227825Stheraven                                     !is_union<_Tp>::value            &&
394227825Stheraven                                     !is_class<_Tp>::value            &&
395227825Stheraven                                     !is_function<_Tp>::value         > {};
396227825Stheraven
397227825Stheraven#endif
398227825Stheraven
399227825Stheraven// is_arithmetic
400227825Stheraven
401249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_arithmetic
402227825Stheraven    : public integral_constant<bool, is_integral<_Tp>::value      ||
403227825Stheraven                                     is_floating_point<_Tp>::value> {};
404227825Stheraven
405227825Stheraven// is_fundamental
406227825Stheraven
407249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_fundamental
408227825Stheraven    : public integral_constant<bool, is_void<_Tp>::value        ||
409227825Stheraven                                     __is_nullptr_t<_Tp>::value ||
410227825Stheraven                                     is_arithmetic<_Tp>::value> {};
411227825Stheraven
412227825Stheraven// is_scalar
413227825Stheraven
414249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_scalar
415227825Stheraven    : public integral_constant<bool, is_arithmetic<_Tp>::value     ||
416227825Stheraven                                     is_member_pointer<_Tp>::value ||
417227825Stheraven                                     is_pointer<_Tp>::value        ||
418227825Stheraven                                     __is_nullptr_t<_Tp>::value    ||
419227825Stheraven                                     is_enum<_Tp>::value           > {};
420227825Stheraven
421249998Sdimtemplate <> struct _LIBCPP_TYPE_VIS is_scalar<nullptr_t> : public true_type {};
422227825Stheraven
423227825Stheraven// is_object
424227825Stheraven
425249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_object
426227825Stheraven    : public integral_constant<bool, is_scalar<_Tp>::value ||
427227825Stheraven                                     is_array<_Tp>::value  ||
428227825Stheraven                                     is_union<_Tp>::value  ||
429227825Stheraven                                     is_class<_Tp>::value  > {};
430227825Stheraven
431227825Stheraven// is_compound
432227825Stheraven
433249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_compound
434227825Stheraven    : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
435227825Stheraven
436227825Stheraven// add_const
437227825Stheraven
438227825Stheraventemplate <class _Tp, bool = is_reference<_Tp>::value ||
439227825Stheraven                            is_function<_Tp>::value  ||
440227825Stheraven                            is_const<_Tp>::value     >
441227825Stheravenstruct __add_const             {typedef _Tp type;};
442227825Stheraven
443227825Stheraventemplate <class _Tp>
444227825Stheravenstruct __add_const<_Tp, false> {typedef const _Tp type;};
445227825Stheraven
446249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS add_const
447227825Stheraven    {typedef typename __add_const<_Tp>::type type;};
448227825Stheraven
449227825Stheraven// add_volatile
450227825Stheraven
451227825Stheraventemplate <class _Tp, bool = is_reference<_Tp>::value ||
452227825Stheraven                            is_function<_Tp>::value  ||
453227825Stheraven                            is_volatile<_Tp>::value  >
454227825Stheravenstruct __add_volatile             {typedef _Tp type;};
455227825Stheraven
456227825Stheraventemplate <class _Tp>
457227825Stheravenstruct __add_volatile<_Tp, false> {typedef volatile _Tp type;};
458227825Stheraven
459249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS add_volatile
460227825Stheraven    {typedef typename __add_volatile<_Tp>::type type;};
461227825Stheraven
462227825Stheraven// add_cv
463227825Stheraven
464249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS add_cv
465227825Stheraven    {typedef typename add_const<typename add_volatile<_Tp>::type>::type type;};
466227825Stheraven
467227825Stheraven// remove_reference
468227825Stheraven
469249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS remove_reference        {typedef _Tp type;};
470249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS remove_reference<_Tp&>  {typedef _Tp type;};
471227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
472249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS remove_reference<_Tp&&> {typedef _Tp type;};
473227825Stheraven#endif
474227825Stheraven
475227825Stheraven// add_lvalue_reference
476227825Stheraven
477249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS add_lvalue_reference                      {typedef _Tp& type;};
478249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS add_lvalue_reference<_Tp&>                {typedef _Tp& type;};  // for older compiler
479249998Sdimtemplate <>          struct _LIBCPP_TYPE_VIS add_lvalue_reference<void>                {typedef void type;};
480249998Sdimtemplate <>          struct _LIBCPP_TYPE_VIS add_lvalue_reference<const void>          {typedef const void type;};
481249998Sdimtemplate <>          struct _LIBCPP_TYPE_VIS add_lvalue_reference<volatile void>       {typedef volatile void type;};
482249998Sdimtemplate <>          struct _LIBCPP_TYPE_VIS add_lvalue_reference<const volatile void> {typedef const volatile void type;};
483227825Stheraven
484227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
485227825Stheraven
486249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS  add_rvalue_reference                     {typedef _Tp&& type;};
487249998Sdimtemplate <>          struct _LIBCPP_TYPE_VIS add_rvalue_reference<void>                {typedef void type;};
488249998Sdimtemplate <>          struct _LIBCPP_TYPE_VIS add_rvalue_reference<const void>          {typedef const void type;};
489249998Sdimtemplate <>          struct _LIBCPP_TYPE_VIS add_rvalue_reference<volatile void>       {typedef volatile void type;};
490249998Sdimtemplate <>          struct _LIBCPP_TYPE_VIS add_rvalue_reference<const volatile void> {typedef const volatile void type;};
491227825Stheraven
492227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
493227825Stheraven
494227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
495227825Stheraven
496227825Stheraventemplate <class _Tp>
497227825Stheraventypename add_rvalue_reference<_Tp>::type
498227825Stheravendeclval() _NOEXCEPT;
499227825Stheraven
500227825Stheraven#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
501227825Stheraven
502227825Stheraventemplate <class _Tp>
503227825Stheraventypename add_lvalue_reference<_Tp>::type
504227825Stheravendeclval();
505227825Stheraven
506227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
507227825Stheraven
508227825Stheravenstruct __any
509227825Stheraven{
510227825Stheraven    __any(...);
511227825Stheraven};
512227825Stheraven
513227825Stheraven// remove_pointer
514227825Stheraven
515249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS remove_pointer                      {typedef _Tp type;};
516249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS remove_pointer<_Tp*>                {typedef _Tp type;};
517249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS remove_pointer<_Tp* const>          {typedef _Tp type;};
518249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS remove_pointer<_Tp* volatile>       {typedef _Tp type;};
519249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS remove_pointer<_Tp* const volatile> {typedef _Tp type;};
520227825Stheraven
521227825Stheraven// add_pointer
522227825Stheraven
523249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS add_pointer
524227825Stheraven    {typedef typename remove_reference<_Tp>::type* type;};
525227825Stheraven
526227825Stheraven// is_signed
527227825Stheraven
528227825Stheraventemplate <class _Tp, bool = is_integral<_Tp>::value>
529227825Stheravenstruct ___is_signed : public integral_constant<bool, _Tp(-1) < _Tp(0)> {};
530227825Stheraven
531227825Stheraventemplate <class _Tp>
532227825Stheravenstruct ___is_signed<_Tp, false> : public true_type {};  // floating point
533227825Stheraven
534227825Stheraventemplate <class _Tp, bool = is_arithmetic<_Tp>::value>
535227825Stheravenstruct __is_signed : public ___is_signed<_Tp> {};
536227825Stheraven
537227825Stheraventemplate <class _Tp> struct __is_signed<_Tp, false> : public false_type {};
538227825Stheraven
539249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_signed : public __is_signed<_Tp> {};
540227825Stheraven
541227825Stheraven// is_unsigned
542227825Stheraven
543227825Stheraventemplate <class _Tp, bool = is_integral<_Tp>::value>
544227825Stheravenstruct ___is_unsigned : public integral_constant<bool, _Tp(0) < _Tp(-1)> {};
545227825Stheraven
546227825Stheraventemplate <class _Tp>
547227825Stheravenstruct ___is_unsigned<_Tp, false> : public false_type {};  // floating point
548227825Stheraven
549227825Stheraventemplate <class _Tp, bool = is_arithmetic<_Tp>::value>
550227825Stheravenstruct __is_unsigned : public ___is_unsigned<_Tp> {};
551227825Stheraven
552227825Stheraventemplate <class _Tp> struct __is_unsigned<_Tp, false> : public false_type {};
553227825Stheraven
554249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_unsigned : public __is_unsigned<_Tp> {};
555227825Stheraven
556227825Stheraven// rank
557227825Stheraven
558249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS rank
559227825Stheraven    : public integral_constant<size_t, 0> {};
560249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS rank<_Tp[]>
561227825Stheraven    : public integral_constant<size_t, rank<_Tp>::value + 1> {};
562249998Sdimtemplate <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS rank<_Tp[_Np]>
563227825Stheraven    : public integral_constant<size_t, rank<_Tp>::value + 1> {};
564227825Stheraven
565227825Stheraven// extent
566227825Stheraven
567249998Sdimtemplate <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TYPE_VIS extent
568227825Stheraven    : public integral_constant<size_t, 0> {};
569249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS extent<_Tp[], 0>
570227825Stheraven    : public integral_constant<size_t, 0> {};
571249998Sdimtemplate <class _Tp, unsigned _Ip> struct _LIBCPP_TYPE_VIS extent<_Tp[], _Ip>
572227825Stheraven    : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
573249998Sdimtemplate <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS extent<_Tp[_Np], 0>
574227825Stheraven    : public integral_constant<size_t, _Np> {};
575249998Sdimtemplate <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TYPE_VIS extent<_Tp[_Np], _Ip>
576227825Stheraven    : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
577227825Stheraven
578227825Stheraven// remove_extent
579227825Stheraven
580249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS remove_extent
581227825Stheraven    {typedef _Tp type;};
582249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS remove_extent<_Tp[]>
583227825Stheraven    {typedef _Tp type;};
584249998Sdimtemplate <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS remove_extent<_Tp[_Np]>
585227825Stheraven    {typedef _Tp type;};
586227825Stheraven
587227825Stheraven// remove_all_extents
588227825Stheraven
589249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS remove_all_extents
590227825Stheraven    {typedef _Tp type;};
591249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS remove_all_extents<_Tp[]>
592227825Stheraven    {typedef typename remove_all_extents<_Tp>::type type;};
593249998Sdimtemplate <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS remove_all_extents<_Tp[_Np]>
594227825Stheraven    {typedef typename remove_all_extents<_Tp>::type type;};
595227825Stheraven
596227825Stheraven// is_abstract
597227825Stheraven
598227825Stheravennamespace __is_abstract_imp
599227825Stheraven{
600227825Stheraventemplate <class _Tp> char  __test(_Tp (*)[1]);
601227825Stheraventemplate <class _Tp> __two __test(...);
602227825Stheraven}
603227825Stheraven
604227825Stheraventemplate <class _Tp, bool = is_class<_Tp>::value>
605227825Stheravenstruct __libcpp_abstract : public integral_constant<bool, sizeof(__is_abstract_imp::__test<_Tp>(0)) != 1> {};
606227825Stheraven
607227825Stheraventemplate <class _Tp> struct __libcpp_abstract<_Tp, false> : public false_type {};
608227825Stheraven
609249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_abstract : public __libcpp_abstract<_Tp> {};
610227825Stheraven
611241903Sdim// is_base_of
612241903Sdim
613241903Sdim#ifdef _LIBCP_HAS_IS_BASE_OF
614241903Sdim
615241903Sdimtemplate <class _Bp, class _Dp>
616249998Sdimstruct _LIBCPP_TYPE_VIS is_base_of
617241903Sdim    : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
618241903Sdim
619241903Sdim#else  // __has_feature(is_base_of)
620241903Sdim
621246487Stheravennamespace __is_base_of_imp
622246487Stheraven{
623246487Stheraventemplate <class _Tp>
624246487Stheravenstruct _Dst
625246487Stheraven{
626246487Stheraven    _Dst(const volatile _Tp &);
627246487Stheraven};
628246487Stheraventemplate <class _Tp>
629246487Stheravenstruct _Src
630246487Stheraven{
631246487Stheraven    operator const volatile _Tp &();
632246487Stheraven    template <class _Up> operator const _Dst<_Up> &();
633246487Stheraven};
634246487Stheraventemplate <size_t> struct __one { typedef char type; };
635246487Stheraventemplate <class _Bp, class _Dp> typename __one<sizeof(_Dst<_Bp>(declval<_Src<_Dp> >()))>::type __test(int);
636246487Stheraventemplate <class _Bp, class _Dp> __two __test(...);
637246487Stheraven}
638241903Sdim
639246487Stheraventemplate <class _Bp, class _Dp>
640249998Sdimstruct _LIBCPP_TYPE_VIS is_base_of
641246487Stheraven    : public integral_constant<bool, is_class<_Bp>::value &&
642246487Stheraven                                     sizeof(__is_base_of_imp::__test<_Bp, _Dp>(0)) == 2> {};
643246487Stheraven
644241903Sdim#endif  // __has_feature(is_base_of)
645241903Sdim
646227825Stheraven// is_convertible
647227825Stheraven
648227825Stheraven#if __has_feature(is_convertible_to)
649227825Stheraven
650249998Sdimtemplate <class _T1, class _T2> struct _LIBCPP_TYPE_VIS is_convertible
651241903Sdim    : public integral_constant<bool, __is_convertible_to(_T1, _T2) &&
652241903Sdim                                     !is_abstract<_T2>::value> {};
653227825Stheraven
654227825Stheraven#else  // __has_feature(is_convertible_to)
655227825Stheraven
656227825Stheravennamespace __is_convertible_imp
657227825Stheraven{
658227825Stheraventemplate <class _Tp> char  __test(_Tp);
659227825Stheraventemplate <class _Tp> __two __test(...);
660227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
661227825Stheraventemplate <class _Tp> _Tp&& __source();
662227825Stheraven#else
663227825Stheraventemplate <class _Tp> typename remove_reference<_Tp>::type& __source();
664227825Stheraven#endif
665227825Stheraven
666227825Stheraventemplate <class _Tp, bool _IsArray =    is_array<_Tp>::value,
667227825Stheraven                     bool _IsFunction = is_function<_Tp>::value,
668227825Stheraven                     bool _IsVoid =     is_void<_Tp>::value>
669227825Stheraven                     struct __is_array_function_or_void                          {enum {value = 0};};
670227825Stheraventemplate <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};};
671227825Stheraventemplate <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};};
672227825Stheraventemplate <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};};
673227825Stheraven}
674227825Stheraven
675227825Stheraventemplate <class _Tp,
676227825Stheraven    unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
677227825Stheravenstruct __is_convertible_check
678227825Stheraven{
679227825Stheraven    static const size_t __v = 0;
680227825Stheraven};
681227825Stheraven
682227825Stheraventemplate <class _Tp>
683227825Stheravenstruct __is_convertible_check<_Tp, 0>
684227825Stheraven{
685227825Stheraven    static const size_t __v = sizeof(_Tp);
686227825Stheraven};
687227825Stheraven
688227825Stheraventemplate <class _T1, class _T2,
689227825Stheraven    unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value,
690227825Stheraven    unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
691227825Stheravenstruct __is_convertible
692227825Stheraven    : public integral_constant<bool,
693241903Sdim#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
694227825Stheraven        sizeof(__is_convertible_imp::__test<_T2>(__is_convertible_imp::__source<_T1>())) == 1
695241903Sdim#else
696241903Sdim        sizeof(__is_convertible_imp::__test<_T2>(__is_convertible_imp::__source<_T1>())) == 1
697241903Sdim         && !(!is_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value
698241903Sdim              && (!is_const<typename remove_reference<_T2>::type>::value
699241903Sdim                  || is_volatile<typename remove_reference<_T2>::type>::value)
700241903Sdim                  && (is_same<typename remove_cv<_T1>::type,
701241903Sdim                              typename remove_cv<typename remove_reference<_T2>::type>::type>::value
702241903Sdim                      || is_base_of<typename remove_reference<_T2>::type, _T1>::value))
703241903Sdim#endif
704227825Stheraven    >
705227825Stheraven{};
706227825Stheraven
707227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 0> : false_type {};
708227825Stheraven
709227825Stheraventemplate <class _T1> struct __is_convertible<_T1, const _T1&, 1, 0> : true_type {};
710227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
711227825Stheraventemplate <class _T1> struct __is_convertible<_T1, _T1&&, 1, 0> : true_type {};
712227825Stheraventemplate <class _T1> struct __is_convertible<_T1, const _T1&&, 1, 0> : true_type {};
713227825Stheraventemplate <class _T1> struct __is_convertible<_T1, volatile _T1&&, 1, 0> : true_type {};
714227825Stheraventemplate <class _T1> struct __is_convertible<_T1, const volatile _T1&&, 1, 0> : true_type {};
715227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
716227825Stheraven
717227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2*, 1, 0>
718227825Stheraven    : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*>::value> {};
719227825Stheraven
720227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2* const, 1, 0>
721227825Stheraven    : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const>::value> {};
722227825Stheraven
723227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2* volatile, 1, 0>
724227825Stheraven    : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*volatile>::value> {};
725227825Stheraven
726227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2* const volatile, 1, 0>
727227825Stheraven    : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const volatile>::value> {};
728227825Stheraven
729227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 0>                : public false_type {};
730227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
731227825Stheraventemplate <class _T1>            struct __is_convertible<_T1, _T1&&, 2, 0>               : public true_type {};
732227825Stheraven#endif
733241903Sdimtemplate <class _T1>            struct __is_convertible<_T1, _T1&, 2, 0>               : public true_type {};
734227825Stheraventemplate <class _T1>            struct __is_convertible<_T1, _T1*, 2, 0>               : public true_type {};
735227825Stheraventemplate <class _T1>            struct __is_convertible<_T1, _T1*const, 2, 0>          : public true_type {};
736227825Stheraventemplate <class _T1>            struct __is_convertible<_T1, _T1*volatile, 2, 0>       : public true_type {};
737227825Stheraventemplate <class _T1>            struct __is_convertible<_T1, _T1*const volatile, 2, 0> : public true_type {};
738227825Stheraven
739227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 0> : public false_type {};
740227825Stheraven
741227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
742227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
743227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
744227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {};
745227825Stheraven
746227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {};
747227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {};
748227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {};
749227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {};
750227825Stheraven
751227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {};
752227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {};
753227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {};
754227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {};
755227825Stheraven
756249998Sdimtemplate <class _T1, class _T2> struct _LIBCPP_TYPE_VIS is_convertible
757227825Stheraven    : public __is_convertible<_T1, _T2>
758227825Stheraven{
759227825Stheraven    static const size_t __complete_check1 = __is_convertible_check<_T1>::__v;
760227825Stheraven    static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
761227825Stheraven};
762227825Stheraven
763227825Stheraven#endif  // __has_feature(is_convertible_to)
764227825Stheraven
765227825Stheraven// is_empty
766227825Stheraven
767232950Stheraven#if __has_feature(is_empty)
768232950Stheraven
769227825Stheraventemplate <class _Tp>
770249998Sdimstruct _LIBCPP_TYPE_VIS is_empty
771232950Stheraven    : public integral_constant<bool, __is_empty(_Tp)> {};
772232950Stheraven
773232950Stheraven#else  // __has_feature(is_empty)
774232950Stheraven
775232950Stheraventemplate <class _Tp>
776227825Stheravenstruct __is_empty1
777227825Stheraven    : public _Tp
778227825Stheraven{
779242945Stheraven    double __lx;
780227825Stheraven};
781227825Stheraven
782227825Stheravenstruct __is_empty2
783227825Stheraven{
784242945Stheraven    double __lx;
785227825Stheraven};
786227825Stheraven
787227825Stheraventemplate <class _Tp, bool = is_class<_Tp>::value>
788227825Stheravenstruct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {};
789227825Stheraven
790227825Stheraventemplate <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {};
791227825Stheraven
792249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_empty : public __libcpp_empty<_Tp> {};
793227825Stheraven
794232950Stheraven#endif  // __has_feature(is_empty)
795232950Stheraven
796227825Stheraven// is_polymorphic
797227825Stheraven
798232950Stheraven#if __has_feature(is_polymorphic)
799232950Stheraven
800232950Stheraventemplate <class _Tp>
801249998Sdimstruct _LIBCPP_TYPE_VIS is_polymorphic
802232950Stheraven    : public integral_constant<bool, __is_polymorphic(_Tp)> {};
803232950Stheraven
804232950Stheraven#else
805232950Stheraven
806249998Sdimtemplate<typename _Tp> char &__is_polymorphic_impl(
807249998Sdim    typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0,
808249998Sdim                       int>::type);
809249998Sdimtemplate<typename _Tp> __two &__is_polymorphic_impl(...);
810227825Stheraven
811249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_polymorphic
812249998Sdim    : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {};
813227825Stheraven
814232950Stheraven#endif // __has_feature(is_polymorphic)
815232950Stheraven
816227825Stheraven// has_virtual_destructor
817227825Stheraven
818227825Stheraven#if __has_feature(has_virtual_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
819227825Stheraven
820249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS has_virtual_destructor
821227825Stheraven    : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
822227825Stheraven
823227825Stheraven#else  // _LIBCPP_HAS_TYPE_TRAITS
824227825Stheraven
825249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS has_virtual_destructor
826227825Stheraven    : public false_type {};
827227825Stheraven
828227825Stheraven#endif  // _LIBCPP_HAS_TYPE_TRAITS
829227825Stheraven
830227825Stheraven// alignment_of
831227825Stheraven
832249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS alignment_of
833249998Sdim    : public integral_constant<size_t, __alignof__(_Tp)> {};
834227825Stheraven
835227825Stheraven// aligned_storage
836227825Stheraven
837227825Stheraventemplate <class _Hp, class _Tp>
838227825Stheravenstruct __type_list
839227825Stheraven{
840227825Stheraven    typedef _Hp _Head;
841227825Stheraven    typedef _Tp _Tail;
842227825Stheraven};
843227825Stheraven
844227825Stheravenstruct __nat
845227825Stheraven{
846227825Stheraven#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
847227825Stheraven    __nat() = delete;
848227825Stheraven    __nat(const __nat&) = delete;
849227825Stheraven    __nat& operator=(const __nat&) = delete;
850227825Stheraven    ~__nat() = delete;
851227825Stheraven#endif
852227825Stheraven};
853227825Stheraven
854227825Stheraventemplate <class _Tp>
855227825Stheravenstruct __align_type
856227825Stheraven{
857227825Stheraven    static const size_t value = alignment_of<_Tp>::value;
858227825Stheraven    typedef _Tp type;
859227825Stheraven};
860227825Stheraven
861242945Stheravenstruct __struct_double {long double __lx;};
862242945Stheravenstruct __struct_double4 {double __lx[4];};
863227825Stheraven
864227825Stheraventypedef
865227825Stheraven    __type_list<__align_type<unsigned char>,
866227825Stheraven    __type_list<__align_type<unsigned short>,
867227825Stheraven    __type_list<__align_type<unsigned int>,
868227825Stheraven    __type_list<__align_type<unsigned long>,
869227825Stheraven    __type_list<__align_type<unsigned long long>,
870227825Stheraven    __type_list<__align_type<double>,
871227825Stheraven    __type_list<__align_type<long double>,
872227825Stheraven    __type_list<__align_type<__struct_double>,
873227825Stheraven    __type_list<__align_type<__struct_double4>,
874227825Stheraven    __type_list<__align_type<int*>,
875227825Stheraven    __nat
876227825Stheraven    > > > > > > > > > > __all_types;
877227825Stheraven
878227825Stheraventemplate <class _TL, size_t _Align> struct __find_pod;
879227825Stheraven
880227825Stheraventemplate <class _Hp, size_t _Align>
881227825Stheravenstruct __find_pod<__type_list<_Hp, __nat>, _Align>
882227825Stheraven{
883227825Stheraven    typedef typename conditional<
884227825Stheraven                             _Align == _Hp::value,
885227825Stheraven                             typename _Hp::type,
886227825Stheraven                             void
887227825Stheraven                         >::type type;
888227825Stheraven};
889227825Stheraven
890227825Stheraventemplate <class _Hp, class _Tp, size_t _Align>
891227825Stheravenstruct __find_pod<__type_list<_Hp, _Tp>, _Align>
892227825Stheraven{
893227825Stheraven    typedef typename conditional<
894227825Stheraven                             _Align == _Hp::value,
895227825Stheraven                             typename _Hp::type,
896227825Stheraven                             typename __find_pod<_Tp, _Align>::type
897227825Stheraven                         >::type type;
898227825Stheraven};
899227825Stheraven
900227825Stheraventemplate <class _TL, size_t _Len> struct __find_max_align;
901227825Stheraven
902227825Stheraventemplate <class _Hp, size_t _Len>
903227825Stheravenstruct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
904227825Stheraven
905227825Stheraventemplate <size_t _Len, size_t _A1, size_t _A2>
906227825Stheravenstruct __select_align
907227825Stheraven{
908227825Stheravenprivate:
909227825Stheraven    static const size_t __min = _A2 < _A1 ? _A2 : _A1;
910227825Stheraven    static const size_t __max = _A1 < _A2 ? _A2 : _A1;
911227825Stheravenpublic:
912227825Stheraven    static const size_t value = _Len < __max ? __min : __max;
913227825Stheraven};
914227825Stheraven
915227825Stheraventemplate <class _Hp, class _Tp, size_t _Len>
916227825Stheravenstruct __find_max_align<__type_list<_Hp, _Tp>, _Len>
917227825Stheraven    : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
918227825Stheraven
919227825Stheraventemplate <size_t _Len, const size_t _Align = __find_max_align<__all_types, _Len>::value>
920249998Sdimstruct _LIBCPP_TYPE_VIS aligned_storage
921227825Stheraven{
922227825Stheraven    typedef typename __find_pod<__all_types, _Align>::type _Aligner;
923227825Stheraven    static_assert(!is_void<_Aligner>::value, "");
924227825Stheraven    union type
925227825Stheraven    {
926227825Stheraven        _Aligner __align;
927227825Stheraven        unsigned char __data[_Len];
928227825Stheraven    };
929227825Stheraven};
930227825Stheraven
931227825Stheraven#define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
932227825Stheraventemplate <size_t _Len>\
933249998Sdimstruct _LIBCPP_TYPE_VIS aligned_storage<_Len, n>\
934227825Stheraven{\
935227825Stheraven    struct _ALIGNAS(n) type\
936227825Stheraven    {\
937242945Stheraven        unsigned char __lx[_Len];\
938227825Stheraven    };\
939227825Stheraven}
940227825Stheraven
941227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
942227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
943227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
944227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
945227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
946227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
947227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
948227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
949227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
950227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
951227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
952227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
953227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
954227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
955227825Stheraven// MSDN says that MSVC does not support alignment beyond 8192 (=0x2000)
956227825Stheraven#if !defined(_MSC_VER)
957227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
958227825Stheraven#endif // !_MSC_VER
959227825Stheraven
960227825Stheraven#undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
961227825Stheraven
962249998Sdim#ifndef _LIBCPP_HAS_NO_VARIADICS
963249998Sdim
964249998Sdim// aligned_union
965249998Sdim
966249998Sdimtemplate <size_t _I0, size_t ..._In>
967249998Sdimstruct __static_max;
968249998Sdim
969249998Sdimtemplate <size_t _I0>
970249998Sdimstruct __static_max<_I0>
971249998Sdim{
972249998Sdim    static const size_t value = _I0;
973249998Sdim};
974249998Sdim
975249998Sdimtemplate <size_t _I0, size_t _I1, size_t ..._In>
976249998Sdimstruct __static_max<_I0, _I1, _In...>
977249998Sdim{
978249998Sdim    static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value :
979249998Sdim                                             __static_max<_I1, _In...>::value;
980249998Sdim};
981249998Sdim
982249998Sdimtemplate <size_t _Len, class _Type0, class ..._Types>
983249998Sdimstruct aligned_union
984249998Sdim{
985249998Sdim    static const size_t alignment_value = __static_max<__alignof__(_Type0),
986249998Sdim                                                       __alignof__(_Types)...>::value;
987249998Sdim    static const size_t __len = __static_max<_Len, sizeof(_Type0),
988249998Sdim                                             sizeof(_Types)...>::value;
989249998Sdim    typedef typename aligned_storage<__len, alignment_value>::type type;
990249998Sdim};
991249998Sdim
992249998Sdim#endif  // _LIBCPP_HAS_NO_VARIADICS
993249998Sdim
994227825Stheraven// __promote
995227825Stheraven
996227825Stheraventemplate <class _A1, class _A2 = void, class _A3 = void,
997227825Stheraven          bool = (is_arithmetic<_A1>::value || is_void<_A1>::value) &&
998227825Stheraven                 (is_arithmetic<_A2>::value || is_void<_A2>::value) &&
999227825Stheraven                 (is_arithmetic<_A3>::value || is_void<_A3>::value)>
1000227825Stheravenclass __promote {};
1001227825Stheraven
1002227825Stheraventemplate <class _A1, class _A2, class _A3>
1003227825Stheravenclass __promote<_A1, _A2, _A3, true>
1004227825Stheraven{
1005227825Stheravenprivate:
1006227825Stheraven    typedef typename __promote<_A1>::type __type1;
1007227825Stheraven    typedef typename __promote<_A2>::type __type2;
1008227825Stheraven    typedef typename __promote<_A3>::type __type3;
1009227825Stheravenpublic:
1010227825Stheraven    typedef decltype(__type1() + __type2() + __type3()) type;
1011227825Stheraven};
1012227825Stheraven
1013227825Stheraventemplate <class _A1, class _A2>
1014227825Stheravenclass __promote<_A1, _A2, void, true>
1015227825Stheraven{
1016227825Stheravenprivate:
1017227825Stheraven    typedef typename __promote<_A1>::type __type1;
1018227825Stheraven    typedef typename __promote<_A2>::type __type2;
1019227825Stheravenpublic:
1020227825Stheraven    typedef decltype(__type1() + __type2()) type;
1021227825Stheraven};
1022227825Stheraven
1023227825Stheraventemplate <class _A1>
1024227825Stheravenclass __promote<_A1, void, void, true>
1025227825Stheraven{
1026227825Stheravenpublic:
1027227825Stheraven    typedef typename conditional<is_arithmetic<_A1>::value,
1028227825Stheraven                     typename conditional<is_integral<_A1>::value, double, _A1>::type,
1029227825Stheraven                     void
1030227825Stheraven            >::type type;
1031227825Stheraven};
1032227825Stheraven
1033227825Stheraven#ifdef _LIBCPP_STORE_AS_OPTIMIZATION
1034227825Stheraven
1035227825Stheraven// __transform
1036227825Stheraven
1037227825Stheraventemplate <class _Tp, size_t = sizeof(_Tp), bool = is_scalar<_Tp>::value> struct __transform {typedef _Tp type;};
1038227825Stheraventemplate <class _Tp> struct __transform<_Tp, 1, true> {typedef unsigned char      type;};
1039227825Stheraventemplate <class _Tp> struct __transform<_Tp, 2, true> {typedef unsigned short     type;};
1040227825Stheraventemplate <class _Tp> struct __transform<_Tp, 4, true> {typedef unsigned int       type;};
1041227825Stheraventemplate <class _Tp> struct __transform<_Tp, 8, true> {typedef unsigned long long type;};
1042227825Stheraven
1043227825Stheraven#endif  // _LIBCPP_STORE_AS_OPTIMIZATION
1044227825Stheraven
1045227825Stheraven// make_signed / make_unsigned
1046227825Stheraven
1047227825Stheraventypedef
1048227825Stheraven    __type_list<signed char,
1049227825Stheraven    __type_list<signed short,
1050227825Stheraven    __type_list<signed int,
1051227825Stheraven    __type_list<signed long,
1052227825Stheraven    __type_list<signed long long,
1053227825Stheraven    __nat
1054227825Stheraven    > > > > > __signed_types;
1055227825Stheraven
1056227825Stheraventypedef
1057227825Stheraven    __type_list<unsigned char,
1058227825Stheraven    __type_list<unsigned short,
1059227825Stheraven    __type_list<unsigned int,
1060227825Stheraven    __type_list<unsigned long,
1061227825Stheraven    __type_list<unsigned long long,
1062227825Stheraven    __nat
1063227825Stheraven    > > > > > __unsigned_types;
1064227825Stheraven
1065227825Stheraventemplate <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
1066227825Stheraven
1067227825Stheraventemplate <class _Hp, class _Tp, size_t _Size>
1068227825Stheravenstruct __find_first<__type_list<_Hp, _Tp>, _Size, true>
1069227825Stheraven{
1070227825Stheraven    typedef _Hp type;
1071227825Stheraven};
1072227825Stheraven
1073227825Stheraventemplate <class _Hp, class _Tp, size_t _Size>
1074227825Stheravenstruct __find_first<__type_list<_Hp, _Tp>, _Size, false>
1075227825Stheraven{
1076227825Stheraven    typedef typename __find_first<_Tp, _Size>::type type;
1077227825Stheraven};
1078227825Stheraven
1079227825Stheraventemplate <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
1080227825Stheraven                             bool = is_volatile<typename remove_reference<_Tp>::type>::value>
1081227825Stheravenstruct __apply_cv
1082227825Stheraven{
1083227825Stheraven    typedef _Up type;
1084227825Stheraven};
1085227825Stheraven
1086227825Stheraventemplate <class _Tp, class _Up>
1087227825Stheravenstruct __apply_cv<_Tp, _Up, true, false>
1088227825Stheraven{
1089227825Stheraven    typedef const _Up type;
1090227825Stheraven};
1091227825Stheraven
1092227825Stheraventemplate <class _Tp, class _Up>
1093227825Stheravenstruct __apply_cv<_Tp, _Up, false, true>
1094227825Stheraven{
1095227825Stheraven    typedef volatile _Up type;
1096227825Stheraven};
1097227825Stheraven
1098227825Stheraventemplate <class _Tp, class _Up>
1099227825Stheravenstruct __apply_cv<_Tp, _Up, true, true>
1100227825Stheraven{
1101227825Stheraven    typedef const volatile _Up type;
1102227825Stheraven};
1103227825Stheraven
1104227825Stheraventemplate <class _Tp, class _Up>
1105227825Stheravenstruct __apply_cv<_Tp&, _Up, false, false>
1106227825Stheraven{
1107227825Stheraven    typedef _Up& type;
1108227825Stheraven};
1109227825Stheraven
1110227825Stheraventemplate <class _Tp, class _Up>
1111227825Stheravenstruct __apply_cv<_Tp&, _Up, true, false>
1112227825Stheraven{
1113227825Stheraven    typedef const _Up& type;
1114227825Stheraven};
1115227825Stheraven
1116227825Stheraventemplate <class _Tp, class _Up>
1117227825Stheravenstruct __apply_cv<_Tp&, _Up, false, true>
1118227825Stheraven{
1119227825Stheraven    typedef volatile _Up& type;
1120227825Stheraven};
1121227825Stheraven
1122227825Stheraventemplate <class _Tp, class _Up>
1123227825Stheravenstruct __apply_cv<_Tp&, _Up, true, true>
1124227825Stheraven{
1125227825Stheraven    typedef const volatile _Up& type;
1126227825Stheraven};
1127227825Stheraven
1128227825Stheraventemplate <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1129227825Stheravenstruct __make_signed {};
1130227825Stheraven
1131227825Stheraventemplate <class _Tp>
1132227825Stheravenstruct __make_signed<_Tp, true>
1133227825Stheraven{
1134227825Stheraven    typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
1135227825Stheraven};
1136227825Stheraven
1137227825Stheraventemplate <> struct __make_signed<bool,               true> {};
1138227825Stheraventemplate <> struct __make_signed<  signed short,     true> {typedef short     type;};
1139227825Stheraventemplate <> struct __make_signed<unsigned short,     true> {typedef short     type;};
1140227825Stheraventemplate <> struct __make_signed<  signed int,       true> {typedef int       type;};
1141227825Stheraventemplate <> struct __make_signed<unsigned int,       true> {typedef int       type;};
1142227825Stheraventemplate <> struct __make_signed<  signed long,      true> {typedef long      type;};
1143227825Stheraventemplate <> struct __make_signed<unsigned long,      true> {typedef long      type;};
1144227825Stheraventemplate <> struct __make_signed<  signed long long, true> {typedef long long type;};
1145227825Stheraventemplate <> struct __make_signed<unsigned long long, true> {typedef long long type;};
1146227825Stheraven
1147227825Stheraventemplate <class _Tp>
1148249998Sdimstruct _LIBCPP_TYPE_VIS make_signed
1149227825Stheraven{
1150227825Stheraven    typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
1151227825Stheraven};
1152227825Stheraven
1153227825Stheraventemplate <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1154227825Stheravenstruct __make_unsigned {};
1155227825Stheraven
1156227825Stheraventemplate <class _Tp>
1157227825Stheravenstruct __make_unsigned<_Tp, true>
1158227825Stheraven{
1159227825Stheraven    typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
1160227825Stheraven};
1161227825Stheraven
1162227825Stheraventemplate <> struct __make_unsigned<bool,               true> {};
1163227825Stheraventemplate <> struct __make_unsigned<  signed short,     true> {typedef unsigned short     type;};
1164227825Stheraventemplate <> struct __make_unsigned<unsigned short,     true> {typedef unsigned short     type;};
1165227825Stheraventemplate <> struct __make_unsigned<  signed int,       true> {typedef unsigned int       type;};
1166227825Stheraventemplate <> struct __make_unsigned<unsigned int,       true> {typedef unsigned int       type;};
1167227825Stheraventemplate <> struct __make_unsigned<  signed long,      true> {typedef unsigned long      type;};
1168227825Stheraventemplate <> struct __make_unsigned<unsigned long,      true> {typedef unsigned long      type;};
1169227825Stheraventemplate <> struct __make_unsigned<  signed long long, true> {typedef unsigned long long type;};
1170227825Stheraventemplate <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
1171227825Stheraven
1172227825Stheraventemplate <class _Tp>
1173249998Sdimstruct _LIBCPP_TYPE_VIS make_unsigned
1174227825Stheraven{
1175227825Stheraven    typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
1176227825Stheraven};
1177227825Stheraven
1178227825Stheraven#ifdef _LIBCPP_HAS_NO_VARIADICS
1179227825Stheraven
1180227825Stheraventemplate <class _Tp, class _Up = void, class V = void>
1181249998Sdimstruct _LIBCPP_TYPE_VIS common_type
1182227825Stheraven{
1183227825Stheravenpublic:
1184227825Stheraven    typedef typename common_type<typename common_type<_Tp, _Up>::type, V>::type type;
1185227825Stheraven};
1186227825Stheraven
1187227825Stheraventemplate <class _Tp>
1188249998Sdimstruct _LIBCPP_TYPE_VIS common_type<_Tp, void, void>
1189227825Stheraven{
1190227825Stheravenpublic:
1191227825Stheraven    typedef _Tp type;
1192227825Stheraven};
1193227825Stheraven
1194227825Stheraventemplate <class _Tp, class _Up>
1195249998Sdimstruct _LIBCPP_TYPE_VIS common_type<_Tp, _Up, void>
1196227825Stheraven{
1197227825Stheravenprivate:
1198227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1199227825Stheraven    static _Tp&& __t();
1200227825Stheraven    static _Up&& __u();
1201227825Stheraven#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1202227825Stheraven    static _Tp __t();
1203227825Stheraven    static _Up __u();
1204227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1205227825Stheravenpublic:
1206232950Stheraven    typedef typename remove_reference<decltype(true ? __t() : __u())>::type type;
1207227825Stheraven};
1208227825Stheraven
1209227825Stheraven#else  // _LIBCPP_HAS_NO_VARIADICS
1210227825Stheraven
1211227825Stheraventemplate <class ..._Tp> struct common_type;
1212227825Stheraven
1213227825Stheraventemplate <class _Tp>
1214249998Sdimstruct _LIBCPP_TYPE_VIS common_type<_Tp>
1215227825Stheraven{
1216227825Stheraven    typedef _Tp type;
1217227825Stheraven};
1218227825Stheraven
1219227825Stheraventemplate <class _Tp, class _Up>
1220249998Sdimstruct _LIBCPP_TYPE_VIS common_type<_Tp, _Up>
1221227825Stheraven{
1222227825Stheravenprivate:
1223227825Stheraven    static _Tp&& __t();
1224227825Stheraven    static _Up&& __u();
1225227825Stheraven    static bool __f();
1226227825Stheravenpublic:
1227232950Stheraven    typedef typename remove_reference<decltype(__f() ? __t() : __u())>::type type;
1228227825Stheraven};
1229227825Stheraven
1230227825Stheraventemplate <class _Tp, class _Up, class ..._Vp>
1231249998Sdimstruct _LIBCPP_TYPE_VIS common_type<_Tp, _Up, _Vp...>
1232227825Stheraven{
1233227825Stheraven    typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp...>::type type;
1234227825Stheraven};
1235227825Stheraven
1236227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
1237227825Stheraven
1238227825Stheraven// is_assignable
1239227825Stheraven
1240227825Stheraventemplate <class _Tp, class _Arg>
1241227825Stheravendecltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>(), true_type()))
1242227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1243227825Stheraven__is_assignable_test(_Tp&&, _Arg&&);
1244227825Stheraven#else
1245227825Stheraven__is_assignable_test(_Tp, _Arg&);
1246227825Stheraven#endif
1247227825Stheraven
1248227825Stheraventemplate <class _Arg>
1249227825Stheravenfalse_type
1250227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1251227825Stheraven__is_assignable_test(__any, _Arg&&);
1252227825Stheraven#else
1253227825Stheraven__is_assignable_test(__any, _Arg&);
1254227825Stheraven#endif
1255227825Stheraven
1256227825Stheraventemplate <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
1257227825Stheravenstruct __is_assignable_imp
1258227825Stheraven    : public common_type
1259227825Stheraven        <
1260227825Stheraven            decltype(__is_assignable_test(declval<_Tp>(), declval<_Arg>()))
1261227825Stheraven        >::type {};
1262227825Stheraven
1263227825Stheraventemplate <class _Tp, class _Arg>
1264227825Stheravenstruct __is_assignable_imp<_Tp, _Arg, true>
1265227825Stheraven    : public false_type
1266227825Stheraven{
1267227825Stheraven};
1268227825Stheraven
1269227825Stheraventemplate <class _Tp, class _Arg>
1270227825Stheravenstruct is_assignable
1271227825Stheraven    : public __is_assignable_imp<_Tp, _Arg> {};
1272227825Stheraven
1273227825Stheraven// is_copy_assignable
1274227825Stheraven
1275249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_copy_assignable
1276227825Stheraven    : public is_assignable<typename add_lvalue_reference<_Tp>::type,
1277227825Stheraven                     const typename add_lvalue_reference<_Tp>::type> {};
1278227825Stheraven
1279227825Stheraven// is_move_assignable
1280227825Stheraven
1281249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_move_assignable
1282227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1283227825Stheraven    : public is_assignable<typename add_lvalue_reference<_Tp>::type,
1284227825Stheraven                     const typename add_rvalue_reference<_Tp>::type> {};
1285227825Stheraven#else
1286227825Stheraven    : public is_copy_assignable<_Tp> {};
1287227825Stheraven#endif
1288227825Stheraven
1289227825Stheraven// is_destructible
1290227825Stheraven
1291227825Stheraventemplate <class _Tp>
1292227825Stheravenstruct __destructible_test
1293227825Stheraven{
1294227825Stheraven    _Tp __t;
1295227825Stheraven};
1296227825Stheraven
1297227825Stheraventemplate <class _Tp>
1298227825Stheravendecltype((_VSTD::declval<__destructible_test<_Tp> >().~__destructible_test<_Tp>(), true_type()))
1299227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1300227825Stheraven__is_destructible_test(_Tp&&);
1301227825Stheraven#else
1302227825Stheraven__is_destructible_test(_Tp&);
1303227825Stheraven#endif
1304227825Stheraven
1305227825Stheravenfalse_type
1306227825Stheraven__is_destructible_test(__any);
1307227825Stheraven
1308227825Stheraventemplate <class _Tp, bool = is_void<_Tp>::value || is_abstract<_Tp>::value>
1309227825Stheravenstruct __destructible_imp
1310227825Stheraven    : public common_type
1311227825Stheraven        <
1312227825Stheraven            decltype(__is_destructible_test(declval<_Tp>()))
1313227825Stheraven        >::type {};
1314227825Stheraven
1315227825Stheraventemplate <class _Tp>
1316227825Stheravenstruct __destructible_imp<_Tp, true>
1317227825Stheraven    : public false_type {};
1318227825Stheraven
1319227825Stheraventemplate <class _Tp>
1320227825Stheravenstruct is_destructible
1321227825Stheraven    : public __destructible_imp<_Tp> {};
1322227825Stheraven
1323227825Stheraven// move
1324227825Stheraven
1325227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1326227825Stheraven
1327227825Stheraventemplate <class _Tp>
1328227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1329227825Stheraventypename remove_reference<_Tp>::type&&
1330227825Stheravenmove(_Tp&& __t) _NOEXCEPT
1331227825Stheraven{
1332227825Stheraven    typedef typename remove_reference<_Tp>::type _Up;
1333227825Stheraven    return static_cast<_Up&&>(__t);
1334227825Stheraven}
1335227825Stheraven
1336227825Stheraventemplate <class _Tp>
1337227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1338227825Stheraven_Tp&&
1339227825Stheravenforward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
1340227825Stheraven{
1341227825Stheraven    return static_cast<_Tp&&>(__t);
1342227825Stheraven}
1343227825Stheraven
1344227825Stheraventemplate <class _Tp>
1345227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1346227825Stheraven_Tp&&
1347227825Stheravenforward(typename std::remove_reference<_Tp>::type&& __t) _NOEXCEPT
1348227825Stheraven{
1349227825Stheraven    static_assert(!std::is_lvalue_reference<_Tp>::value,
1350227825Stheraven                  "Can not forward an rvalue as an lvalue.");
1351227825Stheraven    return static_cast<_Tp&&>(__t);
1352227825Stheraven}
1353227825Stheraven
1354227825Stheraven#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1355227825Stheraven
1356227825Stheraventemplate <class _Tp>
1357227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1358234976Stheraven_Tp&
1359227825Stheravenmove(_Tp& __t)
1360227825Stheraven{
1361227825Stheraven    return __t;
1362227825Stheraven}
1363227825Stheraven
1364227825Stheraventemplate <class _Tp>
1365227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1366234976Stheravenconst _Tp&
1367232950Stheravenmove(const _Tp& __t)
1368232950Stheraven{
1369232950Stheraven    return __t;
1370232950Stheraven}
1371232950Stheraven
1372232950Stheraventemplate <class _Tp>
1373232950Stheraveninline _LIBCPP_INLINE_VISIBILITY
1374234976Stheraven_Tp&
1375234976Stheravenforward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
1376227825Stheraven{
1377227825Stheraven    return __t;
1378227825Stheraven}
1379227825Stheraven
1380227825Stheraven
1381234976Stheraventemplate <class _Tp>
1382234976Stheravenclass __rv
1383227825Stheraven{
1384234976Stheraven    typedef typename remove_reference<_Tp>::type _Trr;
1385234976Stheraven    _Trr& t_;
1386234976Stheravenpublic:
1387234976Stheraven    _LIBCPP_INLINE_VISIBILITY
1388234976Stheraven    _Trr* operator->() {return &t_;}
1389234976Stheraven    _LIBCPP_INLINE_VISIBILITY
1390234976Stheraven    explicit __rv(_Trr& __t) : t_(__t) {}
1391234976Stheraven};
1392227825Stheraven
1393227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1394227825Stheraven
1395227825Stheraventemplate <class _Tp>
1396249998Sdimstruct _LIBCPP_TYPE_VIS decay
1397227825Stheraven{
1398227825Stheravenprivate:
1399227825Stheraven    typedef typename remove_reference<_Tp>::type _Up;
1400227825Stheravenpublic:
1401227825Stheraven    typedef typename conditional
1402227825Stheraven                     <
1403227825Stheraven                         is_array<_Up>::value,
1404227825Stheraven                         typename remove_extent<_Up>::type*,
1405227825Stheraven                         typename conditional
1406227825Stheraven                         <
1407227825Stheraven                              is_function<_Up>::value,
1408227825Stheraven                              typename add_pointer<_Up>::type,
1409227825Stheraven                              typename remove_cv<_Up>::type
1410227825Stheraven                         >::type
1411227825Stheraven                     >::type type;
1412227825Stheraven};
1413227825Stheraven
1414227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1415227825Stheraven
1416227825Stheraventemplate <class _Tp>
1417227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1418227825Stheraventypename decay<_Tp>::type
1419227825Stheraven__decay_copy(_Tp&& __t)
1420227825Stheraven{
1421227825Stheraven    return _VSTD::forward<_Tp>(__t);
1422227825Stheraven}
1423227825Stheraven
1424227825Stheraven#else
1425227825Stheraven
1426227825Stheraventemplate <class _Tp>
1427227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1428227825Stheraventypename decay<_Tp>::type
1429227825Stheraven__decay_copy(const _Tp& __t)
1430227825Stheraven{
1431227825Stheraven    return _VSTD::forward<_Tp>(__t);
1432227825Stheraven}
1433227825Stheraven
1434227825Stheraven#endif
1435227825Stheraven
1436227825Stheraventemplate <class _MP, bool _IsMemberFuctionPtr, bool _IsMemberObjectPtr>
1437227825Stheravenstruct __member_pointer_traits_imp
1438227825Stheraven{
1439227825Stheraven};
1440227825Stheraven
1441227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
1442227825Stheraven
1443232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1444232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
1445227825Stheraven{
1446227825Stheraven    typedef _Class _ClassType;
1447232950Stheraven    typedef _Rp _ReturnType;
1448227825Stheraven};
1449227825Stheraven
1450232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1451232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
1452227825Stheraven{
1453227825Stheraven    typedef _Class const _ClassType;
1454232950Stheraven    typedef _Rp _ReturnType;
1455227825Stheraven};
1456227825Stheraven
1457232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1458232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
1459227825Stheraven{
1460227825Stheraven    typedef _Class volatile _ClassType;
1461232950Stheraven    typedef _Rp _ReturnType;
1462227825Stheraven};
1463227825Stheraven
1464232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1465232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
1466227825Stheraven{
1467227825Stheraven    typedef _Class const volatile _ClassType;
1468232950Stheraven    typedef _Rp _ReturnType;
1469227825Stheraven};
1470227825Stheraven
1471227825Stheraven#if __has_feature(cxx_reference_qualified_functions)
1472227825Stheraven
1473232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1474232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
1475227825Stheraven{
1476227825Stheraven    typedef _Class& _ClassType;
1477232950Stheraven    typedef _Rp _ReturnType;
1478227825Stheraven};
1479227825Stheraven
1480232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1481232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
1482227825Stheraven{
1483227825Stheraven    typedef _Class const& _ClassType;
1484232950Stheraven    typedef _Rp _ReturnType;
1485227825Stheraven};
1486227825Stheraven
1487232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1488232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
1489227825Stheraven{
1490227825Stheraven    typedef _Class volatile& _ClassType;
1491232950Stheraven    typedef _Rp _ReturnType;
1492227825Stheraven};
1493227825Stheraven
1494232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1495232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
1496227825Stheraven{
1497227825Stheraven    typedef _Class const volatile& _ClassType;
1498232950Stheraven    typedef _Rp _ReturnType;
1499227825Stheraven};
1500227825Stheraven
1501232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1502232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
1503227825Stheraven{
1504227825Stheraven    typedef _Class&& _ClassType;
1505232950Stheraven    typedef _Rp _ReturnType;
1506227825Stheraven};
1507227825Stheraven
1508232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1509232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
1510227825Stheraven{
1511227825Stheraven    typedef _Class const&& _ClassType;
1512232950Stheraven    typedef _Rp _ReturnType;
1513227825Stheraven};
1514227825Stheraven
1515232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1516232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
1517227825Stheraven{
1518227825Stheraven    typedef _Class volatile&& _ClassType;
1519232950Stheraven    typedef _Rp _ReturnType;
1520227825Stheraven};
1521227825Stheraven
1522232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1523232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
1524227825Stheraven{
1525227825Stheraven    typedef _Class const volatile&& _ClassType;
1526232950Stheraven    typedef _Rp _ReturnType;
1527227825Stheraven};
1528227825Stheraven
1529227825Stheraven#endif  // __has_feature(cxx_reference_qualified_functions)
1530227825Stheraven
1531227825Stheraven#else  // _LIBCPP_HAS_NO_VARIADICS
1532227825Stheraven
1533232950Stheraventemplate <class _Rp, class _Class>
1534232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(), true, false>
1535227825Stheraven{
1536227825Stheraven    typedef _Class _ClassType;
1537232950Stheraven    typedef _Rp _ReturnType;
1538227825Stheraven};
1539227825Stheraven
1540232950Stheraventemplate <class _Rp, class _Class, class _P0>
1541232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false>
1542227825Stheraven{
1543227825Stheraven    typedef _Class _ClassType;
1544232950Stheraven    typedef _Rp _ReturnType;
1545227825Stheraven};
1546227825Stheraven
1547232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1>
1548232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false>
1549227825Stheraven{
1550227825Stheraven    typedef _Class _ClassType;
1551232950Stheraven    typedef _Rp _ReturnType;
1552227825Stheraven};
1553227825Stheraven
1554232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1, class _P2>
1555232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false>
1556227825Stheraven{
1557227825Stheraven    typedef _Class _ClassType;
1558232950Stheraven    typedef _Rp _ReturnType;
1559227825Stheraven};
1560227825Stheraven
1561232950Stheraventemplate <class _Rp, class _Class>
1562232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false>
1563227825Stheraven{
1564227825Stheraven    typedef _Class const _ClassType;
1565232950Stheraven    typedef _Rp _ReturnType;
1566227825Stheraven};
1567227825Stheraven
1568232950Stheraventemplate <class _Rp, class _Class, class _P0>
1569232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false>
1570227825Stheraven{
1571227825Stheraven    typedef _Class const _ClassType;
1572232950Stheraven    typedef _Rp _ReturnType;
1573227825Stheraven};
1574227825Stheraven
1575232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1>
1576232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false>
1577227825Stheraven{
1578227825Stheraven    typedef _Class const _ClassType;
1579232950Stheraven    typedef _Rp _ReturnType;
1580227825Stheraven};
1581227825Stheraven
1582232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1, class _P2>
1583232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, false>
1584227825Stheraven{
1585227825Stheraven    typedef _Class const _ClassType;
1586232950Stheraven    typedef _Rp _ReturnType;
1587227825Stheraven};
1588227825Stheraven
1589232950Stheraventemplate <class _Rp, class _Class>
1590232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false>
1591227825Stheraven{
1592227825Stheraven    typedef _Class volatile _ClassType;
1593232950Stheraven    typedef _Rp _ReturnType;
1594227825Stheraven};
1595227825Stheraven
1596232950Stheraventemplate <class _Rp, class _Class, class _P0>
1597232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false>
1598227825Stheraven{
1599227825Stheraven    typedef _Class volatile _ClassType;
1600232950Stheraven    typedef _Rp _ReturnType;
1601227825Stheraven};
1602227825Stheraven
1603232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1>
1604232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, false>
1605227825Stheraven{
1606227825Stheraven    typedef _Class volatile _ClassType;
1607232950Stheraven    typedef _Rp _ReturnType;
1608227825Stheraven};
1609227825Stheraven
1610232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1, class _P2>
1611232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true, false>
1612227825Stheraven{
1613227825Stheraven    typedef _Class volatile _ClassType;
1614232950Stheraven    typedef _Rp _ReturnType;
1615227825Stheraven};
1616227825Stheraven
1617232950Stheraventemplate <class _Rp, class _Class>
1618232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false>
1619227825Stheraven{
1620227825Stheraven    typedef _Class const volatile _ClassType;
1621232950Stheraven    typedef _Rp _ReturnType;
1622227825Stheraven};
1623227825Stheraven
1624232950Stheraventemplate <class _Rp, class _Class, class _P0>
1625232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, false>
1626227825Stheraven{
1627227825Stheraven    typedef _Class const volatile _ClassType;
1628232950Stheraven    typedef _Rp _ReturnType;
1629227825Stheraven};
1630227825Stheraven
1631232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1>
1632232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, true, false>
1633227825Stheraven{
1634227825Stheraven    typedef _Class const volatile _ClassType;
1635232950Stheraven    typedef _Rp _ReturnType;
1636227825Stheraven};
1637227825Stheraven
1638232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1, class _P2>
1639232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile, true, false>
1640227825Stheraven{
1641227825Stheraven    typedef _Class const volatile _ClassType;
1642232950Stheraven    typedef _Rp _ReturnType;
1643227825Stheraven};
1644227825Stheraven
1645227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
1646227825Stheraven
1647232950Stheraventemplate <class _Rp, class _Class>
1648232950Stheravenstruct __member_pointer_traits_imp<_Rp _Class::*, false, true>
1649227825Stheraven{
1650227825Stheraven    typedef _Class _ClassType;
1651232950Stheraven    typedef _Rp _ReturnType;
1652227825Stheraven};
1653227825Stheraven
1654227825Stheraventemplate <class _MP>
1655227825Stheravenstruct __member_pointer_traits
1656227825Stheraven    : public __member_pointer_traits_imp<_MP,
1657227825Stheraven                    is_member_function_pointer<_MP>::value,
1658227825Stheraven                    is_member_object_pointer<_MP>::value>
1659227825Stheraven{
1660227825Stheraven//     typedef ... _ClassType;
1661227825Stheraven//     typedef ... _ReturnType;
1662227825Stheraven};
1663227825Stheraven
1664227825Stheraven// result_of
1665227825Stheraven
1666227825Stheraventemplate <class _Callable> class result_of;
1667227825Stheraven
1668241903Sdim#ifdef _LIBCPP_HAS_NO_VARIADICS
1669241903Sdim
1670227825Stheraventemplate <class _Fn, bool, bool>
1671227825Stheravenclass __result_of
1672227825Stheraven{
1673227825Stheraven};
1674227825Stheraven
1675227825Stheraventemplate <class _Fn>
1676227825Stheravenclass __result_of<_Fn(), true, false>
1677227825Stheraven{
1678227825Stheravenpublic:
1679227825Stheraven    typedef decltype(declval<_Fn>()()) type;
1680227825Stheraven};
1681227825Stheraven
1682227825Stheraventemplate <class _Fn, class _A0>
1683227825Stheravenclass __result_of<_Fn(_A0), true, false>
1684227825Stheraven{
1685227825Stheravenpublic:
1686227825Stheraven    typedef decltype(declval<_Fn>()(declval<_A0>())) type;
1687227825Stheraven};
1688227825Stheraven
1689227825Stheraventemplate <class _Fn, class _A0, class _A1>
1690227825Stheravenclass __result_of<_Fn(_A0, _A1), true, false>
1691227825Stheraven{
1692227825Stheravenpublic:
1693227825Stheraven    typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type;
1694227825Stheraven};
1695227825Stheraven
1696227825Stheraventemplate <class _Fn, class _A0, class _A1, class _A2>
1697227825Stheravenclass __result_of<_Fn(_A0, _A1, _A2), true, false>
1698227825Stheraven{
1699227825Stheravenpublic:
1700227825Stheraven    typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type;
1701227825Stheraven};
1702227825Stheraven
1703227825Stheraventemplate <class _MP, class _Tp, bool _IsMemberFunctionPtr>
1704227825Stheravenstruct __result_of_mp;
1705227825Stheraven
1706227825Stheraven// member function pointer
1707227825Stheraven
1708227825Stheraventemplate <class _MP, class _Tp>
1709227825Stheravenstruct __result_of_mp<_MP, _Tp, true>
1710227825Stheraven    : public common_type<typename __member_pointer_traits<_MP>::_ReturnType>
1711227825Stheraven{
1712227825Stheraven};
1713227825Stheraven
1714227825Stheraven// member data pointer
1715227825Stheraven
1716227825Stheraventemplate <class _MP, class _Tp, bool>
1717227825Stheravenstruct __result_of_mdp;
1718227825Stheraven
1719232950Stheraventemplate <class _Rp, class _Class, class _Tp>
1720232950Stheravenstruct __result_of_mdp<_Rp _Class::*, _Tp, false>
1721227825Stheraven{
1722232950Stheraven    typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type;
1723227825Stheraven};
1724227825Stheraven
1725232950Stheraventemplate <class _Rp, class _Class, class _Tp>
1726232950Stheravenstruct __result_of_mdp<_Rp _Class::*, _Tp, true>
1727227825Stheraven{
1728232950Stheraven    typedef typename __apply_cv<_Tp, _Rp>::type& type;
1729227825Stheraven};
1730227825Stheraven
1731232950Stheraventemplate <class _Rp, class _Class, class _Tp>
1732232950Stheravenstruct __result_of_mp<_Rp _Class::*, _Tp, false>
1733232950Stheraven    : public __result_of_mdp<_Rp _Class::*, _Tp,
1734227825Stheraven            is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
1735227825Stheraven{
1736227825Stheraven};
1737227825Stheraven
1738227825Stheraven
1739227825Stheraven
1740227825Stheraventemplate <class _Fn, class _Tp>
1741227825Stheravenclass __result_of<_Fn(_Tp), false, true>  // _Fn must be member pointer
1742227825Stheraven    : public __result_of_mp<typename remove_reference<_Fn>::type,
1743227825Stheraven                            _Tp,
1744227825Stheraven                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1745227825Stheraven{
1746227825Stheraven};
1747227825Stheraven
1748227825Stheraventemplate <class _Fn, class _Tp, class _A0>
1749227825Stheravenclass __result_of<_Fn(_Tp, _A0), false, true>  // _Fn must be member pointer
1750227825Stheraven    : public __result_of_mp<typename remove_reference<_Fn>::type,
1751227825Stheraven                            _Tp,
1752227825Stheraven                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1753227825Stheraven{
1754227825Stheraven};
1755227825Stheraven
1756227825Stheraventemplate <class _Fn, class _Tp, class _A0, class _A1>
1757227825Stheravenclass __result_of<_Fn(_Tp, _A0, _A1), false, true>  // _Fn must be member pointer
1758227825Stheraven    : public __result_of_mp<typename remove_reference<_Fn>::type,
1759227825Stheraven                            _Tp,
1760227825Stheraven                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1761227825Stheraven{
1762227825Stheraven};
1763227825Stheraven
1764227825Stheraventemplate <class _Fn, class _Tp, class _A0, class _A1, class _A2>
1765227825Stheravenclass __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true>  // _Fn must be member pointer
1766227825Stheraven    : public __result_of_mp<typename remove_reference<_Fn>::type,
1767227825Stheraven                            _Tp,
1768227825Stheraven                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1769227825Stheraven{
1770227825Stheraven};
1771227825Stheraven
1772227825Stheraven// result_of
1773227825Stheraven
1774227825Stheraventemplate <class _Fn>
1775249998Sdimclass _LIBCPP_TYPE_VIS result_of<_Fn()>
1776227825Stheraven    : public __result_of<_Fn(),
1777227825Stheraven                         is_class<typename remove_reference<_Fn>::type>::value ||
1778227825Stheraven                         is_function<typename remove_reference<_Fn>::type>::value,
1779227825Stheraven                         is_member_pointer<typename remove_reference<_Fn>::type>::value
1780227825Stheraven                        >
1781227825Stheraven{
1782227825Stheraven};
1783227825Stheraven
1784227825Stheraventemplate <class _Fn, class _A0>
1785249998Sdimclass _LIBCPP_TYPE_VIS result_of<_Fn(_A0)>
1786227825Stheraven    : public __result_of<_Fn(_A0),
1787227825Stheraven                         is_class<typename remove_reference<_Fn>::type>::value ||
1788227825Stheraven                         is_function<typename remove_reference<_Fn>::type>::value,
1789227825Stheraven                         is_member_pointer<typename remove_reference<_Fn>::type>::value
1790227825Stheraven                        >
1791227825Stheraven{
1792227825Stheraven};
1793227825Stheraven
1794227825Stheraventemplate <class _Fn, class _A0, class _A1>
1795249998Sdimclass _LIBCPP_TYPE_VIS result_of<_Fn(_A0, _A1)>
1796227825Stheraven    : public __result_of<_Fn(_A0, _A1),
1797227825Stheraven                         is_class<typename remove_reference<_Fn>::type>::value ||
1798227825Stheraven                         is_function<typename remove_reference<_Fn>::type>::value,
1799227825Stheraven                         is_member_pointer<typename remove_reference<_Fn>::type>::value
1800227825Stheraven                        >
1801227825Stheraven{
1802227825Stheraven};
1803227825Stheraven
1804227825Stheraventemplate <class _Fn, class _A0, class _A1, class _A2>
1805249998Sdimclass _LIBCPP_TYPE_VIS result_of<_Fn(_A0, _A1, _A2)>
1806227825Stheraven    : public __result_of<_Fn(_A0, _A1, _A2),
1807227825Stheraven                         is_class<typename remove_reference<_Fn>::type>::value ||
1808227825Stheraven                         is_function<typename remove_reference<_Fn>::type>::value,
1809227825Stheraven                         is_member_pointer<typename remove_reference<_Fn>::type>::value
1810227825Stheraven                        >
1811227825Stheraven{
1812227825Stheraven};
1813227825Stheraven
1814227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
1815227825Stheraven
1816227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
1817227825Stheraven
1818227825Stheraven// template <class T, class... Args> struct is_constructible;
1819227825Stheraven
1820227825Stheraven//      main is_constructible test
1821227825Stheraven
1822242945Stheraventemplate<typename, typename T> struct __select_2nd { typedef T type; };
1823242945Stheraven
1824227825Stheraventemplate <class _Tp, class ..._Args>
1825242945Stheraventypename __select_2nd<decltype(_VSTD::move(_Tp(_VSTD::declval<_Args>()...))), true_type>::type
1826227825Stheraven__is_constructible_test(_Tp&&, _Args&& ...);
1827227825Stheraven
1828227825Stheraventemplate <class ..._Args>
1829227825Stheravenfalse_type
1830227825Stheraven__is_constructible_test(__any, _Args&& ...);
1831227825Stheraven
1832227825Stheraventemplate <bool, class _Tp, class... _Args>
1833227825Stheravenstruct __is_constructible // false, _Tp is not a scalar
1834227825Stheraven    : public common_type
1835227825Stheraven             <
1836227825Stheraven                 decltype(__is_constructible_test(declval<_Tp>(), declval<_Args>()...))
1837227825Stheraven             >::type
1838227825Stheraven    {};
1839227825Stheraven
1840227825Stheraven//      function types are not constructible
1841227825Stheraven
1842232950Stheraventemplate <class _Rp, class... _A1, class... _A2>
1843232950Stheravenstruct __is_constructible<false, _Rp(_A1...), _A2...>
1844227825Stheraven    : public false_type
1845227825Stheraven    {};
1846227825Stheraven
1847227825Stheraven//      handle scalars and reference types
1848227825Stheraven
1849227825Stheraven//      Scalars are default constructible, references are not
1850227825Stheraven
1851227825Stheraventemplate <class _Tp>
1852227825Stheravenstruct __is_constructible<true, _Tp>
1853227825Stheraven    : public is_scalar<_Tp>
1854227825Stheraven    {};
1855227825Stheraven
1856227825Stheraven//      Scalars and references are constructible from one arg if that arg is
1857227825Stheraven//          implicitly convertible to the scalar or reference.
1858227825Stheraven
1859227825Stheraventemplate <class _Tp>
1860227825Stheravenstruct __is_constructible_ref
1861227825Stheraven{
1862242945Stheraven    true_type static __lxx(_Tp);
1863242945Stheraven    false_type static __lxx(...);
1864227825Stheraven};
1865227825Stheraven
1866227825Stheraventemplate <class _Tp, class _A0>
1867227825Stheravenstruct __is_constructible<true, _Tp, _A0>
1868227825Stheraven    : public common_type
1869227825Stheraven             <
1870242945Stheraven                 decltype(__is_constructible_ref<_Tp>::__lxx(declval<_A0>()))
1871227825Stheraven             >::type
1872227825Stheraven    {};
1873227825Stheraven
1874227825Stheraven//      Scalars and references are not constructible from multiple args.
1875227825Stheraven
1876227825Stheraventemplate <class _Tp, class _A0, class ..._Args>
1877227825Stheravenstruct __is_constructible<true, _Tp, _A0, _Args...>
1878227825Stheraven    : public false_type
1879227825Stheraven    {};
1880227825Stheraven
1881227825Stheraven//      Treat scalars and reference types separately
1882227825Stheraven
1883227825Stheraventemplate <bool, class _Tp, class... _Args>
1884227825Stheravenstruct __is_constructible_void_check
1885227825Stheraven    : public __is_constructible<is_scalar<_Tp>::value || is_reference<_Tp>::value,
1886227825Stheraven                                _Tp, _Args...>
1887227825Stheraven    {};
1888227825Stheraven
1889227825Stheraven//      If any of T or Args is void, is_constructible should be false
1890227825Stheraven
1891227825Stheraventemplate <class _Tp, class... _Args>
1892227825Stheravenstruct __is_constructible_void_check<true, _Tp, _Args...>
1893227825Stheraven    : public false_type
1894227825Stheraven    {};
1895227825Stheraven
1896227825Stheraventemplate <class ..._Args> struct __contains_void;
1897227825Stheraven
1898227825Stheraventemplate <> struct __contains_void<> : false_type {};
1899227825Stheraven
1900227825Stheraventemplate <class _A0, class ..._Args>
1901227825Stheravenstruct __contains_void<_A0, _Args...>
1902227825Stheraven{
1903227825Stheraven    static const bool value = is_void<_A0>::value ||
1904227825Stheraven                              __contains_void<_Args...>::value;
1905227825Stheraven};
1906227825Stheraven
1907227825Stheraven//      is_constructible entry point
1908227825Stheraven
1909227825Stheraventemplate <class _Tp, class... _Args>
1910249998Sdimstruct _LIBCPP_TYPE_VIS is_constructible
1911227825Stheraven    : public __is_constructible_void_check<__contains_void<_Tp, _Args...>::value
1912227825Stheraven                                        || is_abstract<_Tp>::value,
1913227825Stheraven                                           _Tp, _Args...>
1914227825Stheraven    {};
1915227825Stheraven
1916227825Stheraven//      Array types are default constructible if their element type
1917227825Stheraven//      is default constructible
1918227825Stheraven
1919232950Stheraventemplate <class _Ap, size_t _Np>
1920232950Stheravenstruct __is_constructible<false, _Ap[_Np]>
1921232950Stheraven    : public is_constructible<typename remove_all_extents<_Ap>::type>
1922227825Stheraven    {};
1923227825Stheraven
1924227825Stheraven//      Otherwise array types are not constructible by this syntax
1925227825Stheraven
1926232950Stheraventemplate <class _Ap, size_t _Np, class ..._Args>
1927232950Stheravenstruct __is_constructible<false, _Ap[_Np], _Args...>
1928227825Stheraven    : public false_type
1929227825Stheraven    {};
1930227825Stheraven
1931227825Stheraven//      Incomplete array types are not constructible
1932227825Stheraven
1933232950Stheraventemplate <class _Ap, class ..._Args>
1934232950Stheravenstruct __is_constructible<false, _Ap[], _Args...>
1935227825Stheraven    : public false_type
1936227825Stheraven    {};
1937227825Stheraven
1938227825Stheraven#else  // _LIBCPP_HAS_NO_VARIADICS
1939227825Stheraven
1940227825Stheraven// template <class T> struct is_constructible0;
1941227825Stheraven
1942227825Stheraven//      main is_constructible0 test
1943227825Stheraven
1944227825Stheraventemplate <class _Tp>
1945227825Stheravendecltype((_Tp(), true_type()))
1946227825Stheraven__is_constructible0_test(_Tp&);
1947227825Stheraven
1948227825Stheravenfalse_type
1949227825Stheraven__is_constructible0_test(__any);
1950227825Stheraven
1951227825Stheraventemplate <class _Tp, class _A0>
1952227825Stheravendecltype((_Tp(_VSTD::declval<_A0>()), true_type()))
1953227825Stheraven__is_constructible1_test(_Tp&, _A0&);
1954227825Stheraven
1955227825Stheraventemplate <class _A0>
1956227825Stheravenfalse_type
1957227825Stheraven__is_constructible1_test(__any, _A0&);
1958227825Stheraven
1959227825Stheraventemplate <class _Tp, class _A0, class _A1>
1960227825Stheravendecltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>()), true_type()))
1961227825Stheraven__is_constructible2_test(_Tp&, _A0&, _A1&);
1962227825Stheraven
1963227825Stheraventemplate <class _A0, class _A1>
1964227825Stheravenfalse_type
1965227825Stheraven__is_constructible2_test(__any, _A0&, _A1&);
1966227825Stheraven
1967227825Stheraventemplate <bool, class _Tp>
1968227825Stheravenstruct __is_constructible0_imp // false, _Tp is not a scalar
1969227825Stheraven    : public common_type
1970227825Stheraven             <
1971227825Stheraven                 decltype(__is_constructible0_test(declval<_Tp&>()))
1972227825Stheraven             >::type
1973227825Stheraven    {};
1974227825Stheraven
1975227825Stheraventemplate <bool, class _Tp, class _A0>
1976227825Stheravenstruct __is_constructible1_imp // false, _Tp is not a scalar
1977227825Stheraven    : public common_type
1978227825Stheraven             <
1979227825Stheraven                 decltype(__is_constructible1_test(declval<_Tp&>(), declval<_A0&>()))
1980227825Stheraven             >::type
1981227825Stheraven    {};
1982227825Stheraven
1983227825Stheraventemplate <bool, class _Tp, class _A0, class _A1>
1984227825Stheravenstruct __is_constructible2_imp // false, _Tp is not a scalar
1985227825Stheraven    : public common_type
1986227825Stheraven             <
1987227825Stheraven                 decltype(__is_constructible2_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>()))
1988227825Stheraven             >::type
1989227825Stheraven    {};
1990227825Stheraven
1991227825Stheraven//      handle scalars and reference types
1992227825Stheraven
1993227825Stheraven//      Scalars are default constructible, references are not
1994227825Stheraven
1995227825Stheraventemplate <class _Tp>
1996227825Stheravenstruct __is_constructible0_imp<true, _Tp>
1997227825Stheraven    : public is_scalar<_Tp>
1998227825Stheraven    {};
1999227825Stheraven
2000227825Stheraventemplate <class _Tp, class _A0>
2001227825Stheravenstruct __is_constructible1_imp<true, _Tp, _A0>
2002227825Stheraven    : public is_convertible<_A0, _Tp>
2003227825Stheraven    {};
2004227825Stheraven
2005227825Stheraventemplate <class _Tp, class _A0, class _A1>
2006227825Stheravenstruct __is_constructible2_imp<true, _Tp, _A0, _A1>
2007227825Stheraven    : public false_type
2008227825Stheraven    {};
2009227825Stheraven
2010227825Stheraven//      Treat scalars and reference types separately
2011227825Stheraven
2012227825Stheraventemplate <bool, class _Tp>
2013227825Stheravenstruct __is_constructible0_void_check
2014227825Stheraven    : public __is_constructible0_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2015227825Stheraven                                _Tp>
2016227825Stheraven    {};
2017227825Stheraven
2018227825Stheraventemplate <bool, class _Tp, class _A0>
2019227825Stheravenstruct __is_constructible1_void_check
2020227825Stheraven    : public __is_constructible1_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2021227825Stheraven                                _Tp, _A0>
2022227825Stheraven    {};
2023227825Stheraven
2024227825Stheraventemplate <bool, class _Tp, class _A0, class _A1>
2025227825Stheravenstruct __is_constructible2_void_check
2026227825Stheraven    : public __is_constructible2_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2027227825Stheraven                                _Tp, _A0, _A1>
2028227825Stheraven    {};
2029227825Stheraven
2030227825Stheraven//      If any of T or Args is void, is_constructible should be false
2031227825Stheraven
2032227825Stheraventemplate <class _Tp>
2033227825Stheravenstruct __is_constructible0_void_check<true, _Tp>
2034227825Stheraven    : public false_type
2035227825Stheraven    {};
2036227825Stheraven
2037227825Stheraventemplate <class _Tp, class _A0>
2038227825Stheravenstruct __is_constructible1_void_check<true, _Tp, _A0>
2039227825Stheraven    : public false_type
2040227825Stheraven    {};
2041227825Stheraven
2042227825Stheraventemplate <class _Tp, class _A0, class _A1>
2043227825Stheravenstruct __is_constructible2_void_check<true, _Tp, _A0, _A1>
2044227825Stheraven    : public false_type
2045227825Stheraven    {};
2046227825Stheraven
2047227825Stheraven//      is_constructible entry point
2048227825Stheraven
2049227825Stheravennamespace __is_construct
2050227825Stheraven{
2051227825Stheraven
2052227825Stheravenstruct __nat {};
2053227825Stheraven
2054227825Stheraven}
2055227825Stheraven
2056227825Stheraventemplate <class _Tp, class _A0 = __is_construct::__nat,
2057227825Stheraven                     class _A1 = __is_construct::__nat>
2058249998Sdimstruct _LIBCPP_TYPE_VIS is_constructible
2059227825Stheraven    : public __is_constructible2_void_check<is_void<_Tp>::value
2060227825Stheraven                                        || is_abstract<_Tp>::value
2061227825Stheraven                                        || is_function<_Tp>::value
2062227825Stheraven                                        || is_void<_A0>::value
2063227825Stheraven                                        || is_void<_A1>::value,
2064227825Stheraven                                           _Tp, _A0, _A1>
2065227825Stheraven    {};
2066227825Stheraven
2067227825Stheraventemplate <class _Tp>
2068249998Sdimstruct _LIBCPP_TYPE_VIS is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat>
2069227825Stheraven    : public __is_constructible0_void_check<is_void<_Tp>::value
2070227825Stheraven                                        || is_abstract<_Tp>::value
2071227825Stheraven                                        || is_function<_Tp>::value,
2072227825Stheraven                                           _Tp>
2073227825Stheraven    {};
2074227825Stheraven
2075227825Stheraventemplate <class _Tp, class _A0>
2076249998Sdimstruct _LIBCPP_TYPE_VIS is_constructible<_Tp, _A0, __is_construct::__nat>
2077227825Stheraven    : public __is_constructible1_void_check<is_void<_Tp>::value
2078227825Stheraven                                        || is_abstract<_Tp>::value
2079227825Stheraven                                        || is_function<_Tp>::value
2080227825Stheraven                                        || is_void<_A0>::value,
2081227825Stheraven                                           _Tp, _A0>
2082227825Stheraven    {};
2083227825Stheraven
2084227825Stheraven//      Array types are default constructible if their element type
2085227825Stheraven//      is default constructible
2086227825Stheraven
2087232950Stheraventemplate <class _Ap, size_t _Np>
2088232950Stheravenstruct __is_constructible0_imp<false, _Ap[_Np]>
2089232950Stheraven    : public is_constructible<typename remove_all_extents<_Ap>::type>
2090227825Stheraven    {};
2091227825Stheraven
2092232950Stheraventemplate <class _Ap, size_t _Np, class _A0>
2093232950Stheravenstruct __is_constructible1_imp<false, _Ap[_Np], _A0>
2094227825Stheraven    : public false_type
2095227825Stheraven    {};
2096227825Stheraven
2097232950Stheraventemplate <class _Ap, size_t _Np, class _A0, class _A1>
2098232950Stheravenstruct __is_constructible2_imp<false, _Ap[_Np], _A0, _A1>
2099227825Stheraven    : public false_type
2100227825Stheraven    {};
2101227825Stheraven
2102227825Stheraven//      Incomplete array types are not constructible
2103227825Stheraven
2104232950Stheraventemplate <class _Ap>
2105232950Stheravenstruct __is_constructible0_imp<false, _Ap[]>
2106227825Stheraven    : public false_type
2107227825Stheraven    {};
2108227825Stheraven
2109232950Stheraventemplate <class _Ap, class _A0>
2110232950Stheravenstruct __is_constructible1_imp<false, _Ap[], _A0>
2111227825Stheraven    : public false_type
2112227825Stheraven    {};
2113227825Stheraven
2114232950Stheraventemplate <class _Ap, class _A0, class _A1>
2115232950Stheravenstruct __is_constructible2_imp<false, _Ap[], _A0, _A1>
2116227825Stheraven    : public false_type
2117227825Stheraven    {};
2118227825Stheraven
2119227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
2120227825Stheraven
2121227825Stheraven// is_default_constructible
2122227825Stheraven
2123227825Stheraventemplate <class _Tp>
2124249998Sdimstruct _LIBCPP_TYPE_VIS is_default_constructible
2125227825Stheraven    : public is_constructible<_Tp>
2126227825Stheraven    {};
2127227825Stheraven
2128227825Stheraven// is_copy_constructible
2129227825Stheraven
2130227825Stheraventemplate <class _Tp>
2131249998Sdimstruct _LIBCPP_TYPE_VIS is_copy_constructible
2132227825Stheraven    : public is_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type>
2133227825Stheraven    {};
2134227825Stheraven
2135227825Stheraven// is_move_constructible
2136227825Stheraven
2137227825Stheraventemplate <class _Tp>
2138249998Sdimstruct _LIBCPP_TYPE_VIS is_move_constructible
2139227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2140227825Stheraven    : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2141227825Stheraven#else
2142227825Stheraven    : public is_copy_constructible<_Tp>
2143227825Stheraven#endif
2144227825Stheraven    {};
2145227825Stheraven
2146227825Stheraven// is_trivially_constructible
2147227825Stheraven
2148227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
2149227825Stheraven
2150232950Stheraven#if __has_feature(is_trivially_constructible)
2151232950Stheraven
2152227825Stheraventemplate <class _Tp, class... _Args>
2153249998Sdimstruct _LIBCPP_TYPE_VIS is_trivially_constructible
2154232950Stheraven    : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
2155232950Stheraven{
2156232950Stheraven};
2157232950Stheraven
2158232950Stheraven#else  // !__has_feature(is_trivially_constructible)
2159232950Stheraven
2160232950Stheraventemplate <class _Tp, class... _Args>
2161249998Sdimstruct _LIBCPP_TYPE_VIS is_trivially_constructible
2162227825Stheraven    : false_type
2163227825Stheraven{
2164227825Stheraven};
2165227825Stheraven
2166227825Stheraventemplate <class _Tp>
2167249998Sdimstruct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp>
2168227825Stheraven#if __has_feature(has_trivial_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2169227825Stheraven    : integral_constant<bool, __has_trivial_constructor(_Tp)>
2170227825Stheraven#else
2171227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2172227825Stheraven#endif
2173227825Stheraven{
2174227825Stheraven};
2175227825Stheraven
2176227825Stheraventemplate <class _Tp>
2177227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2178249998Sdimstruct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, _Tp&&>
2179227825Stheraven#else
2180249998Sdimstruct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, _Tp>
2181227825Stheraven#endif
2182227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2183227825Stheraven{
2184227825Stheraven};
2185227825Stheraven
2186227825Stheraventemplate <class _Tp>
2187249998Sdimstruct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, const _Tp&>
2188227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2189227825Stheraven{
2190227825Stheraven};
2191227825Stheraven
2192227825Stheraventemplate <class _Tp>
2193249998Sdimstruct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, _Tp&>
2194227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2195227825Stheraven{
2196227825Stheraven};
2197227825Stheraven
2198232950Stheraven#endif  // !__has_feature(is_trivially_constructible)
2199232950Stheraven
2200227825Stheraven#else  // _LIBCPP_HAS_NO_VARIADICS
2201227825Stheraven
2202227825Stheraventemplate <class _Tp, class _A0 = __is_construct::__nat,
2203227825Stheraven                     class _A1 = __is_construct::__nat>
2204249998Sdimstruct _LIBCPP_TYPE_VIS is_trivially_constructible
2205227825Stheraven    : false_type
2206227825Stheraven{
2207227825Stheraven};
2208227825Stheraven
2209232950Stheraven#if __has_feature(is_trivially_constructible)
2210232950Stheraven
2211227825Stheraventemplate <class _Tp>
2212249998Sdimstruct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, __is_construct::__nat,
2213227825Stheraven                                                       __is_construct::__nat>
2214232950Stheraven    : integral_constant<bool, __is_trivially_constructible(_Tp)>
2215232950Stheraven{
2216232950Stheraven};
2217232950Stheraven
2218232950Stheraventemplate <class _Tp>
2219249998Sdimstruct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, _Tp,
2220232950Stheraven                                                       __is_construct::__nat>
2221232950Stheraven    : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp)>
2222232950Stheraven{
2223232950Stheraven};
2224232950Stheraven
2225232950Stheraventemplate <class _Tp>
2226249998Sdimstruct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, const _Tp&,
2227232950Stheraven                                                       __is_construct::__nat>
2228232950Stheraven    : integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)>
2229232950Stheraven{
2230232950Stheraven};
2231232950Stheraven
2232232950Stheraventemplate <class _Tp>
2233249998Sdimstruct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, _Tp&,
2234232950Stheraven                                                       __is_construct::__nat>
2235232950Stheraven    : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&)>
2236232950Stheraven{
2237232950Stheraven};
2238232950Stheraven
2239232950Stheraven#else  // !__has_feature(is_trivially_constructible)
2240232950Stheraven
2241232950Stheraventemplate <class _Tp>
2242249998Sdimstruct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, __is_construct::__nat,
2243232950Stheraven                                                       __is_construct::__nat>
2244227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2245227825Stheraven{
2246227825Stheraven};
2247227825Stheraven
2248227825Stheraventemplate <class _Tp>
2249249998Sdimstruct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, _Tp,
2250227825Stheraven                                                       __is_construct::__nat>
2251227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2252227825Stheraven{
2253227825Stheraven};
2254227825Stheraven
2255227825Stheraventemplate <class _Tp>
2256249998Sdimstruct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, const _Tp&,
2257227825Stheraven                                                       __is_construct::__nat>
2258227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2259227825Stheraven{
2260227825Stheraven};
2261227825Stheraven
2262227825Stheraventemplate <class _Tp>
2263249998Sdimstruct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, _Tp&,
2264227825Stheraven                                                       __is_construct::__nat>
2265227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2266227825Stheraven{
2267227825Stheraven};
2268227825Stheraven
2269232950Stheraven#endif  // !__has_feature(is_trivially_constructible)
2270232950Stheraven
2271227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
2272227825Stheraven
2273227825Stheraven// is_trivially_default_constructible
2274227825Stheraven
2275249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_trivially_default_constructible
2276227825Stheraven    : public is_trivially_constructible<_Tp>
2277227825Stheraven    {};
2278227825Stheraven
2279227825Stheraven// is_trivially_copy_constructible
2280227825Stheraven
2281249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_trivially_copy_constructible
2282227825Stheraven    : public is_trivially_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type>
2283227825Stheraven    {};
2284227825Stheraven
2285227825Stheraven// is_trivially_move_constructible
2286227825Stheraven
2287249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_trivially_move_constructible
2288227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2289227825Stheraven    : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2290227825Stheraven#else
2291227825Stheraven    : public is_trivially_copy_constructible<_Tp>
2292227825Stheraven#endif
2293227825Stheraven    {};
2294227825Stheraven
2295227825Stheraven// is_trivially_assignable
2296227825Stheraven
2297232950Stheraven#if __has_feature(is_trivially_constructible)
2298232950Stheraven
2299227825Stheraventemplate <class _Tp, class _Arg>
2300227825Stheravenstruct is_trivially_assignable
2301232950Stheraven    : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
2302232950Stheraven{
2303232950Stheraven};
2304232950Stheraven
2305232950Stheraven#else  // !__has_feature(is_trivially_constructible)
2306232950Stheraven
2307232950Stheraventemplate <class _Tp, class _Arg>
2308232950Stheravenstruct is_trivially_assignable
2309227825Stheraven    : public false_type {};
2310227825Stheraven
2311227825Stheraventemplate <class _Tp>
2312227825Stheravenstruct is_trivially_assignable<_Tp&, _Tp>
2313227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2314227825Stheraven
2315227825Stheraventemplate <class _Tp>
2316227825Stheravenstruct is_trivially_assignable<_Tp&, _Tp&>
2317227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2318227825Stheraven
2319227825Stheraventemplate <class _Tp>
2320227825Stheravenstruct is_trivially_assignable<_Tp&, const _Tp&>
2321227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2322227825Stheraven
2323227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2324227825Stheraven
2325227825Stheraventemplate <class _Tp>
2326227825Stheravenstruct is_trivially_assignable<_Tp&, _Tp&&>
2327227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2328227825Stheraven
2329227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2330227825Stheraven
2331232950Stheraven#endif  // !__has_feature(is_trivially_constructible)
2332232950Stheraven
2333227825Stheraven// is_trivially_copy_assignable
2334227825Stheraven
2335249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_trivially_copy_assignable
2336227825Stheraven    : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
2337227825Stheraven                               const typename add_lvalue_reference<_Tp>::type>
2338227825Stheraven    {};
2339227825Stheraven
2340227825Stheraven// is_trivially_move_assignable
2341227825Stheraven
2342249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_trivially_move_assignable
2343227825Stheraven    : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
2344227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2345227825Stheraven                                     typename add_rvalue_reference<_Tp>::type>
2346227825Stheraven#else
2347227825Stheraven                                     typename add_lvalue_reference<_Tp>::type>
2348227825Stheraven#endif
2349227825Stheraven    {};
2350227825Stheraven
2351227825Stheraven// is_trivially_destructible
2352227825Stheraven
2353227825Stheraven#if __has_feature(has_trivial_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2354227825Stheraven
2355249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_trivially_destructible
2356227825Stheraven    : public integral_constant<bool, __has_trivial_destructor(_Tp)> {};
2357227825Stheraven
2358227825Stheraven#else  // _LIBCPP_HAS_TYPE_TRAITS
2359227825Stheraven
2360227825Stheraventemplate <class _Tp> struct __libcpp_trivial_destructor
2361227825Stheraven    : public integral_constant<bool, is_scalar<_Tp>::value ||
2362227825Stheraven                                     is_reference<_Tp>::value> {};
2363227825Stheraven
2364249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_trivially_destructible
2365227825Stheraven    : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
2366227825Stheraven
2367227825Stheraven#endif  // _LIBCPP_HAS_TYPE_TRAITS
2368227825Stheraven
2369227825Stheraven// is_nothrow_constructible
2370227825Stheraven
2371227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
2372227825Stheraven
2373227825Stheraven#if __has_feature(cxx_noexcept)
2374227825Stheraven
2375227825Stheraventemplate <bool, class _Tp, class... _Args> struct __is_nothrow_constructible;
2376227825Stheraven
2377227825Stheraventemplate <class _Tp, class... _Args>
2378227825Stheravenstruct __is_nothrow_constructible<true, _Tp, _Args...>
2379227825Stheraven    : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
2380227825Stheraven{
2381227825Stheraven};
2382227825Stheraven
2383227825Stheraventemplate <class _Tp, class... _Args>
2384227825Stheravenstruct __is_nothrow_constructible<false, _Tp, _Args...>
2385227825Stheraven    : public false_type
2386227825Stheraven{
2387227825Stheraven};
2388227825Stheraven
2389227825Stheraventemplate <class _Tp, class... _Args>
2390249998Sdimstruct _LIBCPP_TYPE_VIS is_nothrow_constructible
2391227825Stheraven    : __is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, _Tp, _Args...>
2392227825Stheraven{
2393227825Stheraven};
2394227825Stheraven
2395227825Stheraventemplate <class _Tp, size_t _Ns>
2396249998Sdimstruct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp[_Ns]>
2397227825Stheraven    : __is_nothrow_constructible<is_constructible<_Tp>::value, _Tp>
2398227825Stheraven{
2399227825Stheraven};
2400227825Stheraven
2401227825Stheraven#else  // __has_feature(cxx_noexcept)
2402227825Stheraven
2403227825Stheraventemplate <class _Tp, class... _Args>
2404249998Sdimstruct _LIBCPP_TYPE_VIS is_nothrow_constructible
2405227825Stheraven    : false_type
2406227825Stheraven{
2407227825Stheraven};
2408227825Stheraven
2409227825Stheraventemplate <class _Tp>
2410249998Sdimstruct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp>
2411227825Stheraven#if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2412227825Stheraven    : integral_constant<bool, __has_nothrow_constructor(_Tp)>
2413227825Stheraven#else
2414227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2415227825Stheraven#endif
2416227825Stheraven{
2417227825Stheraven};
2418227825Stheraven
2419227825Stheraventemplate <class _Tp>
2420227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2421249998Sdimstruct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, _Tp&&>
2422227825Stheraven#else
2423249998Sdimstruct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, _Tp>
2424227825Stheraven#endif
2425227825Stheraven#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2426227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
2427227825Stheraven#else
2428227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2429227825Stheraven#endif
2430227825Stheraven{
2431227825Stheraven};
2432227825Stheraven
2433227825Stheraventemplate <class _Tp>
2434249998Sdimstruct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, const _Tp&>
2435227825Stheraven#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2436227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
2437227825Stheraven#else
2438227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2439227825Stheraven#endif
2440227825Stheraven{
2441227825Stheraven};
2442227825Stheraven
2443227825Stheraventemplate <class _Tp>
2444249998Sdimstruct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, _Tp&>
2445227825Stheraven#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2446227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
2447227825Stheraven#else
2448227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2449227825Stheraven#endif
2450227825Stheraven{
2451227825Stheraven};
2452227825Stheraven
2453227825Stheraven#endif  // __has_feature(cxx_noexcept)
2454227825Stheraven
2455227825Stheraven#else  // _LIBCPP_HAS_NO_VARIADICS
2456227825Stheraven
2457227825Stheraventemplate <class _Tp, class _A0 = __is_construct::__nat,
2458227825Stheraven                     class _A1 = __is_construct::__nat>
2459249998Sdimstruct _LIBCPP_TYPE_VIS is_nothrow_constructible
2460227825Stheraven    : false_type
2461227825Stheraven{
2462227825Stheraven};
2463227825Stheraven
2464227825Stheraventemplate <class _Tp>
2465249998Sdimstruct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, __is_construct::__nat,
2466227825Stheraven                                                       __is_construct::__nat>
2467227825Stheraven#if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2468227825Stheraven    : integral_constant<bool, __has_nothrow_constructor(_Tp)>
2469227825Stheraven#else
2470227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2471227825Stheraven#endif
2472227825Stheraven{
2473227825Stheraven};
2474227825Stheraven
2475227825Stheraventemplate <class _Tp>
2476249998Sdimstruct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, _Tp,
2477227825Stheraven                                                       __is_construct::__nat>
2478227825Stheraven#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2479227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
2480227825Stheraven#else
2481227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2482227825Stheraven#endif
2483227825Stheraven{
2484227825Stheraven};
2485227825Stheraven
2486227825Stheraventemplate <class _Tp>
2487249998Sdimstruct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, const _Tp&,
2488227825Stheraven                                                       __is_construct::__nat>
2489227825Stheraven#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2490227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
2491227825Stheraven#else
2492227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2493227825Stheraven#endif
2494227825Stheraven{
2495227825Stheraven};
2496227825Stheraven
2497227825Stheraventemplate <class _Tp>
2498249998Sdimstruct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, _Tp&,
2499227825Stheraven                                                       __is_construct::__nat>
2500227825Stheraven#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2501227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
2502227825Stheraven#else
2503227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2504227825Stheraven#endif
2505227825Stheraven{
2506227825Stheraven};
2507227825Stheraven
2508227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
2509227825Stheraven
2510227825Stheraven// is_nothrow_default_constructible
2511227825Stheraven
2512249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_nothrow_default_constructible
2513227825Stheraven    : public is_nothrow_constructible<_Tp>
2514227825Stheraven    {};
2515227825Stheraven
2516227825Stheraven// is_nothrow_copy_constructible
2517227825Stheraven
2518249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_nothrow_copy_constructible
2519227825Stheraven    : public is_nothrow_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type>
2520227825Stheraven    {};
2521227825Stheraven
2522227825Stheraven// is_nothrow_move_constructible
2523227825Stheraven
2524249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_nothrow_move_constructible
2525227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2526227825Stheraven    : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2527227825Stheraven#else
2528227825Stheraven    : public is_nothrow_copy_constructible<_Tp>
2529227825Stheraven#endif
2530227825Stheraven    {};
2531227825Stheraven
2532227825Stheraven// is_nothrow_assignable
2533227825Stheraven
2534227825Stheraven#if __has_feature(cxx_noexcept)
2535227825Stheraven
2536227825Stheraventemplate <bool, class _Tp, class _Arg> struct __is_nothrow_assignable;
2537227825Stheraven
2538227825Stheraventemplate <class _Tp, class _Arg>
2539227825Stheravenstruct __is_nothrow_assignable<false, _Tp, _Arg>
2540227825Stheraven    : public false_type
2541227825Stheraven{
2542227825Stheraven};
2543227825Stheraven
2544227825Stheraventemplate <class _Tp, class _Arg>
2545227825Stheravenstruct __is_nothrow_assignable<true, _Tp, _Arg>
2546227825Stheraven    : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) >
2547227825Stheraven{
2548227825Stheraven};
2549227825Stheraven
2550227825Stheraventemplate <class _Tp, class _Arg>
2551249998Sdimstruct _LIBCPP_TYPE_VIS is_nothrow_assignable
2552227825Stheraven    : public __is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
2553227825Stheraven{
2554227825Stheraven};
2555227825Stheraven
2556227825Stheraven#else  // __has_feature(cxx_noexcept)
2557227825Stheraven
2558227825Stheraventemplate <class _Tp, class _Arg>
2559249998Sdimstruct _LIBCPP_TYPE_VIS is_nothrow_assignable
2560227825Stheraven    : public false_type {};
2561227825Stheraven
2562227825Stheraventemplate <class _Tp>
2563249998Sdimstruct _LIBCPP_TYPE_VIS is_nothrow_assignable<_Tp&, _Tp>
2564227825Stheraven#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2565227825Stheraven    : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
2566227825Stheraven#else
2567227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2568227825Stheraven#endif
2569227825Stheraven
2570227825Stheraventemplate <class _Tp>
2571249998Sdimstruct _LIBCPP_TYPE_VIS is_nothrow_assignable<_Tp&, _Tp&>
2572227825Stheraven#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2573227825Stheraven    : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
2574227825Stheraven#else
2575227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2576227825Stheraven#endif
2577227825Stheraven
2578227825Stheraventemplate <class _Tp>
2579249998Sdimstruct _LIBCPP_TYPE_VIS is_nothrow_assignable<_Tp&, const _Tp&>
2580227825Stheraven#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2581227825Stheraven    : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
2582227825Stheraven#else
2583227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2584227825Stheraven#endif
2585227825Stheraven
2586227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2587227825Stheraven
2588227825Stheraventemplate <class _Tp>
2589227825Stheravenstruct 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
2596227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2597227825Stheraven
2598227825Stheraven#endif  // __has_feature(cxx_noexcept)
2599227825Stheraven
2600227825Stheraven// is_nothrow_copy_assignable
2601227825Stheraven
2602249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_nothrow_copy_assignable
2603227825Stheraven    : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
2604227825Stheraven                               const typename add_lvalue_reference<_Tp>::type>
2605227825Stheraven    {};
2606227825Stheraven
2607227825Stheraven// is_nothrow_move_assignable
2608227825Stheraven
2609249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_nothrow_move_assignable
2610227825Stheraven    : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
2611227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2612227825Stheraven                                     typename add_rvalue_reference<_Tp>::type>
2613227825Stheraven#else
2614227825Stheraven                                     typename add_lvalue_reference<_Tp>::type>
2615227825Stheraven#endif
2616227825Stheraven    {};
2617227825Stheraven
2618227825Stheraven// is_nothrow_destructible
2619227825Stheraven
2620227825Stheraven#if __has_feature(cxx_noexcept)
2621227825Stheraven
2622227825Stheraventemplate <bool, class _Tp> struct __is_nothrow_destructible;
2623227825Stheraven
2624227825Stheraventemplate <class _Tp>
2625227825Stheravenstruct __is_nothrow_destructible<false, _Tp>
2626227825Stheraven    : public false_type
2627227825Stheraven{
2628227825Stheraven};
2629227825Stheraven
2630227825Stheraventemplate <class _Tp>
2631227825Stheravenstruct __is_nothrow_destructible<true, _Tp>
2632227825Stheraven    : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) >
2633227825Stheraven{
2634227825Stheraven};
2635227825Stheraven
2636227825Stheraventemplate <class _Tp>
2637249998Sdimstruct _LIBCPP_TYPE_VIS is_nothrow_destructible
2638227825Stheraven    : public __is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
2639227825Stheraven{
2640227825Stheraven};
2641227825Stheraven
2642227825Stheraventemplate <class _Tp, size_t _Ns>
2643249998Sdimstruct _LIBCPP_TYPE_VIS is_nothrow_destructible<_Tp[_Ns]>
2644227825Stheraven    : public is_nothrow_destructible<_Tp>
2645227825Stheraven{
2646227825Stheraven};
2647227825Stheraven
2648227825Stheraventemplate <class _Tp>
2649249998Sdimstruct _LIBCPP_TYPE_VIS is_nothrow_destructible<_Tp&>
2650227825Stheraven    : public true_type
2651227825Stheraven{
2652227825Stheraven};
2653227825Stheraven
2654227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2655227825Stheraven
2656227825Stheraventemplate <class _Tp>
2657249998Sdimstruct _LIBCPP_TYPE_VIS is_nothrow_destructible<_Tp&&>
2658227825Stheraven    : public true_type
2659227825Stheraven{
2660227825Stheraven};
2661227825Stheraven
2662227825Stheraven#endif
2663227825Stheraven
2664227825Stheraven#else
2665227825Stheraven
2666227825Stheraventemplate <class _Tp> struct __libcpp_nothrow_destructor
2667227825Stheraven    : public integral_constant<bool, is_scalar<_Tp>::value ||
2668227825Stheraven                                     is_reference<_Tp>::value> {};
2669227825Stheraven
2670249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_nothrow_destructible
2671227825Stheraven    : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
2672227825Stheraven
2673227825Stheraven#endif
2674227825Stheraven
2675227825Stheraven// is_pod
2676227825Stheraven
2677227825Stheraven#if __has_feature(is_pod) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2678227825Stheraven
2679249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_pod
2680227825Stheraven    : public integral_constant<bool, __is_pod(_Tp)> {};
2681227825Stheraven
2682227825Stheraven#else  // _LIBCPP_HAS_TYPE_TRAITS
2683227825Stheraven
2684249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_pod
2685227825Stheraven    : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value   &&
2686227825Stheraven                                     is_trivially_copy_constructible<_Tp>::value      &&
2687227825Stheraven                                     is_trivially_copy_assignable<_Tp>::value    &&
2688227825Stheraven                                     is_trivially_destructible<_Tp>::value> {};
2689227825Stheraven
2690227825Stheraven#endif  // _LIBCPP_HAS_TYPE_TRAITS
2691227825Stheraven
2692227825Stheraven// is_literal_type;
2693227825Stheraven
2694249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_literal_type
2695227825Stheraven#if __has_feature(is_literal)
2696227825Stheraven    : public integral_constant<bool, __is_literal(_Tp)>
2697227825Stheraven#else
2698227825Stheraven    : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value ||
2699227825Stheraven                              is_reference<typename remove_all_extents<_Tp>::type>::value>
2700227825Stheraven#endif
2701227825Stheraven    {};
2702227825Stheraven    
2703227825Stheraven// is_standard_layout;
2704227825Stheraven
2705249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_standard_layout
2706227825Stheraven#if __has_feature(is_standard_layout)
2707227825Stheraven    : public integral_constant<bool, __is_standard_layout(_Tp)>
2708227825Stheraven#else
2709227825Stheraven    : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
2710227825Stheraven#endif
2711227825Stheraven    {};
2712227825Stheraven    
2713227825Stheraven// is_trivially_copyable;
2714227825Stheraven
2715249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_trivially_copyable
2716227825Stheraven#if __has_feature(is_trivially_copyable)
2717227825Stheraven    : public integral_constant<bool, __is_trivially_copyable(_Tp)>
2718227825Stheraven#else
2719227825Stheraven    : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
2720227825Stheraven#endif
2721227825Stheraven    {};
2722227825Stheraven    
2723227825Stheraven// is_trivial;
2724227825Stheraven
2725249998Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS is_trivial
2726227825Stheraven#if __has_feature(is_trivial)
2727227825Stheraven    : public integral_constant<bool, __is_trivial(_Tp)>
2728227825Stheraven#else
2729227825Stheraven    : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
2730227825Stheraven                                 is_trivially_default_constructible<_Tp>::value>
2731227825Stheraven#endif
2732227825Stheraven    {};
2733227825Stheraven
2734227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
2735227825Stheraven
2736227825Stheraven// Check for complete types
2737227825Stheraven
2738232950Stheraventemplate <class ..._Tp> struct __check_complete;
2739227825Stheraven
2740227825Stheraventemplate <>
2741227825Stheravenstruct __check_complete<>
2742227825Stheraven{
2743227825Stheraven};
2744227825Stheraven
2745232950Stheraventemplate <class _Hp, class _T0, class ..._Tp>
2746232950Stheravenstruct __check_complete<_Hp, _T0, _Tp...>
2747232950Stheraven    : private __check_complete<_Hp>,
2748232950Stheraven      private __check_complete<_T0, _Tp...>
2749227825Stheraven{
2750227825Stheraven};
2751227825Stheraven
2752232950Stheraventemplate <class _Hp>
2753232950Stheravenstruct __check_complete<_Hp, _Hp>
2754232950Stheraven    : private __check_complete<_Hp>
2755227825Stheraven{
2756227825Stheraven};
2757227825Stheraven
2758232950Stheraventemplate <class _Tp>
2759232950Stheravenstruct __check_complete<_Tp>
2760227825Stheraven{
2761232950Stheraven    static_assert(sizeof(_Tp) > 0, "Type must be complete.");
2762227825Stheraven};
2763227825Stheraven
2764232950Stheraventemplate <class _Tp>
2765232950Stheravenstruct __check_complete<_Tp&>
2766232950Stheraven    : private __check_complete<_Tp>
2767227825Stheraven{
2768227825Stheraven};
2769227825Stheraven
2770232950Stheraventemplate <class _Tp>
2771232950Stheravenstruct __check_complete<_Tp&&>
2772232950Stheraven    : private __check_complete<_Tp>
2773227825Stheraven{
2774227825Stheraven};
2775227825Stheraven
2776232950Stheraventemplate <class _Rp, class ..._Param>
2777232950Stheravenstruct __check_complete<_Rp (*)(_Param...)>
2778241903Sdim    : private __check_complete<_Rp>
2779227825Stheraven{
2780227825Stheraven};
2781227825Stheraven
2782232950Stheraventemplate <class _Rp, class ..._Param>
2783232950Stheravenstruct __check_complete<_Rp (_Param...)>
2784241903Sdim    : private __check_complete<_Rp>
2785227825Stheraven{
2786227825Stheraven};
2787227825Stheraven
2788232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2789232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...)>
2790241903Sdim    : private __check_complete<_Class>
2791227825Stheraven{
2792227825Stheraven};
2793227825Stheraven
2794232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2795232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) const>
2796241903Sdim    : private __check_complete<_Class>
2797227825Stheraven{
2798227825Stheraven};
2799227825Stheraven
2800232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2801232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) volatile>
2802241903Sdim    : private __check_complete<_Class>
2803227825Stheraven{
2804227825Stheraven};
2805227825Stheraven
2806232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2807232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) const volatile>
2808241903Sdim    : private __check_complete<_Class>
2809227825Stheraven{
2810227825Stheraven};
2811227825Stheraven
2812227825Stheraven#if __has_feature(cxx_reference_qualified_functions)
2813227825Stheraven
2814232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2815232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) &>
2816241903Sdim    : private __check_complete<_Class>
2817227825Stheraven{
2818227825Stheraven};
2819227825Stheraven
2820232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2821232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) const&>
2822241903Sdim    : private __check_complete<_Class>
2823227825Stheraven{
2824227825Stheraven};
2825227825Stheraven
2826232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2827232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) volatile&>
2828241903Sdim    : private __check_complete<_Class>
2829227825Stheraven{
2830227825Stheraven};
2831227825Stheraven
2832232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2833232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) const volatile&>
2834241903Sdim    : private __check_complete<_Class>
2835227825Stheraven{
2836227825Stheraven};
2837227825Stheraven
2838232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2839232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) &&>
2840241903Sdim    : private __check_complete<_Class>
2841227825Stheraven{
2842227825Stheraven};
2843227825Stheraven
2844232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2845232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) const&&>
2846241903Sdim    : private __check_complete<_Class>
2847227825Stheraven{
2848227825Stheraven};
2849227825Stheraven
2850232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2851232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) volatile&&>
2852241903Sdim    : private __check_complete<_Class>
2853227825Stheraven{
2854227825Stheraven};
2855227825Stheraven
2856232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2857232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) const volatile&&>
2858241903Sdim    : private __check_complete<_Class>
2859227825Stheraven{
2860227825Stheraven};
2861227825Stheraven
2862227825Stheraven#endif
2863227825Stheraven
2864232950Stheraventemplate <class _Rp, class _Class>
2865232950Stheravenstruct __check_complete<_Rp _Class::*>
2866227825Stheraven    : private __check_complete<_Class>
2867227825Stheraven{
2868227825Stheraven};
2869227825Stheraven
2870227825Stheraven// __invoke forward declarations
2871227825Stheraven
2872227825Stheraven// fall back - none of the bullets
2873227825Stheraven
2874227825Stheraventemplate <class ..._Args>
2875227825Stheravenauto
2876227825Stheraven__invoke(__any, _Args&& ...__args)
2877227825Stheraven    -> __nat;
2878227825Stheraven
2879227825Stheraven// bullets 1 and 2
2880227825Stheraven
2881232950Stheraventemplate <class _Fp, class _A0, class ..._Args>
2882241903Sdim_LIBCPP_INLINE_VISIBILITY
2883227825Stheravenauto
2884232950Stheraven__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
2885227825Stheraven    -> decltype((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...));
2886227825Stheraven
2887232950Stheraventemplate <class _Fp, class _A0, class ..._Args>
2888241903Sdim_LIBCPP_INLINE_VISIBILITY
2889227825Stheravenauto
2890232950Stheraven__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
2891227825Stheraven    -> decltype(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...));
2892227825Stheraven
2893227825Stheraven// bullets 3 and 4
2894227825Stheraven
2895232950Stheraventemplate <class _Fp, class _A0>
2896241903Sdim_LIBCPP_INLINE_VISIBILITY
2897227825Stheravenauto
2898232950Stheraven__invoke(_Fp&& __f, _A0&& __a0)
2899227825Stheraven    -> decltype(_VSTD::forward<_A0>(__a0).*__f);
2900227825Stheraven
2901232950Stheraventemplate <class _Fp, class _A0>
2902241903Sdim_LIBCPP_INLINE_VISIBILITY
2903227825Stheravenauto
2904232950Stheraven__invoke(_Fp&& __f, _A0&& __a0)
2905227825Stheraven    -> decltype((*_VSTD::forward<_A0>(__a0)).*__f);
2906227825Stheraven
2907227825Stheraven// bullet 5
2908227825Stheraven
2909232950Stheraventemplate <class _Fp, class ..._Args>
2910241903Sdim_LIBCPP_INLINE_VISIBILITY
2911227825Stheravenauto
2912232950Stheraven__invoke(_Fp&& __f, _Args&& ...__args)
2913232950Stheraven    -> decltype(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...));
2914227825Stheraven
2915227825Stheraven// __invokable
2916227825Stheraven
2917232950Stheraventemplate <class _Fp, class ..._Args>
2918227825Stheravenstruct __invokable_imp
2919241903Sdim    : private __check_complete<_Fp>
2920227825Stheraven{
2921227825Stheraven    typedef decltype(
2922232950Stheraven            __invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)
2923227825Stheraven                    ) type;
2924227825Stheraven    static const bool value = !is_same<type, __nat>::value;
2925227825Stheraven};
2926227825Stheraven
2927232950Stheraventemplate <class _Fp, class ..._Args>
2928227825Stheravenstruct __invokable
2929227825Stheraven    : public integral_constant<bool,
2930232950Stheraven          __invokable_imp<_Fp, _Args...>::value>
2931227825Stheraven{
2932227825Stheraven};
2933227825Stheraven
2934227825Stheraven// __invoke_of
2935227825Stheraven
2936232950Stheraventemplate <bool _Invokable, class _Fp, class ..._Args>
2937227825Stheravenstruct __invoke_of_imp  // false
2938227825Stheraven{
2939227825Stheraven};
2940227825Stheraven
2941232950Stheraventemplate <class _Fp, class ..._Args>
2942232950Stheravenstruct __invoke_of_imp<true, _Fp, _Args...>
2943227825Stheraven{
2944232950Stheraven    typedef typename __invokable_imp<_Fp, _Args...>::type type;
2945227825Stheraven};
2946227825Stheraven
2947232950Stheraventemplate <class _Fp, class ..._Args>
2948227825Stheravenstruct __invoke_of
2949232950Stheraven    : public __invoke_of_imp<__invokable<_Fp, _Args...>::value, _Fp, _Args...>
2950227825Stheraven{
2951227825Stheraven};
2952227825Stheraven
2953241903Sdimtemplate <class _Fp, class ..._Args>
2954249998Sdimclass _LIBCPP_TYPE_VIS result_of<_Fp(_Args...)>
2955241903Sdim    : public __invoke_of<_Fp, _Args...>
2956241903Sdim{
2957241903Sdim};
2958241903Sdim
2959227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
2960227825Stheraven
2961227825Stheraventemplate <class _Tp>
2962227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
2963227825Stheraven#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
2964227825Stheraventypename enable_if
2965227825Stheraven<
2966227825Stheraven    is_move_constructible<_Tp>::value &&
2967227825Stheraven    is_move_assignable<_Tp>::value
2968227825Stheraven>::type
2969227825Stheraven#else
2970227825Stheravenvoid
2971227825Stheraven#endif
2972227825Stheravenswap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
2973227825Stheraven                                    is_nothrow_move_assignable<_Tp>::value)
2974227825Stheraven{
2975227825Stheraven    _Tp __t(_VSTD::move(__x));
2976227825Stheraven    __x = _VSTD::move(__y);
2977227825Stheraven    __y = _VSTD::move(__t);
2978227825Stheraven}
2979227825Stheraven
2980227825Stheraventemplate <class _ForwardIterator1, class _ForwardIterator2>
2981227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
2982227825Stheravenvoid
2983227825Stheraveniter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
2984227825Stheraven    //                                  _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
2985227825Stheraven               _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(),
2986227825Stheraven                                          *_VSTD::declval<_ForwardIterator2>())))
2987227825Stheraven{
2988227825Stheraven    swap(*__a, *__b);
2989227825Stheraven}
2990227825Stheraven
2991227825Stheraven// __swappable
2992227825Stheraven
2993227825Stheravennamespace __detail
2994227825Stheraven{
2995227825Stheraven
2996227825Stheravenusing _VSTD::swap;
2997227825Stheraven__nat swap(__any, __any);
2998227825Stheraven
2999227825Stheraventemplate <class _Tp>
3000227825Stheravenstruct __swappable
3001227825Stheraven{
3002227825Stheraven    typedef decltype(swap(_VSTD::declval<_Tp&>(), _VSTD::declval<_Tp&>())) type;
3003227825Stheraven    static const bool value = !is_same<type, __nat>::value;
3004227825Stheraven};
3005227825Stheraven
3006227825Stheraven}  // __detail
3007227825Stheraven
3008227825Stheraventemplate <class _Tp>
3009227825Stheravenstruct __is_swappable
3010227825Stheraven    : public integral_constant<bool, __detail::__swappable<_Tp>::value>
3011227825Stheraven{
3012227825Stheraven};
3013227825Stheraven
3014227825Stheraven#if __has_feature(cxx_noexcept)
3015227825Stheraven
3016227825Stheraventemplate <bool, class _Tp>
3017227825Stheravenstruct __is_nothrow_swappable_imp
3018227825Stheraven    : public integral_constant<bool, noexcept(swap(_VSTD::declval<_Tp&>(),
3019227825Stheraven                                                   _VSTD::declval<_Tp&>()))>
3020227825Stheraven{
3021227825Stheraven};
3022227825Stheraven
3023227825Stheraventemplate <class _Tp>
3024227825Stheravenstruct __is_nothrow_swappable_imp<false, _Tp>
3025227825Stheraven    : public false_type
3026227825Stheraven{
3027227825Stheraven};
3028227825Stheraven
3029227825Stheraventemplate <class _Tp>
3030227825Stheravenstruct __is_nothrow_swappable
3031227825Stheraven    : public __is_nothrow_swappable_imp<__is_swappable<_Tp>::value, _Tp>
3032227825Stheraven{
3033227825Stheraven};
3034227825Stheraven
3035227825Stheraven#else  // __has_feature(cxx_noexcept)
3036227825Stheraven
3037227825Stheraventemplate <class _Tp>
3038227825Stheravenstruct __is_nothrow_swappable
3039227825Stheraven    : public false_type
3040227825Stheraven{
3041227825Stheraven};
3042227825Stheraven
3043227825Stheraven#endif  // __has_feature(cxx_noexcept)
3044227825Stheraven
3045227825Stheraven#ifdef _LIBCXX_UNDERLYING_TYPE
3046227825Stheraven
3047227825Stheraventemplate <class _Tp>
3048227825Stheravenstruct underlying_type
3049227825Stheraven{
3050227825Stheraven    typedef _LIBCXX_UNDERLYING_TYPE(_Tp) type;
3051227825Stheraven};
3052227825Stheraven
3053227825Stheraven#else  // _LIBCXX_UNDERLYING_TYPE
3054227825Stheraven
3055227825Stheraventemplate <class _Tp, bool _Support = false>
3056227825Stheravenstruct underlying_type
3057227825Stheraven{
3058227825Stheraven    static_assert(_Support, "The underyling_type trait requires compiler "
3059227825Stheraven                            "support. Either no such support exists or "
3060227825Stheraven                            "libc++ does not know how to use it.");
3061227825Stheraven};
3062227825Stheraven
3063227825Stheraven#endif // _LIBCXX_UNDERLYING_TYPE
3064227825Stheraven
3065227825Stheraven_LIBCPP_END_NAMESPACE_STD
3066227825Stheraven
3067227825Stheraven#endif  // _LIBCPP_TYPE_TRAITS
3068