type_traits revision 242945
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
620241903Sdim#error is_base_of not implemented.
621241903Sdim
622241903Sdim#endif  // __has_feature(is_base_of)
623241903Sdim
624227825Stheraven// is_convertible
625227825Stheraven
626227825Stheraven#if __has_feature(is_convertible_to)
627227825Stheraven
628227825Stheraventemplate <class _T1, class _T2> struct _LIBCPP_VISIBLE is_convertible
629241903Sdim    : public integral_constant<bool, __is_convertible_to(_T1, _T2) &&
630241903Sdim                                     !is_abstract<_T2>::value> {};
631227825Stheraven
632227825Stheraven#else  // __has_feature(is_convertible_to)
633227825Stheraven
634227825Stheravennamespace __is_convertible_imp
635227825Stheraven{
636227825Stheraventemplate <class _Tp> char  __test(_Tp);
637227825Stheraventemplate <class _Tp> __two __test(...);
638227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
639227825Stheraventemplate <class _Tp> _Tp&& __source();
640227825Stheraven#else
641227825Stheraventemplate <class _Tp> typename remove_reference<_Tp>::type& __source();
642227825Stheraven#endif
643227825Stheraven
644227825Stheraventemplate <class _Tp, bool _IsArray =    is_array<_Tp>::value,
645227825Stheraven                     bool _IsFunction = is_function<_Tp>::value,
646227825Stheraven                     bool _IsVoid =     is_void<_Tp>::value>
647227825Stheraven                     struct __is_array_function_or_void                          {enum {value = 0};};
648227825Stheraventemplate <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};};
649227825Stheraventemplate <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};};
650227825Stheraventemplate <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};};
651227825Stheraven}
652227825Stheraven
653227825Stheraventemplate <class _Tp,
654227825Stheraven    unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
655227825Stheravenstruct __is_convertible_check
656227825Stheraven{
657227825Stheraven    static const size_t __v = 0;
658227825Stheraven};
659227825Stheraven
660227825Stheraventemplate <class _Tp>
661227825Stheravenstruct __is_convertible_check<_Tp, 0>
662227825Stheraven{
663227825Stheraven    static const size_t __v = sizeof(_Tp);
664227825Stheraven};
665227825Stheraven
666227825Stheraventemplate <class _T1, class _T2,
667227825Stheraven    unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value,
668227825Stheraven    unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
669227825Stheravenstruct __is_convertible
670227825Stheraven    : public integral_constant<bool,
671241903Sdim#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
672227825Stheraven        sizeof(__is_convertible_imp::__test<_T2>(__is_convertible_imp::__source<_T1>())) == 1
673241903Sdim#else
674241903Sdim        sizeof(__is_convertible_imp::__test<_T2>(__is_convertible_imp::__source<_T1>())) == 1
675241903Sdim         && !(!is_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value
676241903Sdim              && (!is_const<typename remove_reference<_T2>::type>::value
677241903Sdim                  || is_volatile<typename remove_reference<_T2>::type>::value)
678241903Sdim                  && (is_same<typename remove_cv<_T1>::type,
679241903Sdim                              typename remove_cv<typename remove_reference<_T2>::type>::type>::value
680241903Sdim                      || is_base_of<typename remove_reference<_T2>::type, _T1>::value))
681241903Sdim#endif
682227825Stheraven    >
683227825Stheraven{};
684227825Stheraven
685227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 0> : false_type {};
686227825Stheraven
687227825Stheraventemplate <class _T1> struct __is_convertible<_T1, const _T1&, 1, 0> : true_type {};
688227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
689227825Stheraventemplate <class _T1> struct __is_convertible<_T1, _T1&&, 1, 0> : true_type {};
690227825Stheraventemplate <class _T1> struct __is_convertible<_T1, const _T1&&, 1, 0> : true_type {};
691227825Stheraventemplate <class _T1> struct __is_convertible<_T1, volatile _T1&&, 1, 0> : true_type {};
692227825Stheraventemplate <class _T1> struct __is_convertible<_T1, const volatile _T1&&, 1, 0> : true_type {};
693227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
694227825Stheraven
695227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2*, 1, 0>
696227825Stheraven    : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*>::value> {};
697227825Stheraven
698227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2* const, 1, 0>
699227825Stheraven    : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const>::value> {};
700227825Stheraven
701227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2* volatile, 1, 0>
702227825Stheraven    : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*volatile>::value> {};
703227825Stheraven
704227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2* const volatile, 1, 0>
705227825Stheraven    : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const volatile>::value> {};
706227825Stheraven
707227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 0>                : public false_type {};
708227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
709227825Stheraventemplate <class _T1>            struct __is_convertible<_T1, _T1&&, 2, 0>               : public true_type {};
710227825Stheraven#endif
711241903Sdimtemplate <class _T1>            struct __is_convertible<_T1, _T1&, 2, 0>               : public true_type {};
712227825Stheraventemplate <class _T1>            struct __is_convertible<_T1, _T1*, 2, 0>               : public true_type {};
713227825Stheraventemplate <class _T1>            struct __is_convertible<_T1, _T1*const, 2, 0>          : public true_type {};
714227825Stheraventemplate <class _T1>            struct __is_convertible<_T1, _T1*volatile, 2, 0>       : public true_type {};
715227825Stheraventemplate <class _T1>            struct __is_convertible<_T1, _T1*const volatile, 2, 0> : public true_type {};
716227825Stheraven
717227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 0> : public false_type {};
718227825Stheraven
719227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
720227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
721227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
722227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {};
723227825Stheraven
724227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {};
725227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {};
726227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {};
727227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {};
728227825Stheraven
729227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {};
730227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {};
731227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {};
732227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {};
733227825Stheraven
734227825Stheraventemplate <class _T1, class _T2> struct _LIBCPP_VISIBLE is_convertible
735227825Stheraven    : public __is_convertible<_T1, _T2>
736227825Stheraven{
737227825Stheraven    static const size_t __complete_check1 = __is_convertible_check<_T1>::__v;
738227825Stheraven    static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
739227825Stheraven};
740227825Stheraven
741227825Stheraven#endif  // __has_feature(is_convertible_to)
742227825Stheraven
743227825Stheraven// is_empty
744227825Stheraven
745232950Stheraven#if __has_feature(is_empty)
746232950Stheraven
747227825Stheraventemplate <class _Tp>
748232950Stheravenstruct _LIBCPP_VISIBLE is_empty
749232950Stheraven    : public integral_constant<bool, __is_empty(_Tp)> {};
750232950Stheraven
751232950Stheraven#else  // __has_feature(is_empty)
752232950Stheraven
753232950Stheraventemplate <class _Tp>
754227825Stheravenstruct __is_empty1
755227825Stheraven    : public _Tp
756227825Stheraven{
757242945Stheraven    double __lx;
758227825Stheraven};
759227825Stheraven
760227825Stheravenstruct __is_empty2
761227825Stheraven{
762242945Stheraven    double __lx;
763227825Stheraven};
764227825Stheraven
765227825Stheraventemplate <class _Tp, bool = is_class<_Tp>::value>
766227825Stheravenstruct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {};
767227825Stheraven
768227825Stheraventemplate <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {};
769227825Stheraven
770227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_empty : public __libcpp_empty<_Tp> {};
771227825Stheraven
772232950Stheraven#endif  // __has_feature(is_empty)
773232950Stheraven
774227825Stheraven// is_polymorphic
775227825Stheraven
776232950Stheraven#if __has_feature(is_polymorphic)
777232950Stheraven
778232950Stheraventemplate <class _Tp>
779232950Stheravenstruct _LIBCPP_VISIBLE is_polymorphic
780232950Stheraven    : public integral_constant<bool, __is_polymorphic(_Tp)> {};
781232950Stheraven
782232950Stheraven#else
783232950Stheraven
784227825Stheraventemplate <class _Tp> struct __is_polymorphic1 : public _Tp {};
785227825Stheraventemplate <class _Tp> struct __is_polymorphic2 : public _Tp {virtual ~__is_polymorphic2() throw();};
786227825Stheraven
787227825Stheraventemplate <class _Tp, bool = is_class<_Tp>::value>
788227825Stheravenstruct __libcpp_polymorphic
789227825Stheraven    : public integral_constant<bool, sizeof(__is_polymorphic1<_Tp>) == sizeof(__is_polymorphic2<_Tp>)> {};
790227825Stheraven
791227825Stheraventemplate <class _Tp> struct __libcpp_polymorphic<_Tp, false> : public false_type {};
792227825Stheraven
793227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_polymorphic
794227825Stheraven    : public __libcpp_polymorphic<_Tp> {};
795227825Stheraven
796232950Stheraven#endif // __has_feature(is_polymorphic)
797232950Stheraven
798227825Stheraven// has_virtual_destructor
799227825Stheraven
800227825Stheraven#if __has_feature(has_virtual_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
801227825Stheraven
802227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE has_virtual_destructor
803227825Stheraven    : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
804227825Stheraven
805227825Stheraven#else  // _LIBCPP_HAS_TYPE_TRAITS
806227825Stheraven
807227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE has_virtual_destructor
808227825Stheraven    : public false_type {};
809227825Stheraven
810227825Stheraven#endif  // _LIBCPP_HAS_TYPE_TRAITS
811227825Stheraven
812227825Stheraven// alignment_of
813227825Stheraven
814242945Stheraventemplate <class _Tp> struct __alignment_of {_Tp __lx;};
815227825Stheraven
816227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE alignment_of
817227825Stheraven    : public integral_constant<size_t, __alignof__(__alignment_of<typename remove_all_extents<_Tp>::type>)> {};
818227825Stheraven
819227825Stheraven// aligned_storage
820227825Stheraven
821227825Stheraventemplate <class _Hp, class _Tp>
822227825Stheravenstruct __type_list
823227825Stheraven{
824227825Stheraven    typedef _Hp _Head;
825227825Stheraven    typedef _Tp _Tail;
826227825Stheraven};
827227825Stheraven
828227825Stheravenstruct __nat
829227825Stheraven{
830227825Stheraven#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
831227825Stheraven    __nat() = delete;
832227825Stheraven    __nat(const __nat&) = delete;
833227825Stheraven    __nat& operator=(const __nat&) = delete;
834227825Stheraven    ~__nat() = delete;
835227825Stheraven#endif
836227825Stheraven};
837227825Stheraven
838227825Stheraventemplate <class _Tp>
839227825Stheravenstruct __align_type
840227825Stheraven{
841227825Stheraven    static const size_t value = alignment_of<_Tp>::value;
842227825Stheraven    typedef _Tp type;
843227825Stheraven};
844227825Stheraven
845242945Stheravenstruct __struct_double {long double __lx;};
846242945Stheravenstruct __struct_double4 {double __lx[4];};
847227825Stheraven
848227825Stheraventypedef
849227825Stheraven    __type_list<__align_type<unsigned char>,
850227825Stheraven    __type_list<__align_type<unsigned short>,
851227825Stheraven    __type_list<__align_type<unsigned int>,
852227825Stheraven    __type_list<__align_type<unsigned long>,
853227825Stheraven    __type_list<__align_type<unsigned long long>,
854227825Stheraven    __type_list<__align_type<double>,
855227825Stheraven    __type_list<__align_type<long double>,
856227825Stheraven    __type_list<__align_type<__struct_double>,
857227825Stheraven    __type_list<__align_type<__struct_double4>,
858227825Stheraven    __type_list<__align_type<int*>,
859227825Stheraven    __nat
860227825Stheraven    > > > > > > > > > > __all_types;
861227825Stheraven
862227825Stheraventemplate <class _TL, size_t _Align> struct __find_pod;
863227825Stheraven
864227825Stheraventemplate <class _Hp, size_t _Align>
865227825Stheravenstruct __find_pod<__type_list<_Hp, __nat>, _Align>
866227825Stheraven{
867227825Stheraven    typedef typename conditional<
868227825Stheraven                             _Align == _Hp::value,
869227825Stheraven                             typename _Hp::type,
870227825Stheraven                             void
871227825Stheraven                         >::type type;
872227825Stheraven};
873227825Stheraven
874227825Stheraventemplate <class _Hp, class _Tp, size_t _Align>
875227825Stheravenstruct __find_pod<__type_list<_Hp, _Tp>, _Align>
876227825Stheraven{
877227825Stheraven    typedef typename conditional<
878227825Stheraven                             _Align == _Hp::value,
879227825Stheraven                             typename _Hp::type,
880227825Stheraven                             typename __find_pod<_Tp, _Align>::type
881227825Stheraven                         >::type type;
882227825Stheraven};
883227825Stheraven
884227825Stheraventemplate <class _TL, size_t _Len> struct __find_max_align;
885227825Stheraven
886227825Stheraventemplate <class _Hp, size_t _Len>
887227825Stheravenstruct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
888227825Stheraven
889227825Stheraventemplate <size_t _Len, size_t _A1, size_t _A2>
890227825Stheravenstruct __select_align
891227825Stheraven{
892227825Stheravenprivate:
893227825Stheraven    static const size_t __min = _A2 < _A1 ? _A2 : _A1;
894227825Stheraven    static const size_t __max = _A1 < _A2 ? _A2 : _A1;
895227825Stheravenpublic:
896227825Stheraven    static const size_t value = _Len < __max ? __min : __max;
897227825Stheraven};
898227825Stheraven
899227825Stheraventemplate <class _Hp, class _Tp, size_t _Len>
900227825Stheravenstruct __find_max_align<__type_list<_Hp, _Tp>, _Len>
901227825Stheraven    : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
902227825Stheraven
903227825Stheraventemplate <size_t _Len, const size_t _Align = __find_max_align<__all_types, _Len>::value>
904227825Stheravenstruct _LIBCPP_VISIBLE aligned_storage
905227825Stheraven{
906227825Stheraven    typedef typename __find_pod<__all_types, _Align>::type _Aligner;
907227825Stheraven    static_assert(!is_void<_Aligner>::value, "");
908227825Stheraven    union type
909227825Stheraven    {
910227825Stheraven        _Aligner __align;
911227825Stheraven        unsigned char __data[_Len];
912227825Stheraven    };
913227825Stheraven};
914227825Stheraven
915227825Stheraven#define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
916227825Stheraventemplate <size_t _Len>\
917227825Stheravenstruct _LIBCPP_VISIBLE aligned_storage<_Len, n>\
918227825Stheraven{\
919227825Stheraven    struct _ALIGNAS(n) type\
920227825Stheraven    {\
921242945Stheraven        unsigned char __lx[_Len];\
922227825Stheraven    };\
923227825Stheraven}
924227825Stheraven
925227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
926227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
927227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
928227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
929227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
930227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
931227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
932227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
933227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
934227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
935227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
936227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
937227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
938227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
939227825Stheraven// MSDN says that MSVC does not support alignment beyond 8192 (=0x2000)
940227825Stheraven#if !defined(_MSC_VER)
941227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
942227825Stheraven#endif // !_MSC_VER
943227825Stheraven
944227825Stheraven#undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
945227825Stheraven
946227825Stheraven// __promote
947227825Stheraven
948227825Stheraventemplate <class _A1, class _A2 = void, class _A3 = void,
949227825Stheraven          bool = (is_arithmetic<_A1>::value || is_void<_A1>::value) &&
950227825Stheraven                 (is_arithmetic<_A2>::value || is_void<_A2>::value) &&
951227825Stheraven                 (is_arithmetic<_A3>::value || is_void<_A3>::value)>
952227825Stheravenclass __promote {};
953227825Stheraven
954227825Stheraventemplate <class _A1, class _A2, class _A3>
955227825Stheravenclass __promote<_A1, _A2, _A3, true>
956227825Stheraven{
957227825Stheravenprivate:
958227825Stheraven    typedef typename __promote<_A1>::type __type1;
959227825Stheraven    typedef typename __promote<_A2>::type __type2;
960227825Stheraven    typedef typename __promote<_A3>::type __type3;
961227825Stheravenpublic:
962227825Stheraven    typedef decltype(__type1() + __type2() + __type3()) type;
963227825Stheraven};
964227825Stheraven
965227825Stheraventemplate <class _A1, class _A2>
966227825Stheravenclass __promote<_A1, _A2, void, true>
967227825Stheraven{
968227825Stheravenprivate:
969227825Stheraven    typedef typename __promote<_A1>::type __type1;
970227825Stheraven    typedef typename __promote<_A2>::type __type2;
971227825Stheravenpublic:
972227825Stheraven    typedef decltype(__type1() + __type2()) type;
973227825Stheraven};
974227825Stheraven
975227825Stheraventemplate <class _A1>
976227825Stheravenclass __promote<_A1, void, void, true>
977227825Stheraven{
978227825Stheravenpublic:
979227825Stheraven    typedef typename conditional<is_arithmetic<_A1>::value,
980227825Stheraven                     typename conditional<is_integral<_A1>::value, double, _A1>::type,
981227825Stheraven                     void
982227825Stheraven            >::type type;
983227825Stheraven};
984227825Stheraven
985227825Stheraven#ifdef _LIBCPP_STORE_AS_OPTIMIZATION
986227825Stheraven
987227825Stheraven// __transform
988227825Stheraven
989227825Stheraventemplate <class _Tp, size_t = sizeof(_Tp), bool = is_scalar<_Tp>::value> struct __transform {typedef _Tp type;};
990227825Stheraventemplate <class _Tp> struct __transform<_Tp, 1, true> {typedef unsigned char      type;};
991227825Stheraventemplate <class _Tp> struct __transform<_Tp, 2, true> {typedef unsigned short     type;};
992227825Stheraventemplate <class _Tp> struct __transform<_Tp, 4, true> {typedef unsigned int       type;};
993227825Stheraventemplate <class _Tp> struct __transform<_Tp, 8, true> {typedef unsigned long long type;};
994227825Stheraven
995227825Stheraven#endif  // _LIBCPP_STORE_AS_OPTIMIZATION
996227825Stheraven
997227825Stheraven// make_signed / make_unsigned
998227825Stheraven
999227825Stheraventypedef
1000227825Stheraven    __type_list<signed char,
1001227825Stheraven    __type_list<signed short,
1002227825Stheraven    __type_list<signed int,
1003227825Stheraven    __type_list<signed long,
1004227825Stheraven    __type_list<signed long long,
1005227825Stheraven    __nat
1006227825Stheraven    > > > > > __signed_types;
1007227825Stheraven
1008227825Stheraventypedef
1009227825Stheraven    __type_list<unsigned char,
1010227825Stheraven    __type_list<unsigned short,
1011227825Stheraven    __type_list<unsigned int,
1012227825Stheraven    __type_list<unsigned long,
1013227825Stheraven    __type_list<unsigned long long,
1014227825Stheraven    __nat
1015227825Stheraven    > > > > > __unsigned_types;
1016227825Stheraven
1017227825Stheraventemplate <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
1018227825Stheraven
1019227825Stheraventemplate <class _Hp, class _Tp, size_t _Size>
1020227825Stheravenstruct __find_first<__type_list<_Hp, _Tp>, _Size, true>
1021227825Stheraven{
1022227825Stheraven    typedef _Hp type;
1023227825Stheraven};
1024227825Stheraven
1025227825Stheraventemplate <class _Hp, class _Tp, size_t _Size>
1026227825Stheravenstruct __find_first<__type_list<_Hp, _Tp>, _Size, false>
1027227825Stheraven{
1028227825Stheraven    typedef typename __find_first<_Tp, _Size>::type type;
1029227825Stheraven};
1030227825Stheraven
1031227825Stheraventemplate <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
1032227825Stheraven                             bool = is_volatile<typename remove_reference<_Tp>::type>::value>
1033227825Stheravenstruct __apply_cv
1034227825Stheraven{
1035227825Stheraven    typedef _Up type;
1036227825Stheraven};
1037227825Stheraven
1038227825Stheraventemplate <class _Tp, class _Up>
1039227825Stheravenstruct __apply_cv<_Tp, _Up, true, false>
1040227825Stheraven{
1041227825Stheraven    typedef const _Up type;
1042227825Stheraven};
1043227825Stheraven
1044227825Stheraventemplate <class _Tp, class _Up>
1045227825Stheravenstruct __apply_cv<_Tp, _Up, false, true>
1046227825Stheraven{
1047227825Stheraven    typedef volatile _Up type;
1048227825Stheraven};
1049227825Stheraven
1050227825Stheraventemplate <class _Tp, class _Up>
1051227825Stheravenstruct __apply_cv<_Tp, _Up, true, true>
1052227825Stheraven{
1053227825Stheraven    typedef const volatile _Up type;
1054227825Stheraven};
1055227825Stheraven
1056227825Stheraventemplate <class _Tp, class _Up>
1057227825Stheravenstruct __apply_cv<_Tp&, _Up, false, false>
1058227825Stheraven{
1059227825Stheraven    typedef _Up& type;
1060227825Stheraven};
1061227825Stheraven
1062227825Stheraventemplate <class _Tp, class _Up>
1063227825Stheravenstruct __apply_cv<_Tp&, _Up, true, false>
1064227825Stheraven{
1065227825Stheraven    typedef const _Up& type;
1066227825Stheraven};
1067227825Stheraven
1068227825Stheraventemplate <class _Tp, class _Up>
1069227825Stheravenstruct __apply_cv<_Tp&, _Up, false, true>
1070227825Stheraven{
1071227825Stheraven    typedef volatile _Up& type;
1072227825Stheraven};
1073227825Stheraven
1074227825Stheraventemplate <class _Tp, class _Up>
1075227825Stheravenstruct __apply_cv<_Tp&, _Up, true, true>
1076227825Stheraven{
1077227825Stheraven    typedef const volatile _Up& type;
1078227825Stheraven};
1079227825Stheraven
1080227825Stheraventemplate <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1081227825Stheravenstruct __make_signed {};
1082227825Stheraven
1083227825Stheraventemplate <class _Tp>
1084227825Stheravenstruct __make_signed<_Tp, true>
1085227825Stheraven{
1086227825Stheraven    typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
1087227825Stheraven};
1088227825Stheraven
1089227825Stheraventemplate <> struct __make_signed<bool,               true> {};
1090227825Stheraventemplate <> struct __make_signed<  signed short,     true> {typedef short     type;};
1091227825Stheraventemplate <> struct __make_signed<unsigned short,     true> {typedef short     type;};
1092227825Stheraventemplate <> struct __make_signed<  signed int,       true> {typedef int       type;};
1093227825Stheraventemplate <> struct __make_signed<unsigned int,       true> {typedef int       type;};
1094227825Stheraventemplate <> struct __make_signed<  signed long,      true> {typedef long      type;};
1095227825Stheraventemplate <> struct __make_signed<unsigned long,      true> {typedef long      type;};
1096227825Stheraventemplate <> struct __make_signed<  signed long long, true> {typedef long long type;};
1097227825Stheraventemplate <> struct __make_signed<unsigned long long, true> {typedef long long type;};
1098227825Stheraven
1099227825Stheraventemplate <class _Tp>
1100227825Stheravenstruct _LIBCPP_VISIBLE make_signed
1101227825Stheraven{
1102227825Stheraven    typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
1103227825Stheraven};
1104227825Stheraven
1105227825Stheraventemplate <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1106227825Stheravenstruct __make_unsigned {};
1107227825Stheraven
1108227825Stheraventemplate <class _Tp>
1109227825Stheravenstruct __make_unsigned<_Tp, true>
1110227825Stheraven{
1111227825Stheraven    typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
1112227825Stheraven};
1113227825Stheraven
1114227825Stheraventemplate <> struct __make_unsigned<bool,               true> {};
1115227825Stheraventemplate <> struct __make_unsigned<  signed short,     true> {typedef unsigned short     type;};
1116227825Stheraventemplate <> struct __make_unsigned<unsigned short,     true> {typedef unsigned short     type;};
1117227825Stheraventemplate <> struct __make_unsigned<  signed int,       true> {typedef unsigned int       type;};
1118227825Stheraventemplate <> struct __make_unsigned<unsigned int,       true> {typedef unsigned int       type;};
1119227825Stheraventemplate <> struct __make_unsigned<  signed long,      true> {typedef unsigned long      type;};
1120227825Stheraventemplate <> struct __make_unsigned<unsigned long,      true> {typedef unsigned long      type;};
1121227825Stheraventemplate <> struct __make_unsigned<  signed long long, true> {typedef unsigned long long type;};
1122227825Stheraventemplate <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
1123227825Stheraven
1124227825Stheraventemplate <class _Tp>
1125227825Stheravenstruct _LIBCPP_VISIBLE make_unsigned
1126227825Stheraven{
1127227825Stheraven    typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
1128227825Stheraven};
1129227825Stheraven
1130227825Stheraven#ifdef _LIBCPP_HAS_NO_VARIADICS
1131227825Stheraven
1132227825Stheraventemplate <class _Tp, class _Up = void, class V = void>
1133227825Stheravenstruct _LIBCPP_VISIBLE common_type
1134227825Stheraven{
1135227825Stheravenpublic:
1136227825Stheraven    typedef typename common_type<typename common_type<_Tp, _Up>::type, V>::type type;
1137227825Stheraven};
1138227825Stheraven
1139227825Stheraventemplate <class _Tp>
1140227825Stheravenstruct _LIBCPP_VISIBLE common_type<_Tp, void, void>
1141227825Stheraven{
1142227825Stheravenpublic:
1143227825Stheraven    typedef _Tp type;
1144227825Stheraven};
1145227825Stheraven
1146227825Stheraventemplate <class _Tp, class _Up>
1147227825Stheravenstruct _LIBCPP_VISIBLE common_type<_Tp, _Up, void>
1148227825Stheraven{
1149227825Stheravenprivate:
1150227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1151227825Stheraven    static _Tp&& __t();
1152227825Stheraven    static _Up&& __u();
1153227825Stheraven#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1154227825Stheraven    static _Tp __t();
1155227825Stheraven    static _Up __u();
1156227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1157227825Stheravenpublic:
1158232950Stheraven    typedef typename remove_reference<decltype(true ? __t() : __u())>::type type;
1159227825Stheraven};
1160227825Stheraven
1161227825Stheraven#else  // _LIBCPP_HAS_NO_VARIADICS
1162227825Stheraven
1163227825Stheraventemplate <class ..._Tp> struct common_type;
1164227825Stheraven
1165227825Stheraventemplate <class _Tp>
1166227825Stheravenstruct _LIBCPP_VISIBLE common_type<_Tp>
1167227825Stheraven{
1168227825Stheraven    typedef _Tp type;
1169227825Stheraven};
1170227825Stheraven
1171227825Stheraventemplate <class _Tp, class _Up>
1172227825Stheravenstruct _LIBCPP_VISIBLE common_type<_Tp, _Up>
1173227825Stheraven{
1174227825Stheravenprivate:
1175227825Stheraven    static _Tp&& __t();
1176227825Stheraven    static _Up&& __u();
1177227825Stheraven    static bool __f();
1178227825Stheravenpublic:
1179232950Stheraven    typedef typename remove_reference<decltype(__f() ? __t() : __u())>::type type;
1180227825Stheraven};
1181227825Stheraven
1182227825Stheraventemplate <class _Tp, class _Up, class ..._Vp>
1183227825Stheravenstruct _LIBCPP_VISIBLE common_type<_Tp, _Up, _Vp...>
1184227825Stheraven{
1185227825Stheraven    typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp...>::type type;
1186227825Stheraven};
1187227825Stheraven
1188227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
1189227825Stheraven
1190227825Stheraven// is_assignable
1191227825Stheraven
1192227825Stheraventemplate <class _Tp, class _Arg>
1193227825Stheravendecltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>(), true_type()))
1194227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1195227825Stheraven__is_assignable_test(_Tp&&, _Arg&&);
1196227825Stheraven#else
1197227825Stheraven__is_assignable_test(_Tp, _Arg&);
1198227825Stheraven#endif
1199227825Stheraven
1200227825Stheraventemplate <class _Arg>
1201227825Stheravenfalse_type
1202227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1203227825Stheraven__is_assignable_test(__any, _Arg&&);
1204227825Stheraven#else
1205227825Stheraven__is_assignable_test(__any, _Arg&);
1206227825Stheraven#endif
1207227825Stheraven
1208227825Stheraventemplate <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
1209227825Stheravenstruct __is_assignable_imp
1210227825Stheraven    : public common_type
1211227825Stheraven        <
1212227825Stheraven            decltype(__is_assignable_test(declval<_Tp>(), declval<_Arg>()))
1213227825Stheraven        >::type {};
1214227825Stheraven
1215227825Stheraventemplate <class _Tp, class _Arg>
1216227825Stheravenstruct __is_assignable_imp<_Tp, _Arg, true>
1217227825Stheraven    : public false_type
1218227825Stheraven{
1219227825Stheraven};
1220227825Stheraven
1221227825Stheraventemplate <class _Tp, class _Arg>
1222227825Stheravenstruct is_assignable
1223227825Stheraven    : public __is_assignable_imp<_Tp, _Arg> {};
1224227825Stheraven
1225227825Stheraven// is_copy_assignable
1226227825Stheraven
1227227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_copy_assignable
1228227825Stheraven    : public is_assignable<typename add_lvalue_reference<_Tp>::type,
1229227825Stheraven                     const typename add_lvalue_reference<_Tp>::type> {};
1230227825Stheraven
1231227825Stheraven// is_move_assignable
1232227825Stheraven
1233227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_move_assignable
1234227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1235227825Stheraven    : public is_assignable<typename add_lvalue_reference<_Tp>::type,
1236227825Stheraven                     const typename add_rvalue_reference<_Tp>::type> {};
1237227825Stheraven#else
1238227825Stheraven    : public is_copy_assignable<_Tp> {};
1239227825Stheraven#endif
1240227825Stheraven
1241227825Stheraven// is_destructible
1242227825Stheraven
1243227825Stheraventemplate <class _Tp>
1244227825Stheravenstruct __destructible_test
1245227825Stheraven{
1246227825Stheraven    _Tp __t;
1247227825Stheraven};
1248227825Stheraven
1249227825Stheraventemplate <class _Tp>
1250227825Stheravendecltype((_VSTD::declval<__destructible_test<_Tp> >().~__destructible_test<_Tp>(), true_type()))
1251227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1252227825Stheraven__is_destructible_test(_Tp&&);
1253227825Stheraven#else
1254227825Stheraven__is_destructible_test(_Tp&);
1255227825Stheraven#endif
1256227825Stheraven
1257227825Stheravenfalse_type
1258227825Stheraven__is_destructible_test(__any);
1259227825Stheraven
1260227825Stheraventemplate <class _Tp, bool = is_void<_Tp>::value || is_abstract<_Tp>::value>
1261227825Stheravenstruct __destructible_imp
1262227825Stheraven    : public common_type
1263227825Stheraven        <
1264227825Stheraven            decltype(__is_destructible_test(declval<_Tp>()))
1265227825Stheraven        >::type {};
1266227825Stheraven
1267227825Stheraventemplate <class _Tp>
1268227825Stheravenstruct __destructible_imp<_Tp, true>
1269227825Stheraven    : public false_type {};
1270227825Stheraven
1271227825Stheraventemplate <class _Tp>
1272227825Stheravenstruct is_destructible
1273227825Stheraven    : public __destructible_imp<_Tp> {};
1274227825Stheraven
1275227825Stheraven// move
1276227825Stheraven
1277227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1278227825Stheraven
1279227825Stheraventemplate <class _Tp>
1280227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1281227825Stheraventypename remove_reference<_Tp>::type&&
1282227825Stheravenmove(_Tp&& __t) _NOEXCEPT
1283227825Stheraven{
1284227825Stheraven    typedef typename remove_reference<_Tp>::type _Up;
1285227825Stheraven    return static_cast<_Up&&>(__t);
1286227825Stheraven}
1287227825Stheraven
1288227825Stheraventemplate <class _Tp>
1289227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1290227825Stheraven_Tp&&
1291227825Stheravenforward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
1292227825Stheraven{
1293227825Stheraven    return static_cast<_Tp&&>(__t);
1294227825Stheraven}
1295227825Stheraven
1296227825Stheraventemplate <class _Tp>
1297227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1298227825Stheraven_Tp&&
1299227825Stheravenforward(typename std::remove_reference<_Tp>::type&& __t) _NOEXCEPT
1300227825Stheraven{
1301227825Stheraven    static_assert(!std::is_lvalue_reference<_Tp>::value,
1302227825Stheraven                  "Can not forward an rvalue as an lvalue.");
1303227825Stheraven    return static_cast<_Tp&&>(__t);
1304227825Stheraven}
1305227825Stheraven
1306227825Stheraven#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1307227825Stheraven
1308227825Stheraventemplate <class _Tp>
1309227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1310234976Stheraven_Tp&
1311227825Stheravenmove(_Tp& __t)
1312227825Stheraven{
1313227825Stheraven    return __t;
1314227825Stheraven}
1315227825Stheraven
1316227825Stheraventemplate <class _Tp>
1317227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1318234976Stheravenconst _Tp&
1319232950Stheravenmove(const _Tp& __t)
1320232950Stheraven{
1321232950Stheraven    return __t;
1322232950Stheraven}
1323232950Stheraven
1324232950Stheraventemplate <class _Tp>
1325232950Stheraveninline _LIBCPP_INLINE_VISIBILITY
1326234976Stheraven_Tp&
1327234976Stheravenforward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
1328227825Stheraven{
1329227825Stheraven    return __t;
1330227825Stheraven}
1331227825Stheraven
1332227825Stheraven
1333234976Stheraventemplate <class _Tp>
1334234976Stheravenclass __rv
1335227825Stheraven{
1336234976Stheraven    typedef typename remove_reference<_Tp>::type _Trr;
1337234976Stheraven    _Trr& t_;
1338234976Stheravenpublic:
1339234976Stheraven    _LIBCPP_INLINE_VISIBILITY
1340234976Stheraven    _Trr* operator->() {return &t_;}
1341234976Stheraven    _LIBCPP_INLINE_VISIBILITY
1342234976Stheraven    explicit __rv(_Trr& __t) : t_(__t) {}
1343234976Stheraven};
1344227825Stheraven
1345227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1346227825Stheraven
1347227825Stheraventemplate <class _Tp>
1348227825Stheravenstruct _LIBCPP_VISIBLE decay
1349227825Stheraven{
1350227825Stheravenprivate:
1351227825Stheraven    typedef typename remove_reference<_Tp>::type _Up;
1352227825Stheravenpublic:
1353227825Stheraven    typedef typename conditional
1354227825Stheraven                     <
1355227825Stheraven                         is_array<_Up>::value,
1356227825Stheraven                         typename remove_extent<_Up>::type*,
1357227825Stheraven                         typename conditional
1358227825Stheraven                         <
1359227825Stheraven                              is_function<_Up>::value,
1360227825Stheraven                              typename add_pointer<_Up>::type,
1361227825Stheraven                              typename remove_cv<_Up>::type
1362227825Stheraven                         >::type
1363227825Stheraven                     >::type type;
1364227825Stheraven};
1365227825Stheraven
1366227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1367227825Stheraven
1368227825Stheraventemplate <class _Tp>
1369227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1370227825Stheraventypename decay<_Tp>::type
1371227825Stheraven__decay_copy(_Tp&& __t)
1372227825Stheraven{
1373227825Stheraven    return _VSTD::forward<_Tp>(__t);
1374227825Stheraven}
1375227825Stheraven
1376227825Stheraven#else
1377227825Stheraven
1378227825Stheraventemplate <class _Tp>
1379227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1380227825Stheraventypename decay<_Tp>::type
1381227825Stheraven__decay_copy(const _Tp& __t)
1382227825Stheraven{
1383227825Stheraven    return _VSTD::forward<_Tp>(__t);
1384227825Stheraven}
1385227825Stheraven
1386227825Stheraven#endif
1387227825Stheraven
1388227825Stheraventemplate <class _MP, bool _IsMemberFuctionPtr, bool _IsMemberObjectPtr>
1389227825Stheravenstruct __member_pointer_traits_imp
1390227825Stheraven{
1391227825Stheraven};
1392227825Stheraven
1393227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
1394227825Stheraven
1395232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1396232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
1397227825Stheraven{
1398227825Stheraven    typedef _Class _ClassType;
1399232950Stheraven    typedef _Rp _ReturnType;
1400227825Stheraven};
1401227825Stheraven
1402232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1403232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
1404227825Stheraven{
1405227825Stheraven    typedef _Class const _ClassType;
1406232950Stheraven    typedef _Rp _ReturnType;
1407227825Stheraven};
1408227825Stheraven
1409232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1410232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
1411227825Stheraven{
1412227825Stheraven    typedef _Class volatile _ClassType;
1413232950Stheraven    typedef _Rp _ReturnType;
1414227825Stheraven};
1415227825Stheraven
1416232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1417232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
1418227825Stheraven{
1419227825Stheraven    typedef _Class const volatile _ClassType;
1420232950Stheraven    typedef _Rp _ReturnType;
1421227825Stheraven};
1422227825Stheraven
1423227825Stheraven#if __has_feature(cxx_reference_qualified_functions)
1424227825Stheraven
1425232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1426232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
1427227825Stheraven{
1428227825Stheraven    typedef _Class& _ClassType;
1429232950Stheraven    typedef _Rp _ReturnType;
1430227825Stheraven};
1431227825Stheraven
1432232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1433232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
1434227825Stheraven{
1435227825Stheraven    typedef _Class const& _ClassType;
1436232950Stheraven    typedef _Rp _ReturnType;
1437227825Stheraven};
1438227825Stheraven
1439232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1440232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
1441227825Stheraven{
1442227825Stheraven    typedef _Class volatile& _ClassType;
1443232950Stheraven    typedef _Rp _ReturnType;
1444227825Stheraven};
1445227825Stheraven
1446232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1447232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
1448227825Stheraven{
1449227825Stheraven    typedef _Class const volatile& _ClassType;
1450232950Stheraven    typedef _Rp _ReturnType;
1451227825Stheraven};
1452227825Stheraven
1453232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1454232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
1455227825Stheraven{
1456227825Stheraven    typedef _Class&& _ClassType;
1457232950Stheraven    typedef _Rp _ReturnType;
1458227825Stheraven};
1459227825Stheraven
1460232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1461232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
1462227825Stheraven{
1463227825Stheraven    typedef _Class const&& _ClassType;
1464232950Stheraven    typedef _Rp _ReturnType;
1465227825Stheraven};
1466227825Stheraven
1467232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1468232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
1469227825Stheraven{
1470227825Stheraven    typedef _Class volatile&& _ClassType;
1471232950Stheraven    typedef _Rp _ReturnType;
1472227825Stheraven};
1473227825Stheraven
1474232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
1475232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
1476227825Stheraven{
1477227825Stheraven    typedef _Class const volatile&& _ClassType;
1478232950Stheraven    typedef _Rp _ReturnType;
1479227825Stheraven};
1480227825Stheraven
1481227825Stheraven#endif  // __has_feature(cxx_reference_qualified_functions)
1482227825Stheraven
1483227825Stheraven#else  // _LIBCPP_HAS_NO_VARIADICS
1484227825Stheraven
1485232950Stheraventemplate <class _Rp, class _Class>
1486232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(), true, false>
1487227825Stheraven{
1488227825Stheraven    typedef _Class _ClassType;
1489232950Stheraven    typedef _Rp _ReturnType;
1490227825Stheraven};
1491227825Stheraven
1492232950Stheraventemplate <class _Rp, class _Class, class _P0>
1493232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false>
1494227825Stheraven{
1495227825Stheraven    typedef _Class _ClassType;
1496232950Stheraven    typedef _Rp _ReturnType;
1497227825Stheraven};
1498227825Stheraven
1499232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1>
1500232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false>
1501227825Stheraven{
1502227825Stheraven    typedef _Class _ClassType;
1503232950Stheraven    typedef _Rp _ReturnType;
1504227825Stheraven};
1505227825Stheraven
1506232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1, class _P2>
1507232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false>
1508227825Stheraven{
1509227825Stheraven    typedef _Class _ClassType;
1510232950Stheraven    typedef _Rp _ReturnType;
1511227825Stheraven};
1512227825Stheraven
1513232950Stheraventemplate <class _Rp, class _Class>
1514232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false>
1515227825Stheraven{
1516227825Stheraven    typedef _Class const _ClassType;
1517232950Stheraven    typedef _Rp _ReturnType;
1518227825Stheraven};
1519227825Stheraven
1520232950Stheraventemplate <class _Rp, class _Class, class _P0>
1521232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false>
1522227825Stheraven{
1523227825Stheraven    typedef _Class const _ClassType;
1524232950Stheraven    typedef _Rp _ReturnType;
1525227825Stheraven};
1526227825Stheraven
1527232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1>
1528232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false>
1529227825Stheraven{
1530227825Stheraven    typedef _Class const _ClassType;
1531232950Stheraven    typedef _Rp _ReturnType;
1532227825Stheraven};
1533227825Stheraven
1534232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1, class _P2>
1535232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, false>
1536227825Stheraven{
1537227825Stheraven    typedef _Class const _ClassType;
1538232950Stheraven    typedef _Rp _ReturnType;
1539227825Stheraven};
1540227825Stheraven
1541232950Stheraventemplate <class _Rp, class _Class>
1542232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false>
1543227825Stheraven{
1544227825Stheraven    typedef _Class volatile _ClassType;
1545232950Stheraven    typedef _Rp _ReturnType;
1546227825Stheraven};
1547227825Stheraven
1548232950Stheraventemplate <class _Rp, class _Class, class _P0>
1549232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false>
1550227825Stheraven{
1551227825Stheraven    typedef _Class volatile _ClassType;
1552232950Stheraven    typedef _Rp _ReturnType;
1553227825Stheraven};
1554227825Stheraven
1555232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1>
1556232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, false>
1557227825Stheraven{
1558227825Stheraven    typedef _Class volatile _ClassType;
1559232950Stheraven    typedef _Rp _ReturnType;
1560227825Stheraven};
1561227825Stheraven
1562232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1, class _P2>
1563232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true, false>
1564227825Stheraven{
1565227825Stheraven    typedef _Class volatile _ClassType;
1566232950Stheraven    typedef _Rp _ReturnType;
1567227825Stheraven};
1568227825Stheraven
1569232950Stheraventemplate <class _Rp, class _Class>
1570232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false>
1571227825Stheraven{
1572227825Stheraven    typedef _Class const volatile _ClassType;
1573232950Stheraven    typedef _Rp _ReturnType;
1574227825Stheraven};
1575227825Stheraven
1576232950Stheraventemplate <class _Rp, class _Class, class _P0>
1577232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, false>
1578227825Stheraven{
1579227825Stheraven    typedef _Class const volatile _ClassType;
1580232950Stheraven    typedef _Rp _ReturnType;
1581227825Stheraven};
1582227825Stheraven
1583232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1>
1584232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, true, false>
1585227825Stheraven{
1586227825Stheraven    typedef _Class const volatile _ClassType;
1587232950Stheraven    typedef _Rp _ReturnType;
1588227825Stheraven};
1589227825Stheraven
1590232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1, class _P2>
1591232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile, true, false>
1592227825Stheraven{
1593227825Stheraven    typedef _Class const volatile _ClassType;
1594232950Stheraven    typedef _Rp _ReturnType;
1595227825Stheraven};
1596227825Stheraven
1597227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
1598227825Stheraven
1599232950Stheraventemplate <class _Rp, class _Class>
1600232950Stheravenstruct __member_pointer_traits_imp<_Rp _Class::*, false, true>
1601227825Stheraven{
1602227825Stheraven    typedef _Class _ClassType;
1603232950Stheraven    typedef _Rp _ReturnType;
1604227825Stheraven};
1605227825Stheraven
1606227825Stheraventemplate <class _MP>
1607227825Stheravenstruct __member_pointer_traits
1608227825Stheraven    : public __member_pointer_traits_imp<_MP,
1609227825Stheraven                    is_member_function_pointer<_MP>::value,
1610227825Stheraven                    is_member_object_pointer<_MP>::value>
1611227825Stheraven{
1612227825Stheraven//     typedef ... _ClassType;
1613227825Stheraven//     typedef ... _ReturnType;
1614227825Stheraven};
1615227825Stheraven
1616227825Stheraven// result_of
1617227825Stheraven
1618227825Stheraventemplate <class _Callable> class result_of;
1619227825Stheraven
1620241903Sdim#ifdef _LIBCPP_HAS_NO_VARIADICS
1621241903Sdim
1622227825Stheraventemplate <class _Fn, bool, bool>
1623227825Stheravenclass __result_of
1624227825Stheraven{
1625227825Stheraven};
1626227825Stheraven
1627227825Stheraventemplate <class _Fn>
1628227825Stheravenclass __result_of<_Fn(), true, false>
1629227825Stheraven{
1630227825Stheravenpublic:
1631227825Stheraven    typedef decltype(declval<_Fn>()()) type;
1632227825Stheraven};
1633227825Stheraven
1634227825Stheraventemplate <class _Fn, class _A0>
1635227825Stheravenclass __result_of<_Fn(_A0), true, false>
1636227825Stheraven{
1637227825Stheravenpublic:
1638227825Stheraven    typedef decltype(declval<_Fn>()(declval<_A0>())) type;
1639227825Stheraven};
1640227825Stheraven
1641227825Stheraventemplate <class _Fn, class _A0, class _A1>
1642227825Stheravenclass __result_of<_Fn(_A0, _A1), true, false>
1643227825Stheraven{
1644227825Stheravenpublic:
1645227825Stheraven    typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type;
1646227825Stheraven};
1647227825Stheraven
1648227825Stheraventemplate <class _Fn, class _A0, class _A1, class _A2>
1649227825Stheravenclass __result_of<_Fn(_A0, _A1, _A2), true, false>
1650227825Stheraven{
1651227825Stheravenpublic:
1652227825Stheraven    typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type;
1653227825Stheraven};
1654227825Stheraven
1655227825Stheraventemplate <class _MP, class _Tp, bool _IsMemberFunctionPtr>
1656227825Stheravenstruct __result_of_mp;
1657227825Stheraven
1658227825Stheraven// member function pointer
1659227825Stheraven
1660227825Stheraventemplate <class _MP, class _Tp>
1661227825Stheravenstruct __result_of_mp<_MP, _Tp, true>
1662227825Stheraven    : public common_type<typename __member_pointer_traits<_MP>::_ReturnType>
1663227825Stheraven{
1664227825Stheraven};
1665227825Stheraven
1666227825Stheraven// member data pointer
1667227825Stheraven
1668227825Stheraventemplate <class _MP, class _Tp, bool>
1669227825Stheravenstruct __result_of_mdp;
1670227825Stheraven
1671232950Stheraventemplate <class _Rp, class _Class, class _Tp>
1672232950Stheravenstruct __result_of_mdp<_Rp _Class::*, _Tp, false>
1673227825Stheraven{
1674232950Stheraven    typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type;
1675227825Stheraven};
1676227825Stheraven
1677232950Stheraventemplate <class _Rp, class _Class, class _Tp>
1678232950Stheravenstruct __result_of_mdp<_Rp _Class::*, _Tp, true>
1679227825Stheraven{
1680232950Stheraven    typedef typename __apply_cv<_Tp, _Rp>::type& type;
1681227825Stheraven};
1682227825Stheraven
1683232950Stheraventemplate <class _Rp, class _Class, class _Tp>
1684232950Stheravenstruct __result_of_mp<_Rp _Class::*, _Tp, false>
1685232950Stheraven    : public __result_of_mdp<_Rp _Class::*, _Tp,
1686227825Stheraven            is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
1687227825Stheraven{
1688227825Stheraven};
1689227825Stheraven
1690227825Stheraven
1691227825Stheraven
1692227825Stheraventemplate <class _Fn, class _Tp>
1693227825Stheravenclass __result_of<_Fn(_Tp), false, true>  // _Fn must be member pointer
1694227825Stheraven    : public __result_of_mp<typename remove_reference<_Fn>::type,
1695227825Stheraven                            _Tp,
1696227825Stheraven                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1697227825Stheraven{
1698227825Stheraven};
1699227825Stheraven
1700227825Stheraventemplate <class _Fn, class _Tp, class _A0>
1701227825Stheravenclass __result_of<_Fn(_Tp, _A0), false, true>  // _Fn must be member pointer
1702227825Stheraven    : public __result_of_mp<typename remove_reference<_Fn>::type,
1703227825Stheraven                            _Tp,
1704227825Stheraven                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1705227825Stheraven{
1706227825Stheraven};
1707227825Stheraven
1708227825Stheraventemplate <class _Fn, class _Tp, class _A0, class _A1>
1709227825Stheravenclass __result_of<_Fn(_Tp, _A0, _A1), false, true>  // _Fn must be member pointer
1710227825Stheraven    : public __result_of_mp<typename remove_reference<_Fn>::type,
1711227825Stheraven                            _Tp,
1712227825Stheraven                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1713227825Stheraven{
1714227825Stheraven};
1715227825Stheraven
1716227825Stheraventemplate <class _Fn, class _Tp, class _A0, class _A1, class _A2>
1717227825Stheravenclass __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true>  // _Fn must be member pointer
1718227825Stheraven    : public __result_of_mp<typename remove_reference<_Fn>::type,
1719227825Stheraven                            _Tp,
1720227825Stheraven                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1721227825Stheraven{
1722227825Stheraven};
1723227825Stheraven
1724227825Stheraven// result_of
1725227825Stheraven
1726227825Stheraventemplate <class _Fn>
1727227825Stheravenclass _LIBCPP_VISIBLE result_of<_Fn()>
1728227825Stheraven    : public __result_of<_Fn(),
1729227825Stheraven                         is_class<typename remove_reference<_Fn>::type>::value ||
1730227825Stheraven                         is_function<typename remove_reference<_Fn>::type>::value,
1731227825Stheraven                         is_member_pointer<typename remove_reference<_Fn>::type>::value
1732227825Stheraven                        >
1733227825Stheraven{
1734227825Stheraven};
1735227825Stheraven
1736227825Stheraventemplate <class _Fn, class _A0>
1737227825Stheravenclass _LIBCPP_VISIBLE result_of<_Fn(_A0)>
1738227825Stheraven    : public __result_of<_Fn(_A0),
1739227825Stheraven                         is_class<typename remove_reference<_Fn>::type>::value ||
1740227825Stheraven                         is_function<typename remove_reference<_Fn>::type>::value,
1741227825Stheraven                         is_member_pointer<typename remove_reference<_Fn>::type>::value
1742227825Stheraven                        >
1743227825Stheraven{
1744227825Stheraven};
1745227825Stheraven
1746227825Stheraventemplate <class _Fn, class _A0, class _A1>
1747227825Stheravenclass _LIBCPP_VISIBLE result_of<_Fn(_A0, _A1)>
1748227825Stheraven    : public __result_of<_Fn(_A0, _A1),
1749227825Stheraven                         is_class<typename remove_reference<_Fn>::type>::value ||
1750227825Stheraven                         is_function<typename remove_reference<_Fn>::type>::value,
1751227825Stheraven                         is_member_pointer<typename remove_reference<_Fn>::type>::value
1752227825Stheraven                        >
1753227825Stheraven{
1754227825Stheraven};
1755227825Stheraven
1756227825Stheraventemplate <class _Fn, class _A0, class _A1, class _A2>
1757227825Stheravenclass _LIBCPP_VISIBLE result_of<_Fn(_A0, _A1, _A2)>
1758227825Stheraven    : public __result_of<_Fn(_A0, _A1, _A2),
1759227825Stheraven                         is_class<typename remove_reference<_Fn>::type>::value ||
1760227825Stheraven                         is_function<typename remove_reference<_Fn>::type>::value,
1761227825Stheraven                         is_member_pointer<typename remove_reference<_Fn>::type>::value
1762227825Stheraven                        >
1763227825Stheraven{
1764227825Stheraven};
1765227825Stheraven
1766227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
1767227825Stheraven
1768227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
1769227825Stheraven
1770227825Stheraven// template <class T, class... Args> struct is_constructible;
1771227825Stheraven
1772227825Stheraven//      main is_constructible test
1773227825Stheraven
1774242945Stheraventemplate<typename, typename T> struct __select_2nd { typedef T type; };
1775242945Stheraven
1776227825Stheraventemplate <class _Tp, class ..._Args>
1777242945Stheraventypename __select_2nd<decltype(_VSTD::move(_Tp(_VSTD::declval<_Args>()...))), true_type>::type
1778227825Stheraven__is_constructible_test(_Tp&&, _Args&& ...);
1779227825Stheraven
1780227825Stheraventemplate <class ..._Args>
1781227825Stheravenfalse_type
1782227825Stheraven__is_constructible_test(__any, _Args&& ...);
1783227825Stheraven
1784227825Stheraventemplate <bool, class _Tp, class... _Args>
1785227825Stheravenstruct __is_constructible // false, _Tp is not a scalar
1786227825Stheraven    : public common_type
1787227825Stheraven             <
1788227825Stheraven                 decltype(__is_constructible_test(declval<_Tp>(), declval<_Args>()...))
1789227825Stheraven             >::type
1790227825Stheraven    {};
1791227825Stheraven
1792227825Stheraven//      function types are not constructible
1793227825Stheraven
1794232950Stheraventemplate <class _Rp, class... _A1, class... _A2>
1795232950Stheravenstruct __is_constructible<false, _Rp(_A1...), _A2...>
1796227825Stheraven    : public false_type
1797227825Stheraven    {};
1798227825Stheraven
1799227825Stheraven//      handle scalars and reference types
1800227825Stheraven
1801227825Stheraven//      Scalars are default constructible, references are not
1802227825Stheraven
1803227825Stheraventemplate <class _Tp>
1804227825Stheravenstruct __is_constructible<true, _Tp>
1805227825Stheraven    : public is_scalar<_Tp>
1806227825Stheraven    {};
1807227825Stheraven
1808227825Stheraven//      Scalars and references are constructible from one arg if that arg is
1809227825Stheraven//          implicitly convertible to the scalar or reference.
1810227825Stheraven
1811227825Stheraventemplate <class _Tp>
1812227825Stheravenstruct __is_constructible_ref
1813227825Stheraven{
1814242945Stheraven    true_type static __lxx(_Tp);
1815242945Stheraven    false_type static __lxx(...);
1816227825Stheraven};
1817227825Stheraven
1818227825Stheraventemplate <class _Tp, class _A0>
1819227825Stheravenstruct __is_constructible<true, _Tp, _A0>
1820227825Stheraven    : public common_type
1821227825Stheraven             <
1822242945Stheraven                 decltype(__is_constructible_ref<_Tp>::__lxx(declval<_A0>()))
1823227825Stheraven             >::type
1824227825Stheraven    {};
1825227825Stheraven
1826227825Stheraven//      Scalars and references are not constructible from multiple args.
1827227825Stheraven
1828227825Stheraventemplate <class _Tp, class _A0, class ..._Args>
1829227825Stheravenstruct __is_constructible<true, _Tp, _A0, _Args...>
1830227825Stheraven    : public false_type
1831227825Stheraven    {};
1832227825Stheraven
1833227825Stheraven//      Treat scalars and reference types separately
1834227825Stheraven
1835227825Stheraventemplate <bool, class _Tp, class... _Args>
1836227825Stheravenstruct __is_constructible_void_check
1837227825Stheraven    : public __is_constructible<is_scalar<_Tp>::value || is_reference<_Tp>::value,
1838227825Stheraven                                _Tp, _Args...>
1839227825Stheraven    {};
1840227825Stheraven
1841227825Stheraven//      If any of T or Args is void, is_constructible should be false
1842227825Stheraven
1843227825Stheraventemplate <class _Tp, class... _Args>
1844227825Stheravenstruct __is_constructible_void_check<true, _Tp, _Args...>
1845227825Stheraven    : public false_type
1846227825Stheraven    {};
1847227825Stheraven
1848227825Stheraventemplate <class ..._Args> struct __contains_void;
1849227825Stheraven
1850227825Stheraventemplate <> struct __contains_void<> : false_type {};
1851227825Stheraven
1852227825Stheraventemplate <class _A0, class ..._Args>
1853227825Stheravenstruct __contains_void<_A0, _Args...>
1854227825Stheraven{
1855227825Stheraven    static const bool value = is_void<_A0>::value ||
1856227825Stheraven                              __contains_void<_Args...>::value;
1857227825Stheraven};
1858227825Stheraven
1859227825Stheraven//      is_constructible entry point
1860227825Stheraven
1861227825Stheraventemplate <class _Tp, class... _Args>
1862227825Stheravenstruct _LIBCPP_VISIBLE is_constructible
1863227825Stheraven    : public __is_constructible_void_check<__contains_void<_Tp, _Args...>::value
1864227825Stheraven                                        || is_abstract<_Tp>::value,
1865227825Stheraven                                           _Tp, _Args...>
1866227825Stheraven    {};
1867227825Stheraven
1868227825Stheraven//      Array types are default constructible if their element type
1869227825Stheraven//      is default constructible
1870227825Stheraven
1871232950Stheraventemplate <class _Ap, size_t _Np>
1872232950Stheravenstruct __is_constructible<false, _Ap[_Np]>
1873232950Stheraven    : public is_constructible<typename remove_all_extents<_Ap>::type>
1874227825Stheraven    {};
1875227825Stheraven
1876227825Stheraven//      Otherwise array types are not constructible by this syntax
1877227825Stheraven
1878232950Stheraventemplate <class _Ap, size_t _Np, class ..._Args>
1879232950Stheravenstruct __is_constructible<false, _Ap[_Np], _Args...>
1880227825Stheraven    : public false_type
1881227825Stheraven    {};
1882227825Stheraven
1883227825Stheraven//      Incomplete array types are not constructible
1884227825Stheraven
1885232950Stheraventemplate <class _Ap, class ..._Args>
1886232950Stheravenstruct __is_constructible<false, _Ap[], _Args...>
1887227825Stheraven    : public false_type
1888227825Stheraven    {};
1889227825Stheraven
1890227825Stheraven#else  // _LIBCPP_HAS_NO_VARIADICS
1891227825Stheraven
1892227825Stheraven// template <class T> struct is_constructible0;
1893227825Stheraven
1894227825Stheraven//      main is_constructible0 test
1895227825Stheraven
1896227825Stheraventemplate <class _Tp>
1897227825Stheravendecltype((_Tp(), true_type()))
1898227825Stheraven__is_constructible0_test(_Tp&);
1899227825Stheraven
1900227825Stheravenfalse_type
1901227825Stheraven__is_constructible0_test(__any);
1902227825Stheraven
1903227825Stheraventemplate <class _Tp, class _A0>
1904227825Stheravendecltype((_Tp(_VSTD::declval<_A0>()), true_type()))
1905227825Stheraven__is_constructible1_test(_Tp&, _A0&);
1906227825Stheraven
1907227825Stheraventemplate <class _A0>
1908227825Stheravenfalse_type
1909227825Stheraven__is_constructible1_test(__any, _A0&);
1910227825Stheraven
1911227825Stheraventemplate <class _Tp, class _A0, class _A1>
1912227825Stheravendecltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>()), true_type()))
1913227825Stheraven__is_constructible2_test(_Tp&, _A0&, _A1&);
1914227825Stheraven
1915227825Stheraventemplate <class _A0, class _A1>
1916227825Stheravenfalse_type
1917227825Stheraven__is_constructible2_test(__any, _A0&, _A1&);
1918227825Stheraven
1919227825Stheraventemplate <bool, class _Tp>
1920227825Stheravenstruct __is_constructible0_imp // false, _Tp is not a scalar
1921227825Stheraven    : public common_type
1922227825Stheraven             <
1923227825Stheraven                 decltype(__is_constructible0_test(declval<_Tp&>()))
1924227825Stheraven             >::type
1925227825Stheraven    {};
1926227825Stheraven
1927227825Stheraventemplate <bool, class _Tp, class _A0>
1928227825Stheravenstruct __is_constructible1_imp // false, _Tp is not a scalar
1929227825Stheraven    : public common_type
1930227825Stheraven             <
1931227825Stheraven                 decltype(__is_constructible1_test(declval<_Tp&>(), declval<_A0&>()))
1932227825Stheraven             >::type
1933227825Stheraven    {};
1934227825Stheraven
1935227825Stheraventemplate <bool, class _Tp, class _A0, class _A1>
1936227825Stheravenstruct __is_constructible2_imp // false, _Tp is not a scalar
1937227825Stheraven    : public common_type
1938227825Stheraven             <
1939227825Stheraven                 decltype(__is_constructible2_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>()))
1940227825Stheraven             >::type
1941227825Stheraven    {};
1942227825Stheraven
1943227825Stheraven//      handle scalars and reference types
1944227825Stheraven
1945227825Stheraven//      Scalars are default constructible, references are not
1946227825Stheraven
1947227825Stheraventemplate <class _Tp>
1948227825Stheravenstruct __is_constructible0_imp<true, _Tp>
1949227825Stheraven    : public is_scalar<_Tp>
1950227825Stheraven    {};
1951227825Stheraven
1952227825Stheraventemplate <class _Tp, class _A0>
1953227825Stheravenstruct __is_constructible1_imp<true, _Tp, _A0>
1954227825Stheraven    : public is_convertible<_A0, _Tp>
1955227825Stheraven    {};
1956227825Stheraven
1957227825Stheraventemplate <class _Tp, class _A0, class _A1>
1958227825Stheravenstruct __is_constructible2_imp<true, _Tp, _A0, _A1>
1959227825Stheraven    : public false_type
1960227825Stheraven    {};
1961227825Stheraven
1962227825Stheraven//      Treat scalars and reference types separately
1963227825Stheraven
1964227825Stheraventemplate <bool, class _Tp>
1965227825Stheravenstruct __is_constructible0_void_check
1966227825Stheraven    : public __is_constructible0_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
1967227825Stheraven                                _Tp>
1968227825Stheraven    {};
1969227825Stheraven
1970227825Stheraventemplate <bool, class _Tp, class _A0>
1971227825Stheravenstruct __is_constructible1_void_check
1972227825Stheraven    : public __is_constructible1_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
1973227825Stheraven                                _Tp, _A0>
1974227825Stheraven    {};
1975227825Stheraven
1976227825Stheraventemplate <bool, class _Tp, class _A0, class _A1>
1977227825Stheravenstruct __is_constructible2_void_check
1978227825Stheraven    : public __is_constructible2_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
1979227825Stheraven                                _Tp, _A0, _A1>
1980227825Stheraven    {};
1981227825Stheraven
1982227825Stheraven//      If any of T or Args is void, is_constructible should be false
1983227825Stheraven
1984227825Stheraventemplate <class _Tp>
1985227825Stheravenstruct __is_constructible0_void_check<true, _Tp>
1986227825Stheraven    : public false_type
1987227825Stheraven    {};
1988227825Stheraven
1989227825Stheraventemplate <class _Tp, class _A0>
1990227825Stheravenstruct __is_constructible1_void_check<true, _Tp, _A0>
1991227825Stheraven    : public false_type
1992227825Stheraven    {};
1993227825Stheraven
1994227825Stheraventemplate <class _Tp, class _A0, class _A1>
1995227825Stheravenstruct __is_constructible2_void_check<true, _Tp, _A0, _A1>
1996227825Stheraven    : public false_type
1997227825Stheraven    {};
1998227825Stheraven
1999227825Stheraven//      is_constructible entry point
2000227825Stheraven
2001227825Stheravennamespace __is_construct
2002227825Stheraven{
2003227825Stheraven
2004227825Stheravenstruct __nat {};
2005227825Stheraven
2006227825Stheraven}
2007227825Stheraven
2008227825Stheraventemplate <class _Tp, class _A0 = __is_construct::__nat,
2009227825Stheraven                     class _A1 = __is_construct::__nat>
2010227825Stheravenstruct _LIBCPP_VISIBLE is_constructible
2011227825Stheraven    : public __is_constructible2_void_check<is_void<_Tp>::value
2012227825Stheraven                                        || is_abstract<_Tp>::value
2013227825Stheraven                                        || is_function<_Tp>::value
2014227825Stheraven                                        || is_void<_A0>::value
2015227825Stheraven                                        || is_void<_A1>::value,
2016227825Stheraven                                           _Tp, _A0, _A1>
2017227825Stheraven    {};
2018227825Stheraven
2019227825Stheraventemplate <class _Tp>
2020227825Stheravenstruct _LIBCPP_VISIBLE is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat>
2021227825Stheraven    : public __is_constructible0_void_check<is_void<_Tp>::value
2022227825Stheraven                                        || is_abstract<_Tp>::value
2023227825Stheraven                                        || is_function<_Tp>::value,
2024227825Stheraven                                           _Tp>
2025227825Stheraven    {};
2026227825Stheraven
2027227825Stheraventemplate <class _Tp, class _A0>
2028227825Stheravenstruct _LIBCPP_VISIBLE is_constructible<_Tp, _A0, __is_construct::__nat>
2029227825Stheraven    : public __is_constructible1_void_check<is_void<_Tp>::value
2030227825Stheraven                                        || is_abstract<_Tp>::value
2031227825Stheraven                                        || is_function<_Tp>::value
2032227825Stheraven                                        || is_void<_A0>::value,
2033227825Stheraven                                           _Tp, _A0>
2034227825Stheraven    {};
2035227825Stheraven
2036227825Stheraven//      Array types are default constructible if their element type
2037227825Stheraven//      is default constructible
2038227825Stheraven
2039232950Stheraventemplate <class _Ap, size_t _Np>
2040232950Stheravenstruct __is_constructible0_imp<false, _Ap[_Np]>
2041232950Stheraven    : public is_constructible<typename remove_all_extents<_Ap>::type>
2042227825Stheraven    {};
2043227825Stheraven
2044232950Stheraventemplate <class _Ap, size_t _Np, class _A0>
2045232950Stheravenstruct __is_constructible1_imp<false, _Ap[_Np], _A0>
2046227825Stheraven    : public false_type
2047227825Stheraven    {};
2048227825Stheraven
2049232950Stheraventemplate <class _Ap, size_t _Np, class _A0, class _A1>
2050232950Stheravenstruct __is_constructible2_imp<false, _Ap[_Np], _A0, _A1>
2051227825Stheraven    : public false_type
2052227825Stheraven    {};
2053227825Stheraven
2054227825Stheraven//      Incomplete array types are not constructible
2055227825Stheraven
2056232950Stheraventemplate <class _Ap>
2057232950Stheravenstruct __is_constructible0_imp<false, _Ap[]>
2058227825Stheraven    : public false_type
2059227825Stheraven    {};
2060227825Stheraven
2061232950Stheraventemplate <class _Ap, class _A0>
2062232950Stheravenstruct __is_constructible1_imp<false, _Ap[], _A0>
2063227825Stheraven    : public false_type
2064227825Stheraven    {};
2065227825Stheraven
2066232950Stheraventemplate <class _Ap, class _A0, class _A1>
2067232950Stheravenstruct __is_constructible2_imp<false, _Ap[], _A0, _A1>
2068227825Stheraven    : public false_type
2069227825Stheraven    {};
2070227825Stheraven
2071227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
2072227825Stheraven
2073227825Stheraven// is_default_constructible
2074227825Stheraven
2075227825Stheraventemplate <class _Tp>
2076227825Stheravenstruct _LIBCPP_VISIBLE is_default_constructible
2077227825Stheraven    : public is_constructible<_Tp>
2078227825Stheraven    {};
2079227825Stheraven
2080227825Stheraven// is_copy_constructible
2081227825Stheraven
2082227825Stheraventemplate <class _Tp>
2083227825Stheravenstruct _LIBCPP_VISIBLE is_copy_constructible
2084227825Stheraven    : public is_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type>
2085227825Stheraven    {};
2086227825Stheraven
2087227825Stheraven// is_move_constructible
2088227825Stheraven
2089227825Stheraventemplate <class _Tp>
2090227825Stheravenstruct _LIBCPP_VISIBLE is_move_constructible
2091227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2092227825Stheraven    : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2093227825Stheraven#else
2094227825Stheraven    : public is_copy_constructible<_Tp>
2095227825Stheraven#endif
2096227825Stheraven    {};
2097227825Stheraven
2098227825Stheraven// is_trivially_constructible
2099227825Stheraven
2100227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
2101227825Stheraven
2102232950Stheraven#if __has_feature(is_trivially_constructible)
2103232950Stheraven
2104227825Stheraventemplate <class _Tp, class... _Args>
2105227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible
2106232950Stheraven    : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
2107232950Stheraven{
2108232950Stheraven};
2109232950Stheraven
2110232950Stheraven#else  // !__has_feature(is_trivially_constructible)
2111232950Stheraven
2112232950Stheraventemplate <class _Tp, class... _Args>
2113232950Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible
2114227825Stheraven    : false_type
2115227825Stheraven{
2116227825Stheraven};
2117227825Stheraven
2118227825Stheraventemplate <class _Tp>
2119227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp>
2120227825Stheraven#if __has_feature(has_trivial_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2121227825Stheraven    : integral_constant<bool, __has_trivial_constructor(_Tp)>
2122227825Stheraven#else
2123227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2124227825Stheraven#endif
2125227825Stheraven{
2126227825Stheraven};
2127227825Stheraven
2128227825Stheraventemplate <class _Tp>
2129227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2130227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp&&>
2131227825Stheraven#else
2132227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp>
2133227825Stheraven#endif
2134227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2135227825Stheraven{
2136227825Stheraven};
2137227825Stheraven
2138227825Stheraventemplate <class _Tp>
2139227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, const _Tp&>
2140227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2141227825Stheraven{
2142227825Stheraven};
2143227825Stheraven
2144227825Stheraventemplate <class _Tp>
2145227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp&>
2146227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2147227825Stheraven{
2148227825Stheraven};
2149227825Stheraven
2150232950Stheraven#endif  // !__has_feature(is_trivially_constructible)
2151232950Stheraven
2152227825Stheraven#else  // _LIBCPP_HAS_NO_VARIADICS
2153227825Stheraven
2154227825Stheraventemplate <class _Tp, class _A0 = __is_construct::__nat,
2155227825Stheraven                     class _A1 = __is_construct::__nat>
2156227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible
2157227825Stheraven    : false_type
2158227825Stheraven{
2159227825Stheraven};
2160227825Stheraven
2161232950Stheraven#if __has_feature(is_trivially_constructible)
2162232950Stheraven
2163227825Stheraventemplate <class _Tp>
2164227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, __is_construct::__nat,
2165227825Stheraven                                                       __is_construct::__nat>
2166232950Stheraven    : integral_constant<bool, __is_trivially_constructible(_Tp)>
2167232950Stheraven{
2168232950Stheraven};
2169232950Stheraven
2170232950Stheraventemplate <class _Tp>
2171232950Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp,
2172232950Stheraven                                                       __is_construct::__nat>
2173232950Stheraven    : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp)>
2174232950Stheraven{
2175232950Stheraven};
2176232950Stheraven
2177232950Stheraventemplate <class _Tp>
2178232950Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, const _Tp&,
2179232950Stheraven                                                       __is_construct::__nat>
2180232950Stheraven    : integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)>
2181232950Stheraven{
2182232950Stheraven};
2183232950Stheraven
2184232950Stheraventemplate <class _Tp>
2185232950Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp&,
2186232950Stheraven                                                       __is_construct::__nat>
2187232950Stheraven    : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&)>
2188232950Stheraven{
2189232950Stheraven};
2190232950Stheraven
2191232950Stheraven#else  // !__has_feature(is_trivially_constructible)
2192232950Stheraven
2193232950Stheraventemplate <class _Tp>
2194232950Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, __is_construct::__nat,
2195232950Stheraven                                                       __is_construct::__nat>
2196227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2197227825Stheraven{
2198227825Stheraven};
2199227825Stheraven
2200227825Stheraventemplate <class _Tp>
2201227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp,
2202227825Stheraven                                                       __is_construct::__nat>
2203227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2204227825Stheraven{
2205227825Stheraven};
2206227825Stheraven
2207227825Stheraventemplate <class _Tp>
2208227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, const _Tp&,
2209227825Stheraven                                                       __is_construct::__nat>
2210227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2211227825Stheraven{
2212227825Stheraven};
2213227825Stheraven
2214227825Stheraventemplate <class _Tp>
2215227825Stheravenstruct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp&,
2216227825Stheraven                                                       __is_construct::__nat>
2217227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2218227825Stheraven{
2219227825Stheraven};
2220227825Stheraven
2221232950Stheraven#endif  // !__has_feature(is_trivially_constructible)
2222232950Stheraven
2223227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
2224227825Stheraven
2225227825Stheraven// is_trivially_default_constructible
2226227825Stheraven
2227227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivially_default_constructible
2228227825Stheraven    : public is_trivially_constructible<_Tp>
2229227825Stheraven    {};
2230227825Stheraven
2231227825Stheraven// is_trivially_copy_constructible
2232227825Stheraven
2233227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivially_copy_constructible
2234227825Stheraven    : public is_trivially_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type>
2235227825Stheraven    {};
2236227825Stheraven
2237227825Stheraven// is_trivially_move_constructible
2238227825Stheraven
2239227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivially_move_constructible
2240227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2241227825Stheraven    : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2242227825Stheraven#else
2243227825Stheraven    : public is_trivially_copy_constructible<_Tp>
2244227825Stheraven#endif
2245227825Stheraven    {};
2246227825Stheraven
2247227825Stheraven// is_trivially_assignable
2248227825Stheraven
2249232950Stheraven#if __has_feature(is_trivially_constructible)
2250232950Stheraven
2251227825Stheraventemplate <class _Tp, class _Arg>
2252227825Stheravenstruct is_trivially_assignable
2253232950Stheraven    : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
2254232950Stheraven{
2255232950Stheraven};
2256232950Stheraven
2257232950Stheraven#else  // !__has_feature(is_trivially_constructible)
2258232950Stheraven
2259232950Stheraventemplate <class _Tp, class _Arg>
2260232950Stheravenstruct is_trivially_assignable
2261227825Stheraven    : public false_type {};
2262227825Stheraven
2263227825Stheraventemplate <class _Tp>
2264227825Stheravenstruct is_trivially_assignable<_Tp&, _Tp>
2265227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2266227825Stheraven
2267227825Stheraventemplate <class _Tp>
2268227825Stheravenstruct is_trivially_assignable<_Tp&, _Tp&>
2269227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2270227825Stheraven
2271227825Stheraventemplate <class _Tp>
2272227825Stheravenstruct is_trivially_assignable<_Tp&, const _Tp&>
2273227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2274227825Stheraven
2275227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2276227825Stheraven
2277227825Stheraventemplate <class _Tp>
2278227825Stheravenstruct is_trivially_assignable<_Tp&, _Tp&&>
2279227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2280227825Stheraven
2281227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2282227825Stheraven
2283232950Stheraven#endif  // !__has_feature(is_trivially_constructible)
2284232950Stheraven
2285227825Stheraven// is_trivially_copy_assignable
2286227825Stheraven
2287227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivially_copy_assignable
2288227825Stheraven    : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
2289227825Stheraven                               const typename add_lvalue_reference<_Tp>::type>
2290227825Stheraven    {};
2291227825Stheraven
2292227825Stheraven// is_trivially_move_assignable
2293227825Stheraven
2294227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivially_move_assignable
2295227825Stheraven    : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
2296227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2297227825Stheraven                                     typename add_rvalue_reference<_Tp>::type>
2298227825Stheraven#else
2299227825Stheraven                                     typename add_lvalue_reference<_Tp>::type>
2300227825Stheraven#endif
2301227825Stheraven    {};
2302227825Stheraven
2303227825Stheraven// is_trivially_destructible
2304227825Stheraven
2305227825Stheraven#if __has_feature(has_trivial_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2306227825Stheraven
2307227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivially_destructible
2308227825Stheraven    : public integral_constant<bool, __has_trivial_destructor(_Tp)> {};
2309227825Stheraven
2310227825Stheraven#else  // _LIBCPP_HAS_TYPE_TRAITS
2311227825Stheraven
2312227825Stheraventemplate <class _Tp> struct __libcpp_trivial_destructor
2313227825Stheraven    : public integral_constant<bool, is_scalar<_Tp>::value ||
2314227825Stheraven                                     is_reference<_Tp>::value> {};
2315227825Stheraven
2316227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivially_destructible
2317227825Stheraven    : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
2318227825Stheraven
2319227825Stheraven#endif  // _LIBCPP_HAS_TYPE_TRAITS
2320227825Stheraven
2321227825Stheraven// is_nothrow_constructible
2322227825Stheraven
2323227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
2324227825Stheraven
2325227825Stheraven#if __has_feature(cxx_noexcept)
2326227825Stheraven
2327227825Stheraventemplate <bool, class _Tp, class... _Args> struct __is_nothrow_constructible;
2328227825Stheraven
2329227825Stheraventemplate <class _Tp, class... _Args>
2330227825Stheravenstruct __is_nothrow_constructible<true, _Tp, _Args...>
2331227825Stheraven    : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
2332227825Stheraven{
2333227825Stheraven};
2334227825Stheraven
2335227825Stheraventemplate <class _Tp, class... _Args>
2336227825Stheravenstruct __is_nothrow_constructible<false, _Tp, _Args...>
2337227825Stheraven    : public false_type
2338227825Stheraven{
2339227825Stheraven};
2340227825Stheraven
2341227825Stheraventemplate <class _Tp, class... _Args>
2342227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible
2343227825Stheraven    : __is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, _Tp, _Args...>
2344227825Stheraven{
2345227825Stheraven};
2346227825Stheraven
2347227825Stheraventemplate <class _Tp, size_t _Ns>
2348227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp[_Ns]>
2349227825Stheraven    : __is_nothrow_constructible<is_constructible<_Tp>::value, _Tp>
2350227825Stheraven{
2351227825Stheraven};
2352227825Stheraven
2353227825Stheraven#else  // __has_feature(cxx_noexcept)
2354227825Stheraven
2355227825Stheraventemplate <class _Tp, class... _Args>
2356227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible
2357227825Stheraven    : false_type
2358227825Stheraven{
2359227825Stheraven};
2360227825Stheraven
2361227825Stheraventemplate <class _Tp>
2362227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp>
2363227825Stheraven#if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2364227825Stheraven    : integral_constant<bool, __has_nothrow_constructor(_Tp)>
2365227825Stheraven#else
2366227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2367227825Stheraven#endif
2368227825Stheraven{
2369227825Stheraven};
2370227825Stheraven
2371227825Stheraventemplate <class _Tp>
2372227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2373227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, _Tp&&>
2374227825Stheraven#else
2375227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, _Tp>
2376227825Stheraven#endif
2377227825Stheraven#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2378227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
2379227825Stheraven#else
2380227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2381227825Stheraven#endif
2382227825Stheraven{
2383227825Stheraven};
2384227825Stheraven
2385227825Stheraventemplate <class _Tp>
2386227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, const _Tp&>
2387227825Stheraven#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2388227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
2389227825Stheraven#else
2390227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2391227825Stheraven#endif
2392227825Stheraven{
2393227825Stheraven};
2394227825Stheraven
2395227825Stheraventemplate <class _Tp>
2396227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, _Tp&>
2397227825Stheraven#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2398227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
2399227825Stheraven#else
2400227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2401227825Stheraven#endif
2402227825Stheraven{
2403227825Stheraven};
2404227825Stheraven
2405227825Stheraven#endif  // __has_feature(cxx_noexcept)
2406227825Stheraven
2407227825Stheraven#else  // _LIBCPP_HAS_NO_VARIADICS
2408227825Stheraven
2409227825Stheraventemplate <class _Tp, class _A0 = __is_construct::__nat,
2410227825Stheraven                     class _A1 = __is_construct::__nat>
2411227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible
2412227825Stheraven    : false_type
2413227825Stheraven{
2414227825Stheraven};
2415227825Stheraven
2416227825Stheraventemplate <class _Tp>
2417227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, __is_construct::__nat,
2418227825Stheraven                                                       __is_construct::__nat>
2419227825Stheraven#if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2420227825Stheraven    : integral_constant<bool, __has_nothrow_constructor(_Tp)>
2421227825Stheraven#else
2422227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2423227825Stheraven#endif
2424227825Stheraven{
2425227825Stheraven};
2426227825Stheraven
2427227825Stheraventemplate <class _Tp>
2428227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, _Tp,
2429227825Stheraven                                                       __is_construct::__nat>
2430227825Stheraven#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2431227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
2432227825Stheraven#else
2433227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2434227825Stheraven#endif
2435227825Stheraven{
2436227825Stheraven};
2437227825Stheraven
2438227825Stheraventemplate <class _Tp>
2439227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, const _Tp&,
2440227825Stheraven                                                       __is_construct::__nat>
2441227825Stheraven#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2442227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
2443227825Stheraven#else
2444227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2445227825Stheraven#endif
2446227825Stheraven{
2447227825Stheraven};
2448227825Stheraven
2449227825Stheraventemplate <class _Tp>
2450227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, _Tp&,
2451227825Stheraven                                                       __is_construct::__nat>
2452227825Stheraven#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2453227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
2454227825Stheraven#else
2455227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
2456227825Stheraven#endif
2457227825Stheraven{
2458227825Stheraven};
2459227825Stheraven
2460227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
2461227825Stheraven
2462227825Stheraven// is_nothrow_default_constructible
2463227825Stheraven
2464227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_default_constructible
2465227825Stheraven    : public is_nothrow_constructible<_Tp>
2466227825Stheraven    {};
2467227825Stheraven
2468227825Stheraven// is_nothrow_copy_constructible
2469227825Stheraven
2470227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_copy_constructible
2471227825Stheraven    : public is_nothrow_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type>
2472227825Stheraven    {};
2473227825Stheraven
2474227825Stheraven// is_nothrow_move_constructible
2475227825Stheraven
2476227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_move_constructible
2477227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2478227825Stheraven    : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2479227825Stheraven#else
2480227825Stheraven    : public is_nothrow_copy_constructible<_Tp>
2481227825Stheraven#endif
2482227825Stheraven    {};
2483227825Stheraven
2484227825Stheraven// is_nothrow_assignable
2485227825Stheraven
2486227825Stheraven#if __has_feature(cxx_noexcept)
2487227825Stheraven
2488227825Stheraventemplate <bool, class _Tp, class _Arg> struct __is_nothrow_assignable;
2489227825Stheraven
2490227825Stheraventemplate <class _Tp, class _Arg>
2491227825Stheravenstruct __is_nothrow_assignable<false, _Tp, _Arg>
2492227825Stheraven    : public false_type
2493227825Stheraven{
2494227825Stheraven};
2495227825Stheraven
2496227825Stheraventemplate <class _Tp, class _Arg>
2497227825Stheravenstruct __is_nothrow_assignable<true, _Tp, _Arg>
2498227825Stheraven    : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) >
2499227825Stheraven{
2500227825Stheraven};
2501227825Stheraven
2502227825Stheraventemplate <class _Tp, class _Arg>
2503227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_assignable
2504227825Stheraven    : public __is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
2505227825Stheraven{
2506227825Stheraven};
2507227825Stheraven
2508227825Stheraven#else  // __has_feature(cxx_noexcept)
2509227825Stheraven
2510227825Stheraventemplate <class _Tp, class _Arg>
2511227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_assignable
2512227825Stheraven    : public false_type {};
2513227825Stheraven
2514227825Stheraventemplate <class _Tp>
2515227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_assignable<_Tp&, _Tp>
2516227825Stheraven#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2517227825Stheraven    : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
2518227825Stheraven#else
2519227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2520227825Stheraven#endif
2521227825Stheraven
2522227825Stheraventemplate <class _Tp>
2523227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_assignable<_Tp&, _Tp&>
2524227825Stheraven#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2525227825Stheraven    : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
2526227825Stheraven#else
2527227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2528227825Stheraven#endif
2529227825Stheraven
2530227825Stheraventemplate <class _Tp>
2531227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_assignable<_Tp&, const _Tp&>
2532227825Stheraven#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2533227825Stheraven    : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
2534227825Stheraven#else
2535227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2536227825Stheraven#endif
2537227825Stheraven
2538227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2539227825Stheraven
2540227825Stheraventemplate <class _Tp>
2541227825Stheravenstruct is_nothrow_assignable<_Tp&, _Tp&&>
2542227825Stheraven#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2543227825Stheraven    : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
2544227825Stheraven#else
2545227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
2546227825Stheraven#endif
2547227825Stheraven
2548227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2549227825Stheraven
2550227825Stheraven#endif  // __has_feature(cxx_noexcept)
2551227825Stheraven
2552227825Stheraven// is_nothrow_copy_assignable
2553227825Stheraven
2554227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_copy_assignable
2555227825Stheraven    : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
2556227825Stheraven                               const typename add_lvalue_reference<_Tp>::type>
2557227825Stheraven    {};
2558227825Stheraven
2559227825Stheraven// is_nothrow_move_assignable
2560227825Stheraven
2561227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_move_assignable
2562227825Stheraven    : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
2563227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2564227825Stheraven                                     typename add_rvalue_reference<_Tp>::type>
2565227825Stheraven#else
2566227825Stheraven                                     typename add_lvalue_reference<_Tp>::type>
2567227825Stheraven#endif
2568227825Stheraven    {};
2569227825Stheraven
2570227825Stheraven// is_nothrow_destructible
2571227825Stheraven
2572227825Stheraven#if __has_feature(cxx_noexcept)
2573227825Stheraven
2574227825Stheraventemplate <bool, class _Tp> struct __is_nothrow_destructible;
2575227825Stheraven
2576227825Stheraventemplate <class _Tp>
2577227825Stheravenstruct __is_nothrow_destructible<false, _Tp>
2578227825Stheraven    : public false_type
2579227825Stheraven{
2580227825Stheraven};
2581227825Stheraven
2582227825Stheraventemplate <class _Tp>
2583227825Stheravenstruct __is_nothrow_destructible<true, _Tp>
2584227825Stheraven    : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) >
2585227825Stheraven{
2586227825Stheraven};
2587227825Stheraven
2588227825Stheraventemplate <class _Tp>
2589227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_destructible
2590227825Stheraven    : public __is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
2591227825Stheraven{
2592227825Stheraven};
2593227825Stheraven
2594227825Stheraventemplate <class _Tp, size_t _Ns>
2595227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_destructible<_Tp[_Ns]>
2596227825Stheraven    : public is_nothrow_destructible<_Tp>
2597227825Stheraven{
2598227825Stheraven};
2599227825Stheraven
2600227825Stheraventemplate <class _Tp>
2601227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_destructible<_Tp&>
2602227825Stheraven    : public true_type
2603227825Stheraven{
2604227825Stheraven};
2605227825Stheraven
2606227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2607227825Stheraven
2608227825Stheraventemplate <class _Tp>
2609227825Stheravenstruct _LIBCPP_VISIBLE is_nothrow_destructible<_Tp&&>
2610227825Stheraven    : public true_type
2611227825Stheraven{
2612227825Stheraven};
2613227825Stheraven
2614227825Stheraven#endif
2615227825Stheraven
2616227825Stheraven#else
2617227825Stheraven
2618227825Stheraventemplate <class _Tp> struct __libcpp_nothrow_destructor
2619227825Stheraven    : public integral_constant<bool, is_scalar<_Tp>::value ||
2620227825Stheraven                                     is_reference<_Tp>::value> {};
2621227825Stheraven
2622227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_destructible
2623227825Stheraven    : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
2624227825Stheraven
2625227825Stheraven#endif
2626227825Stheraven
2627227825Stheraven// is_pod
2628227825Stheraven
2629227825Stheraven#if __has_feature(is_pod) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2630227825Stheraven
2631227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_pod
2632227825Stheraven    : public integral_constant<bool, __is_pod(_Tp)> {};
2633227825Stheraven
2634227825Stheraven#else  // _LIBCPP_HAS_TYPE_TRAITS
2635227825Stheraven
2636227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_pod
2637227825Stheraven    : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value   &&
2638227825Stheraven                                     is_trivially_copy_constructible<_Tp>::value      &&
2639227825Stheraven                                     is_trivially_copy_assignable<_Tp>::value    &&
2640227825Stheraven                                     is_trivially_destructible<_Tp>::value> {};
2641227825Stheraven
2642227825Stheraven#endif  // _LIBCPP_HAS_TYPE_TRAITS
2643227825Stheraven
2644227825Stheraven// is_literal_type;
2645227825Stheraven
2646227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_literal_type
2647227825Stheraven#if __has_feature(is_literal)
2648227825Stheraven    : public integral_constant<bool, __is_literal(_Tp)>
2649227825Stheraven#else
2650227825Stheraven    : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value ||
2651227825Stheraven                              is_reference<typename remove_all_extents<_Tp>::type>::value>
2652227825Stheraven#endif
2653227825Stheraven    {};
2654227825Stheraven    
2655227825Stheraven// is_standard_layout;
2656227825Stheraven
2657227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_standard_layout
2658227825Stheraven#if __has_feature(is_standard_layout)
2659227825Stheraven    : public integral_constant<bool, __is_standard_layout(_Tp)>
2660227825Stheraven#else
2661227825Stheraven    : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
2662227825Stheraven#endif
2663227825Stheraven    {};
2664227825Stheraven    
2665227825Stheraven// is_trivially_copyable;
2666227825Stheraven
2667227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivially_copyable
2668227825Stheraven#if __has_feature(is_trivially_copyable)
2669227825Stheraven    : public integral_constant<bool, __is_trivially_copyable(_Tp)>
2670227825Stheraven#else
2671227825Stheraven    : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
2672227825Stheraven#endif
2673227825Stheraven    {};
2674227825Stheraven    
2675227825Stheraven// is_trivial;
2676227825Stheraven
2677227825Stheraventemplate <class _Tp> struct _LIBCPP_VISIBLE is_trivial
2678227825Stheraven#if __has_feature(is_trivial)
2679227825Stheraven    : public integral_constant<bool, __is_trivial(_Tp)>
2680227825Stheraven#else
2681227825Stheraven    : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
2682227825Stheraven                                 is_trivially_default_constructible<_Tp>::value>
2683227825Stheraven#endif
2684227825Stheraven    {};
2685227825Stheraven
2686227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
2687227825Stheraven
2688227825Stheraven// Check for complete types
2689227825Stheraven
2690232950Stheraventemplate <class ..._Tp> struct __check_complete;
2691227825Stheraven
2692227825Stheraventemplate <>
2693227825Stheravenstruct __check_complete<>
2694227825Stheraven{
2695227825Stheraven};
2696227825Stheraven
2697232950Stheraventemplate <class _Hp, class _T0, class ..._Tp>
2698232950Stheravenstruct __check_complete<_Hp, _T0, _Tp...>
2699232950Stheraven    : private __check_complete<_Hp>,
2700232950Stheraven      private __check_complete<_T0, _Tp...>
2701227825Stheraven{
2702227825Stheraven};
2703227825Stheraven
2704232950Stheraventemplate <class _Hp>
2705232950Stheravenstruct __check_complete<_Hp, _Hp>
2706232950Stheraven    : private __check_complete<_Hp>
2707227825Stheraven{
2708227825Stheraven};
2709227825Stheraven
2710232950Stheraventemplate <class _Tp>
2711232950Stheravenstruct __check_complete<_Tp>
2712227825Stheraven{
2713232950Stheraven    static_assert(sizeof(_Tp) > 0, "Type must be complete.");
2714227825Stheraven};
2715227825Stheraven
2716232950Stheraventemplate <class _Tp>
2717232950Stheravenstruct __check_complete<_Tp&>
2718232950Stheraven    : private __check_complete<_Tp>
2719227825Stheraven{
2720227825Stheraven};
2721227825Stheraven
2722232950Stheraventemplate <class _Tp>
2723232950Stheravenstruct __check_complete<_Tp&&>
2724232950Stheraven    : private __check_complete<_Tp>
2725227825Stheraven{
2726227825Stheraven};
2727227825Stheraven
2728232950Stheraventemplate <class _Rp, class ..._Param>
2729232950Stheravenstruct __check_complete<_Rp (*)(_Param...)>
2730241903Sdim    : private __check_complete<_Rp>
2731227825Stheraven{
2732227825Stheraven};
2733227825Stheraven
2734232950Stheraventemplate <class _Rp, class ..._Param>
2735232950Stheravenstruct __check_complete<_Rp (_Param...)>
2736241903Sdim    : private __check_complete<_Rp>
2737227825Stheraven{
2738227825Stheraven};
2739227825Stheraven
2740232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2741232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...)>
2742241903Sdim    : private __check_complete<_Class>
2743227825Stheraven{
2744227825Stheraven};
2745227825Stheraven
2746232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2747232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) const>
2748241903Sdim    : private __check_complete<_Class>
2749227825Stheraven{
2750227825Stheraven};
2751227825Stheraven
2752232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2753232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) volatile>
2754241903Sdim    : private __check_complete<_Class>
2755227825Stheraven{
2756227825Stheraven};
2757227825Stheraven
2758232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2759232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) const volatile>
2760241903Sdim    : private __check_complete<_Class>
2761227825Stheraven{
2762227825Stheraven};
2763227825Stheraven
2764227825Stheraven#if __has_feature(cxx_reference_qualified_functions)
2765227825Stheraven
2766232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2767232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) &>
2768241903Sdim    : private __check_complete<_Class>
2769227825Stheraven{
2770227825Stheraven};
2771227825Stheraven
2772232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2773232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) const&>
2774241903Sdim    : private __check_complete<_Class>
2775227825Stheraven{
2776227825Stheraven};
2777227825Stheraven
2778232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2779232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) volatile&>
2780241903Sdim    : private __check_complete<_Class>
2781227825Stheraven{
2782227825Stheraven};
2783227825Stheraven
2784232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2785232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) const volatile&>
2786241903Sdim    : private __check_complete<_Class>
2787227825Stheraven{
2788227825Stheraven};
2789227825Stheraven
2790232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2791232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) &&>
2792241903Sdim    : private __check_complete<_Class>
2793227825Stheraven{
2794227825Stheraven};
2795227825Stheraven
2796232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2797232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) const&&>
2798241903Sdim    : private __check_complete<_Class>
2799227825Stheraven{
2800227825Stheraven};
2801227825Stheraven
2802232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2803232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) volatile&&>
2804241903Sdim    : private __check_complete<_Class>
2805227825Stheraven{
2806227825Stheraven};
2807227825Stheraven
2808232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2809232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) const volatile&&>
2810241903Sdim    : private __check_complete<_Class>
2811227825Stheraven{
2812227825Stheraven};
2813227825Stheraven
2814227825Stheraven#endif
2815227825Stheraven
2816232950Stheraventemplate <class _Rp, class _Class>
2817232950Stheravenstruct __check_complete<_Rp _Class::*>
2818227825Stheraven    : private __check_complete<_Class>
2819227825Stheraven{
2820227825Stheraven};
2821227825Stheraven
2822227825Stheraven// __invoke forward declarations
2823227825Stheraven
2824227825Stheraven// fall back - none of the bullets
2825227825Stheraven
2826227825Stheraventemplate <class ..._Args>
2827227825Stheravenauto
2828227825Stheraven__invoke(__any, _Args&& ...__args)
2829227825Stheraven    -> __nat;
2830227825Stheraven
2831227825Stheraven// bullets 1 and 2
2832227825Stheraven
2833232950Stheraventemplate <class _Fp, class _A0, class ..._Args>
2834241903Sdim_LIBCPP_INLINE_VISIBILITY
2835227825Stheravenauto
2836232950Stheraven__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
2837227825Stheraven    -> decltype((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...));
2838227825Stheraven
2839232950Stheraventemplate <class _Fp, class _A0, class ..._Args>
2840241903Sdim_LIBCPP_INLINE_VISIBILITY
2841227825Stheravenauto
2842232950Stheraven__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
2843227825Stheraven    -> decltype(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...));
2844227825Stheraven
2845227825Stheraven// bullets 3 and 4
2846227825Stheraven
2847232950Stheraventemplate <class _Fp, class _A0>
2848241903Sdim_LIBCPP_INLINE_VISIBILITY
2849227825Stheravenauto
2850232950Stheraven__invoke(_Fp&& __f, _A0&& __a0)
2851227825Stheraven    -> decltype(_VSTD::forward<_A0>(__a0).*__f);
2852227825Stheraven
2853232950Stheraventemplate <class _Fp, class _A0>
2854241903Sdim_LIBCPP_INLINE_VISIBILITY
2855227825Stheravenauto
2856232950Stheraven__invoke(_Fp&& __f, _A0&& __a0)
2857227825Stheraven    -> decltype((*_VSTD::forward<_A0>(__a0)).*__f);
2858227825Stheraven
2859227825Stheraven// bullet 5
2860227825Stheraven
2861232950Stheraventemplate <class _Fp, class ..._Args>
2862241903Sdim_LIBCPP_INLINE_VISIBILITY
2863227825Stheravenauto
2864232950Stheraven__invoke(_Fp&& __f, _Args&& ...__args)
2865232950Stheraven    -> decltype(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...));
2866227825Stheraven
2867227825Stheraven// __invokable
2868227825Stheraven
2869232950Stheraventemplate <class _Fp, class ..._Args>
2870227825Stheravenstruct __invokable_imp
2871241903Sdim    : private __check_complete<_Fp>
2872227825Stheraven{
2873227825Stheraven    typedef decltype(
2874232950Stheraven            __invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)
2875227825Stheraven                    ) type;
2876227825Stheraven    static const bool value = !is_same<type, __nat>::value;
2877227825Stheraven};
2878227825Stheraven
2879232950Stheraventemplate <class _Fp, class ..._Args>
2880227825Stheravenstruct __invokable
2881227825Stheraven    : public integral_constant<bool,
2882232950Stheraven          __invokable_imp<_Fp, _Args...>::value>
2883227825Stheraven{
2884227825Stheraven};
2885227825Stheraven
2886227825Stheraven// __invoke_of
2887227825Stheraven
2888232950Stheraventemplate <bool _Invokable, class _Fp, class ..._Args>
2889227825Stheravenstruct __invoke_of_imp  // false
2890227825Stheraven{
2891227825Stheraven};
2892227825Stheraven
2893232950Stheraventemplate <class _Fp, class ..._Args>
2894232950Stheravenstruct __invoke_of_imp<true, _Fp, _Args...>
2895227825Stheraven{
2896232950Stheraven    typedef typename __invokable_imp<_Fp, _Args...>::type type;
2897227825Stheraven};
2898227825Stheraven
2899232950Stheraventemplate <class _Fp, class ..._Args>
2900227825Stheravenstruct __invoke_of
2901232950Stheraven    : public __invoke_of_imp<__invokable<_Fp, _Args...>::value, _Fp, _Args...>
2902227825Stheraven{
2903227825Stheraven};
2904227825Stheraven
2905241903Sdimtemplate <class _Fp, class ..._Args>
2906241903Sdimclass _LIBCPP_VISIBLE result_of<_Fp(_Args...)>
2907241903Sdim    : public __invoke_of<_Fp, _Args...>
2908241903Sdim{
2909241903Sdim};
2910241903Sdim
2911227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
2912227825Stheraven
2913227825Stheraventemplate <class _Tp>
2914227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
2915227825Stheraven#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
2916227825Stheraventypename enable_if
2917227825Stheraven<
2918227825Stheraven    is_move_constructible<_Tp>::value &&
2919227825Stheraven    is_move_assignable<_Tp>::value
2920227825Stheraven>::type
2921227825Stheraven#else
2922227825Stheravenvoid
2923227825Stheraven#endif
2924227825Stheravenswap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
2925227825Stheraven                                    is_nothrow_move_assignable<_Tp>::value)
2926227825Stheraven{
2927227825Stheraven    _Tp __t(_VSTD::move(__x));
2928227825Stheraven    __x = _VSTD::move(__y);
2929227825Stheraven    __y = _VSTD::move(__t);
2930227825Stheraven}
2931227825Stheraven
2932227825Stheraventemplate <class _ForwardIterator1, class _ForwardIterator2>
2933227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
2934227825Stheravenvoid
2935227825Stheraveniter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
2936227825Stheraven    //                                  _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
2937227825Stheraven               _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(),
2938227825Stheraven                                          *_VSTD::declval<_ForwardIterator2>())))
2939227825Stheraven{
2940227825Stheraven    swap(*__a, *__b);
2941227825Stheraven}
2942227825Stheraven
2943227825Stheraven// __swappable
2944227825Stheraven
2945227825Stheravennamespace __detail
2946227825Stheraven{
2947227825Stheraven
2948227825Stheravenusing _VSTD::swap;
2949227825Stheraven__nat swap(__any, __any);
2950227825Stheraven
2951227825Stheraventemplate <class _Tp>
2952227825Stheravenstruct __swappable
2953227825Stheraven{
2954227825Stheraven    typedef decltype(swap(_VSTD::declval<_Tp&>(), _VSTD::declval<_Tp&>())) type;
2955227825Stheraven    static const bool value = !is_same<type, __nat>::value;
2956227825Stheraven};
2957227825Stheraven
2958227825Stheraven}  // __detail
2959227825Stheraven
2960227825Stheraventemplate <class _Tp>
2961227825Stheravenstruct __is_swappable
2962227825Stheraven    : public integral_constant<bool, __detail::__swappable<_Tp>::value>
2963227825Stheraven{
2964227825Stheraven};
2965227825Stheraven
2966227825Stheraven#if __has_feature(cxx_noexcept)
2967227825Stheraven
2968227825Stheraventemplate <bool, class _Tp>
2969227825Stheravenstruct __is_nothrow_swappable_imp
2970227825Stheraven    : public integral_constant<bool, noexcept(swap(_VSTD::declval<_Tp&>(),
2971227825Stheraven                                                   _VSTD::declval<_Tp&>()))>
2972227825Stheraven{
2973227825Stheraven};
2974227825Stheraven
2975227825Stheraventemplate <class _Tp>
2976227825Stheravenstruct __is_nothrow_swappable_imp<false, _Tp>
2977227825Stheraven    : public false_type
2978227825Stheraven{
2979227825Stheraven};
2980227825Stheraven
2981227825Stheraventemplate <class _Tp>
2982227825Stheravenstruct __is_nothrow_swappable
2983227825Stheraven    : public __is_nothrow_swappable_imp<__is_swappable<_Tp>::value, _Tp>
2984227825Stheraven{
2985227825Stheraven};
2986227825Stheraven
2987227825Stheraven#else  // __has_feature(cxx_noexcept)
2988227825Stheraven
2989227825Stheraventemplate <class _Tp>
2990227825Stheravenstruct __is_nothrow_swappable
2991227825Stheraven    : public false_type
2992227825Stheraven{
2993227825Stheraven};
2994227825Stheraven
2995227825Stheraven#endif  // __has_feature(cxx_noexcept)
2996227825Stheraven
2997227825Stheraven#ifdef _LIBCXX_UNDERLYING_TYPE
2998227825Stheraven
2999227825Stheraventemplate <class _Tp>
3000227825Stheravenstruct underlying_type
3001227825Stheraven{
3002227825Stheraven    typedef _LIBCXX_UNDERLYING_TYPE(_Tp) type;
3003227825Stheraven};
3004227825Stheraven
3005227825Stheraven#else  // _LIBCXX_UNDERLYING_TYPE
3006227825Stheraven
3007227825Stheraventemplate <class _Tp, bool _Support = false>
3008227825Stheravenstruct underlying_type
3009227825Stheraven{
3010227825Stheraven    static_assert(_Support, "The underyling_type trait requires compiler "
3011227825Stheraven                            "support. Either no such support exists or "
3012227825Stheraven                            "libc++ does not know how to use it.");
3013227825Stheraven};
3014227825Stheraven
3015227825Stheraven#endif // _LIBCXX_UNDERLYING_TYPE
3016227825Stheraven
3017227825Stheraven_LIBCPP_END_NAMESPACE_STD
3018227825Stheraven
3019227825Stheraven#endif  // _LIBCPP_TYPE_TRAITS
3020