type_traits revision 246487
1227825Stheraven// -*- C++ -*-
2227825Stheraven//===------------------------ type_traits ---------------------------------===//
3227825Stheraven//
4227825Stheraven//                     The LLVM Compiler Infrastructure
5227825Stheraven//
6227825Stheraven// This file is dual licensed under the MIT and the University of Illinois Open
7227825Stheraven// Source Licenses. See LICENSE.TXT for details.
8227825Stheraven//
9227825Stheraven//===----------------------------------------------------------------------===//
10227825Stheraven
11227825Stheraven#ifndef _LIBCPP_TYPE_TRAITS
12227825Stheraven#define _LIBCPP_TYPE_TRAITS
13227825Stheraven
14227825Stheraven/*
15227825Stheraven    type_traits synopsis
16227825Stheraven
17227825Stheravennamespace std
18227825Stheraven{
19227825Stheraven
20227825Stheraven    // helper class:
21227825Stheraven    template <class T, T v> struct integral_constant;
22227825Stheraven    typedef integral_constant<bool, true>  true_type;
23227825Stheraven    typedef integral_constant<bool, false> false_type;
24227825Stheraven
25227825Stheraven    // helper traits
26227825Stheraven    template <bool, class T = void> struct enable_if;
27227825Stheraven    template <bool, class T, class F> struct conditional;
28227825Stheraven
29227825Stheraven    // Primary classification traits:
30227825Stheraven    template <class T> struct is_void;
31227825Stheraven    template <class T> struct is_integral;
32227825Stheraven    template <class T> struct is_floating_point;
33227825Stheraven    template <class T> struct is_array;
34227825Stheraven    template <class T> struct is_pointer;
35227825Stheraven    template <class T> struct is_lvalue_reference;
36227825Stheraven    template <class T> struct is_rvalue_reference;
37227825Stheraven    template <class T> struct is_member_object_pointer;
38227825Stheraven    template <class T> struct is_member_function_pointer;
39227825Stheraven    template <class T> struct is_enum;
40227825Stheraven    template <class T> struct is_union;
41227825Stheraven    template <class T> struct is_class;
42227825Stheraven    template <class T> struct is_function;
43227825Stheraven
44227825Stheraven    // Secondary classification traits:
45227825Stheraven    template <class T> struct is_reference;
46227825Stheraven    template <class T> struct is_arithmetic;
47227825Stheraven    template <class T> struct is_fundamental;
48227825Stheraven    template <class T> struct is_member_pointer;
49227825Stheraven    template <class T> struct is_scalar;
50227825Stheraven    template <class T> struct is_object;
51227825Stheraven    template <class T> struct is_compound;
52227825Stheraven
53227825Stheraven    // Const-volatile properties and transformations:
54227825Stheraven    template <class T> struct is_const;
55227825Stheraven    template <class T> struct is_volatile;
56227825Stheraven    template <class T> struct remove_const;
57227825Stheraven    template <class T> struct remove_volatile;
58227825Stheraven    template <class T> struct remove_cv;
59227825Stheraven    template <class T> struct add_const;
60227825Stheraven    template <class T> struct add_volatile;
61227825Stheraven    template <class T> struct add_cv;
62227825Stheraven
63227825Stheraven    // Reference transformations:
64227825Stheraven    template <class T> struct remove_reference;
65227825Stheraven    template <class T> struct add_lvalue_reference;
66227825Stheraven    template <class T> struct add_rvalue_reference;
67227825Stheraven
68227825Stheraven    // Pointer transformations:
69227825Stheraven    template <class T> struct remove_pointer;
70227825Stheraven    template <class T> struct add_pointer;
71227825Stheraven
72227825Stheraven    // Integral properties:
73227825Stheraven    template <class T> struct is_signed;
74227825Stheraven    template <class T> struct is_unsigned;
75227825Stheraven    template <class T> struct make_signed;
76227825Stheraven    template <class T> struct make_unsigned;
77227825Stheraven
78227825Stheraven    // Array properties and transformations:
79227825Stheraven    template <class T> struct rank;
80227825Stheraven    template <class T, unsigned I = 0> struct extent;
81227825Stheraven    template <class T> struct remove_extent;
82227825Stheraven    template <class T> struct remove_all_extents;
83227825Stheraven
84227825Stheraven    // Member introspection:
85227825Stheraven    template <class T> struct is_pod;
86227825Stheraven    template <class T> struct is_trivial;
87227825Stheraven    template <class T> struct is_trivially_copyable;
88227825Stheraven    template <class T> struct is_standard_layout;
89227825Stheraven    template <class T> struct is_literal_type;
90227825Stheraven    template <class T> struct is_empty;
91227825Stheraven    template <class T> struct is_polymorphic;
92227825Stheraven    template <class T> struct is_abstract;
93227825Stheraven
94227825Stheraven    template <class T, class... Args> struct is_constructible;
95227825Stheraven    template <class T>                struct is_default_constructible;
96227825Stheraven    template <class T>                struct is_copy_constructible;
97227825Stheraven    template <class T>                struct is_move_constructible;
98227825Stheraven    template <class T, class U>       struct is_assignable;
99227825Stheraven    template <class T>                struct is_copy_assignable;
100227825Stheraven    template <class T>                struct is_move_assignable;
101227825Stheraven    template <class T>                struct is_destructible;
102227825Stheraven
103227825Stheraven    template <class T, class... Args> struct is_trivially_constructible;
104227825Stheraven    template <class T>                struct is_trivially_default_constructible;
105227825Stheraven    template <class T>                struct is_trivially_copy_constructible;
106227825Stheraven    template <class T>                struct is_trivially_move_constructible;
107227825Stheraven    template <class T, class U>       struct is_trivially_assignable;
108227825Stheraven    template <class T>                struct is_trivially_copy_assignable;
109227825Stheraven    template <class T>                struct is_trivially_move_assignable;
110227825Stheraven    template <class T>                struct is_trivially_destructible;
111227825Stheraven
112227825Stheraven    template <class T, class... Args> struct is_nothrow_constructible;
113227825Stheraven    template <class T>                struct is_nothrow_default_constructible;
114227825Stheraven    template <class T>                struct is_nothrow_copy_constructible;
115227825Stheraven    template <class T>                struct is_nothrow_move_constructible;
116227825Stheraven    template <class T, class U>       struct is_nothrow_assignable;
117227825Stheraven    template <class T>                struct is_nothrow_copy_assignable;
118227825Stheraven    template <class T>                struct is_nothrow_move_assignable;
119227825Stheraven    template <class T>                struct is_nothrow_destructible;
120227825Stheraven
121227825Stheraven    template <class T> struct has_virtual_destructor;
122227825Stheraven
123227825Stheraven    // Relationships between types:
124227825Stheraven    template <class T, class U> struct is_same;
125227825Stheraven    template <class Base, class Derived> struct is_base_of;
126227825Stheraven    template <class From, class To> struct is_convertible;
127227825Stheraven
128227825Stheraven    // Alignment properties and transformations:
129227825Stheraven    template <class T> struct alignment_of;
130227825Stheraven    template <size_t Len, size_t Align = most_stringent_alignment_requirement>
131227825Stheraven        struct aligned_storage;
132227825Stheraven
133227825Stheraven    template <class T> struct decay;
134227825Stheraven    template <class... T> struct common_type;
135227825Stheraven    template <class T> struct underlying_type;
136227825Stheraven    template <class> class result_of; // undefined
137227825Stheraven    template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>;
138227825Stheraven
139227825Stheraven}  // std
140227825Stheraven
141227825Stheraven*/
142227825Stheraven#include <__config>
143227825Stheraven#include <cstddef>
144227825Stheraven
145227825Stheraven#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
146227825Stheraven#pragma GCC system_header
147227825Stheraven#endif
148227825Stheraven
149227825Stheraven_LIBCPP_BEGIN_NAMESPACE_STD
150227825Stheraven
151232950Stheraventemplate <bool _Bp, class _If, class _Then>
152227825Stheraven    struct _LIBCPP_VISIBLE conditional {typedef _If type;};
153227825Stheraventemplate <class _If, class _Then>
154227825Stheraven    struct _LIBCPP_VISIBLE conditional<false, _If, _Then> {typedef _Then type;};
155227825Stheraven
156227825Stheraventemplate <bool, class _Tp = void> struct _LIBCPP_VISIBLE enable_if {};
157227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE enable_if<true, _Tp> {typedef _Tp type;};
158227825Stheraven
159242945Stheravenstruct __two {char __lx[2];};
160227825Stheraven
161227825Stheraven// helper class:
162227825Stheraven
163227825Stheraventemplate <class _Tp, _Tp __v>
164227825Stheravenstruct _LIBCPP_VISIBLE integral_constant
165227825Stheraven{
166234976Stheraven    static _LIBCPP_CONSTEXPR const _Tp      value = __v;
167227825Stheraven    typedef _Tp               value_type;
168227825Stheraven    typedef integral_constant type;
169227825Stheraven    _LIBCPP_INLINE_VISIBILITY
170234976Stheraven        _LIBCPP_CONSTEXPR operator value_type() const {return value;}
171227825Stheraven};
172227825Stheraven
173227825Stheraventemplate <class _Tp, _Tp __v>
174234976Stheraven_LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
175227825Stheraven
176227825Stheraventypedef integral_constant<bool, true>  true_type;
177227825Stheraventypedef integral_constant<bool, false> false_type;
178227825Stheraven
179227825Stheraven// is_const
180227825Stheraven
181227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_const            : public false_type {};
182227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_const<_Tp const> : public true_type {};
183227825Stheraven
184227825Stheraven// is_volatile
185227825Stheraven
186227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_volatile               : public false_type {};
187227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_volatile<_Tp volatile> : public true_type {};
188227825Stheraven
189227825Stheraven// remove_const
190227825Stheraven
191227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE remove_const            {typedef _Tp type;};
192227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE remove_const<const _Tp> {typedef _Tp type;};
193227825Stheraven
194227825Stheraven// remove_volatile
195227825Stheraven
196227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE remove_volatile               {typedef _Tp type;};
197227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE remove_volatile<volatile _Tp> {typedef _Tp type;};
198227825Stheraven
199227825Stheraven// remove_cv
200227825Stheraven
201227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE remove_cv
202227825Stheraven{typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
203227825Stheraven
204227825Stheraven// is_void
205227825Stheraven
206227825Stheraventemplate <class _Tp> struct __is_void       : public false_type {};
207227825Stheraventemplate <>          struct __is_void<void> : public true_type {};
208227825Stheraven
209227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_void
210227825Stheraven    : public __is_void<typename remove_cv<_Tp>::type> {};
211227825Stheraven
212227825Stheraven// __is_nullptr_t
213227825Stheraven
214227825Stheraventemplate <class _Tp> struct ____is_nullptr_t       : public false_type {};
215227825Stheraventemplate <>          struct ____is_nullptr_t<nullptr_t> : public true_type {};
216227825Stheraven
217227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE __is_nullptr_t
218227825Stheraven    : public ____is_nullptr_t<typename remove_cv<_Tp>::type> {};
219227825Stheraven
220227825Stheraven// is_integral
221227825Stheraven
222227825Stheraventemplate <class _Tp> struct __is_integral                     : public false_type {};
223227825Stheraventemplate <>          struct __is_integral<bool>               : public true_type {};
224227825Stheraventemplate <>          struct __is_integral<char>               : public true_type {};
225227825Stheraventemplate <>          struct __is_integral<signed char>        : public true_type {};
226227825Stheraventemplate <>          struct __is_integral<unsigned char>      : public true_type {};
227227825Stheraventemplate <>          struct __is_integral<wchar_t>            : public true_type {};
228227825Stheraven#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
229227825Stheraventemplate <>          struct __is_integral<char16_t>           : public true_type {};
230227825Stheraventemplate <>          struct __is_integral<char32_t>           : public true_type {};
231227825Stheraven#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
232227825Stheraventemplate <>          struct __is_integral<short>              : public true_type {};
233227825Stheraventemplate <>          struct __is_integral<unsigned short>     : public true_type {};
234227825Stheraventemplate <>          struct __is_integral<int>                : public true_type {};
235227825Stheraventemplate <>          struct __is_integral<unsigned int>       : public true_type {};
236227825Stheraventemplate <>          struct __is_integral<long>               : public true_type {};
237227825Stheraventemplate <>          struct __is_integral<unsigned long>      : public true_type {};
238227825Stheraventemplate <>          struct __is_integral<long long>          : public true_type {};
239227825Stheraventemplate <>          struct __is_integral<unsigned long long> : public true_type {};
240227825Stheraven
241227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_integral
242227825Stheraven    : public __is_integral<typename remove_cv<_Tp>::type> {};
243227825Stheraven
244227825Stheraven// is_floating_point
245227825Stheraven
246227825Stheraventemplate <class _Tp> struct __is_floating_point              : public false_type {};
247227825Stheraventemplate <>          struct __is_floating_point<float>       : public true_type {};
248227825Stheraventemplate <>          struct __is_floating_point<double>      : public true_type {};
249227825Stheraventemplate <>          struct __is_floating_point<long double> : public true_type {};
250227825Stheraven
251227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_floating_point
252227825Stheraven    : public __is_floating_point<typename remove_cv<_Tp>::type> {};
253227825Stheraven
254227825Stheraven// is_array
255227825Stheraven
256227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_array
257227825Stheraven    : public false_type {};
258227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_array<_Tp[]>
259227825Stheraven    : public true_type {};
260227825Stheraventemplate <class _Tp, size_t _Np> struct _LIBCPP_VISIBLE is_array<_Tp[_Np]>
261227825Stheraven    : public true_type {};
262227825Stheraven
263227825Stheraven// is_pointer
264227825Stheraven
265227825Stheraventemplate <class _Tp> struct __is_pointer       : public false_type {};
266227825Stheraventemplate <class _Tp> struct __is_pointer<_Tp*> : public true_type {};
267227825Stheraven
268227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_pointer
269227825Stheraven    : public __is_pointer<typename remove_cv<_Tp>::type> {};
270227825Stheraven
271227825Stheraven// is_reference
272227825Stheraven
273227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_lvalue_reference       : public false_type {};
274227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_lvalue_reference<_Tp&> : public true_type {};
275227825Stheraven
276227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_rvalue_reference        : public false_type {};
277227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
278227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_rvalue_reference<_Tp&&> : public true_type {};
279227825Stheraven#endif
280227825Stheraven
281227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_reference        : public false_type {};
282227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_reference<_Tp&>  : public true_type {};
283227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
284227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_reference<_Tp&&> : public true_type {};
285227825Stheraven#endif
286227825Stheraven
287227825Stheraven#if defined(__clang__) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
288227825Stheraven#define _LIBCPP_HAS_TYPE_TRAITS
289227825Stheraven#endif
290227825Stheraven
291227825Stheraven// is_union
292227825Stheraven
293227825Stheraven#if __has_feature(is_union) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
294227825Stheraven
295227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_union
296227825Stheraven    : public integral_constant<bool, __is_union(_Tp)> {};
297227825Stheraven
298227825Stheraven#else
299227825Stheraven
300227825Stheraventemplate <class _Tp> struct __libcpp_union : public false_type {};
301227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_union
302227825Stheraven    : public __libcpp_union<typename remove_cv<_Tp>::type> {};
303227825Stheraven
304227825Stheraven#endif
305227825Stheraven
306227825Stheraven// is_class
307227825Stheraven
308227825Stheraven#if __has_feature(is_class) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
309227825Stheraven
310227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_class
311227825Stheraven    : public integral_constant<bool, __is_class(_Tp)> {};
312227825Stheraven
313227825Stheraven#else
314227825Stheraven
315227825Stheravennamespace __is_class_imp
316227825Stheraven{
317227825Stheraventemplate <class _Tp> char  __test(int _Tp::*);
318227825Stheraventemplate <class _Tp> __two __test(...);
319227825Stheraven}
320227825Stheraven
321227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_class
322227825Stheraven    : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {};
323227825Stheraven
324227825Stheraven#endif
325227825Stheraven
326227825Stheraven// is_same
327227825Stheraven
328227825Stheraventemplate <class _Tp, class _Up> struct _LIBCPP_VISIBLE is_same           : public false_type {};
329227825Stheraventemplate <class _Tp>            struct _LIBCPP_VISIBLE is_same<_Tp, _Tp> : public true_type {};
330227825Stheraven
331227825Stheraven// is_function
332227825Stheraven
333227825Stheravennamespace __is_function_imp
334227825Stheraven{
335227825Stheraventemplate <class _Tp> char  __test(_Tp*);
336227825Stheraventemplate <class _Tp> __two __test(...);
337227825Stheraventemplate <class _Tp> _Tp&  __source();
338227825Stheraven}
339227825Stheraven
340227825Stheraventemplate <class _Tp, bool = is_class<_Tp>::value ||
341227825Stheraven                            is_union<_Tp>::value ||
342227825Stheraven                            is_void<_Tp>::value  ||
343227825Stheraven                            is_reference<_Tp>::value ||
344227825Stheraven                            is_same<_Tp, nullptr_t>::value >
345227825Stheravenstruct __is_function
346227825Stheraven    : public integral_constant<bool, sizeof(__is_function_imp::__test<_Tp>(__is_function_imp::__source<_Tp>())) == 1>
347227825Stheraven    {};
348227825Stheraventemplate <class _Tp> struct __is_function<_Tp, true> : public false_type {};
349227825Stheraven
350227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_function
351227825Stheraven    : public __is_function<_Tp> {};
352227825Stheraven
353227825Stheraven// is_member_function_pointer
354227825Stheraven
355227825Stheraventemplate <class _Tp> struct            __is_member_function_pointer             : public false_type {};
356227825Stheraventemplate <class _Tp, class _Up> struct __is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {};
357227825Stheraven
358227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_member_function_pointer
359227825Stheraven    : public __is_member_function_pointer<typename remove_cv<_Tp>::type> {};
360227825Stheraven
361227825Stheraven// is_member_pointer
362227825Stheraven
363227825Stheraventemplate <class _Tp>            struct __is_member_pointer             : public false_type {};
364227825Stheraventemplate <class _Tp, class _Up> struct __is_member_pointer<_Tp _Up::*> : public true_type {};
365227825Stheraven
366227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_member_pointer
367227825Stheraven    : public __is_member_pointer<typename remove_cv<_Tp>::type> {};
368227825Stheraven
369227825Stheraven// is_member_object_pointer
370227825Stheraven
371227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_member_object_pointer
372227825Stheraven    : public integral_constant<bool, is_member_pointer<_Tp>::value &&
373227825Stheraven                                    !is_member_function_pointer<_Tp>::value> {};
374227825Stheraven
375227825Stheraven// is_enum
376227825Stheraven
377227825Stheraven#if __has_feature(is_enum) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
378227825Stheraven
379227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_enum
380227825Stheraven    : public integral_constant<bool, __is_enum(_Tp)> {};
381227825Stheraven
382227825Stheraven#else
383227825Stheraven
384227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_enum
385227825Stheraven    : public integral_constant<bool, !is_void<_Tp>::value             &&
386227825Stheraven                                     !is_integral<_Tp>::value         &&
387227825Stheraven                                     !is_floating_point<_Tp>::value   &&
388227825Stheraven                                     !is_array<_Tp>::value            &&
389227825Stheraven                                     !is_pointer<_Tp>::value          &&
390227825Stheraven                                     !is_reference<_Tp>::value        &&
391227825Stheraven                                     !is_member_pointer<_Tp>::value   &&
392227825Stheraven                                     !is_union<_Tp>::value            &&
393227825Stheraven                                     !is_class<_Tp>::value            &&
394227825Stheraven                                     !is_function<_Tp>::value         > {};
395227825Stheraven
396227825Stheraven#endif
397227825Stheraven
398227825Stheraven// is_arithmetic
399227825Stheraven
400227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_arithmetic
401227825Stheraven    : public integral_constant<bool, is_integral<_Tp>::value      ||
402227825Stheraven                                     is_floating_point<_Tp>::value> {};
403227825Stheraven
404227825Stheraven// is_fundamental
405227825Stheraven
406227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_fundamental
407227825Stheraven    : public integral_constant<bool, is_void<_Tp>::value        ||
408227825Stheraven                                     __is_nullptr_t<_Tp>::value ||
409227825Stheraven                                     is_arithmetic<_Tp>::value> {};
410227825Stheraven
411227825Stheraven// is_scalar
412227825Stheraven
413227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_scalar
414227825Stheraven    : public integral_constant<bool, is_arithmetic<_Tp>::value     ||
415227825Stheraven                                     is_member_pointer<_Tp>::value ||
416227825Stheraven                                     is_pointer<_Tp>::value        ||
417227825Stheraven                                     __is_nullptr_t<_Tp>::value    ||
418227825Stheraven                                     is_enum<_Tp>::value           > {};
419227825Stheraven
420227825Stheraventemplate <> struct _LIBCPP_VISIBLE is_scalar<nullptr_t> : public true_type {};
421227825Stheraven
422227825Stheraven// is_object
423227825Stheraven
424227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_object
425227825Stheraven    : public integral_constant<bool, is_scalar<_Tp>::value ||
426227825Stheraven                                     is_array<_Tp>::value  ||
427227825Stheraven                                     is_union<_Tp>::value  ||
428227825Stheraven                                     is_class<_Tp>::value  > {};
429227825Stheraven
430227825Stheraven// is_compound
431227825Stheraven
432227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_compound
433227825Stheraven    : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
434227825Stheraven
435227825Stheraven// add_const
436227825Stheraven
437227825Stheraventemplate <class _Tp, bool = is_reference<_Tp>::value ||
438227825Stheraven                            is_function<_Tp>::value  ||
439227825Stheraven                            is_const<_Tp>::value     >
440227825Stheravenstruct __add_const             {typedef _Tp type;};
441227825Stheraven
442227825Stheraventemplate <class _Tp>
443227825Stheravenstruct __add_const<_Tp, false> {typedef const _Tp type;};
444227825Stheraven
445227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE add_const
446227825Stheraven    {typedef typename __add_const<_Tp>::type type;};
447227825Stheraven
448227825Stheraven// add_volatile
449227825Stheraven
450227825Stheraventemplate <class _Tp, bool = is_reference<_Tp>::value ||
451227825Stheraven                            is_function<_Tp>::value  ||
452227825Stheraven                            is_volatile<_Tp>::value  >
453227825Stheravenstruct __add_volatile             {typedef _Tp type;};
454227825Stheraven
455227825Stheraventemplate <class _Tp>
456227825Stheravenstruct __add_volatile<_Tp, false> {typedef volatile _Tp type;};
457227825Stheraven
458227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE add_volatile
459227825Stheraven    {typedef typename __add_volatile<_Tp>::type type;};
460227825Stheraven
461227825Stheraven// add_cv
462227825Stheraven
463227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE add_cv
464227825Stheraven    {typedef typename add_const<typename add_volatile<_Tp>::type>::type type;};
465227825Stheraven
466227825Stheraven// remove_reference
467227825Stheraven
468227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE remove_reference        {typedef _Tp type;};
469227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE remove_reference<_Tp&>  {typedef _Tp type;};
470227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
471227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE remove_reference<_Tp&&> {typedef _Tp type;};
472227825Stheraven#endif
473227825Stheraven
474227825Stheraven// add_lvalue_reference
475227825Stheraven
476227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE add_lvalue_reference                      {typedef _Tp& type;};
477227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE add_lvalue_reference<_Tp&>                {typedef _Tp& type;};  // for older compiler
478227825Stheraventemplate <>          struct _LIBCPP_VISIBLE add_lvalue_reference<void>                {typedef void type;};
479227825Stheraventemplate <>          struct _LIBCPP_VISIBLE add_lvalue_reference<const void>          {typedef const void type;};
480227825Stheraventemplate <>          struct _LIBCPP_VISIBLE add_lvalue_reference<volatile void>       {typedef volatile void type;};
481227825Stheraventemplate <>          struct _LIBCPP_VISIBLE add_lvalue_reference<const volatile void> {typedef const volatile void type;};
482227825Stheraven
483227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
484227825Stheraven
485227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE  add_rvalue_reference                     {typedef _Tp&& type;};
486227825Stheraventemplate <>          struct _LIBCPP_VISIBLE add_rvalue_reference<void>                {typedef void type;};
487227825Stheraventemplate <>          struct _LIBCPP_VISIBLE add_rvalue_reference<const void>          {typedef const void type;};
488227825Stheraventemplate <>          struct _LIBCPP_VISIBLE add_rvalue_reference<volatile void>       {typedef volatile void type;};
489227825Stheraventemplate <>          struct _LIBCPP_VISIBLE add_rvalue_reference<const volatile void> {typedef const volatile void type;};
490227825Stheraven
491227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
492227825Stheraven
493227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
494227825Stheraven
495227825Stheraventemplate <class _Tp>
496227825Stheraventypename add_rvalue_reference<_Tp>::type
497227825Stheravendeclval() _NOEXCEPT;
498227825Stheraven
499227825Stheraven#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
500227825Stheraven
501227825Stheraventemplate <class _Tp>
502227825Stheraventypename add_lvalue_reference<_Tp>::type
503227825Stheravendeclval();
504227825Stheraven
505227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
506227825Stheraven
507227825Stheravenstruct __any
508227825Stheraven{
509227825Stheraven    __any(...);
510227825Stheraven};
511227825Stheraven
512227825Stheraven// remove_pointer
513227825Stheraven
514227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE remove_pointer                      {typedef _Tp type;};
515227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE remove_pointer<_Tp*>                {typedef _Tp type;};
516227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE remove_pointer<_Tp* const>          {typedef _Tp type;};
517227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE remove_pointer<_Tp* volatile>       {typedef _Tp type;};
518227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE remove_pointer<_Tp* const volatile> {typedef _Tp type;};
519227825Stheraven
520227825Stheraven// add_pointer
521227825Stheraven
522227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE add_pointer
523227825Stheraven    {typedef typename remove_reference<_Tp>::type* type;};
524227825Stheraven
525227825Stheraven// is_signed
526227825Stheraven
527227825Stheraventemplate <class _Tp, bool = is_integral<_Tp>::value>
528227825Stheravenstruct ___is_signed : public integral_constant<bool, _Tp(-1) < _Tp(0)> {};
529227825Stheraven
530227825Stheraventemplate <class _Tp>
531227825Stheravenstruct ___is_signed<_Tp, false> : public true_type {};  // floating point
532227825Stheraven
533227825Stheraventemplate <class _Tp, bool = is_arithmetic<_Tp>::value>
534227825Stheravenstruct __is_signed : public ___is_signed<_Tp> {};
535227825Stheraven
536227825Stheraventemplate <class _Tp> struct __is_signed<_Tp, false> : public false_type {};
537227825Stheraven
538227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_signed : public __is_signed<_Tp> {};
539227825Stheraven
540227825Stheraven// is_unsigned
541227825Stheraven
542227825Stheraventemplate <class _Tp, bool = is_integral<_Tp>::value>
543227825Stheravenstruct ___is_unsigned : public integral_constant<bool, _Tp(0) < _Tp(-1)> {};
544227825Stheraven
545227825Stheraventemplate <class _Tp>
546227825Stheravenstruct ___is_unsigned<_Tp, false> : public false_type {};  // floating point
547227825Stheraven
548227825Stheraventemplate <class _Tp, bool = is_arithmetic<_Tp>::value>
549227825Stheravenstruct __is_unsigned : public ___is_unsigned<_Tp> {};
550227825Stheraven
551227825Stheraventemplate <class _Tp> struct __is_unsigned<_Tp, false> : public false_type {};
552227825Stheraven
553227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_unsigned : public __is_unsigned<_Tp> {};
554227825Stheraven
555227825Stheraven// rank
556227825Stheraven
557227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE rank
558227825Stheraven    : public integral_constant<size_t, 0> {};
559227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE rank<_Tp[]>
560227825Stheraven    : public integral_constant<size_t, rank<_Tp>::value + 1> {};
561227825Stheraventemplate <class _Tp, size_t _Np> struct _LIBCPP_VISIBLE rank<_Tp[_Np]>
562227825Stheraven    : public integral_constant<size_t, rank<_Tp>::value + 1> {};
563227825Stheraven
564227825Stheraven// extent
565227825Stheraven
566227825Stheraventemplate <class _Tp, unsigned _Ip = 0> struct _LIBCPP_VISIBLE extent
567227825Stheraven    : public integral_constant<size_t, 0> {};
568227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE extent<_Tp[], 0>
569227825Stheraven    : public integral_constant<size_t, 0> {};
570227825Stheraventemplate <class _Tp, unsigned _Ip> struct _LIBCPP_VISIBLE extent<_Tp[], _Ip>
571227825Stheraven    : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
572227825Stheraventemplate <class _Tp, size_t _Np> struct _LIBCPP_VISIBLE extent<_Tp[_Np], 0>
573227825Stheraven    : public integral_constant<size_t, _Np> {};
574227825Stheraventemplate <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_VISIBLE extent<_Tp[_Np], _Ip>
575227825Stheraven    : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
576227825Stheraven
577227825Stheraven// remove_extent
578227825Stheraven
579227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE remove_extent
580227825Stheraven    {typedef _Tp type;};
581227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE remove_extent<_Tp[]>
582227825Stheraven    {typedef _Tp type;};
583227825Stheraventemplate <class _Tp, size_t _Np> struct _LIBCPP_VISIBLE remove_extent<_Tp[_Np]>
584227825Stheraven    {typedef _Tp type;};
585227825Stheraven
586227825Stheraven// remove_all_extents
587227825Stheraven
588227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE remove_all_extents
589227825Stheraven    {typedef _Tp type;};
590227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE remove_all_extents<_Tp[]>
591227825Stheraven    {typedef typename remove_all_extents<_Tp>::type type;};
592227825Stheraventemplate <class _Tp, size_t _Np> struct _LIBCPP_VISIBLE remove_all_extents<_Tp[_Np]>
593227825Stheraven    {typedef typename remove_all_extents<_Tp>::type type;};
594227825Stheraven
595227825Stheraven// is_abstract
596227825Stheraven
597227825Stheravennamespace __is_abstract_imp
598227825Stheraven{
599227825Stheraventemplate <class _Tp> char  __test(_Tp (*)[1]);
600227825Stheraventemplate <class _Tp> __two __test(...);
601227825Stheraven}
602227825Stheraven
603227825Stheraventemplate <class _Tp, bool = is_class<_Tp>::value>
604227825Stheravenstruct __libcpp_abstract : public integral_constant<bool, sizeof(__is_abstract_imp::__test<_Tp>(0)) != 1> {};
605227825Stheraven
606227825Stheraventemplate <class _Tp> struct __libcpp_abstract<_Tp, false> : public false_type {};
607227825Stheraven
608227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_abstract : public __libcpp_abstract<_Tp> {};
609227825Stheraven
610241903Sdim// is_base_of
611241903Sdim
612241903Sdim#ifdef _LIBCP_HAS_IS_BASE_OF
613241903Sdim
614241903Sdimtemplate <class _Bp, class _Dp>
615241903Sdimstruct _LIBCPP_VISIBLE is_base_of
616241903Sdim    : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
617241903Sdim
618241903Sdim#else  // __has_feature(is_base_of)
619241903Sdim
620246487Stheravennamespace __is_base_of_imp
621246487Stheraven{
622246487Stheraventemplate <class _Tp>
623246487Stheravenstruct _Dst
624246487Stheraven{
625246487Stheraven    _Dst(const volatile _Tp &);
626246487Stheraven};
627246487Stheraventemplate <class _Tp>
628246487Stheravenstruct _Src
629246487Stheraven{
630246487Stheraven    operator const volatile _Tp &();
631246487Stheraven    template <class _Up> operator const _Dst<_Up> &();
632246487Stheraven};
633246487Stheraventemplate <size_t> struct __one { typedef char type; };
634246487Stheraventemplate <class _Bp, class _Dp> typename __one<sizeof(_Dst<_Bp>(declval<_Src<_Dp> >()))>::type __test(int);
635246487Stheraventemplate <class _Bp, class _Dp> __two __test(...);
636246487Stheraven}
637241903Sdim
638246487Stheraventemplate <class _Bp, class _Dp>
639246487Stheravenstruct _LIBCPP_VISIBLE is_base_of
640246487Stheraven    : public integral_constant<bool, is_class<_Bp>::value &&
641246487Stheraven                                     sizeof(__is_base_of_imp::__test<_Bp, _Dp>(0)) == 2> {};
642246487Stheraven
643241903Sdim#endif  // __has_feature(is_base_of)
644241903Sdim
645227825Stheraven// is_convertible
646227825Stheraven
647227825Stheraven#if __has_feature(is_convertible_to)
648227825Stheraven
649227825Stheraventemplate <class _T1, class _T2> struct _LIBCPP_VISIBLE is_convertible
650241903Sdim    : public integral_constant<bool, __is_convertible_to(_T1, _T2) &&
651241903Sdim                                     !is_abstract<_T2>::value> {};
652227825Stheraven
653227825Stheraven#else  // __has_feature(is_convertible_to)
654227825Stheraven
655227825Stheravennamespace __is_convertible_imp
656227825Stheraven{
657227825Stheraventemplate <class _Tp> char  __test(_Tp);
658227825Stheraventemplate <class _Tp> __two __test(...);
659227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
660227825Stheraventemplate <class _Tp> _Tp&& __source();
661227825Stheraven#else
662227825Stheraventemplate <class _Tp> typename remove_reference<_Tp>::type& __source();
663227825Stheraven#endif
664227825Stheraven
665227825Stheraventemplate <class _Tp, bool _IsArray =    is_array<_Tp>::value,
666227825Stheraven                     bool _IsFunction = is_function<_Tp>::value,
667227825Stheraven                     bool _IsVoid =     is_void<_Tp>::value>
668227825Stheraven                     struct __is_array_function_or_void                          {enum {value = 0};};
669227825Stheraventemplate <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};};
670227825Stheraventemplate <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};};
671227825Stheraventemplate <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};};
672227825Stheraven}
673227825Stheraven
674227825Stheraventemplate <class _Tp,
675227825Stheraven    unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
676227825Stheravenstruct __is_convertible_check
677227825Stheraven{
678227825Stheraven    static const size_t __v = 0;
679227825Stheraven};
680227825Stheraven
681227825Stheraventemplate <class _Tp>
682227825Stheravenstruct __is_convertible_check<_Tp, 0>
683227825Stheraven{
684227825Stheraven    static const size_t __v = sizeof(_Tp);
685227825Stheraven};
686227825Stheraven
687227825Stheraventemplate <class _T1, class _T2,
688227825Stheraven    unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value,
689227825Stheraven    unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
690227825Stheravenstruct __is_convertible
691227825Stheraven    : public integral_constant<bool,
692241903Sdim#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
693227825Stheraven        sizeof(__is_convertible_imp::__test<_T2>(__is_convertible_imp::__source<_T1>())) == 1
694241903Sdim#else
695241903Sdim        sizeof(__is_convertible_imp::__test<_T2>(__is_convertible_imp::__source<_T1>())) == 1
696241903Sdim         && !(!is_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value
697241903Sdim              && (!is_const<typename remove_reference<_T2>::type>::value
698241903Sdim                  || is_volatile<typename remove_reference<_T2>::type>::value)
699241903Sdim                  && (is_same<typename remove_cv<_T1>::type,
700241903Sdim                              typename remove_cv<typename remove_reference<_T2>::type>::type>::value
701241903Sdim                      || is_base_of<typename remove_reference<_T2>::type, _T1>::value))
702241903Sdim#endif
703227825Stheraven    >
704227825Stheraven{};
705227825Stheraven
706227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 0> : false_type {};
707227825Stheraven
708227825Stheraventemplate <class _T1> struct __is_convertible<_T1, const _T1&, 1, 0> : true_type {};
709227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
710227825Stheraventemplate <class _T1> struct __is_convertible<_T1, _T1&&, 1, 0> : true_type {};
711227825Stheraventemplate <class _T1> struct __is_convertible<_T1, const _T1&&, 1, 0> : true_type {};
712227825Stheraventemplate <class _T1> struct __is_convertible<_T1, volatile _T1&&, 1, 0> : true_type {};
713227825Stheraventemplate <class _T1> struct __is_convertible<_T1, const volatile _T1&&, 1, 0> : true_type {};
714227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
715227825Stheraven
716227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2*, 1, 0>
717227825Stheraven    : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*>::value> {};
718227825Stheraven
719227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2* const, 1, 0>
720227825Stheraven    : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const>::value> {};
721227825Stheraven
722227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2* volatile, 1, 0>
723227825Stheraven    : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*volatile>::value> {};
724227825Stheraven
725227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2* const volatile, 1, 0>
726227825Stheraven    : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const volatile>::value> {};
727227825Stheraven
728227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 0>                : public false_type {};
729227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
730227825Stheraventemplate <class _T1>            struct __is_convertible<_T1, _T1&&, 2, 0>               : public true_type {};
731227825Stheraven#endif
732241903Sdimtemplate <class _T1>            struct __is_convertible<_T1, _T1&, 2, 0>               : public true_type {};
733227825Stheraventemplate <class _T1>            struct __is_convertible<_T1, _T1*, 2, 0>               : public true_type {};
734227825Stheraventemplate <class _T1>            struct __is_convertible<_T1, _T1*const, 2, 0>          : public true_type {};
735227825Stheraventemplate <class _T1>            struct __is_convertible<_T1, _T1*volatile, 2, 0>       : public true_type {};
736227825Stheraventemplate <class _T1>            struct __is_convertible<_T1, _T1*const volatile, 2, 0> : public true_type {};
737227825Stheraven
738227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 0> : public false_type {};
739227825Stheraven
740227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
741227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
742227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
743227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {};
744227825Stheraven
745227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {};
746227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {};
747227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {};
748227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {};
749227825Stheraven
750227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {};
751227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {};
752227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {};
753227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {};
754227825Stheraven
755227825Stheraventemplate <class _T1, class _T2> struct _LIBCPP_VISIBLE is_convertible
756227825Stheraven    : public __is_convertible<_T1, _T2>
757227825Stheraven{
758227825Stheraven    static const size_t __complete_check1 = __is_convertible_check<_T1>::__v;
759227825Stheraven    static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
760227825Stheraven};
761227825Stheraven
762227825Stheraven#endif  // __has_feature(is_convertible_to)
763227825Stheraven
764227825Stheraven// is_empty
765227825Stheraven
766232950Stheraven#if __has_feature(is_empty)
767232950Stheraven
768227825Stheraventemplate <class _Tp>
769232950Stheravenstruct _LIBCPP_VISIBLE is_empty
770232950Stheraven    : public integral_constant<bool, __is_empty(_Tp)> {};
771232950Stheraven
772232950Stheraven#else  // __has_feature(is_empty)
773232950Stheraven
774232950Stheraventemplate <class _Tp>
775227825Stheravenstruct __is_empty1
776227825Stheraven    : public _Tp
777227825Stheraven{
778242945Stheraven    double __lx;
779227825Stheraven};
780227825Stheraven
781227825Stheravenstruct __is_empty2
782227825Stheraven{
783242945Stheraven    double __lx;
784227825Stheraven};
785227825Stheraven
786227825Stheraventemplate <class _Tp, bool = is_class<_Tp>::value>
787227825Stheravenstruct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {};
788227825Stheraven
789227825Stheraventemplate <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {};
790227825Stheraven
791227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_empty : public __libcpp_empty<_Tp> {};
792227825Stheraven
793232950Stheraven#endif  // __has_feature(is_empty)
794232950Stheraven
795227825Stheraven// is_polymorphic
796227825Stheraven
797232950Stheraven#if __has_feature(is_polymorphic)
798232950Stheraven
799232950Stheraventemplate <class _Tp>
800232950Stheravenstruct _LIBCPP_VISIBLE is_polymorphic
801232950Stheraven    : public integral_constant<bool, __is_polymorphic(_Tp)> {};
802232950Stheraven
803232950Stheraven#else
804232950Stheraven
805227825Stheraventemplate <class _Tp> struct __is_polymorphic1 : public _Tp {};
806227825Stheraventemplate <class _Tp> struct __is_polymorphic2 : public _Tp {virtual ~__is_polymorphic2() throw();};
807227825Stheraven
808227825Stheraventemplate <class _Tp, bool = is_class<_Tp>::value>
809227825Stheravenstruct __libcpp_polymorphic
810227825Stheraven    : public integral_constant<bool, sizeof(__is_polymorphic1<_Tp>) == sizeof(__is_polymorphic2<_Tp>)> {};
811227825Stheraven
812227825Stheraventemplate <class _Tp> struct __libcpp_polymorphic<_Tp, false> : public false_type {};
813227825Stheraven
814227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_polymorphic
815227825Stheraven    : public __libcpp_polymorphic<_Tp> {};
816227825Stheraven
817232950Stheraven#endif // __has_feature(is_polymorphic)
818232950Stheraven
819227825Stheraven// has_virtual_destructor
820227825Stheraven
821227825Stheraven#if __has_feature(has_virtual_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
822227825Stheraven
823227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE has_virtual_destructor
824227825Stheraven    : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
825227825Stheraven
826227825Stheraven#else  // _LIBCPP_HAS_TYPE_TRAITS
827227825Stheraven
828227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE has_virtual_destructor
829227825Stheraven    : public false_type {};
830227825Stheraven
831227825Stheraven#endif  // _LIBCPP_HAS_TYPE_TRAITS
832227825Stheraven
833227825Stheraven// alignment_of
834227825Stheraven
835242945Stheraventemplate <class _Tp> struct __alignment_of {_Tp __lx;};
836227825Stheraven
837227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE alignment_of
838227825Stheraven    : public integral_constant<size_t, __alignof__(__alignment_of<typename remove_all_extents<_Tp>::type>)> {};
839227825Stheraven
840227825Stheraven// aligned_storage
841227825Stheraven
842227825Stheraventemplate <class _Hp, class _Tp>
843227825Stheravenstruct __type_list
844227825Stheraven{
845227825Stheraven    typedef _Hp _Head;
846227825Stheraven    typedef _Tp _Tail;
847227825Stheraven};
848227825Stheraven
849227825Stheravenstruct __nat
850227825Stheraven{
851227825Stheraven#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
852227825Stheraven    __nat() = delete;
853227825Stheraven    __nat(const __nat&) = delete;
854227825Stheraven    __nat& operator=(const __nat&) = delete;
855227825Stheraven    ~__nat() = delete;
856227825Stheraven#endif
857227825Stheraven};
858227825Stheraven
859227825Stheraventemplate <class _Tp>
860227825Stheravenstruct __align_type
861227825Stheraven{
862227825Stheraven    static const size_t value = alignment_of<_Tp>::value;
863227825Stheraven    typedef _Tp type;
864227825Stheraven};
865227825Stheraven
866242945Stheravenstruct __struct_double {long double __lx;};
867242945Stheravenstruct __struct_double4 {double __lx[4];};
868227825Stheraven
869227825Stheraventypedef
870227825Stheraven    __type_list<__align_type<unsigned char>,
871227825Stheraven    __type_list<__align_type<unsigned short>,
872227825Stheraven    __type_list<__align_type<unsigned int>,
873227825Stheraven    __type_list<__align_type<unsigned long>,
874227825Stheraven    __type_list<__align_type<unsigned long long>,
875227825Stheraven    __type_list<__align_type<double>,
876227825Stheraven    __type_list<__align_type<long double>,
877227825Stheraven    __type_list<__align_type<__struct_double>,
878227825Stheraven    __type_list<__align_type<__struct_double4>,
879227825Stheraven    __type_list<__align_type<int*>,
880227825Stheraven    __nat
881227825Stheraven    > > > > > > > > > > __all_types;
882227825Stheraven
883227825Stheraventemplate <class _TL, size_t _Align> struct __find_pod;
884227825Stheraven
885227825Stheraventemplate <class _Hp, size_t _Align>
886227825Stheravenstruct __find_pod<__type_list<_Hp, __nat>, _Align>
887227825Stheraven{
888227825Stheraven    typedef typename conditional<
889227825Stheraven                             _Align == _Hp::value,
890227825Stheraven                             typename _Hp::type,
891227825Stheraven                             void
892227825Stheraven                         >::type type;
893227825Stheraven};
894227825Stheraven
895227825Stheraventemplate <class _Hp, class _Tp, size_t _Align>
896227825Stheravenstruct __find_pod<__type_list<_Hp, _Tp>, _Align>
897227825Stheraven{
898227825Stheraven    typedef typename conditional<
899227825Stheraven                             _Align == _Hp::value,
900227825Stheraven                             typename _Hp::type,
901227825Stheraven                             typename __find_pod<_Tp, _Align>::type
902227825Stheraven                         >::type type;
903227825Stheraven};
904227825Stheraven
905227825Stheraventemplate <class _TL, size_t _Len> struct __find_max_align;
906227825Stheraven
907227825Stheraventemplate <class _Hp, size_t _Len>
908227825Stheravenstruct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
909227825Stheraven
910227825Stheraventemplate <size_t _Len, size_t _A1, size_t _A2>
911227825Stheravenstruct __select_align
912227825Stheraven{
913227825Stheravenprivate:
914227825Stheraven    static const size_t __min = _A2 < _A1 ? _A2 : _A1;
915227825Stheraven    static const size_t __max = _A1 < _A2 ? _A2 : _A1;
916227825Stheravenpublic:
917227825Stheraven    static const size_t value = _Len < __max ? __min : __max;
918227825Stheraven};
919227825Stheraven
920227825Stheraventemplate <class _Hp, class _Tp, size_t _Len>
921227825Stheravenstruct __find_max_align<__type_list<_Hp, _Tp>, _Len>
922227825Stheraven    : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
923227825Stheraven
924227825Stheraventemplate <size_t _Len, const size_t _Align = __find_max_align<__all_types, _Len>::value>
925227825Stheravenstruct _LIBCPP_VISIBLE aligned_storage
926227825Stheraven{
927227825Stheraven    typedef typename __find_pod<__all_types, _Align>::type _Aligner;
928227825Stheraven    static_assert(!is_void<_Aligner>::value, "");
929227825Stheraven    union type
930227825Stheraven    {
931227825Stheraven        _Aligner __align;
932227825Stheraven        unsigned char __data[_Len];
933227825Stheraven    };
934227825Stheraven};
935227825Stheraven
936227825Stheraven#define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
937227825Stheraventemplate <size_t _Len>\
938227825Stheravenstruct _LIBCPP_VISIBLE aligned_storage<_Len, n>\
939227825Stheraven{\
940227825Stheraven    struct _ALIGNAS(n) type\
941227825Stheraven    {\
942242945Stheraven        unsigned char __lx[_Len];\
943227825Stheraven    };\
944227825Stheraven}
945227825Stheraven
946227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
947227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
948227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
949227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
950227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
951227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
952227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
953227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
954227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
955227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
956227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
957227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
958227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
959227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
960227825Stheraven// MSDN says that MSVC does not support alignment beyond 8192 (=0x2000)
961227825Stheraven#if !defined(_MSC_VER)
962227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
963227825Stheraven#endif // !_MSC_VER
964227825Stheraven
965227825Stheraven#undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
966227825Stheraven
967227825Stheraven// __promote
968227825Stheraven
969227825Stheraventemplate <class _A1, class _A2 = void, class _A3 = void,
970227825Stheraven          bool = (is_arithmetic<_A1>::value || is_void<_A1>::value) &&
971227825Stheraven                 (is_arithmetic<_A2>::value || is_void<_A2>::value) &&
972227825Stheraven                 (is_arithmetic<_A3>::value || is_void<_A3>::value)>
973227825Stheravenclass __promote {};
974227825Stheraven
975227825Stheraventemplate <class _A1, class _A2, class _A3>
976227825Stheravenclass __promote<_A1, _A2, _A3, true>
977227825Stheraven{
978227825Stheravenprivate:
979227825Stheraven    typedef typename __promote<_A1>::type __type1;
980227825Stheraven    typedef typename __promote<_A2>::type __type2;
981227825Stheraven    typedef typename __promote<_A3>::type __type3;
982227825Stheravenpublic:
983227825Stheraven    typedef decltype(__type1() + __type2() + __type3()) type;
984227825Stheraven};
985227825Stheraven
986227825Stheraventemplate <class _A1, class _A2>
987227825Stheravenclass __promote<_A1, _A2, void, true>
988227825Stheraven{
989227825Stheravenprivate:
990227825Stheraven    typedef typename __promote<_A1>::type __type1;
991227825Stheraven    typedef typename __promote<_A2>::type __type2;
992227825Stheravenpublic:
993227825Stheraven    typedef decltype(__type1() + __type2()) type;
994227825Stheraven};
995227825Stheraven
996227825Stheraventemplate <class _A1>
997227825Stheravenclass __promote<_A1, void, void, true>
998227825Stheraven{
999227825Stheravenpublic:
1000227825Stheraven    typedef typename conditional<is_arithmetic<_A1>::value,
1001227825Stheraven                     typename conditional<is_integral<_A1>::value, double, _A1>::type,
1002227825Stheraven                     void
1003227825Stheraven            >::type type;
1004227825Stheraven};
1005227825Stheraven
1006227825Stheraven#ifdef _LIBCPP_STORE_AS_OPTIMIZATION
1007227825Stheraven
1008227825Stheraven// __transform
1009227825Stheraven
1010227825Stheraventemplate <class _Tp, size_t = sizeof(_Tp), bool = is_scalar<_Tp>::value> struct __transform {typedef _Tp type;};
1011227825Stheraventemplate <class _Tp> struct __transform<_Tp, 1, true> {typedef unsigned char      type;};
1012227825Stheraventemplate <class _Tp> struct __transform<_Tp, 2, true> {typedef unsigned short     type;};
1013227825Stheraventemplate <class _Tp> struct __transform<_Tp, 4, true> {typedef unsigned int       type;};
1014227825Stheraventemplate <class _Tp> struct __transform<_Tp, 8, true> {typedef unsigned long long type;};
1015227825Stheraven
1016227825Stheraven#endif  // _LIBCPP_STORE_AS_OPTIMIZATION
1017227825Stheraven
1018227825Stheraven// make_signed / make_unsigned
1019227825Stheraven
1020227825Stheraventypedef
1021227825Stheraven    __type_list<signed char,
1022227825Stheraven    __type_list<signed short,
1023227825Stheraven    __type_list<signed int,
1024227825Stheraven    __type_list<signed long,
1025227825Stheraven    __type_list<signed long long,
1026227825Stheraven    __nat
1027227825Stheraven    > > > > > __signed_types;
1028227825Stheraven
1029227825Stheraventypedef
1030227825Stheraven    __type_list<unsigned char,
1031227825Stheraven    __type_list<unsigned short,
1032227825Stheraven    __type_list<unsigned int,
1033227825Stheraven    __type_list<unsigned long,
1034227825Stheraven    __type_list<unsigned long long,
1035227825Stheraven    __nat
1036227825Stheraven    > > > > > __unsigned_types;
1037227825Stheraven
1038227825Stheraventemplate <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
1039227825Stheraven
1040227825Stheraventemplate <class _Hp, class _Tp, size_t _Size>
1041227825Stheravenstruct __find_first<__type_list<_Hp, _Tp>, _Size, true>
1042227825Stheraven{
1043227825Stheraven    typedef _Hp type;
1044227825Stheraven};
1045227825Stheraven
1046227825Stheraventemplate <class _Hp, class _Tp, size_t _Size>
1047227825Stheravenstruct __find_first<__type_list<_Hp, _Tp>, _Size, false>
1048227825Stheraven{
1049227825Stheraven    typedef typename __find_first<_Tp, _Size>::type type;
1050227825Stheraven};
1051227825Stheraven
1052227825Stheraventemplate <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
1053227825Stheraven                             bool = is_volatile<typename remove_reference<_Tp>::type>::value>
1054227825Stheravenstruct __apply_cv
1055227825Stheraven{
1056227825Stheraven    typedef _Up type;
1057227825Stheraven};
1058227825Stheraven
1059227825Stheraventemplate <class _Tp, class _Up>
1060227825Stheravenstruct __apply_cv<_Tp, _Up, true, false>
1061227825Stheraven{
1062227825Stheraven    typedef const _Up type;
1063227825Stheraven};
1064227825Stheraven
1065227825Stheraventemplate <class _Tp, class _Up>
1066227825Stheravenstruct __apply_cv<_Tp, _Up, false, true>
1067227825Stheraven{
1068227825Stheraven    typedef volatile _Up type;
1069227825Stheraven};
1070227825Stheraven
1071227825Stheraventemplate <class _Tp, class _Up>
1072227825Stheravenstruct __apply_cv<_Tp, _Up, true, true>
1073227825Stheraven{
1074227825Stheraven    typedef const volatile _Up type;
1075227825Stheraven};
1076227825Stheraven
1077227825Stheraventemplate <class _Tp, class _Up>
1078227825Stheravenstruct __apply_cv<_Tp&, _Up, false, false>
1079227825Stheraven{
1080227825Stheraven    typedef _Up& type;
1081227825Stheraven};
1082227825Stheraven
1083227825Stheraventemplate <class _Tp, class _Up>
1084227825Stheravenstruct __apply_cv<_Tp&, _Up, true, false>
1085227825Stheraven{
1086227825Stheraven    typedef const _Up& type;
1087227825Stheraven};
1088227825Stheraven
1089227825Stheraventemplate <class _Tp, class _Up>
1090227825Stheravenstruct __apply_cv<_Tp&, _Up, false, true>
1091227825Stheraven{
1092227825Stheraven    typedef volatile _Up& type;
1093227825Stheraven};
1094227825Stheraven
1095227825Stheraventemplate <class _Tp, class _Up>
1096227825Stheravenstruct __apply_cv<_Tp&, _Up, true, true>
1097227825Stheraven{
1098227825Stheraven    typedef const volatile _Up& type;
1099227825Stheraven};
1100227825Stheraven
1101227825Stheraventemplate <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1102227825Stheravenstruct __make_signed {};
1103227825Stheraven
1104227825Stheraventemplate <class _Tp>
1105227825Stheravenstruct __make_signed<_Tp, true>
1106227825Stheraven{
1107227825Stheraven    typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
1108227825Stheraven};
1109227825Stheraven
1110227825Stheraventemplate <> struct __make_signed<bool,               true> {};
1111227825Stheraventemplate <> struct __make_signed<  signed short,     true> {typedef short     type;};
1112227825Stheraventemplate <> struct __make_signed<unsigned short,     true> {typedef short     type;};
1113227825Stheraventemplate <> struct __make_signed<  signed int,       true> {typedef int       type;};
1114227825Stheraventemplate <> struct __make_signed<unsigned int,       true> {typedef int       type;};
1115227825Stheraventemplate <> struct __make_signed<  signed long,      true> {typedef long      type;};
1116227825Stheraventemplate <> struct __make_signed<unsigned long,      true> {typedef long      type;};
1117227825Stheraventemplate <> struct __make_signed<  signed long long, true> {typedef long long type;};
1118227825Stheraventemplate <> struct __make_signed<unsigned long long, true> {typedef long long type;};
1119227825Stheraven
1120227825Stheraventemplate <class _Tp>
1121227825Stheravenstruct _LIBCPP_VISIBLE make_signed
1122227825Stheraven{
1123227825Stheraven    typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
1124227825Stheraven};
1125227825Stheraven
1126227825Stheraventemplate <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1127227825Stheravenstruct __make_unsigned {};
1128227825Stheraven
1129227825Stheraventemplate <class _Tp>
1130227825Stheravenstruct __make_unsigned<_Tp, true>
1131227825Stheraven{
1132227825Stheraven    typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
1133227825Stheraven};
1134227825Stheraven
1135227825Stheraventemplate <> struct __make_unsigned<bool,               true> {};
1136227825Stheraventemplate <> struct __make_unsigned<  signed short,     true> {typedef unsigned short     type;};
1137227825Stheraventemplate <> struct __make_unsigned<unsigned short,     true> {typedef unsigned short     type;};
1138227825Stheraventemplate <> struct __make_unsigned<  signed int,       true> {typedef unsigned int       type;};
1139227825Stheraventemplate <> struct __make_unsigned<unsigned int,       true> {typedef unsigned int       type;};
1140227825Stheraventemplate <> struct __make_unsigned<  signed long,      true> {typedef unsigned long      type;};
1141227825Stheraventemplate <> struct __make_unsigned<unsigned long,      true> {typedef unsigned long      type;};
1142227825Stheraventemplate <> struct __make_unsigned<  signed long long, true> {typedef unsigned long long type;};
1143227825Stheraventemplate <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
1144227825Stheraven
1145227825Stheraventemplate <class _Tp>
1146227825Stheravenstruct _LIBCPP_VISIBLE make_unsigned
1147227825Stheraven{
1148227825Stheraven    typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
1149227825Stheraven};
1150227825Stheraven
1151227825Stheraven#ifdef _LIBCPP_HAS_NO_VARIADICS
1152227825Stheraven
1153227825Stheraventemplate <class _Tp, class _Up = void, class V = void>
1154227825Stheravenstruct _LIBCPP_VISIBLE common_type
1155227825Stheraven{
1156227825Stheravenpublic:
1157227825Stheraven    typedef typename common_type<typename common_type<_Tp, _Up>::type, V>::type type;
1158227825Stheraven};
1159227825Stheraven
1160227825Stheraventemplate <class _Tp>
1161227825Stheravenstruct _LIBCPP_VISIBLE common_type<_Tp, void, void>
1162227825Stheraven{
1163227825Stheravenpublic:
1164227825Stheraven    typedef _Tp type;
1165227825Stheraven};
1166227825Stheraven
1167227825Stheraventemplate <class _Tp, class _Up>
1168227825Stheravenstruct _LIBCPP_VISIBLE common_type<_Tp, _Up, void>
1169227825Stheraven{
1170227825Stheravenprivate:
1171227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1172227825Stheraven    static _Tp&& __t();
1173227825Stheraven    static _Up&& __u();
1174227825Stheraven#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1175227825Stheraven    static _Tp __t();
1176227825Stheraven    static _Up __u();
1177227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1178227825Stheravenpublic:
1179232950Stheraven    typedef typename remove_reference<decltype(true ? __t() : __u())>::type type;
1180227825Stheraven};
1181227825Stheraven
1182227825Stheraven#else  // _LIBCPP_HAS_NO_VARIADICS
1183227825Stheraven
1184227825Stheraventemplate <class ..._Tp> struct common_type;
1185227825Stheraven
1186227825Stheraventemplate <class _Tp>
1187227825Stheravenstruct _LIBCPP_VISIBLE common_type<_Tp>
1188227825Stheraven{
1189227825Stheraven    typedef _Tp type;
1190227825Stheraven};
1191227825Stheraven
1192227825Stheraventemplate <class _Tp, class _Up>
1193227825Stheravenstruct _LIBCPP_VISIBLE common_type<_Tp, _Up>
1194227825Stheraven{
1195227825Stheravenprivate:
1196227825Stheraven    static _Tp&& __t();
1197227825Stheraven    static _Up&& __u();
1198227825Stheraven    static bool __f();
1199227825Stheravenpublic:
1200232950Stheraven    typedef typename remove_reference<decltype(__f() ? __t() : __u())>::type type;
1201227825Stheraven};
1202227825Stheraven
1203227825Stheraventemplate <class _Tp, class _Up, class ..._Vp>
1204227825Stheravenstruct _LIBCPP_VISIBLE common_type<_Tp, _Up, _Vp...>
1205227825Stheraven{
1206227825Stheraven    typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp...>::type type;
1207227825Stheraven};
1208227825Stheraven
1209227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
1210227825Stheraven
1211227825Stheraven// is_assignable
1212227825Stheraven
1213227825Stheraventemplate <class _Tp, class _Arg>
1214227825Stheravendecltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>(), true_type()))
1215227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1216227825Stheraven__is_assignable_test(_Tp&&, _Arg&&);
1217227825Stheraven#else
1218227825Stheraven__is_assignable_test(_Tp, _Arg&);
1219227825Stheraven#endif
1220227825Stheraven
1221227825Stheraventemplate <class _Arg>
1222227825Stheravenfalse_type
1223227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1224227825Stheraven__is_assignable_test(__any, _Arg&&);
1225227825Stheraven#else
1226227825Stheraven__is_assignable_test(__any, _Arg&);
1227227825Stheraven#endif
1228227825Stheraven
1229227825Stheraventemplate <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
1230227825Stheravenstruct __is_assignable_imp
1231227825Stheraven    : public common_type
1232227825Stheraven        <
1233227825Stheraven            decltype(__is_assignable_test(declval<_Tp>(), declval<_Arg>()))
1234227825Stheraven        >::type {};
1235227825Stheraven
1236227825Stheraventemplate <class _Tp, class _Arg>
1237227825Stheravenstruct __is_assignable_imp<_Tp, _Arg, true>
1238227825Stheraven    : public false_type
1239227825Stheraven{
1240227825Stheraven};
1241227825Stheraven
1242227825Stheraventemplate <class _Tp, class _Arg>
1243227825Stheravenstruct is_assignable
1244227825Stheraven    : public __is_assignable_imp<_Tp, _Arg> {};
1245227825Stheraven
1246227825Stheraven// is_copy_assignable
1247227825Stheraven
1248227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_copy_assignable
1249227825Stheraven    : public is_assignable<typename add_lvalue_reference<_Tp>::type,
1250227825Stheraven                     const typename add_lvalue_reference<_Tp>::type> {};
1251227825Stheraven
1252227825Stheraven// is_move_assignable
1253227825Stheraven
1254227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_move_assignable
1255227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1256227825Stheraven    : public is_assignable<typename add_lvalue_reference<_Tp>::type,
1257227825Stheraven                     const typename add_rvalue_reference<_Tp>::type> {};
1258227825Stheraven#else
1259227825Stheraven    : public is_copy_assignable<_Tp> {};
1260227825Stheraven#endif
1261227825Stheraven
1262227825Stheraven// is_destructible
1263227825Stheraven
1264227825Stheraventemplate <class _Tp>
1265227825Stheravenstruct __destructible_test
1266227825Stheraven{
1267227825Stheraven    _Tp __t;
1268227825Stheraven};
1269227825Stheraven
1270227825Stheraventemplate <class _Tp>
1271227825Stheravendecltype((_VSTD::declval<__destructible_test<_Tp> >().~__destructible_test<_Tp>(), true_type()))
1272227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1273227825Stheraven__is_destructible_test(_Tp&&);
1274227825Stheraven#else
1275227825Stheraven__is_destructible_test(_Tp&);
1276227825Stheraven#endif
1277227825Stheraven
1278227825Stheravenfalse_type
1279227825Stheraven__is_destructible_test(__any);
1280227825Stheraven
1281227825Stheraventemplate <class _Tp, bool = is_void<_Tp>::value || is_abstract<_Tp>::value>
1282227825Stheravenstruct __destructible_imp
1283227825Stheraven    : public common_type
1284227825Stheraven        <
1285227825Stheraven            decltype(__is_destructible_test(declval<_Tp>()))
1286227825Stheraven        >::type {};
1287227825Stheraven
1288227825Stheraventemplate <class _Tp>
1289227825Stheravenstruct __destructible_imp<_Tp, true>
1290227825Stheraven    : public false_type {};
1291227825Stheraven
1292227825Stheraventemplate <class _Tp>
1293227825Stheravenstruct is_destructible
1294227825Stheraven    : public __destructible_imp<_Tp> {};
1295227825Stheraven
1296227825Stheraven// move
1297227825Stheraven
1298227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1299227825Stheraven
1300227825Stheraventemplate <class _Tp>
1301227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1302227825Stheraventypename remove_reference<_Tp>::type&&
1303227825Stheravenmove(_Tp&& __t) _NOEXCEPT
1304227825Stheraven{
1305227825Stheraven    typedef typename remove_reference<_Tp>::type _Up;
1306227825Stheraven    return static_cast<_Up&&>(__t);
1307227825Stheraven}
1308227825Stheraven
1309227825Stheraventemplate <class _Tp>
1310227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1311227825Stheraven_Tp&&
1312227825Stheravenforward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
1313227825Stheraven{
1314227825Stheraven    return static_cast<_Tp&&>(__t);
1315227825Stheraven}
1316227825Stheraven
1317227825Stheraventemplate <class _Tp>
1318227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1319227825Stheraven_Tp&&
1320227825Stheravenforward(typename std::remove_reference<_Tp>::type&& __t) _NOEXCEPT
1321227825Stheraven{
1322227825Stheraven    static_assert(!std::is_lvalue_reference<_Tp>::value,
1323227825Stheraven                  "Can not forward an rvalue as an lvalue.");
1324227825Stheraven    return static_cast<_Tp&&>(__t);
1325227825Stheraven}
1326227825Stheraven
1327227825Stheraven#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1328227825Stheraven
1329227825Stheraventemplate <class _Tp>
1330227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1331234976Stheraven_Tp&
1332227825Stheravenmove(_Tp& __t)
1333227825Stheraven{
1334227825Stheraven    return __t;
1335227825Stheraven}
1336227825Stheraven
1337227825Stheraventemplate <class _Tp>
1338227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1339234976Stheravenconst _Tp&
1340232950Stheravenmove(const _Tp& __t)
1341232950Stheraven{
1342232950Stheraven    return __t;
1343232950Stheraven}
1344232950Stheraven
1345232950Stheraventemplate <class _Tp>
1346232950Stheraveninline _LIBCPP_INLINE_VISIBILITY
1347234976Stheraven_Tp&
1348234976Stheravenforward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
1349227825Stheraven{
1350227825Stheraven    return __t;
1351227825Stheraven}
1352227825Stheraven
1353227825Stheraven
1354234976Stheraventemplate <class _Tp>
1355234976Stheravenclass __rv
1356227825Stheraven{
1357234976Stheraven    typedef typename remove_reference<_Tp>::type _Trr;
1358234976Stheraven    _Trr& t_;
1359234976Stheravenpublic:
1360234976Stheraven    _LIBCPP_INLINE_VISIBILITY
1361234976Stheraven    _Trr* operator->() {return &t_;}
1362234976Stheraven    _LIBCPP_INLINE_VISIBILITY
1363234976Stheraven    explicit __rv(_Trr& __t) : t_(__t) {}
1364234976Stheraven};
1365227825Stheraven
1366227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1367227825Stheraven
1368227825Stheraventemplate <class _Tp>
1369227825Stheravenstruct _LIBCPP_VISIBLE decay
1370227825Stheraven{
1371227825Stheravenprivate:
1372227825Stheraven    typedef typename remove_reference<_Tp>::type _Up;
1373227825Stheravenpublic:
1374227825Stheraven    typedef typename conditional
1375227825Stheraven                     <
1376227825Stheraven                         is_array<_Up>::value,
1377227825Stheraven                         typename remove_extent<_Up>::type*,
1378227825Stheraven                         typename conditional
1379227825Stheraven                         <
1380227825Stheraven                              is_function<_Up>::value,
1381227825Stheraven                              typename add_pointer<_Up>::type,
1382227825Stheraven                              typename remove_cv<_Up>::type
1383227825Stheraven                         >::type
1384227825Stheraven                     >::type type;
1385227825Stheraven};
1386227825Stheraven
1387227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1388227825Stheraven
1389227825Stheraventemplate <class _Tp>
1390227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1391227825Stheraventypename decay<_Tp>::type
1392227825Stheraven__decay_copy(_Tp&& __t)
1393227825Stheraven{
1394227825Stheraven    return _VSTD::forward<_Tp>(__t);
1395227825Stheraven}
1396227825Stheraven
1397227825Stheraven#else
1398227825Stheraven
1399227825Stheraventemplate <class _Tp>
1400227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1401227825Stheraventypename decay<_Tp>::type
1402227825Stheraven__decay_copy(const _Tp& __t)
1403227825Stheraven{
1404227825Stheraven    return _VSTD::forward<_Tp>(__t);
1405227825Stheraven}
1406227825Stheraven
1407227825Stheraven#endif
1408227825Stheraven
1409227825Stheraventemplate <class _MP, bool _IsMemberFuctionPtr, bool _IsMemberObjectPtr>
1410227825Stheravenstruct __member_pointer_traits_imp
1411227825Stheraven{
1412227825Stheraven};
1413227825Stheraven
1414227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
1415227825Stheraven
1416232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1417232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
1418227825Stheraven{
1419227825Stheraven    typedef _Class _ClassType;
1420232950Stheraven    typedef _Rp _ReturnType;
1421227825Stheraven};
1422227825Stheraven
1423232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1424232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
1425227825Stheraven{
1426227825Stheraven    typedef _Class const _ClassType;
1427232950Stheraven    typedef _Rp _ReturnType;
1428227825Stheraven};
1429227825Stheraven
1430232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1431232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
1432227825Stheraven{
1433227825Stheraven    typedef _Class volatile _ClassType;
1434232950Stheraven    typedef _Rp _ReturnType;
1435227825Stheraven};
1436227825Stheraven
1437232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1438232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
1439227825Stheraven{
1440227825Stheraven    typedef _Class const volatile _ClassType;
1441232950Stheraven    typedef _Rp _ReturnType;
1442227825Stheraven};
1443227825Stheraven
1444227825Stheraven#if __has_feature(cxx_reference_qualified_functions)
1445227825Stheraven
1446232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1447232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
1448227825Stheraven{
1449227825Stheraven    typedef _Class& _ClassType;
1450232950Stheraven    typedef _Rp _ReturnType;
1451227825Stheraven};
1452227825Stheraven
1453232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1454232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
1455227825Stheraven{
1456227825Stheraven    typedef _Class const& _ClassType;
1457232950Stheraven    typedef _Rp _ReturnType;
1458227825Stheraven};
1459227825Stheraven
1460232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1461232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
1462227825Stheraven{
1463227825Stheraven    typedef _Class volatile& _ClassType;
1464232950Stheraven    typedef _Rp _ReturnType;
1465227825Stheraven};
1466227825Stheraven
1467232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1468232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
1469227825Stheraven{
1470227825Stheraven    typedef _Class const volatile& _ClassType;
1471232950Stheraven    typedef _Rp _ReturnType;
1472227825Stheraven};
1473227825Stheraven
1474232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1475232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
1476227825Stheraven{
1477227825Stheraven    typedef _Class&& _ClassType;
1478232950Stheraven    typedef _Rp _ReturnType;
1479227825Stheraven};
1480227825Stheraven
1481232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1482232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
1483227825Stheraven{
1484227825Stheraven    typedef _Class const&& _ClassType;
1485232950Stheraven    typedef _Rp _ReturnType;
1486227825Stheraven};
1487227825Stheraven
1488232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1489232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
1490227825Stheraven{
1491227825Stheraven    typedef _Class volatile&& _ClassType;
1492232950Stheraven    typedef _Rp _ReturnType;
1493227825Stheraven};
1494227825Stheraven
1495232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1496232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
1497227825Stheraven{
1498227825Stheraven    typedef _Class const volatile&& _ClassType;
1499232950Stheraven    typedef _Rp _ReturnType;
1500227825Stheraven};
1501227825Stheraven
1502227825Stheraven#endif  // __has_feature(cxx_reference_qualified_functions)
1503227825Stheraven
1504227825Stheraven#else  // _LIBCPP_HAS_NO_VARIADICS
1505227825Stheraven
1506232950Stheraventemplate <class _Rp, class _Class>
1507232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(), true, false>
1508227825Stheraven{
1509227825Stheraven    typedef _Class _ClassType;
1510232950Stheraven    typedef _Rp _ReturnType;
1511227825Stheraven};
1512227825Stheraven
1513232950Stheraventemplate <class _Rp, class _Class, class _P0>
1514232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false>
1515227825Stheraven{
1516227825Stheraven    typedef _Class _ClassType;
1517232950Stheraven    typedef _Rp _ReturnType;
1518227825Stheraven};
1519227825Stheraven
1520232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1>
1521232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false>
1522227825Stheraven{
1523227825Stheraven    typedef _Class _ClassType;
1524232950Stheraven    typedef _Rp _ReturnType;
1525227825Stheraven};
1526227825Stheraven
1527232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1, class _P2>
1528232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false>
1529227825Stheraven{
1530227825Stheraven    typedef _Class _ClassType;
1531232950Stheraven    typedef _Rp _ReturnType;
1532227825Stheraven};
1533227825Stheraven
1534232950Stheraventemplate <class _Rp, class _Class>
1535232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false>
1536227825Stheraven{
1537227825Stheraven    typedef _Class const _ClassType;
1538232950Stheraven    typedef _Rp _ReturnType;
1539227825Stheraven};
1540227825Stheraven
1541232950Stheraventemplate <class _Rp, class _Class, class _P0>
1542232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false>
1543227825Stheraven{
1544227825Stheraven    typedef _Class const _ClassType;
1545232950Stheraven    typedef _Rp _ReturnType;
1546227825Stheraven};
1547227825Stheraven
1548232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1>
1549232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false>
1550227825Stheraven{
1551227825Stheraven    typedef _Class const _ClassType;
1552232950Stheraven    typedef _Rp _ReturnType;
1553227825Stheraven};
1554227825Stheraven
1555232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1, class _P2>
1556232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, false>
1557227825Stheraven{
1558227825Stheraven    typedef _Class const _ClassType;
1559232950Stheraven    typedef _Rp _ReturnType;
1560227825Stheraven};
1561227825Stheraven
1562232950Stheraventemplate <class _Rp, class _Class>
1563232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false>
1564227825Stheraven{
1565227825Stheraven    typedef _Class volatile _ClassType;
1566232950Stheraven    typedef _Rp _ReturnType;
1567227825Stheraven};
1568227825Stheraven
1569232950Stheraventemplate <class _Rp, class _Class, class _P0>
1570232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false>
1571227825Stheraven{
1572227825Stheraven    typedef _Class volatile _ClassType;
1573232950Stheraven    typedef _Rp _ReturnType;
1574227825Stheraven};
1575227825Stheraven
1576232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1>
1577232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, false>
1578227825Stheraven{
1579227825Stheraven    typedef _Class volatile _ClassType;
1580232950Stheraven    typedef _Rp _ReturnType;
1581227825Stheraven};
1582227825Stheraven
1583232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1, class _P2>
1584232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true, false>
1585227825Stheraven{
1586227825Stheraven    typedef _Class volatile _ClassType;
1587232950Stheraven    typedef _Rp _ReturnType;
1588227825Stheraven};
1589227825Stheraven
1590232950Stheraventemplate <class _Rp, class _Class>
1591232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false>
1592227825Stheraven{
1593227825Stheraven    typedef _Class const volatile _ClassType;
1594232950Stheraven    typedef _Rp _ReturnType;
1595227825Stheraven};
1596227825Stheraven
1597232950Stheraventemplate <class _Rp, class _Class, class _P0>
1598232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, false>
1599227825Stheraven{
1600227825Stheraven    typedef _Class const volatile _ClassType;
1601232950Stheraven    typedef _Rp _ReturnType;
1602227825Stheraven};
1603227825Stheraven
1604232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1>
1605232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, true, false>
1606227825Stheraven{
1607227825Stheraven    typedef _Class const volatile _ClassType;
1608232950Stheraven    typedef _Rp _ReturnType;
1609227825Stheraven};
1610227825Stheraven
1611232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1, class _P2>
1612232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile, true, false>
1613227825Stheraven{
1614227825Stheraven    typedef _Class const volatile _ClassType;
1615232950Stheraven    typedef _Rp _ReturnType;
1616227825Stheraven};
1617227825Stheraven
1618227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
1619227825Stheraven
1620232950Stheraventemplate <class _Rp, class _Class>
1621232950Stheravenstruct __member_pointer_traits_imp<_Rp _Class::*, false, true>
1622227825Stheraven{
1623227825Stheraven    typedef _Class _ClassType;
1624232950Stheraven    typedef _Rp _ReturnType;
1625227825Stheraven};
1626227825Stheraven
1627227825Stheraventemplate <class _MP>
1628227825Stheravenstruct __member_pointer_traits
1629227825Stheraven    : public __member_pointer_traits_imp<_MP,
1630227825Stheraven                    is_member_function_pointer<_MP>::value,
1631227825Stheraven                    is_member_object_pointer<_MP>::value>
1632227825Stheraven{
1633227825Stheraven//     typedef ... _ClassType;
1634227825Stheraven//     typedef ... _ReturnType;
1635227825Stheraven};
1636227825Stheraven
1637227825Stheraven// result_of
1638227825Stheraven
1639227825Stheraventemplate <class _Callable> class result_of;
1640227825Stheraven
1641241903Sdim#ifdef _LIBCPP_HAS_NO_VARIADICS
1642241903Sdim
1643227825Stheraventemplate <class _Fn, bool, bool>
1644227825Stheravenclass __result_of
1645227825Stheraven{
1646227825Stheraven};
1647227825Stheraven
1648227825Stheraventemplate <class _Fn>
1649227825Stheravenclass __result_of<_Fn(), true, false>
1650227825Stheraven{
1651227825Stheravenpublic:
1652227825Stheraven    typedef decltype(declval<_Fn>()()) type;
1653227825Stheraven};
1654227825Stheraven
1655227825Stheraventemplate <class _Fn, class _A0>
1656227825Stheravenclass __result_of<_Fn(_A0), true, false>
1657227825Stheraven{
1658227825Stheravenpublic:
1659227825Stheraven    typedef decltype(declval<_Fn>()(declval<_A0>())) type;
1660227825Stheraven};
1661227825Stheraven
1662227825Stheraventemplate <class _Fn, class _A0, class _A1>
1663227825Stheravenclass __result_of<_Fn(_A0, _A1), true, false>
1664227825Stheraven{
1665227825Stheravenpublic:
1666227825Stheraven    typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type;
1667227825Stheraven};
1668227825Stheraven
1669227825Stheraventemplate <class _Fn, class _A0, class _A1, class _A2>
1670227825Stheravenclass __result_of<_Fn(_A0, _A1, _A2), true, false>
1671227825Stheraven{
1672227825Stheravenpublic:
1673227825Stheraven    typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type;
1674227825Stheraven};
1675227825Stheraven
1676227825Stheraventemplate <class _MP, class _Tp, bool _IsMemberFunctionPtr>
1677227825Stheravenstruct __result_of_mp;
1678227825Stheraven
1679227825Stheraven// member function pointer
1680227825Stheraven
1681227825Stheraventemplate <class _MP, class _Tp>
1682227825Stheravenstruct __result_of_mp<_MP, _Tp, true>
1683227825Stheraven    : public common_type<typename __member_pointer_traits<_MP>::_ReturnType>
1684227825Stheraven{
1685227825Stheraven};
1686227825Stheraven
1687227825Stheraven// member data pointer
1688227825Stheraven
1689227825Stheraventemplate <class _MP, class _Tp, bool>
1690227825Stheravenstruct __result_of_mdp;
1691227825Stheraven
1692232950Stheraventemplate <class _Rp, class _Class, class _Tp>
1693232950Stheravenstruct __result_of_mdp<_Rp _Class::*, _Tp, false>
1694227825Stheraven{
1695232950Stheraven    typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type;
1696227825Stheraven};
1697227825Stheraven
1698232950Stheraventemplate <class _Rp, class _Class, class _Tp>
1699232950Stheravenstruct __result_of_mdp<_Rp _Class::*, _Tp, true>
1700227825Stheraven{
1701232950Stheraven    typedef typename __apply_cv<_Tp, _Rp>::type& type;
1702227825Stheraven};
1703227825Stheraven
1704232950Stheraventemplate <class _Rp, class _Class, class _Tp>
1705232950Stheravenstruct __result_of_mp<_Rp _Class::*, _Tp, false>
1706232950Stheraven    : public __result_of_mdp<_Rp _Class::*, _Tp,
1707227825Stheraven            is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
1708227825Stheraven{
1709227825Stheraven};
1710227825Stheraven
1711227825Stheraven
1712227825Stheraven
1713227825Stheraventemplate <class _Fn, class _Tp>
1714227825Stheravenclass __result_of<_Fn(_Tp), false, true>  // _Fn must be member pointer
1715227825Stheraven    : public __result_of_mp<typename remove_reference<_Fn>::type,
1716227825Stheraven                            _Tp,
1717227825Stheraven                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1718227825Stheraven{
1719227825Stheraven};
1720227825Stheraven
1721227825Stheraventemplate <class _Fn, class _Tp, class _A0>
1722227825Stheravenclass __result_of<_Fn(_Tp, _A0), false, true>  // _Fn must be member pointer
1723227825Stheraven    : public __result_of_mp<typename remove_reference<_Fn>::type,
1724227825Stheraven                            _Tp,
1725227825Stheraven                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1726227825Stheraven{
1727227825Stheraven};
1728227825Stheraven
1729227825Stheraventemplate <class _Fn, class _Tp, class _A0, class _A1>
1730227825Stheravenclass __result_of<_Fn(_Tp, _A0, _A1), false, true>  // _Fn must be member pointer
1731227825Stheraven    : public __result_of_mp<typename remove_reference<_Fn>::type,
1732227825Stheraven                            _Tp,
1733227825Stheraven                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1734227825Stheraven{
1735227825Stheraven};
1736227825Stheraven
1737227825Stheraventemplate <class _Fn, class _Tp, class _A0, class _A1, class _A2>
1738227825Stheravenclass __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true>  // _Fn must be member pointer
1739227825Stheraven    : public __result_of_mp<typename remove_reference<_Fn>::type,
1740227825Stheraven                            _Tp,
1741227825Stheraven                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1742227825Stheraven{
1743227825Stheraven};
1744227825Stheraven
1745227825Stheraven// result_of
1746227825Stheraven
1747227825Stheraventemplate <class _Fn>
1748227825Stheravenclass _LIBCPP_VISIBLE result_of<_Fn()>
1749227825Stheraven    : public __result_of<_Fn(),
1750227825Stheraven                         is_class<typename remove_reference<_Fn>::type>::value ||
1751227825Stheraven                         is_function<typename remove_reference<_Fn>::type>::value,
1752227825Stheraven                         is_member_pointer<typename remove_reference<_Fn>::type>::value
1753227825Stheraven                        >
1754227825Stheraven{
1755227825Stheraven};
1756227825Stheraven
1757227825Stheraventemplate <class _Fn, class _A0>
1758227825Stheravenclass _LIBCPP_VISIBLE result_of<_Fn(_A0)>
1759227825Stheraven    : public __result_of<_Fn(_A0),
1760227825Stheraven                         is_class<typename remove_reference<_Fn>::type>::value ||
1761227825Stheraven                         is_function<typename remove_reference<_Fn>::type>::value,
1762227825Stheraven                         is_member_pointer<typename remove_reference<_Fn>::type>::value
1763227825Stheraven                        >
1764227825Stheraven{
1765227825Stheraven};
1766227825Stheraven
1767227825Stheraventemplate <class _Fn, class _A0, class _A1>
1768227825Stheravenclass _LIBCPP_VISIBLE result_of<_Fn(_A0, _A1)>
1769227825Stheraven    : public __result_of<_Fn(_A0, _A1),
1770227825Stheraven                         is_class<typename remove_reference<_Fn>::type>::value ||
1771227825Stheraven                         is_function<typename remove_reference<_Fn>::type>::value,
1772227825Stheraven                         is_member_pointer<typename remove_reference<_Fn>::type>::value
1773227825Stheraven                        >
1774227825Stheraven{
1775227825Stheraven};
1776227825Stheraven
1777227825Stheraventemplate <class _Fn, class _A0, class _A1, class _A2>
1778227825Stheravenclass _LIBCPP_VISIBLE result_of<_Fn(_A0, _A1, _A2)>
1779227825Stheraven    : public __result_of<_Fn(_A0, _A1, _A2),
1780227825Stheraven                         is_class<typename remove_reference<_Fn>::type>::value ||
1781227825Stheraven                         is_function<typename remove_reference<_Fn>::type>::value,
1782227825Stheraven                         is_member_pointer<typename remove_reference<_Fn>::type>::value
1783227825Stheraven                        >
1784227825Stheraven{
1785227825Stheraven};
1786227825Stheraven
1787227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
1788227825Stheraven
1789227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
1790227825Stheraven
1791227825Stheraven// template <class T, class... Args> struct is_constructible;
1792227825Stheraven
1793227825Stheraven//      main is_constructible test
1794227825Stheraven
1795242945Stheraventemplate<typename, typename T> struct __select_2nd { typedef T type; };
1796242945Stheraven
1797227825Stheraventemplate <class _Tp, class ..._Args>
1798242945Stheraventypename __select_2nd<decltype(_VSTD::move(_Tp(_VSTD::declval<_Args>()...))), true_type>::type
1799227825Stheraven__is_constructible_test(_Tp&&, _Args&& ...);
1800227825Stheraven
1801227825Stheraventemplate <class ..._Args>
1802227825Stheravenfalse_type
1803227825Stheraven__is_constructible_test(__any, _Args&& ...);
1804227825Stheraven
1805227825Stheraventemplate <bool, class _Tp, class... _Args>
1806227825Stheravenstruct __is_constructible // false, _Tp is not a scalar
1807227825Stheraven    : public common_type
1808227825Stheraven             <
1809227825Stheraven                 decltype(__is_constructible_test(declval<_Tp>(), declval<_Args>()...))
1810227825Stheraven             >::type
1811227825Stheraven    {};
1812227825Stheraven
1813227825Stheraven//      function types are not constructible
1814227825Stheraven
1815232950Stheraventemplate <class _Rp, class... _A1, class... _A2>
1816232950Stheravenstruct __is_constructible<false, _Rp(_A1...), _A2...>
1817227825Stheraven    : public false_type
1818227825Stheraven    {};
1819227825Stheraven
1820227825Stheraven//      handle scalars and reference types
1821227825Stheraven
1822227825Stheraven//      Scalars are default constructible, references are not
1823227825Stheraven
1824227825Stheraventemplate <class _Tp>
1825227825Stheravenstruct __is_constructible<true, _Tp>
1826227825Stheraven    : public is_scalar<_Tp>
1827227825Stheraven    {};
1828227825Stheraven
1829227825Stheraven//      Scalars and references are constructible from one arg if that arg is
1830227825Stheraven//          implicitly convertible to the scalar or reference.
1831227825Stheraven
1832227825Stheraventemplate <class _Tp>
1833227825Stheravenstruct __is_constructible_ref
1834227825Stheraven{
1835242945Stheraven    true_type static __lxx(_Tp);
1836242945Stheraven    false_type static __lxx(...);
1837227825Stheraven};
1838227825Stheraven
1839227825Stheraventemplate <class _Tp, class _A0>
1840227825Stheravenstruct __is_constructible<true, _Tp, _A0>
1841227825Stheraven    : public common_type
1842227825Stheraven             <
1843242945Stheraven                 decltype(__is_constructible_ref<_Tp>::__lxx(declval<_A0>()))
1844227825Stheraven             >::type
1845227825Stheraven    {};
1846227825Stheraven
1847227825Stheraven//      Scalars and references are not constructible from multiple args.
1848227825Stheraven
1849227825Stheraventemplate <class _Tp, class _A0, class ..._Args>
1850227825Stheravenstruct __is_constructible<true, _Tp, _A0, _Args...>
1851227825Stheraven    : public false_type
1852227825Stheraven    {};
1853227825Stheraven
1854227825Stheraven//      Treat scalars and reference types separately
1855227825Stheraven
1856227825Stheraventemplate <bool, class _Tp, class... _Args>
1857227825Stheravenstruct __is_constructible_void_check
1858227825Stheraven    : public __is_constructible<is_scalar<_Tp>::value || is_reference<_Tp>::value,
1859227825Stheraven                                _Tp, _Args...>
1860227825Stheraven    {};
1861227825Stheraven
1862227825Stheraven//      If any of T or Args is void, is_constructible should be false
1863227825Stheraven
1864227825Stheraventemplate <class _Tp, class... _Args>
1865227825Stheravenstruct __is_constructible_void_check<true, _Tp, _Args...>
1866227825Stheraven    : public false_type
1867227825Stheraven    {};
1868227825Stheraven
1869227825Stheraventemplate <class ..._Args> struct __contains_void;
1870227825Stheraven
1871227825Stheraventemplate <> struct __contains_void<> : false_type {};
1872227825Stheraven
1873227825Stheraventemplate <class _A0, class ..._Args>
1874227825Stheravenstruct __contains_void<_A0, _Args...>
1875227825Stheraven{
1876227825Stheraven    static const bool value = is_void<_A0>::value ||
1877227825Stheraven                              __contains_void<_Args...>::value;
1878227825Stheraven};
1879227825Stheraven
1880227825Stheraven//      is_constructible entry point
1881227825Stheraven
1882227825Stheraventemplate <class _Tp, class... _Args>
1883227825Stheravenstruct _LIBCPP_VISIBLE is_constructible
1884227825Stheraven    : public __is_constructible_void_check<__contains_void<_Tp, _Args...>::value
1885227825Stheraven                                        || is_abstract<_Tp>::value,
1886227825Stheraven                                           _Tp, _Args...>
1887227825Stheraven    {};
1888227825Stheraven
1889227825Stheraven//      Array types are default constructible if their element type
1890227825Stheraven//      is default constructible
1891227825Stheraven
1892232950Stheraventemplate <class _Ap, size_t _Np>
1893232950Stheravenstruct __is_constructible<false, _Ap[_Np]>
1894232950Stheraven    : public is_constructible<typename remove_all_extents<_Ap>::type>
1895227825Stheraven    {};
1896227825Stheraven
1897227825Stheraven//      Otherwise array types are not constructible by this syntax
1898227825Stheraven
1899232950Stheraventemplate <class _Ap, size_t _Np, class ..._Args>
1900232950Stheravenstruct __is_constructible<false, _Ap[_Np], _Args...>
1901227825Stheraven    : public false_type
1902227825Stheraven    {};
1903227825Stheraven
1904227825Stheraven//      Incomplete array types are not constructible
1905227825Stheraven
1906232950Stheraventemplate <class _Ap, class ..._Args>
1907232950Stheravenstruct __is_constructible<false, _Ap[], _Args...>
1908227825Stheraven    : public false_type
1909227825Stheraven    {};
1910227825Stheraven
1911227825Stheraven#else  // _LIBCPP_HAS_NO_VARIADICS
1912227825Stheraven
1913227825Stheraven// template <class T> struct is_constructible0;
1914227825Stheraven
1915227825Stheraven//      main is_constructible0 test
1916227825Stheraven
1917227825Stheraventemplate <class _Tp>
1918227825Stheravendecltype((_Tp(), true_type()))
1919227825Stheraven__is_constructible0_test(_Tp&);
1920227825Stheraven
1921227825Stheravenfalse_type
1922227825Stheraven__is_constructible0_test(__any);
1923227825Stheraven
1924227825Stheraventemplate <class _Tp, class _A0>
1925227825Stheravendecltype((_Tp(_VSTD::declval<_A0>()), true_type()))
1926227825Stheraven__is_constructible1_test(_Tp&, _A0&);
1927227825Stheraven
1928227825Stheraventemplate <class _A0>
1929227825Stheravenfalse_type
1930227825Stheraven__is_constructible1_test(__any, _A0&);
1931227825Stheraven
1932227825Stheraventemplate <class _Tp, class _A0, class _A1>
1933227825Stheravendecltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>()), true_type()))
1934227825Stheraven__is_constructible2_test(_Tp&, _A0&, _A1&);
1935227825Stheraven
1936227825Stheraventemplate <class _A0, class _A1>
1937227825Stheravenfalse_type
1938227825Stheraven__is_constructible2_test(__any, _A0&, _A1&);
1939227825Stheraven
1940227825Stheraventemplate <bool, class _Tp>
1941227825Stheravenstruct __is_constructible0_imp // false, _Tp is not a scalar
1942227825Stheraven    : public common_type
1943227825Stheraven             <
1944227825Stheraven                 decltype(__is_constructible0_test(declval<_Tp&>()))
1945227825Stheraven             >::type
1946227825Stheraven    {};
1947227825Stheraven
1948227825Stheraventemplate <bool, class _Tp, class _A0>
1949227825Stheravenstruct __is_constructible1_imp // false, _Tp is not a scalar
1950227825Stheraven    : public common_type
1951227825Stheraven             <
1952227825Stheraven                 decltype(__is_constructible1_test(declval<_Tp&>(), declval<_A0&>()))
1953227825Stheraven             >::type
1954227825Stheraven    {};
1955227825Stheraven
1956227825Stheraventemplate <bool, class _Tp, class _A0, class _A1>
1957227825Stheravenstruct __is_constructible2_imp // false, _Tp is not a scalar
1958227825Stheraven    : public common_type
1959227825Stheraven             <
1960227825Stheraven                 decltype(__is_constructible2_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>()))
1961227825Stheraven             >::type
1962227825Stheraven    {};
1963227825Stheraven
1964227825Stheraven//      handle scalars and reference types
1965227825Stheraven
1966227825Stheraven//      Scalars are default constructible, references are not
1967227825Stheraven
1968227825Stheraventemplate <class _Tp>
1969227825Stheravenstruct __is_constructible0_imp<true, _Tp>
1970227825Stheraven    : public is_scalar<_Tp>
1971227825Stheraven    {};
1972227825Stheraven
1973227825Stheraventemplate <class _Tp, class _A0>
1974227825Stheravenstruct __is_constructible1_imp<true, _Tp, _A0>
1975227825Stheraven    : public is_convertible<_A0, _Tp>
1976227825Stheraven    {};
1977227825Stheraven
1978227825Stheraventemplate <class _Tp, class _A0, class _A1>
1979227825Stheravenstruct __is_constructible2_imp<true, _Tp, _A0, _A1>
1980227825Stheraven    : public false_type
1981227825Stheraven    {};
1982227825Stheraven
1983227825Stheraven//      Treat scalars and reference types separately
1984227825Stheraven
1985227825Stheraventemplate <bool, class _Tp>
1986227825Stheravenstruct __is_constructible0_void_check
1987227825Stheraven    : public __is_constructible0_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
1988227825Stheraven                                _Tp>
1989227825Stheraven    {};
1990227825Stheraven
1991227825Stheraventemplate <bool, class _Tp, class _A0>
1992227825Stheravenstruct __is_constructible1_void_check
1993227825Stheraven    : public __is_constructible1_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
1994227825Stheraven                                _Tp, _A0>
1995227825Stheraven    {};
1996227825Stheraven
1997227825Stheraventemplate <bool, class _Tp, class _A0, class _A1>
1998227825Stheravenstruct __is_constructible2_void_check
1999227825Stheraven    : public __is_constructible2_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2000227825Stheraven                                _Tp, _A0, _A1>
2001227825Stheraven    {};
2002227825Stheraven
2003227825Stheraven//      If any of T or Args is void, is_constructible should be false
2004227825Stheraven
2005227825Stheraventemplate <class _Tp>
2006227825Stheravenstruct __is_constructible0_void_check<true, _Tp>
2007227825Stheraven    : public false_type
2008227825Stheraven    {};
2009227825Stheraven
2010227825Stheraventemplate <class _Tp, class _A0>
2011227825Stheravenstruct __is_constructible1_void_check<true, _Tp, _A0>
2012227825Stheraven    : public false_type
2013227825Stheraven    {};
2014227825Stheraven
2015227825Stheraventemplate <class _Tp, class _A0, class _A1>
2016227825Stheravenstruct __is_constructible2_void_check<true, _Tp, _A0, _A1>
2017227825Stheraven    : public false_type
2018227825Stheraven    {};
2019227825Stheraven
2020227825Stheraven//      is_constructible entry point
2021227825Stheraven
2022227825Stheravennamespace __is_construct
2023227825Stheraven{
2024227825Stheraven
2025227825Stheravenstruct __nat {};
2026227825Stheraven
2027227825Stheraven}
2028227825Stheraven
2029227825Stheraventemplate <class _Tp, class _A0 = __is_construct::__nat,
2030227825Stheraven                     class _A1 = __is_construct::__nat>
2031227825Stheravenstruct _LIBCPP_VISIBLE is_constructible
2032227825Stheraven    : public __is_constructible2_void_check<is_void<_Tp>::value
2033227825Stheraven                                        || is_abstract<_Tp>::value
2034227825Stheraven                                        || is_function<_Tp>::value
2035227825Stheraven                                        || is_void<_A0>::value
2036227825Stheraven                                        || is_void<_A1>::value,
2037227825Stheraven                                           _Tp, _A0, _A1>
2038227825Stheraven    {};
2039227825Stheraven
2040227825Stheraventemplate <class _Tp>
2041227825Stheravenstruct _LIBCPP_VISIBLE is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat>
2042227825Stheraven    : public __is_constructible0_void_check<is_void<_Tp>::value
2043227825Stheraven                                        || is_abstract<_Tp>::value
2044227825Stheraven                                        || is_function<_Tp>::value,
2045227825Stheraven                                           _Tp>
2046227825Stheraven    {};
2047227825Stheraven
2048227825Stheraventemplate <class _Tp, class _A0>
2049227825Stheravenstruct _LIBCPP_VISIBLE is_constructible<_Tp, _A0, __is_construct::__nat>
2050227825Stheraven    : public __is_constructible1_void_check<is_void<_Tp>::value
2051227825Stheraven                                        || is_abstract<_Tp>::value
2052227825Stheraven                                        || is_function<_Tp>::value
2053227825Stheraven                                        || is_void<_A0>::value,
2054227825Stheraven                                           _Tp, _A0>
2055227825Stheraven    {};
2056227825Stheraven
2057227825Stheraven//      Array types are default constructible if their element type
2058227825Stheraven//      is default constructible
2059227825Stheraven
2060232950Stheraventemplate <class _Ap, size_t _Np>
2061232950Stheravenstruct __is_constructible0_imp<false, _Ap[_Np]>
2062232950Stheraven    : public is_constructible<typename remove_all_extents<_Ap>::type>
2063227825Stheraven    {};
2064227825Stheraven
2065232950Stheraventemplate <class _Ap, size_t _Np, class _A0>
2066232950Stheravenstruct __is_constructible1_imp<false, _Ap[_Np], _A0>
2067227825Stheraven    : public false_type
2068227825Stheraven    {};
2069227825Stheraven
2070232950Stheraventemplate <class _Ap, size_t _Np, class _A0, class _A1>
2071232950Stheravenstruct __is_constructible2_imp<false, _Ap[_Np], _A0, _A1>
2072227825Stheraven    : public false_type
2073227825Stheraven    {};
2074227825Stheraven
2075227825Stheraven//      Incomplete array types are not constructible
2076227825Stheraven
2077232950Stheraventemplate <class _Ap>
2078232950Stheravenstruct __is_constructible0_imp<false, _Ap[]>
2079227825Stheraven    : public false_type
2080227825Stheraven    {};
2081227825Stheraven
2082232950Stheraventemplate <class _Ap, class _A0>
2083232950Stheravenstruct __is_constructible1_imp<false, _Ap[], _A0>
2084227825Stheraven    : public false_type
2085227825Stheraven    {};
2086227825Stheraven
2087232950Stheraventemplate <class _Ap, class _A0, class _A1>
2088232950Stheravenstruct __is_constructible2_imp<false, _Ap[], _A0, _A1>
2089227825Stheraven    : public false_type
2090227825Stheraven    {};
2091227825Stheraven
2092227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
2093227825Stheraven
2094227825Stheraven// is_default_constructible
2095227825Stheraven
2096227825Stheraventemplate <class _Tp>
2097227825Stheravenstruct _LIBCPP_VISIBLE is_default_constructible
2098227825Stheraven    : public is_constructible<_Tp>
2099227825Stheraven    {};
2100227825Stheraven
2101227825Stheraven// is_copy_constructible
2102227825Stheraven
2103227825Stheraventemplate <class _Tp>
2104227825Stheravenstruct _LIBCPP_VISIBLE is_copy_constructible
2105227825Stheraven    : public is_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type>
2106227825Stheraven    {};
2107227825Stheraven
2108227825Stheraven// is_move_constructible
2109227825Stheraven
2110227825Stheraventemplate <class _Tp>
2111227825Stheravenstruct _LIBCPP_VISIBLE is_move_constructible
2112227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2113227825Stheraven    : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2114227825Stheraven#else
2115227825Stheraven    : public is_copy_constructible<_Tp>
2116227825Stheraven#endif
2117227825Stheraven    {};
2118227825Stheraven
2119227825Stheraven// is_trivially_constructible
2120227825Stheraven
2121227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
2122227825Stheraven
2123232950Stheraven#if __has_feature(is_trivially_constructible)
2124232950Stheraven
2125227825Stheraventemplate <class _Tp, class... _Args>
2126227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible
2127232950Stheraven    : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
2128232950Stheraven{
2129232950Stheraven};
2130232950Stheraven
2131232950Stheraven#else  // !__has_feature(is_trivially_constructible)
2132232950Stheraven
2133232950Stheraventemplate <class _Tp, class... _Args>
2134232950Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible
2135227825Stheraven    : false_type
2136227825Stheraven{
2137227825Stheraven};
2138227825Stheraven
2139227825Stheraventemplate <class _Tp>
2140227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp>
2141227825Stheraven#if __has_feature(has_trivial_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2142227825Stheraven    : integral_constant<bool, __has_trivial_constructor(_Tp)>
2143227825Stheraven#else
2144227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2145227825Stheraven#endif
2146227825Stheraven{
2147227825Stheraven};
2148227825Stheraven
2149227825Stheraventemplate <class _Tp>
2150227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2151227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp&&>
2152227825Stheraven#else
2153227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp>
2154227825Stheraven#endif
2155227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2156227825Stheraven{
2157227825Stheraven};
2158227825Stheraven
2159227825Stheraventemplate <class _Tp>
2160227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, const _Tp&>
2161227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2162227825Stheraven{
2163227825Stheraven};
2164227825Stheraven
2165227825Stheraventemplate <class _Tp>
2166227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp&>
2167227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2168227825Stheraven{
2169227825Stheraven};
2170227825Stheraven
2171232950Stheraven#endif  // !__has_feature(is_trivially_constructible)
2172232950Stheraven
2173227825Stheraven#else  // _LIBCPP_HAS_NO_VARIADICS
2174227825Stheraven
2175227825Stheraventemplate <class _Tp, class _A0 = __is_construct::__nat,
2176227825Stheraven                     class _A1 = __is_construct::__nat>
2177227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible
2178227825Stheraven    : false_type
2179227825Stheraven{
2180227825Stheraven};
2181227825Stheraven
2182232950Stheraven#if __has_feature(is_trivially_constructible)
2183232950Stheraven
2184227825Stheraventemplate <class _Tp>
2185227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, __is_construct::__nat,
2186227825Stheraven                                                       __is_construct::__nat>
2187232950Stheraven    : integral_constant<bool, __is_trivially_constructible(_Tp)>
2188232950Stheraven{
2189232950Stheraven};
2190232950Stheraven
2191232950Stheraventemplate <class _Tp>
2192232950Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp,
2193232950Stheraven                                                       __is_construct::__nat>
2194232950Stheraven    : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp)>
2195232950Stheraven{
2196232950Stheraven};
2197232950Stheraven
2198232950Stheraventemplate <class _Tp>
2199232950Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, const _Tp&,
2200232950Stheraven                                                       __is_construct::__nat>
2201232950Stheraven    : integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)>
2202232950Stheraven{
2203232950Stheraven};
2204232950Stheraven
2205232950Stheraventemplate <class _Tp>
2206232950Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp&,
2207232950Stheraven                                                       __is_construct::__nat>
2208232950Stheraven    : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&)>
2209232950Stheraven{
2210232950Stheraven};
2211232950Stheraven
2212232950Stheraven#else  // !__has_feature(is_trivially_constructible)
2213232950Stheraven
2214232950Stheraventemplate <class _Tp>
2215232950Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, __is_construct::__nat,
2216232950Stheraven                                                       __is_construct::__nat>
2217227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2218227825Stheraven{
2219227825Stheraven};
2220227825Stheraven
2221227825Stheraventemplate <class _Tp>
2222227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp,
2223227825Stheraven                                                       __is_construct::__nat>
2224227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2225227825Stheraven{
2226227825Stheraven};
2227227825Stheraven
2228227825Stheraventemplate <class _Tp>
2229227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, const _Tp&,
2230227825Stheraven                                                       __is_construct::__nat>
2231227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2232227825Stheraven{
2233227825Stheraven};
2234227825Stheraven
2235227825Stheraventemplate <class _Tp>
2236227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp&,
2237227825Stheraven                                                       __is_construct::__nat>
2238227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2239227825Stheraven{
2240227825Stheraven};
2241227825Stheraven
2242232950Stheraven#endif  // !__has_feature(is_trivially_constructible)
2243232950Stheraven
2244227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
2245227825Stheraven
2246227825Stheraven// is_trivially_default_constructible
2247227825Stheraven
2248227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivially_default_constructible
2249227825Stheraven    : public is_trivially_constructible<_Tp>
2250227825Stheraven    {};
2251227825Stheraven
2252227825Stheraven// is_trivially_copy_constructible
2253227825Stheraven
2254227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivially_copy_constructible
2255227825Stheraven    : public is_trivially_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type>
2256227825Stheraven    {};
2257227825Stheraven
2258227825Stheraven// is_trivially_move_constructible
2259227825Stheraven
2260227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivially_move_constructible
2261227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2262227825Stheraven    : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2263227825Stheraven#else
2264227825Stheraven    : public is_trivially_copy_constructible<_Tp>
2265227825Stheraven#endif
2266227825Stheraven    {};
2267227825Stheraven
2268227825Stheraven// is_trivially_assignable
2269227825Stheraven
2270232950Stheraven#if __has_feature(is_trivially_constructible)
2271232950Stheraven
2272227825Stheraventemplate <class _Tp, class _Arg>
2273227825Stheravenstruct is_trivially_assignable
2274232950Stheraven    : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
2275232950Stheraven{
2276232950Stheraven};
2277232950Stheraven
2278232950Stheraven#else  // !__has_feature(is_trivially_constructible)
2279232950Stheraven
2280232950Stheraventemplate <class _Tp, class _Arg>
2281232950Stheravenstruct is_trivially_assignable
2282227825Stheraven    : public false_type {};
2283227825Stheraven
2284227825Stheraventemplate <class _Tp>
2285227825Stheravenstruct is_trivially_assignable<_Tp&, _Tp>
2286227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2287227825Stheraven
2288227825Stheraventemplate <class _Tp>
2289227825Stheravenstruct is_trivially_assignable<_Tp&, _Tp&>
2290227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2291227825Stheraven
2292227825Stheraventemplate <class _Tp>
2293227825Stheravenstruct is_trivially_assignable<_Tp&, const _Tp&>
2294227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2295227825Stheraven
2296227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2297227825Stheraven
2298227825Stheraventemplate <class _Tp>
2299227825Stheravenstruct is_trivially_assignable<_Tp&, _Tp&&>
2300227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2301227825Stheraven
2302227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2303227825Stheraven
2304232950Stheraven#endif  // !__has_feature(is_trivially_constructible)
2305232950Stheraven
2306227825Stheraven// is_trivially_copy_assignable
2307227825Stheraven
2308227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivially_copy_assignable
2309227825Stheraven    : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
2310227825Stheraven                               const typename add_lvalue_reference<_Tp>::type>
2311227825Stheraven    {};
2312227825Stheraven
2313227825Stheraven// is_trivially_move_assignable
2314227825Stheraven
2315227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivially_move_assignable
2316227825Stheraven    : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
2317227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2318227825Stheraven                                     typename add_rvalue_reference<_Tp>::type>
2319227825Stheraven#else
2320227825Stheraven                                     typename add_lvalue_reference<_Tp>::type>
2321227825Stheraven#endif
2322227825Stheraven    {};
2323227825Stheraven
2324227825Stheraven// is_trivially_destructible
2325227825Stheraven
2326227825Stheraven#if __has_feature(has_trivial_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2327227825Stheraven
2328227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivially_destructible
2329227825Stheraven    : public integral_constant<bool, __has_trivial_destructor(_Tp)> {};
2330227825Stheraven
2331227825Stheraven#else  // _LIBCPP_HAS_TYPE_TRAITS
2332227825Stheraven
2333227825Stheraventemplate <class _Tp> struct __libcpp_trivial_destructor
2334227825Stheraven    : public integral_constant<bool, is_scalar<_Tp>::value ||
2335227825Stheraven                                     is_reference<_Tp>::value> {};
2336227825Stheraven
2337227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivially_destructible
2338227825Stheraven    : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
2339227825Stheraven
2340227825Stheraven#endif  // _LIBCPP_HAS_TYPE_TRAITS
2341227825Stheraven
2342227825Stheraven// is_nothrow_constructible
2343227825Stheraven
2344227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
2345227825Stheraven
2346227825Stheraven#if __has_feature(cxx_noexcept)
2347227825Stheraven
2348227825Stheraventemplate <bool, class _Tp, class... _Args> struct __is_nothrow_constructible;
2349227825Stheraven
2350227825Stheraventemplate <class _Tp, class... _Args>
2351227825Stheravenstruct __is_nothrow_constructible<true, _Tp, _Args...>
2352227825Stheraven    : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
2353227825Stheraven{
2354227825Stheraven};
2355227825Stheraven
2356227825Stheraventemplate <class _Tp, class... _Args>
2357227825Stheravenstruct __is_nothrow_constructible<false, _Tp, _Args...>
2358227825Stheraven    : public false_type
2359227825Stheraven{
2360227825Stheraven};
2361227825Stheraven
2362227825Stheraventemplate <class _Tp, class... _Args>
2363227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible
2364227825Stheraven    : __is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, _Tp, _Args...>
2365227825Stheraven{
2366227825Stheraven};
2367227825Stheraven
2368227825Stheraventemplate <class _Tp, size_t _Ns>
2369227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp[_Ns]>
2370227825Stheraven    : __is_nothrow_constructible<is_constructible<_Tp>::value, _Tp>
2371227825Stheraven{
2372227825Stheraven};
2373227825Stheraven
2374227825Stheraven#else  // __has_feature(cxx_noexcept)
2375227825Stheraven
2376227825Stheraventemplate <class _Tp, class... _Args>
2377227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible
2378227825Stheraven    : false_type
2379227825Stheraven{
2380227825Stheraven};
2381227825Stheraven
2382227825Stheraventemplate <class _Tp>
2383227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp>
2384227825Stheraven#if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2385227825Stheraven    : integral_constant<bool, __has_nothrow_constructor(_Tp)>
2386227825Stheraven#else
2387227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2388227825Stheraven#endif
2389227825Stheraven{
2390227825Stheraven};
2391227825Stheraven
2392227825Stheraventemplate <class _Tp>
2393227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2394227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, _Tp&&>
2395227825Stheraven#else
2396227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, _Tp>
2397227825Stheraven#endif
2398227825Stheraven#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2399227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
2400227825Stheraven#else
2401227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2402227825Stheraven#endif
2403227825Stheraven{
2404227825Stheraven};
2405227825Stheraven
2406227825Stheraventemplate <class _Tp>
2407227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, const _Tp&>
2408227825Stheraven#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2409227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
2410227825Stheraven#else
2411227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2412227825Stheraven#endif
2413227825Stheraven{
2414227825Stheraven};
2415227825Stheraven
2416227825Stheraventemplate <class _Tp>
2417227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, _Tp&>
2418227825Stheraven#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2419227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
2420227825Stheraven#else
2421227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2422227825Stheraven#endif
2423227825Stheraven{
2424227825Stheraven};
2425227825Stheraven
2426227825Stheraven#endif  // __has_feature(cxx_noexcept)
2427227825Stheraven
2428227825Stheraven#else  // _LIBCPP_HAS_NO_VARIADICS
2429227825Stheraven
2430227825Stheraventemplate <class _Tp, class _A0 = __is_construct::__nat,
2431227825Stheraven                     class _A1 = __is_construct::__nat>
2432227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible
2433227825Stheraven    : false_type
2434227825Stheraven{
2435227825Stheraven};
2436227825Stheraven
2437227825Stheraventemplate <class _Tp>
2438227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, __is_construct::__nat,
2439227825Stheraven                                                       __is_construct::__nat>
2440227825Stheraven#if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2441227825Stheraven    : integral_constant<bool, __has_nothrow_constructor(_Tp)>
2442227825Stheraven#else
2443227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2444227825Stheraven#endif
2445227825Stheraven{
2446227825Stheraven};
2447227825Stheraven
2448227825Stheraventemplate <class _Tp>
2449227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, _Tp,
2450227825Stheraven                                                       __is_construct::__nat>
2451227825Stheraven#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2452227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
2453227825Stheraven#else
2454227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2455227825Stheraven#endif
2456227825Stheraven{
2457227825Stheraven};
2458227825Stheraven
2459227825Stheraventemplate <class _Tp>
2460227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, const _Tp&,
2461227825Stheraven                                                       __is_construct::__nat>
2462227825Stheraven#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2463227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
2464227825Stheraven#else
2465227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2466227825Stheraven#endif
2467227825Stheraven{
2468227825Stheraven};
2469227825Stheraven
2470227825Stheraventemplate <class _Tp>
2471227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, _Tp&,
2472227825Stheraven                                                       __is_construct::__nat>
2473227825Stheraven#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2474227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
2475227825Stheraven#else
2476227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2477227825Stheraven#endif
2478227825Stheraven{
2479227825Stheraven};
2480227825Stheraven
2481227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
2482227825Stheraven
2483227825Stheraven// is_nothrow_default_constructible
2484227825Stheraven
2485227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_default_constructible
2486227825Stheraven    : public is_nothrow_constructible<_Tp>
2487227825Stheraven    {};
2488227825Stheraven
2489227825Stheraven// is_nothrow_copy_constructible
2490227825Stheraven
2491227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_copy_constructible
2492227825Stheraven    : public is_nothrow_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type>
2493227825Stheraven    {};
2494227825Stheraven
2495227825Stheraven// is_nothrow_move_constructible
2496227825Stheraven
2497227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_move_constructible
2498227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2499227825Stheraven    : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2500227825Stheraven#else
2501227825Stheraven    : public is_nothrow_copy_constructible<_Tp>
2502227825Stheraven#endif
2503227825Stheraven    {};
2504227825Stheraven
2505227825Stheraven// is_nothrow_assignable
2506227825Stheraven
2507227825Stheraven#if __has_feature(cxx_noexcept)
2508227825Stheraven
2509227825Stheraventemplate <bool, class _Tp, class _Arg> struct __is_nothrow_assignable;
2510227825Stheraven
2511227825Stheraventemplate <class _Tp, class _Arg>
2512227825Stheravenstruct __is_nothrow_assignable<false, _Tp, _Arg>
2513227825Stheraven    : public false_type
2514227825Stheraven{
2515227825Stheraven};
2516227825Stheraven
2517227825Stheraventemplate <class _Tp, class _Arg>
2518227825Stheravenstruct __is_nothrow_assignable<true, _Tp, _Arg>
2519227825Stheraven    : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) >
2520227825Stheraven{
2521227825Stheraven};
2522227825Stheraven
2523227825Stheraventemplate <class _Tp, class _Arg>
2524227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_assignable
2525227825Stheraven    : public __is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
2526227825Stheraven{
2527227825Stheraven};
2528227825Stheraven
2529227825Stheraven#else  // __has_feature(cxx_noexcept)
2530227825Stheraven
2531227825Stheraventemplate <class _Tp, class _Arg>
2532227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_assignable
2533227825Stheraven    : public false_type {};
2534227825Stheraven
2535227825Stheraventemplate <class _Tp>
2536227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_assignable<_Tp&, _Tp>
2537227825Stheraven#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2538227825Stheraven    : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
2539227825Stheraven#else
2540227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2541227825Stheraven#endif
2542227825Stheraven
2543227825Stheraventemplate <class _Tp>
2544227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_assignable<_Tp&, _Tp&>
2545227825Stheraven#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2546227825Stheraven    : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
2547227825Stheraven#else
2548227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2549227825Stheraven#endif
2550227825Stheraven
2551227825Stheraventemplate <class _Tp>
2552227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_assignable<_Tp&, const _Tp&>
2553227825Stheraven#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2554227825Stheraven    : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
2555227825Stheraven#else
2556227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2557227825Stheraven#endif
2558227825Stheraven
2559227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2560227825Stheraven
2561227825Stheraventemplate <class _Tp>
2562227825Stheravenstruct is_nothrow_assignable<_Tp&, _Tp&&>
2563227825Stheraven#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2564227825Stheraven    : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
2565227825Stheraven#else
2566227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2567227825Stheraven#endif
2568227825Stheraven
2569227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2570227825Stheraven
2571227825Stheraven#endif  // __has_feature(cxx_noexcept)
2572227825Stheraven
2573227825Stheraven// is_nothrow_copy_assignable
2574227825Stheraven
2575227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_copy_assignable
2576227825Stheraven    : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
2577227825Stheraven                               const typename add_lvalue_reference<_Tp>::type>
2578227825Stheraven    {};
2579227825Stheraven
2580227825Stheraven// is_nothrow_move_assignable
2581227825Stheraven
2582227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_move_assignable
2583227825Stheraven    : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
2584227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2585227825Stheraven                                     typename add_rvalue_reference<_Tp>::type>
2586227825Stheraven#else
2587227825Stheraven                                     typename add_lvalue_reference<_Tp>::type>
2588227825Stheraven#endif
2589227825Stheraven    {};
2590227825Stheraven
2591227825Stheraven// is_nothrow_destructible
2592227825Stheraven
2593227825Stheraven#if __has_feature(cxx_noexcept)
2594227825Stheraven
2595227825Stheraventemplate <bool, class _Tp> struct __is_nothrow_destructible;
2596227825Stheraven
2597227825Stheraventemplate <class _Tp>
2598227825Stheravenstruct __is_nothrow_destructible<false, _Tp>
2599227825Stheraven    : public false_type
2600227825Stheraven{
2601227825Stheraven};
2602227825Stheraven
2603227825Stheraventemplate <class _Tp>
2604227825Stheravenstruct __is_nothrow_destructible<true, _Tp>
2605227825Stheraven    : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) >
2606227825Stheraven{
2607227825Stheraven};
2608227825Stheraven
2609227825Stheraventemplate <class _Tp>
2610227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_destructible
2611227825Stheraven    : public __is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
2612227825Stheraven{
2613227825Stheraven};
2614227825Stheraven
2615227825Stheraventemplate <class _Tp, size_t _Ns>
2616227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_destructible<_Tp[_Ns]>
2617227825Stheraven    : public is_nothrow_destructible<_Tp>
2618227825Stheraven{
2619227825Stheraven};
2620227825Stheraven
2621227825Stheraventemplate <class _Tp>
2622227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_destructible<_Tp&>
2623227825Stheraven    : public true_type
2624227825Stheraven{
2625227825Stheraven};
2626227825Stheraven
2627227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2628227825Stheraven
2629227825Stheraventemplate <class _Tp>
2630227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_destructible<_Tp&&>
2631227825Stheraven    : public true_type
2632227825Stheraven{
2633227825Stheraven};
2634227825Stheraven
2635227825Stheraven#endif
2636227825Stheraven
2637227825Stheraven#else
2638227825Stheraven
2639227825Stheraventemplate <class _Tp> struct __libcpp_nothrow_destructor
2640227825Stheraven    : public integral_constant<bool, is_scalar<_Tp>::value ||
2641227825Stheraven                                     is_reference<_Tp>::value> {};
2642227825Stheraven
2643227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_destructible
2644227825Stheraven    : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
2645227825Stheraven
2646227825Stheraven#endif
2647227825Stheraven
2648227825Stheraven// is_pod
2649227825Stheraven
2650227825Stheraven#if __has_feature(is_pod) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2651227825Stheraven
2652227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_pod
2653227825Stheraven    : public integral_constant<bool, __is_pod(_Tp)> {};
2654227825Stheraven
2655227825Stheraven#else  // _LIBCPP_HAS_TYPE_TRAITS
2656227825Stheraven
2657227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_pod
2658227825Stheraven    : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value   &&
2659227825Stheraven                                     is_trivially_copy_constructible<_Tp>::value      &&
2660227825Stheraven                                     is_trivially_copy_assignable<_Tp>::value    &&
2661227825Stheraven                                     is_trivially_destructible<_Tp>::value> {};
2662227825Stheraven
2663227825Stheraven#endif  // _LIBCPP_HAS_TYPE_TRAITS
2664227825Stheraven
2665227825Stheraven// is_literal_type;
2666227825Stheraven
2667227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_literal_type
2668227825Stheraven#if __has_feature(is_literal)
2669227825Stheraven    : public integral_constant<bool, __is_literal(_Tp)>
2670227825Stheraven#else
2671227825Stheraven    : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value ||
2672227825Stheraven                              is_reference<typename remove_all_extents<_Tp>::type>::value>
2673227825Stheraven#endif
2674227825Stheraven    {};
2675227825Stheraven    
2676227825Stheraven// is_standard_layout;
2677227825Stheraven
2678227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_standard_layout
2679227825Stheraven#if __has_feature(is_standard_layout)
2680227825Stheraven    : public integral_constant<bool, __is_standard_layout(_Tp)>
2681227825Stheraven#else
2682227825Stheraven    : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
2683227825Stheraven#endif
2684227825Stheraven    {};
2685227825Stheraven    
2686227825Stheraven// is_trivially_copyable;
2687227825Stheraven
2688227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivially_copyable
2689227825Stheraven#if __has_feature(is_trivially_copyable)
2690227825Stheraven    : public integral_constant<bool, __is_trivially_copyable(_Tp)>
2691227825Stheraven#else
2692227825Stheraven    : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
2693227825Stheraven#endif
2694227825Stheraven    {};
2695227825Stheraven    
2696227825Stheraven// is_trivial;
2697227825Stheraven
2698227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivial
2699227825Stheraven#if __has_feature(is_trivial)
2700227825Stheraven    : public integral_constant<bool, __is_trivial(_Tp)>
2701227825Stheraven#else
2702227825Stheraven    : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
2703227825Stheraven                                 is_trivially_default_constructible<_Tp>::value>
2704227825Stheraven#endif
2705227825Stheraven    {};
2706227825Stheraven
2707227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
2708227825Stheraven
2709227825Stheraven// Check for complete types
2710227825Stheraven
2711232950Stheraventemplate <class ..._Tp> struct __check_complete;
2712227825Stheraven
2713227825Stheraventemplate <>
2714227825Stheravenstruct __check_complete<>
2715227825Stheraven{
2716227825Stheraven};
2717227825Stheraven
2718232950Stheraventemplate <class _Hp, class _T0, class ..._Tp>
2719232950Stheravenstruct __check_complete<_Hp, _T0, _Tp...>
2720232950Stheraven    : private __check_complete<_Hp>,
2721232950Stheraven      private __check_complete<_T0, _Tp...>
2722227825Stheraven{
2723227825Stheraven};
2724227825Stheraven
2725232950Stheraventemplate <class _Hp>
2726232950Stheravenstruct __check_complete<_Hp, _Hp>
2727232950Stheraven    : private __check_complete<_Hp>
2728227825Stheraven{
2729227825Stheraven};
2730227825Stheraven
2731232950Stheraventemplate <class _Tp>
2732232950Stheravenstruct __check_complete<_Tp>
2733227825Stheraven{
2734232950Stheraven    static_assert(sizeof(_Tp) > 0, "Type must be complete.");
2735227825Stheraven};
2736227825Stheraven
2737232950Stheraventemplate <class _Tp>
2738232950Stheravenstruct __check_complete<_Tp&>
2739232950Stheraven    : private __check_complete<_Tp>
2740227825Stheraven{
2741227825Stheraven};
2742227825Stheraven
2743232950Stheraventemplate <class _Tp>
2744232950Stheravenstruct __check_complete<_Tp&&>
2745232950Stheraven    : private __check_complete<_Tp>
2746227825Stheraven{
2747227825Stheraven};
2748227825Stheraven
2749232950Stheraventemplate <class _Rp, class ..._Param>
2750232950Stheravenstruct __check_complete<_Rp (*)(_Param...)>
2751241903Sdim    : private __check_complete<_Rp>
2752227825Stheraven{
2753227825Stheraven};
2754227825Stheraven
2755232950Stheraventemplate <class _Rp, class ..._Param>
2756232950Stheravenstruct __check_complete<_Rp (_Param...)>
2757241903Sdim    : private __check_complete<_Rp>
2758227825Stheraven{
2759227825Stheraven};
2760227825Stheraven
2761232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2762232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...)>
2763241903Sdim    : private __check_complete<_Class>
2764227825Stheraven{
2765227825Stheraven};
2766227825Stheraven
2767232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2768232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) const>
2769241903Sdim    : private __check_complete<_Class>
2770227825Stheraven{
2771227825Stheraven};
2772227825Stheraven
2773232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2774232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) volatile>
2775241903Sdim    : private __check_complete<_Class>
2776227825Stheraven{
2777227825Stheraven};
2778227825Stheraven
2779232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2780232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) const volatile>
2781241903Sdim    : private __check_complete<_Class>
2782227825Stheraven{
2783227825Stheraven};
2784227825Stheraven
2785227825Stheraven#if __has_feature(cxx_reference_qualified_functions)
2786227825Stheraven
2787232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2788232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) &>
2789241903Sdim    : private __check_complete<_Class>
2790227825Stheraven{
2791227825Stheraven};
2792227825Stheraven
2793232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2794232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) const&>
2795241903Sdim    : private __check_complete<_Class>
2796227825Stheraven{
2797227825Stheraven};
2798227825Stheraven
2799232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2800232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) volatile&>
2801241903Sdim    : private __check_complete<_Class>
2802227825Stheraven{
2803227825Stheraven};
2804227825Stheraven
2805232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2806232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) const volatile&>
2807241903Sdim    : private __check_complete<_Class>
2808227825Stheraven{
2809227825Stheraven};
2810227825Stheraven
2811232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2812232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) &&>
2813241903Sdim    : private __check_complete<_Class>
2814227825Stheraven{
2815227825Stheraven};
2816227825Stheraven
2817232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2818232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) const&&>
2819241903Sdim    : private __check_complete<_Class>
2820227825Stheraven{
2821227825Stheraven};
2822227825Stheraven
2823232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2824232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) volatile&&>
2825241903Sdim    : private __check_complete<_Class>
2826227825Stheraven{
2827227825Stheraven};
2828227825Stheraven
2829232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2830232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) const volatile&&>
2831241903Sdim    : private __check_complete<_Class>
2832227825Stheraven{
2833227825Stheraven};
2834227825Stheraven
2835227825Stheraven#endif
2836227825Stheraven
2837232950Stheraventemplate <class _Rp, class _Class>
2838232950Stheravenstruct __check_complete<_Rp _Class::*>
2839227825Stheraven    : private __check_complete<_Class>
2840227825Stheraven{
2841227825Stheraven};
2842227825Stheraven
2843227825Stheraven// __invoke forward declarations
2844227825Stheraven
2845227825Stheraven// fall back - none of the bullets
2846227825Stheraven
2847227825Stheraventemplate <class ..._Args>
2848227825Stheravenauto
2849227825Stheraven__invoke(__any, _Args&& ...__args)
2850227825Stheraven    -> __nat;
2851227825Stheraven
2852227825Stheraven// bullets 1 and 2
2853227825Stheraven
2854232950Stheraventemplate <class _Fp, class _A0, class ..._Args>
2855241903Sdim_LIBCPP_INLINE_VISIBILITY
2856227825Stheravenauto
2857232950Stheraven__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
2858227825Stheraven    -> decltype((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...));
2859227825Stheraven
2860232950Stheraventemplate <class _Fp, class _A0, class ..._Args>
2861241903Sdim_LIBCPP_INLINE_VISIBILITY
2862227825Stheravenauto
2863232950Stheraven__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
2864227825Stheraven    -> decltype(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...));
2865227825Stheraven
2866227825Stheraven// bullets 3 and 4
2867227825Stheraven
2868232950Stheraventemplate <class _Fp, class _A0>
2869241903Sdim_LIBCPP_INLINE_VISIBILITY
2870227825Stheravenauto
2871232950Stheraven__invoke(_Fp&& __f, _A0&& __a0)
2872227825Stheraven    -> decltype(_VSTD::forward<_A0>(__a0).*__f);
2873227825Stheraven
2874232950Stheraventemplate <class _Fp, class _A0>
2875241903Sdim_LIBCPP_INLINE_VISIBILITY
2876227825Stheravenauto
2877232950Stheraven__invoke(_Fp&& __f, _A0&& __a0)
2878227825Stheraven    -> decltype((*_VSTD::forward<_A0>(__a0)).*__f);
2879227825Stheraven
2880227825Stheraven// bullet 5
2881227825Stheraven
2882232950Stheraventemplate <class _Fp, class ..._Args>
2883241903Sdim_LIBCPP_INLINE_VISIBILITY
2884227825Stheravenauto
2885232950Stheraven__invoke(_Fp&& __f, _Args&& ...__args)
2886232950Stheraven    -> decltype(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...));
2887227825Stheraven
2888227825Stheraven// __invokable
2889227825Stheraven
2890232950Stheraventemplate <class _Fp, class ..._Args>
2891227825Stheravenstruct __invokable_imp
2892241903Sdim    : private __check_complete<_Fp>
2893227825Stheraven{
2894227825Stheraven    typedef decltype(
2895232950Stheraven            __invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)
2896227825Stheraven                    ) type;
2897227825Stheraven    static const bool value = !is_same<type, __nat>::value;
2898227825Stheraven};
2899227825Stheraven
2900232950Stheraventemplate <class _Fp, class ..._Args>
2901227825Stheravenstruct __invokable
2902227825Stheraven    : public integral_constant<bool,
2903232950Stheraven          __invokable_imp<_Fp, _Args...>::value>
2904227825Stheraven{
2905227825Stheraven};
2906227825Stheraven
2907227825Stheraven// __invoke_of
2908227825Stheraven
2909232950Stheraventemplate <bool _Invokable, class _Fp, class ..._Args>
2910227825Stheravenstruct __invoke_of_imp  // false
2911227825Stheraven{
2912227825Stheraven};
2913227825Stheraven
2914232950Stheraventemplate <class _Fp, class ..._Args>
2915232950Stheravenstruct __invoke_of_imp<true, _Fp, _Args...>
2916227825Stheraven{
2917232950Stheraven    typedef typename __invokable_imp<_Fp, _Args...>::type type;
2918227825Stheraven};
2919227825Stheraven
2920232950Stheraventemplate <class _Fp, class ..._Args>
2921227825Stheravenstruct __invoke_of
2922232950Stheraven    : public __invoke_of_imp<__invokable<_Fp, _Args...>::value, _Fp, _Args...>
2923227825Stheraven{
2924227825Stheraven};
2925227825Stheraven
2926241903Sdimtemplate <class _Fp, class ..._Args>
2927241903Sdimclass _LIBCPP_VISIBLE result_of<_Fp(_Args...)>
2928241903Sdim    : public __invoke_of<_Fp, _Args...>
2929241903Sdim{
2930241903Sdim};
2931241903Sdim
2932227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
2933227825Stheraven
2934227825Stheraventemplate <class _Tp>
2935227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
2936227825Stheraven#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
2937227825Stheraventypename enable_if
2938227825Stheraven<
2939227825Stheraven    is_move_constructible<_Tp>::value &&
2940227825Stheraven    is_move_assignable<_Tp>::value
2941227825Stheraven>::type
2942227825Stheraven#else
2943227825Stheravenvoid
2944227825Stheraven#endif
2945227825Stheravenswap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
2946227825Stheraven                                    is_nothrow_move_assignable<_Tp>::value)
2947227825Stheraven{
2948227825Stheraven    _Tp __t(_VSTD::move(__x));
2949227825Stheraven    __x = _VSTD::move(__y);
2950227825Stheraven    __y = _VSTD::move(__t);
2951227825Stheraven}
2952227825Stheraven
2953227825Stheraventemplate <class _ForwardIterator1, class _ForwardIterator2>
2954227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
2955227825Stheravenvoid
2956227825Stheraveniter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
2957227825Stheraven    //                                  _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
2958227825Stheraven               _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(),
2959227825Stheraven                                          *_VSTD::declval<_ForwardIterator2>())))
2960227825Stheraven{
2961227825Stheraven    swap(*__a, *__b);
2962227825Stheraven}
2963227825Stheraven
2964227825Stheraven// __swappable
2965227825Stheraven
2966227825Stheravennamespace __detail
2967227825Stheraven{
2968227825Stheraven
2969227825Stheravenusing _VSTD::swap;
2970227825Stheraven__nat swap(__any, __any);
2971227825Stheraven
2972227825Stheraventemplate <class _Tp>
2973227825Stheravenstruct __swappable
2974227825Stheraven{
2975227825Stheraven    typedef decltype(swap(_VSTD::declval<_Tp&>(), _VSTD::declval<_Tp&>())) type;
2976227825Stheraven    static const bool value = !is_same<type, __nat>::value;
2977227825Stheraven};
2978227825Stheraven
2979227825Stheraven}  // __detail
2980227825Stheraven
2981227825Stheraventemplate <class _Tp>
2982227825Stheravenstruct __is_swappable
2983227825Stheraven    : public integral_constant<bool, __detail::__swappable<_Tp>::value>
2984227825Stheraven{
2985227825Stheraven};
2986227825Stheraven
2987227825Stheraven#if __has_feature(cxx_noexcept)
2988227825Stheraven
2989227825Stheraventemplate <bool, class _Tp>
2990227825Stheravenstruct __is_nothrow_swappable_imp
2991227825Stheraven    : public integral_constant<bool, noexcept(swap(_VSTD::declval<_Tp&>(),
2992227825Stheraven                                                   _VSTD::declval<_Tp&>()))>
2993227825Stheraven{
2994227825Stheraven};
2995227825Stheraven
2996227825Stheraventemplate <class _Tp>
2997227825Stheravenstruct __is_nothrow_swappable_imp<false, _Tp>
2998227825Stheraven    : public false_type
2999227825Stheraven{
3000227825Stheraven};
3001227825Stheraven
3002227825Stheraventemplate <class _Tp>
3003227825Stheravenstruct __is_nothrow_swappable
3004227825Stheraven    : public __is_nothrow_swappable_imp<__is_swappable<_Tp>::value, _Tp>
3005227825Stheraven{
3006227825Stheraven};
3007227825Stheraven
3008227825Stheraven#else  // __has_feature(cxx_noexcept)
3009227825Stheraven
3010227825Stheraventemplate <class _Tp>
3011227825Stheravenstruct __is_nothrow_swappable
3012227825Stheraven    : public false_type
3013227825Stheraven{
3014227825Stheraven};
3015227825Stheraven
3016227825Stheraven#endif  // __has_feature(cxx_noexcept)
3017227825Stheraven
3018227825Stheraven#ifdef _LIBCXX_UNDERLYING_TYPE
3019227825Stheraven
3020227825Stheraventemplate <class _Tp>
3021227825Stheravenstruct underlying_type
3022227825Stheraven{
3023227825Stheraven    typedef _LIBCXX_UNDERLYING_TYPE(_Tp) type;
3024227825Stheraven};
3025227825Stheraven
3026227825Stheraven#else  // _LIBCXX_UNDERLYING_TYPE
3027227825Stheraven
3028227825Stheraventemplate <class _Tp, bool _Support = false>
3029227825Stheravenstruct underlying_type
3030227825Stheraven{
3031227825Stheraven    static_assert(_Support, "The underyling_type trait requires compiler "
3032227825Stheraven                            "support. Either no such support exists or "
3033227825Stheraven                            "libc++ does not know how to use it.");
3034227825Stheraven};
3035227825Stheraven
3036227825Stheraven#endif // _LIBCXX_UNDERLYING_TYPE
3037227825Stheraven
3038227825Stheraven_LIBCPP_END_NAMESPACE_STD
3039227825Stheraven
3040227825Stheraven#endif  // _LIBCPP_TYPE_TRAITS
3041