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;
22288943Sdim    typedef integral_constant<bool, true>  true_type;   // C++11
23288943Sdim    typedef integral_constant<bool, false> false_type;  // C++11
24288943Sdim    
25288943Sdim    template <bool B>                                   // C++14
26288943Sdim    using bool_constant = integral_constant<bool, B>;   // C++14
27288943Sdim    typedef bool_constant<true> true_type;              // C++14
28288943Sdim    typedef bool_constant<false> false_type;            // C++14
29227825Stheraven
30227825Stheraven    // helper traits
31227825Stheraven    template <bool, class T = void> struct enable_if;
32227825Stheraven    template <bool, class T, class F> struct conditional;
33227825Stheraven
34227825Stheraven    // Primary classification traits:
35227825Stheraven    template <class T> struct is_void;
36261283Sdim    template <class T> struct is_null_pointer;  // C++14
37227825Stheraven    template <class T> struct is_integral;
38227825Stheraven    template <class T> struct is_floating_point;
39227825Stheraven    template <class T> struct is_array;
40227825Stheraven    template <class T> struct is_pointer;
41227825Stheraven    template <class T> struct is_lvalue_reference;
42227825Stheraven    template <class T> struct is_rvalue_reference;
43227825Stheraven    template <class T> struct is_member_object_pointer;
44227825Stheraven    template <class T> struct is_member_function_pointer;
45227825Stheraven    template <class T> struct is_enum;
46227825Stheraven    template <class T> struct is_union;
47227825Stheraven    template <class T> struct is_class;
48227825Stheraven    template <class T> struct is_function;
49227825Stheraven
50227825Stheraven    // Secondary classification traits:
51227825Stheraven    template <class T> struct is_reference;
52227825Stheraven    template <class T> struct is_arithmetic;
53227825Stheraven    template <class T> struct is_fundamental;
54227825Stheraven    template <class T> struct is_member_pointer;
55227825Stheraven    template <class T> struct is_scalar;
56227825Stheraven    template <class T> struct is_object;
57227825Stheraven    template <class T> struct is_compound;
58227825Stheraven
59227825Stheraven    // Const-volatile properties and transformations:
60227825Stheraven    template <class T> struct is_const;
61227825Stheraven    template <class T> struct is_volatile;
62227825Stheraven    template <class T> struct remove_const;
63227825Stheraven    template <class T> struct remove_volatile;
64227825Stheraven    template <class T> struct remove_cv;
65227825Stheraven    template <class T> struct add_const;
66227825Stheraven    template <class T> struct add_volatile;
67227825Stheraven    template <class T> struct add_cv;
68227825Stheraven
69227825Stheraven    // Reference transformations:
70227825Stheraven    template <class T> struct remove_reference;
71227825Stheraven    template <class T> struct add_lvalue_reference;
72227825Stheraven    template <class T> struct add_rvalue_reference;
73227825Stheraven
74227825Stheraven    // Pointer transformations:
75227825Stheraven    template <class T> struct remove_pointer;
76227825Stheraven    template <class T> struct add_pointer;
77227825Stheraven
78227825Stheraven    // Integral properties:
79227825Stheraven    template <class T> struct is_signed;
80227825Stheraven    template <class T> struct is_unsigned;
81227825Stheraven    template <class T> struct make_signed;
82227825Stheraven    template <class T> struct make_unsigned;
83227825Stheraven
84227825Stheraven    // Array properties and transformations:
85227825Stheraven    template <class T> struct rank;
86227825Stheraven    template <class T, unsigned I = 0> struct extent;
87227825Stheraven    template <class T> struct remove_extent;
88227825Stheraven    template <class T> struct remove_all_extents;
89227825Stheraven
90227825Stheraven    // Member introspection:
91227825Stheraven    template <class T> struct is_pod;
92227825Stheraven    template <class T> struct is_trivial;
93227825Stheraven    template <class T> struct is_trivially_copyable;
94227825Stheraven    template <class T> struct is_standard_layout;
95227825Stheraven    template <class T> struct is_literal_type;
96227825Stheraven    template <class T> struct is_empty;
97227825Stheraven    template <class T> struct is_polymorphic;
98227825Stheraven    template <class T> struct is_abstract;
99277217Sdim    template <class T> struct is_final; // C++14
100227825Stheraven
101227825Stheraven    template <class T, class... Args> struct is_constructible;
102227825Stheraven    template <class T>                struct is_default_constructible;
103227825Stheraven    template <class T>                struct is_copy_constructible;
104227825Stheraven    template <class T>                struct is_move_constructible;
105227825Stheraven    template <class T, class U>       struct is_assignable;
106227825Stheraven    template <class T>                struct is_copy_assignable;
107227825Stheraven    template <class T>                struct is_move_assignable;
108227825Stheraven    template <class T>                struct is_destructible;
109227825Stheraven
110227825Stheraven    template <class T, class... Args> struct is_trivially_constructible;
111227825Stheraven    template <class T>                struct is_trivially_default_constructible;
112227825Stheraven    template <class T>                struct is_trivially_copy_constructible;
113227825Stheraven    template <class T>                struct is_trivially_move_constructible;
114227825Stheraven    template <class T, class U>       struct is_trivially_assignable;
115227825Stheraven    template <class T>                struct is_trivially_copy_assignable;
116227825Stheraven    template <class T>                struct is_trivially_move_assignable;
117227825Stheraven    template <class T>                struct is_trivially_destructible;
118227825Stheraven
119227825Stheraven    template <class T, class... Args> struct is_nothrow_constructible;
120227825Stheraven    template <class T>                struct is_nothrow_default_constructible;
121227825Stheraven    template <class T>                struct is_nothrow_copy_constructible;
122227825Stheraven    template <class T>                struct is_nothrow_move_constructible;
123227825Stheraven    template <class T, class U>       struct is_nothrow_assignable;
124227825Stheraven    template <class T>                struct is_nothrow_copy_assignable;
125227825Stheraven    template <class T>                struct is_nothrow_move_assignable;
126227825Stheraven    template <class T>                struct is_nothrow_destructible;
127227825Stheraven
128227825Stheraven    template <class T> struct has_virtual_destructor;
129227825Stheraven
130227825Stheraven    // Relationships between types:
131227825Stheraven    template <class T, class U> struct is_same;
132227825Stheraven    template <class Base, class Derived> struct is_base_of;
133227825Stheraven    template <class From, class To> struct is_convertible;
134227825Stheraven
135227825Stheraven    // Alignment properties and transformations:
136227825Stheraven    template <class T> struct alignment_of;
137227825Stheraven    template <size_t Len, size_t Align = most_stringent_alignment_requirement>
138227825Stheraven        struct aligned_storage;
139249998Sdim    template <size_t Len, class... Types> struct aligned_union;
140227825Stheraven
141227825Stheraven    template <class T> struct decay;
142227825Stheraven    template <class... T> struct common_type;
143227825Stheraven    template <class T> struct underlying_type;
144227825Stheraven    template <class> class result_of; // undefined
145227825Stheraven    template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>;
146227825Stheraven
147253159Stheraven    // const-volatile modifications:
148253159Stheraven    template <class T>
149253159Stheraven      using remove_const_t    = typename remove_const<T>::type;  // C++14
150253159Stheraven    template <class T>
151253159Stheraven      using remove_volatile_t = typename remove_volatile<T>::type;  // C++14
152253159Stheraven    template <class T>
153253159Stheraven      using remove_cv_t       = typename remove_cv<T>::type;  // C++14
154253159Stheraven    template <class T>
155253159Stheraven      using add_const_t       = typename add_const<T>::type;  // C++14
156253159Stheraven    template <class T>
157253159Stheraven      using add_volatile_t    = typename add_volatile<T>::type;  // C++14
158253159Stheraven    template <class T>
159253159Stheraven      using add_cv_t          = typename add_cv<T>::type;  // C++14
160253159Stheraven  
161253159Stheraven    // reference modifications:
162253159Stheraven    template <class T>
163253159Stheraven      using remove_reference_t     = typename remove_reference<T>::type;  // C++14
164253159Stheraven    template <class T>
165253159Stheraven      using add_lvalue_reference_t = typename add_lvalue_reference<T>::type;  // C++14
166253159Stheraven    template <class T>
167253159Stheraven      using add_rvalue_reference_t = typename add_rvalue_reference<T>::type;  // C++14
168253159Stheraven  
169253159Stheraven    // sign modifications:
170253159Stheraven    template <class T>
171253159Stheraven      using make_signed_t   = typename make_signed<T>::type;  // C++14
172253159Stheraven    template <class T>
173253159Stheraven      using make_unsigned_t = typename make_unsigned<T>::type;  // C++14
174253159Stheraven  
175253159Stheraven    // array modifications:
176253159Stheraven    template <class T>
177253159Stheraven      using remove_extent_t      = typename remove_extent<T>::type;  // C++14
178253159Stheraven    template <class T>
179253159Stheraven      using remove_all_extents_t = typename remove_all_extents<T>::type;  // C++14
180253159Stheraven
181253159Stheraven    // pointer modifications:
182253159Stheraven    template <class T>
183253159Stheraven      using remove_pointer_t = typename remove_pointer<T>::type;  // C++14
184253159Stheraven    template <class T>
185253159Stheraven      using add_pointer_t    = typename add_pointer<T>::type;  // C++14
186253159Stheraven
187253159Stheraven    // other transformations:
188253159Stheraven    template <size_t Len, std::size_t Align=default-alignment>
189253159Stheraven      using aligned_storage_t = typename aligned_storage<Len,Align>::type;  // C++14
190253159Stheraven    template <std::size_t Len, class... Types>
191253159Stheraven      using aligned_union_t   = typename aligned_union<Len,Types...>::type;  // C++14
192253159Stheraven    template <class T>
193253159Stheraven      using decay_t           = typename decay<T>::type;  // C++14
194253159Stheraven    template <bool b, class T=void>
195253159Stheraven      using enable_if_t       = typename enable_if<b,T>::type;  // C++14
196253159Stheraven    template <bool b, class T, class F>
197253159Stheraven      using conditional_t     = typename conditional<b,T,F>::type;  // C++14
198253159Stheraven    template <class... T>
199253159Stheraven      using common_type_t     = typename common_type<T...>::type;  // C++14
200253159Stheraven    template <class T>
201253159Stheraven      using underlying_type_t = typename underlying_type<T>::type;  // C++14
202253159Stheraven    template <class F, class... ArgTypes>
203253159Stheraven      using result_of_t       = typename result_of<F(ArgTypes...)>::type;  // C++14
204253159Stheraven
205277217Sdim    template <class...>
206300770Sdim      using void_t = void;   // C++17
207300770Sdim      
208300770Sdim      // See C++14 20.10.4.1, primary type categories
209300770Sdim      template <class T> constexpr bool is_void_v
210300770Sdim        = is_void<T>::value;                                             // C++17
211300770Sdim      template <class T> constexpr bool is_null_pointer_v
212300770Sdim        = is_null_pointer<T>::value;                                     // C++17
213300770Sdim      template <class T> constexpr bool is_integral_v
214300770Sdim        = is_integral<T>::value;                                         // C++17
215300770Sdim      template <class T> constexpr bool is_floating_point_v
216300770Sdim        = is_floating_point<T>::value;                                   // C++17
217300770Sdim      template <class T> constexpr bool is_array_v
218300770Sdim        = is_array<T>::value;                                            // C++17
219300770Sdim      template <class T> constexpr bool is_pointer_v
220300770Sdim        = is_pointer<T>::value;                                          // C++17
221300770Sdim      template <class T> constexpr bool is_lvalue_reference_v
222300770Sdim        = is_lvalue_reference<T>::value;                                 // C++17
223300770Sdim      template <class T> constexpr bool is_rvalue_reference_v
224300770Sdim        = is_rvalue_reference<T>::value;                                 // C++17
225300770Sdim      template <class T> constexpr bool is_member_object_pointer_v
226300770Sdim        = is_member_object_pointer<T>::value;                            // C++17
227300770Sdim      template <class T> constexpr bool is_member_function_pointer_v
228300770Sdim        = is_member_function_pointer<T>::value;                          // C++17
229300770Sdim      template <class T> constexpr bool is_enum_v
230300770Sdim        = is_enum<T>::value;                                             // C++17
231300770Sdim      template <class T> constexpr bool is_union_v
232300770Sdim        = is_union<T>::value;                                            // C++17
233300770Sdim      template <class T> constexpr bool is_class_v
234300770Sdim        = is_class<T>::value;                                            // C++17
235300770Sdim      template <class T> constexpr bool is_function_v
236300770Sdim        = is_function<T>::value;                                         // C++17
237227825Stheraven
238300770Sdim      // See C++14 20.10.4.2, composite type categories
239300770Sdim      template <class T> constexpr bool is_reference_v
240300770Sdim        = is_reference<T>::value;                                        // C++17
241300770Sdim      template <class T> constexpr bool is_arithmetic_v
242300770Sdim        = is_arithmetic<T>::value;                                       // C++17
243300770Sdim      template <class T> constexpr bool is_fundamental_v
244300770Sdim        = is_fundamental<T>::value;                                      // C++17
245300770Sdim      template <class T> constexpr bool is_object_v
246300770Sdim        = is_object<T>::value;                                           // C++17
247300770Sdim      template <class T> constexpr bool is_scalar_v
248300770Sdim        = is_scalar<T>::value;                                           // C++17
249300770Sdim      template <class T> constexpr bool is_compound_v
250300770Sdim        = is_compound<T>::value;                                         // C++17
251300770Sdim      template <class T> constexpr bool is_member_pointer_v
252300770Sdim        = is_member_pointer<T>::value;                                   // C++17
253300770Sdim
254300770Sdim      // See C++14 20.10.4.3, type properties
255300770Sdim      template <class T> constexpr bool is_const_v
256300770Sdim        = is_const<T>::value;                                            // C++17
257300770Sdim      template <class T> constexpr bool is_volatile_v
258300770Sdim        = is_volatile<T>::value;                                         // C++17
259300770Sdim      template <class T> constexpr bool is_trivial_v
260300770Sdim        = is_trivial<T>::value;                                          // C++17
261300770Sdim      template <class T> constexpr bool is_trivially_copyable_v
262300770Sdim        = is_trivially_copyable<T>::value;                               // C++17
263300770Sdim      template <class T> constexpr bool is_standard_layout_v
264300770Sdim        = is_standard_layout<T>::value;                                  // C++17
265300770Sdim      template <class T> constexpr bool is_pod_v
266300770Sdim        = is_pod<T>::value;                                              // C++17
267300770Sdim      template <class T> constexpr bool is_literal_type_v
268300770Sdim        = is_literal_type<T>::value;                                     // C++17
269300770Sdim      template <class T> constexpr bool is_empty_v
270300770Sdim        = is_empty<T>::value;                                            // C++17
271300770Sdim      template <class T> constexpr bool is_polymorphic_v
272300770Sdim        = is_polymorphic<T>::value;                                      // C++17
273300770Sdim      template <class T> constexpr bool is_abstract_v
274300770Sdim        = is_abstract<T>::value;                                         // C++17
275300770Sdim      template <class T> constexpr bool is_final_v
276300770Sdim        = is_final<T>::value;                                            // C++17
277300770Sdim      template <class T> constexpr bool is_signed_v
278300770Sdim        = is_signed<T>::value;                                           // C++17
279300770Sdim      template <class T> constexpr bool is_unsigned_v
280300770Sdim        = is_unsigned<T>::value;                                         // C++17
281300770Sdim      template <class T, class... Args> constexpr bool is_constructible_v
282300770Sdim        = is_constructible<T, Args...>::value;                           // C++17
283300770Sdim      template <class T> constexpr bool is_default_constructible_v
284300770Sdim        = is_default_constructible<T>::value;                            // C++17
285300770Sdim      template <class T> constexpr bool is_copy_constructible_v
286300770Sdim        = is_copy_constructible<T>::value;                               // C++17
287300770Sdim      template <class T> constexpr bool is_move_constructible_v
288300770Sdim        = is_move_constructible<T>::value;                               // C++17
289300770Sdim      template <class T, class U> constexpr bool is_assignable_v
290300770Sdim        = is_assignable<T, U>::value;                                    // C++17
291300770Sdim      template <class T> constexpr bool is_copy_assignable_v
292300770Sdim        = is_copy_assignable<T>::value;                                  // C++17
293300770Sdim      template <class T> constexpr bool is_move_assignable_v
294300770Sdim        = is_move_assignable<T>::value;                                  // C++17
295300770Sdim      template <class T> constexpr bool is_destructible_v
296300770Sdim        = is_destructible<T>::value;                                     // C++17
297300770Sdim      template <class T, class... Args> constexpr bool is_trivially_constructible_v
298300770Sdim        = is_trivially_constructible<T, Args...>::value;                 // C++17
299300770Sdim      template <class T> constexpr bool is_trivially_default_constructible_v
300300770Sdim        = is_trivially_default_constructible<T>::value;                  // C++17
301300770Sdim      template <class T> constexpr bool is_trivially_copy_constructible_v
302300770Sdim        = is_trivially_copy_constructible<T>::value;                     // C++17
303300770Sdim      template <class T> constexpr bool is_trivially_move_constructible_v
304300770Sdim        = is_trivially_move_constructible<T>::value;                     // C++17
305300770Sdim      template <class T, class U> constexpr bool is_trivially_assignable_v
306300770Sdim        = is_trivially_assignable<T, U>::value;                          // C++17
307300770Sdim      template <class T> constexpr bool is_trivially_copy_assignable_v
308300770Sdim        = is_trivially_copy_assignable<T>::value;                        // C++17
309300770Sdim      template <class T> constexpr bool is_trivially_move_assignable_v
310300770Sdim        = is_trivially_move_assignable<T>::value;                        // C++17
311300770Sdim      template <class T> constexpr bool is_trivially_destructible_v
312300770Sdim        = is_trivially_destructible<T>::value;                           // C++17
313300770Sdim      template <class T, class... Args> constexpr bool is_nothrow_constructible_v
314300770Sdim        = is_nothrow_constructible<T, Args...>::value;                   // C++17
315300770Sdim      template <class T> constexpr bool is_nothrow_default_constructible_v
316300770Sdim        = is_nothrow_default_constructible<T>::value;                    // C++17
317300770Sdim      template <class T> constexpr bool is_nothrow_copy_constructible_v
318300770Sdim        = is_nothrow_copy_constructible<T>::value;                       // C++17
319300770Sdim      template <class T> constexpr bool is_nothrow_move_constructible_v
320300770Sdim        = is_nothrow_move_constructible<T>::value;                       // C++17
321300770Sdim      template <class T, class U> constexpr bool is_nothrow_assignable_v
322300770Sdim        = is_nothrow_assignable<T, U>::value;                            // C++17
323300770Sdim      template <class T> constexpr bool is_nothrow_copy_assignable_v
324300770Sdim        = is_nothrow_copy_assignable<T>::value;                          // C++17
325300770Sdim      template <class T> constexpr bool is_nothrow_move_assignable_v
326300770Sdim        = is_nothrow_move_assignable<T>::value;                          // C++17
327300770Sdim      template <class T> constexpr bool is_nothrow_destructible_v
328300770Sdim        = is_nothrow_destructible<T>::value;                             // C++17
329300770Sdim      template <class T> constexpr bool has_virtual_destructor_v
330300770Sdim        = has_virtual_destructor<T>::value;                              // C++17
331300770Sdim
332300770Sdim      // See C++14 20.10.5, type property queries
333300770Sdim      template <class T> constexpr size_t alignment_of_v
334300770Sdim        = alignment_of<T>::value;                                        // C++17
335300770Sdim      template <class T> constexpr size_t rank_v
336300770Sdim        = rank<T>::value;                                                // C++17
337300770Sdim      template <class T, unsigned I = 0> constexpr size_t extent_v
338300770Sdim        = extent<T, I>::value;                                           // C++17
339300770Sdim
340300770Sdim      // See C++14 20.10.6, type relations
341300770Sdim      template <class T, class U> constexpr bool is_same_v
342300770Sdim        = is_same<T, U>::value;                                          // C++17
343300770Sdim      template <class Base, class Derived> constexpr bool is_base_of_v
344300770Sdim        = is_base_of<Base, Derived>::value;                              // C++17
345300770Sdim      template <class From, class To> constexpr bool is_convertible_v
346300770Sdim        = is_convertible<From, To>::value;                               // C++17
347300770Sdim
348300770Sdim      // [meta.logical], logical operator traits:
349300770Sdim      template<class... B> struct conjunction;                           // C++17
350300770Sdim      template<class... B> 
351300770Sdim        constexpr bool conjunction_v = conjunction<B...>::value;         // C++17
352300770Sdim      template<class... B> struct disjunction;                           // C++17
353300770Sdim      template<class... B>
354300770Sdim        constexpr bool disjunction_v = disjunction<B...>::value;         // C++17
355300770Sdim      template<class B> struct negation;                                 // C++17
356300770Sdim      template<class B> 
357300770Sdim        constexpr bool negation_v = negation<B>::value;                  // C++17
358300770Sdim
359300770Sdim}
360300770Sdim
361227825Stheraven*/
362227825Stheraven#include <__config>
363227825Stheraven#include <cstddef>
364227825Stheraven
365227825Stheraven#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
366227825Stheraven#pragma GCC system_header
367227825Stheraven#endif
368227825Stheraven
369227825Stheraven_LIBCPP_BEGIN_NAMESPACE_STD
370227825Stheraven
371288943Sdimtemplate <class>
372277217Sdimstruct __void_t { typedef void type; };
373277217Sdim
374288943Sdimtemplate <class _Tp>
375288943Sdimstruct __identity { typedef _Tp type; };
376288943Sdim
377288943Sdimtemplate <class _Tp, bool>
378288943Sdimstruct _LIBCPP_TYPE_VIS_ONLY __dependent_type : public _Tp {};
379288943Sdim
380232950Stheraventemplate <bool _Bp, class _If, class _Then>
381261283Sdim    struct _LIBCPP_TYPE_VIS_ONLY conditional {typedef _If type;};
382227825Stheraventemplate <class _If, class _Then>
383261283Sdim    struct _LIBCPP_TYPE_VIS_ONLY conditional<false, _If, _Then> {typedef _Then type;};
384227825Stheraven
385253159Stheraven#if _LIBCPP_STD_VER > 11
386253159Stheraventemplate <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type;
387253159Stheraven#endif
388253159Stheraven
389277217Sdimtemplate <bool, class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __lazy_enable_if {};
390277217Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __lazy_enable_if<true, _Tp> {typedef typename _Tp::type type;};
391277217Sdim
392261283Sdimtemplate <bool, class _Tp = void> struct _LIBCPP_TYPE_VIS_ONLY enable_if {};
393261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY enable_if<true, _Tp> {typedef _Tp type;};
394227825Stheraven
395253159Stheraven#if _LIBCPP_STD_VER > 11
396253159Stheraventemplate <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type;
397253159Stheraven#endif
398253159Stheraven
399300770Sdim// addressof
400253159Stheraven
401300770Sdimtemplate <class _Tp>
402300770Sdiminline _LIBCPP_INLINE_VISIBILITY
403300770Sdim_Tp*
404300770Sdimaddressof(_Tp& __x) _NOEXCEPT
405300770Sdim{
406300770Sdim    return (_Tp*)&reinterpret_cast<const volatile char&>(__x);
407300770Sdim}
408300770Sdim
409300770Sdim#if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF)
410300770Sdim// Objective-C++ Automatic Reference Counting uses qualified pointers
411300770Sdim// that require special addressof() signatures. When
412300770Sdim// _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler
413300770Sdim// itself is providing these definitions. Otherwise, we provide them.
414300770Sdimtemplate <class _Tp>
415300770Sdiminline _LIBCPP_INLINE_VISIBILITY
416300770Sdim__strong _Tp*
417300770Sdimaddressof(__strong _Tp& __x) _NOEXCEPT
418300770Sdim{
419300770Sdim  return &__x;
420300770Sdim}
421300770Sdim
422300770Sdim#ifdef _LIBCPP_HAS_OBJC_ARC_WEAK
423300770Sdimtemplate <class _Tp>
424300770Sdiminline _LIBCPP_INLINE_VISIBILITY
425300770Sdim__weak _Tp*
426300770Sdimaddressof(__weak _Tp& __x) _NOEXCEPT
427300770Sdim{
428300770Sdim  return &__x;
429300770Sdim}
430300770Sdim#endif
431300770Sdim
432300770Sdimtemplate <class _Tp>
433300770Sdiminline _LIBCPP_INLINE_VISIBILITY
434300770Sdim__autoreleasing _Tp*
435300770Sdimaddressof(__autoreleasing _Tp& __x) _NOEXCEPT
436300770Sdim{
437300770Sdim  return &__x;
438300770Sdim}
439300770Sdim
440300770Sdimtemplate <class _Tp>
441300770Sdiminline _LIBCPP_INLINE_VISIBILITY
442300770Sdim__unsafe_unretained _Tp*
443300770Sdimaddressof(__unsafe_unretained _Tp& __x) _NOEXCEPT
444300770Sdim{
445300770Sdim  return &__x;
446300770Sdim}
447300770Sdim#endif
448300770Sdim
449242945Stheravenstruct __two {char __lx[2];};
450227825Stheraven
451227825Stheraven// helper class:
452227825Stheraven
453227825Stheraventemplate <class _Tp, _Tp __v>
454261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY integral_constant
455227825Stheraven{
456234976Stheraven    static _LIBCPP_CONSTEXPR const _Tp      value = __v;
457227825Stheraven    typedef _Tp               value_type;
458227825Stheraven    typedef integral_constant type;
459227825Stheraven    _LIBCPP_INLINE_VISIBILITY
460277217Sdim        _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT {return value;}
461261283Sdim#if _LIBCPP_STD_VER > 11
462261283Sdim    _LIBCPP_INLINE_VISIBILITY
463277217Sdim         constexpr value_type operator ()() const _NOEXCEPT {return value;}
464261283Sdim#endif
465227825Stheraven};
466227825Stheraven
467227825Stheraventemplate <class _Tp, _Tp __v>
468234976Stheraven_LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
469227825Stheraven
470288943Sdim#if _LIBCPP_STD_VER > 14
471288943Sdimtemplate <bool __b>
472288943Sdimusing bool_constant = integral_constant<bool, __b>;
473300770Sdim#define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)>
474288943Sdim#else
475300770Sdim#define _LIBCPP_BOOL_CONSTANT(__b) integral_constant<bool,(__b)>
476288943Sdim#endif
477227825Stheraven
478288943Sdimtypedef _LIBCPP_BOOL_CONSTANT(true)  true_type;
479288943Sdimtypedef _LIBCPP_BOOL_CONSTANT(false) false_type;
480288943Sdim
481300770Sdim#if !defined(_LIBCPP_HAS_NO_VARIADICS)
482300770Sdim
483300770Sdim// __lazy_and
484300770Sdim
485300770Sdimtemplate <bool _Last, class ..._Preds>
486300770Sdimstruct __lazy_and_impl;
487300770Sdim
488300770Sdimtemplate <class ..._Preds>
489300770Sdimstruct __lazy_and_impl<false, _Preds...> : false_type {};
490300770Sdim
491300770Sdimtemplate <>
492300770Sdimstruct __lazy_and_impl<true> : true_type {};
493300770Sdim
494300770Sdimtemplate <class _Pred>
495300770Sdimstruct __lazy_and_impl<true, _Pred> : integral_constant<bool, _Pred::type::value> {};
496300770Sdim
497300770Sdimtemplate <class _Hp, class ..._Tp>
498300770Sdimstruct __lazy_and_impl<true, _Hp, _Tp...> : __lazy_and_impl<_Hp::type::value, _Tp...> {};
499300770Sdim
500300770Sdimtemplate <class _P1, class ..._Pr>
501300770Sdimstruct __lazy_and : __lazy_and_impl<_P1::type::value, _Pr...> {};
502300770Sdim
503300770Sdim// __lazy_or
504300770Sdim
505300770Sdimtemplate <bool _List, class ..._Preds>
506300770Sdimstruct __lazy_or_impl;
507300770Sdim
508300770Sdimtemplate <class ..._Preds>
509300770Sdimstruct __lazy_or_impl<true, _Preds...> : true_type {};
510300770Sdim
511300770Sdimtemplate <>
512300770Sdimstruct __lazy_or_impl<false> : false_type {};
513300770Sdim
514300770Sdimtemplate <class _Hp, class ..._Tp>
515300770Sdimstruct __lazy_or_impl<false, _Hp, _Tp...>
516300770Sdim        : __lazy_or_impl<_Hp::type::value, _Tp...> {};
517300770Sdim
518300770Sdimtemplate <class _P1, class ..._Pr>
519300770Sdimstruct __lazy_or : __lazy_or_impl<_P1::type::value, _Pr...> {};
520300770Sdim
521300770Sdim// __lazy_not
522300770Sdim
523300770Sdimtemplate <class _Pred>
524300770Sdimstruct __lazy_not : integral_constant<bool, !_Pred::type::value> {};
525300770Sdim
526300770Sdim// __and_
527300770Sdimtemplate<class...> struct __and_;
528300770Sdimtemplate<> struct __and_<> : true_type {};
529300770Sdim
530300770Sdimtemplate<class _B0> struct __and_<_B0> : _B0 {};
531300770Sdim
532300770Sdimtemplate<class _B0, class _B1>
533300770Sdimstruct __and_<_B0, _B1> : conditional<_B0::value, _B1, _B0>::type {};
534300770Sdim
535300770Sdimtemplate<class _B0, class _B1, class _B2, class... _Bn>
536300770Sdimstruct __and_<_B0, _B1, _B2, _Bn...> 
537300770Sdim        : conditional<_B0::value, __and_<_B1, _B2, _Bn...>, _B0>::type {};
538300770Sdim
539300770Sdim// __or_
540300770Sdimtemplate<class...> struct __or_;
541300770Sdimtemplate<> struct __or_<> : false_type {};
542300770Sdim
543300770Sdimtemplate<class _B0> struct __or_<_B0> : _B0 {};
544300770Sdim
545300770Sdimtemplate<class _B0, class _B1>
546300770Sdimstruct __or_<_B0, _B1> : conditional<_B0::value, _B0, _B1>::type {};
547300770Sdim
548300770Sdimtemplate<class _B0, class _B1, class _B2, class... _Bn>
549300770Sdimstruct __or_<_B0, _B1, _B2, _Bn...> 
550300770Sdim        : conditional<_B0::value, _B0, __or_<_B1, _B2, _Bn...> >::type {};
551300770Sdim
552300770Sdim// __not_
553300770Sdimtemplate<class _Tp> 
554300770Sdimstruct __not_ : conditional<_Tp::value, false_type, true_type>::type {};
555300770Sdim
556300770Sdim#endif // !defined(_LIBCPP_HAS_NO_VARIADICS)
557300770Sdim
558227825Stheraven// is_const
559227825Stheraven
560261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_const            : public false_type {};
561261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_const<_Tp const> : public true_type {};
562227825Stheraven
563300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
564300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_const_v
565300770Sdim    = is_const<_Tp>::value;
566300770Sdim#endif
567300770Sdim
568227825Stheraven// is_volatile
569227825Stheraven
570261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_volatile               : public false_type {};
571261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_volatile<_Tp volatile> : public true_type {};
572227825Stheraven
573300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
574300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_volatile_v
575300770Sdim    = is_volatile<_Tp>::value;
576300770Sdim#endif
577300770Sdim
578227825Stheraven// remove_const
579227825Stheraven
580261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_const            {typedef _Tp type;};
581261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_const<const _Tp> {typedef _Tp type;};
582253159Stheraven#if _LIBCPP_STD_VER > 11
583253159Stheraventemplate <class _Tp> using remove_const_t = typename remove_const<_Tp>::type;
584253159Stheraven#endif
585227825Stheraven
586227825Stheraven// remove_volatile
587227825Stheraven
588261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_volatile               {typedef _Tp type;};
589261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_volatile<volatile _Tp> {typedef _Tp type;};
590253159Stheraven#if _LIBCPP_STD_VER > 11
591253159Stheraventemplate <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type;
592253159Stheraven#endif
593227825Stheraven
594227825Stheraven// remove_cv
595227825Stheraven
596261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_cv
597227825Stheraven{typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
598253159Stheraven#if _LIBCPP_STD_VER > 11
599253159Stheraventemplate <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type;
600253159Stheraven#endif
601227825Stheraven
602227825Stheraven// is_void
603227825Stheraven
604260015Sdimtemplate <class _Tp> struct __libcpp_is_void       : public false_type {};
605260015Sdimtemplate <>          struct __libcpp_is_void<void> : public true_type {};
606227825Stheraven
607261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_void
608260015Sdim    : public __libcpp_is_void<typename remove_cv<_Tp>::type> {};
609227825Stheraven
610300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
611300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_void_v
612300770Sdim    = is_void<_Tp>::value;
613300770Sdim#endif
614300770Sdim
615227825Stheraven// __is_nullptr_t
616227825Stheraven
617277217Sdimtemplate <class _Tp> struct __is_nullptr_t_impl       : public false_type {};
618277217Sdimtemplate <>          struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
619227825Stheraven
620261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __is_nullptr_t
621277217Sdim    : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
622227825Stheraven
623261283Sdim#if _LIBCPP_STD_VER > 11
624261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_null_pointer
625277217Sdim    : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
626300770Sdim
627300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
628300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_null_pointer_v
629300770Sdim    = is_null_pointer<_Tp>::value;
630261283Sdim#endif
631300770Sdim#endif
632261283Sdim
633227825Stheraven// is_integral
634227825Stheraven
635260015Sdimtemplate <class _Tp> struct __libcpp_is_integral                     : public false_type {};
636260015Sdimtemplate <>          struct __libcpp_is_integral<bool>               : public true_type {};
637260015Sdimtemplate <>          struct __libcpp_is_integral<char>               : public true_type {};
638260015Sdimtemplate <>          struct __libcpp_is_integral<signed char>        : public true_type {};
639260015Sdimtemplate <>          struct __libcpp_is_integral<unsigned char>      : public true_type {};
640260015Sdimtemplate <>          struct __libcpp_is_integral<wchar_t>            : public true_type {};
641227825Stheraven#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
642260015Sdimtemplate <>          struct __libcpp_is_integral<char16_t>           : public true_type {};
643260015Sdimtemplate <>          struct __libcpp_is_integral<char32_t>           : public true_type {};
644227825Stheraven#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
645260015Sdimtemplate <>          struct __libcpp_is_integral<short>              : public true_type {};
646260015Sdimtemplate <>          struct __libcpp_is_integral<unsigned short>     : public true_type {};
647260015Sdimtemplate <>          struct __libcpp_is_integral<int>                : public true_type {};
648260015Sdimtemplate <>          struct __libcpp_is_integral<unsigned int>       : public true_type {};
649260015Sdimtemplate <>          struct __libcpp_is_integral<long>               : public true_type {};
650260015Sdimtemplate <>          struct __libcpp_is_integral<unsigned long>      : public true_type {};
651260015Sdimtemplate <>          struct __libcpp_is_integral<long long>          : public true_type {};
652260015Sdimtemplate <>          struct __libcpp_is_integral<unsigned long long> : public true_type {};
653277217Sdim#ifndef _LIBCPP_HAS_NO_INT128
654277217Sdimtemplate <>          struct __libcpp_is_integral<__int128_t>         : public true_type {};
655277217Sdimtemplate <>          struct __libcpp_is_integral<__uint128_t>        : public true_type {};
656277217Sdim#endif
657227825Stheraven
658261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_integral
659260015Sdim    : public __libcpp_is_integral<typename remove_cv<_Tp>::type> {};
660227825Stheraven
661300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
662300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_integral_v
663300770Sdim    = is_integral<_Tp>::value;
664300770Sdim#endif
665300770Sdim
666227825Stheraven// is_floating_point
667227825Stheraven
668260015Sdimtemplate <class _Tp> struct __libcpp_is_floating_point              : public false_type {};
669260015Sdimtemplate <>          struct __libcpp_is_floating_point<float>       : public true_type {};
670260015Sdimtemplate <>          struct __libcpp_is_floating_point<double>      : public true_type {};
671260015Sdimtemplate <>          struct __libcpp_is_floating_point<long double> : public true_type {};
672227825Stheraven
673261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_floating_point
674260015Sdim    : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {};
675227825Stheraven
676300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
677300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_floating_point_v
678300770Sdim    = is_floating_point<_Tp>::value;
679300770Sdim#endif
680300770Sdim
681227825Stheraven// is_array
682227825Stheraven
683261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_array
684227825Stheraven    : public false_type {};
685261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[]>
686227825Stheraven    : public true_type {};
687261283Sdimtemplate <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[_Np]>
688227825Stheraven    : public true_type {};
689227825Stheraven
690300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
691300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_array_v
692300770Sdim    = is_array<_Tp>::value;
693300770Sdim#endif
694300770Sdim
695227825Stheraven// is_pointer
696227825Stheraven
697260015Sdimtemplate <class _Tp> struct __libcpp_is_pointer       : public false_type {};
698260015Sdimtemplate <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {};
699227825Stheraven
700261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pointer
701260015Sdim    : public __libcpp_is_pointer<typename remove_cv<_Tp>::type> {};
702227825Stheraven
703300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
704300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_pointer_v
705300770Sdim    = is_pointer<_Tp>::value;
706300770Sdim#endif
707300770Sdim
708227825Stheraven// is_reference
709227825Stheraven
710261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference       : public false_type {};
711261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference<_Tp&> : public true_type {};
712227825Stheraven
713261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference        : public false_type {};
714227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
715261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference<_Tp&&> : public true_type {};
716227825Stheraven#endif
717227825Stheraven
718261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference        : public false_type {};
719261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&>  : public true_type {};
720227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
721261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&&> : public true_type {};
722227825Stheraven#endif
723227825Stheraven
724300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
725300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_reference_v
726300770Sdim    = is_reference<_Tp>::value;
727300770Sdim
728300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_lvalue_reference_v
729300770Sdim    = is_lvalue_reference<_Tp>::value;
730300770Sdim
731300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_rvalue_reference_v
732300770Sdim    = is_rvalue_reference<_Tp>::value;
733300770Sdim#endif
734227825Stheraven// is_union
735227825Stheraven
736277217Sdim#if __has_feature(is_union) || (_GNUC_VER >= 403)
737227825Stheraven
738261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_union
739227825Stheraven    : public integral_constant<bool, __is_union(_Tp)> {};
740227825Stheraven
741227825Stheraven#else
742227825Stheraven
743227825Stheraventemplate <class _Tp> struct __libcpp_union : public false_type {};
744261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_union
745227825Stheraven    : public __libcpp_union<typename remove_cv<_Tp>::type> {};
746227825Stheraven
747227825Stheraven#endif
748227825Stheraven
749300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
750300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_union_v
751300770Sdim    = is_union<_Tp>::value;
752300770Sdim#endif
753300770Sdim
754227825Stheraven// is_class
755227825Stheraven
756277217Sdim#if __has_feature(is_class) || (_GNUC_VER >= 403)
757227825Stheraven
758261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_class
759227825Stheraven    : public integral_constant<bool, __is_class(_Tp)> {};
760227825Stheraven
761227825Stheraven#else
762227825Stheraven
763227825Stheravennamespace __is_class_imp
764227825Stheraven{
765227825Stheraventemplate <class _Tp> char  __test(int _Tp::*);
766227825Stheraventemplate <class _Tp> __two __test(...);
767227825Stheraven}
768227825Stheraven
769261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_class
770227825Stheraven    : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {};
771227825Stheraven
772227825Stheraven#endif
773227825Stheraven
774300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
775300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_class_v
776300770Sdim    = is_class<_Tp>::value;
777300770Sdim#endif
778300770Sdim
779227825Stheraven// is_same
780227825Stheraven
781261283Sdimtemplate <class _Tp, class _Up> struct _LIBCPP_TYPE_VIS_ONLY is_same           : public false_type {};
782261283Sdimtemplate <class _Tp>            struct _LIBCPP_TYPE_VIS_ONLY is_same<_Tp, _Tp> : public true_type {};
783227825Stheraven
784300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
785300770Sdimtemplate <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_same_v
786300770Sdim    = is_same<_Tp, _Up>::value;
787300770Sdim#endif
788300770Sdim
789227825Stheraven// is_function
790227825Stheraven
791277217Sdimnamespace __libcpp_is_function_imp
792227825Stheraven{
793288943Sdimstruct __dummy_type {};
794227825Stheraventemplate <class _Tp> char  __test(_Tp*);
795288943Sdimtemplate <class _Tp> char __test(__dummy_type);
796227825Stheraventemplate <class _Tp> __two __test(...);
797288943Sdimtemplate <class _Tp> _Tp&  __source(int);
798288943Sdimtemplate <class _Tp> __dummy_type __source(...);
799227825Stheraven}
800227825Stheraven
801227825Stheraventemplate <class _Tp, bool = is_class<_Tp>::value ||
802227825Stheraven                            is_union<_Tp>::value ||
803227825Stheraven                            is_void<_Tp>::value  ||
804227825Stheraven                            is_reference<_Tp>::value ||
805261283Sdim                            __is_nullptr_t<_Tp>::value >
806260015Sdimstruct __libcpp_is_function
807288943Sdim    : public integral_constant<bool, sizeof(__libcpp_is_function_imp::__test<_Tp>(__libcpp_is_function_imp::__source<_Tp>(0))) == 1>
808227825Stheraven    {};
809260015Sdimtemplate <class _Tp> struct __libcpp_is_function<_Tp, true> : public false_type {};
810227825Stheraven
811261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_function
812260015Sdim    : public __libcpp_is_function<_Tp> {};
813227825Stheraven
814300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
815300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_function_v
816300770Sdim    = is_function<_Tp>::value;
817300770Sdim#endif
818300770Sdim
819227825Stheraven// is_member_function_pointer
820227825Stheraven
821275366Sdim// template <class _Tp> struct            __libcpp_is_member_function_pointer             : public false_type {};
822275366Sdim// template <class _Tp, class _Up> struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {};
823275366Sdim// 
824227825Stheraven
825300770Sdimtemplate <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr>
826275366Sdimstruct __member_pointer_traits_imp
827275366Sdim{  // forward declaration; specializations later
828275366Sdim};
829275366Sdim
830275366Sdim
831275366Sdimtemplate <class _Tp> struct __libcpp_is_member_function_pointer
832288943Sdim    : public false_type {};
833275366Sdim
834288943Sdimtemplate <class _Ret, class _Class>
835288943Sdimstruct __libcpp_is_member_function_pointer<_Ret _Class::*>
836288943Sdim    : public is_function<_Ret> {};
837288943Sdim
838261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_function_pointer
839288943Sdim    : public __libcpp_is_member_function_pointer<typename remove_cv<_Tp>::type>::type {};
840227825Stheraven
841300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
842300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_member_function_pointer_v
843300770Sdim    = is_member_function_pointer<_Tp>::value;
844300770Sdim#endif
845300770Sdim
846227825Stheraven// is_member_pointer
847227825Stheraven
848260015Sdimtemplate <class _Tp>            struct __libcpp_is_member_pointer             : public false_type {};
849260015Sdimtemplate <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> : public true_type {};
850227825Stheraven
851261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_pointer
852260015Sdim    : public __libcpp_is_member_pointer<typename remove_cv<_Tp>::type> {};
853227825Stheraven
854300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
855300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_member_pointer_v
856300770Sdim    = is_member_pointer<_Tp>::value;
857300770Sdim#endif
858300770Sdim
859227825Stheraven// is_member_object_pointer
860227825Stheraven
861261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_object_pointer
862227825Stheraven    : public integral_constant<bool, is_member_pointer<_Tp>::value &&
863227825Stheraven                                    !is_member_function_pointer<_Tp>::value> {};
864227825Stheraven
865300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
866300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_member_object_pointer_v
867300770Sdim    = is_member_object_pointer<_Tp>::value;
868300770Sdim#endif
869300770Sdim
870227825Stheraven// is_enum
871227825Stheraven
872277217Sdim#if __has_feature(is_enum) || (_GNUC_VER >= 403)
873227825Stheraven
874261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_enum
875227825Stheraven    : public integral_constant<bool, __is_enum(_Tp)> {};
876227825Stheraven
877227825Stheraven#else
878227825Stheraven
879261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_enum
880227825Stheraven    : public integral_constant<bool, !is_void<_Tp>::value             &&
881227825Stheraven                                     !is_integral<_Tp>::value         &&
882227825Stheraven                                     !is_floating_point<_Tp>::value   &&
883227825Stheraven                                     !is_array<_Tp>::value            &&
884227825Stheraven                                     !is_pointer<_Tp>::value          &&
885227825Stheraven                                     !is_reference<_Tp>::value        &&
886227825Stheraven                                     !is_member_pointer<_Tp>::value   &&
887227825Stheraven                                     !is_union<_Tp>::value            &&
888227825Stheraven                                     !is_class<_Tp>::value            &&
889227825Stheraven                                     !is_function<_Tp>::value         > {};
890227825Stheraven
891227825Stheraven#endif
892227825Stheraven
893300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
894300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_enum_v
895300770Sdim    = is_enum<_Tp>::value;
896300770Sdim#endif
897300770Sdim
898227825Stheraven// is_arithmetic
899227825Stheraven
900261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_arithmetic
901227825Stheraven    : public integral_constant<bool, is_integral<_Tp>::value      ||
902227825Stheraven                                     is_floating_point<_Tp>::value> {};
903227825Stheraven
904300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
905300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_arithmetic_v
906300770Sdim    = is_arithmetic<_Tp>::value;
907300770Sdim#endif
908300770Sdim
909227825Stheraven// is_fundamental
910227825Stheraven
911261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_fundamental
912227825Stheraven    : public integral_constant<bool, is_void<_Tp>::value        ||
913227825Stheraven                                     __is_nullptr_t<_Tp>::value ||
914227825Stheraven                                     is_arithmetic<_Tp>::value> {};
915227825Stheraven
916300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
917300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_fundamental_v
918300770Sdim    = is_fundamental<_Tp>::value;
919300770Sdim#endif
920300770Sdim
921227825Stheraven// is_scalar
922227825Stheraven
923261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_scalar
924227825Stheraven    : public integral_constant<bool, is_arithmetic<_Tp>::value     ||
925227825Stheraven                                     is_member_pointer<_Tp>::value ||
926227825Stheraven                                     is_pointer<_Tp>::value        ||
927227825Stheraven                                     __is_nullptr_t<_Tp>::value    ||
928227825Stheraven                                     is_enum<_Tp>::value           > {};
929227825Stheraven
930261283Sdimtemplate <> struct _LIBCPP_TYPE_VIS_ONLY is_scalar<nullptr_t> : public true_type {};
931227825Stheraven
932300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
933300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_scalar_v
934300770Sdim    = is_scalar<_Tp>::value;
935300770Sdim#endif
936300770Sdim
937227825Stheraven// is_object
938227825Stheraven
939261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_object
940227825Stheraven    : public integral_constant<bool, is_scalar<_Tp>::value ||
941227825Stheraven                                     is_array<_Tp>::value  ||
942227825Stheraven                                     is_union<_Tp>::value  ||
943227825Stheraven                                     is_class<_Tp>::value  > {};
944227825Stheraven
945300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
946300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_object_v
947300770Sdim    = is_object<_Tp>::value;
948300770Sdim#endif
949300770Sdim
950227825Stheraven// is_compound
951227825Stheraven
952261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_compound
953227825Stheraven    : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
954227825Stheraven
955300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
956300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_compound_v
957300770Sdim    = is_compound<_Tp>::value;
958300770Sdim#endif
959300770Sdim
960227825Stheraven// add_const
961227825Stheraven
962227825Stheraventemplate <class _Tp, bool = is_reference<_Tp>::value ||
963227825Stheraven                            is_function<_Tp>::value  ||
964227825Stheraven                            is_const<_Tp>::value     >
965227825Stheravenstruct __add_const             {typedef _Tp type;};
966227825Stheraven
967227825Stheraventemplate <class _Tp>
968227825Stheravenstruct __add_const<_Tp, false> {typedef const _Tp type;};
969227825Stheraven
970261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_const
971227825Stheraven    {typedef typename __add_const<_Tp>::type type;};
972227825Stheraven
973253159Stheraven#if _LIBCPP_STD_VER > 11
974253159Stheraventemplate <class _Tp> using add_const_t = typename add_const<_Tp>::type;
975253159Stheraven#endif
976253159Stheraven
977227825Stheraven// add_volatile
978227825Stheraven
979227825Stheraventemplate <class _Tp, bool = is_reference<_Tp>::value ||
980227825Stheraven                            is_function<_Tp>::value  ||
981227825Stheraven                            is_volatile<_Tp>::value  >
982227825Stheravenstruct __add_volatile             {typedef _Tp type;};
983227825Stheraven
984227825Stheraventemplate <class _Tp>
985227825Stheravenstruct __add_volatile<_Tp, false> {typedef volatile _Tp type;};
986227825Stheraven
987261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_volatile
988227825Stheraven    {typedef typename __add_volatile<_Tp>::type type;};
989227825Stheraven
990253159Stheraven#if _LIBCPP_STD_VER > 11
991253159Stheraventemplate <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type;
992253159Stheraven#endif
993253159Stheraven
994227825Stheraven// add_cv
995227825Stheraven
996261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_cv
997227825Stheraven    {typedef typename add_const<typename add_volatile<_Tp>::type>::type type;};
998227825Stheraven
999253159Stheraven#if _LIBCPP_STD_VER > 11
1000253159Stheraventemplate <class _Tp> using add_cv_t = typename add_cv<_Tp>::type;
1001253159Stheraven#endif
1002253159Stheraven
1003227825Stheraven// remove_reference
1004227825Stheraven
1005261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference        {typedef _Tp type;};
1006261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&>  {typedef _Tp type;};
1007227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1008261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&&> {typedef _Tp type;};
1009227825Stheraven#endif
1010227825Stheraven
1011253159Stheraven#if _LIBCPP_STD_VER > 11
1012253159Stheraventemplate <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
1013253159Stheraven#endif
1014253159Stheraven
1015227825Stheraven// add_lvalue_reference
1016227825Stheraven
1017261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference                      {typedef _Tp& type;};
1018261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<_Tp&>                {typedef _Tp& type;};  // for older compiler
1019261283Sdimtemplate <>          struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<void>                {typedef void type;};
1020261283Sdimtemplate <>          struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<const void>          {typedef const void type;};
1021261283Sdimtemplate <>          struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<volatile void>       {typedef volatile void type;};
1022261283Sdimtemplate <>          struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<const volatile void> {typedef const volatile void type;};
1023227825Stheraven
1024253159Stheraven#if _LIBCPP_STD_VER > 11
1025253159Stheraventemplate <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
1026253159Stheraven#endif
1027253159Stheraven
1028227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1029227825Stheraven
1030261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY  add_rvalue_reference                     {typedef _Tp&& type;};
1031261283Sdimtemplate <>          struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<void>                {typedef void type;};
1032261283Sdimtemplate <>          struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<const void>          {typedef const void type;};
1033261283Sdimtemplate <>          struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<volatile void>       {typedef volatile void type;};
1034261283Sdimtemplate <>          struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<const volatile void> {typedef const volatile void type;};
1035227825Stheraven
1036253159Stheraven#if _LIBCPP_STD_VER > 11
1037253159Stheraventemplate <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
1038253159Stheraven#endif
1039253159Stheraven
1040227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1041227825Stheraven
1042227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1043227825Stheraven
1044227825Stheraventemplate <class _Tp>
1045227825Stheraventypename add_rvalue_reference<_Tp>::type
1046227825Stheravendeclval() _NOEXCEPT;
1047227825Stheraven
1048227825Stheraven#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1049227825Stheraven
1050227825Stheraventemplate <class _Tp>
1051227825Stheraventypename add_lvalue_reference<_Tp>::type
1052227825Stheravendeclval();
1053227825Stheraven
1054227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1055227825Stheraven
1056227825Stheravenstruct __any
1057227825Stheraven{
1058227825Stheraven    __any(...);
1059227825Stheraven};
1060227825Stheraven
1061227825Stheraven// remove_pointer
1062227825Stheraven
1063261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer                      {typedef _Tp type;};
1064261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp*>                {typedef _Tp type;};
1065261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const>          {typedef _Tp type;};
1066261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* volatile>       {typedef _Tp type;};
1067261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const volatile> {typedef _Tp type;};
1068227825Stheraven
1069253159Stheraven#if _LIBCPP_STD_VER > 11
1070253159Stheraventemplate <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type;
1071253159Stheraven#endif
1072253159Stheraven
1073227825Stheraven// add_pointer
1074227825Stheraven
1075261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_pointer
1076227825Stheraven    {typedef typename remove_reference<_Tp>::type* type;};
1077227825Stheraven
1078253159Stheraven#if _LIBCPP_STD_VER > 11
1079253159Stheraventemplate <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
1080253159Stheraven#endif
1081253159Stheraven
1082227825Stheraven// is_signed
1083227825Stheraven
1084227825Stheraventemplate <class _Tp, bool = is_integral<_Tp>::value>
1085288943Sdimstruct __libcpp_is_signed_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(-1) < _Tp(0)) {};
1086227825Stheraven
1087227825Stheraventemplate <class _Tp>
1088277217Sdimstruct __libcpp_is_signed_impl<_Tp, false> : public true_type {};  // floating point
1089227825Stheraven
1090227825Stheraventemplate <class _Tp, bool = is_arithmetic<_Tp>::value>
1091277217Sdimstruct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {};
1092227825Stheraven
1093260015Sdimtemplate <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {};
1094227825Stheraven
1095261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_signed : public __libcpp_is_signed<_Tp> {};
1096227825Stheraven
1097300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1098300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_signed_v
1099300770Sdim    = is_signed<_Tp>::value;
1100300770Sdim#endif
1101300770Sdim
1102227825Stheraven// is_unsigned
1103227825Stheraven
1104227825Stheraventemplate <class _Tp, bool = is_integral<_Tp>::value>
1105288943Sdimstruct __libcpp_is_unsigned_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(0) < _Tp(-1)) {};
1106227825Stheraven
1107227825Stheraventemplate <class _Tp>
1108277217Sdimstruct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {};  // floating point
1109227825Stheraven
1110227825Stheraventemplate <class _Tp, bool = is_arithmetic<_Tp>::value>
1111277217Sdimstruct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {};
1112227825Stheraven
1113260015Sdimtemplate <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {};
1114227825Stheraven
1115261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_unsigned : public __libcpp_is_unsigned<_Tp> {};
1116227825Stheraven
1117300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1118300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_unsigned_v
1119300770Sdim    = is_unsigned<_Tp>::value;
1120300770Sdim#endif
1121300770Sdim
1122227825Stheraven// rank
1123227825Stheraven
1124261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY rank
1125227825Stheraven    : public integral_constant<size_t, 0> {};
1126261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[]>
1127227825Stheraven    : public integral_constant<size_t, rank<_Tp>::value + 1> {};
1128261283Sdimtemplate <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[_Np]>
1129227825Stheraven    : public integral_constant<size_t, rank<_Tp>::value + 1> {};
1130227825Stheraven
1131300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1132300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR size_t rank_v
1133300770Sdim    = rank<_Tp>::value;
1134300770Sdim#endif
1135300770Sdim
1136227825Stheraven// extent
1137227825Stheraven
1138261283Sdimtemplate <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TYPE_VIS_ONLY extent
1139227825Stheraven    : public integral_constant<size_t, 0> {};
1140261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], 0>
1141227825Stheraven    : public integral_constant<size_t, 0> {};
1142261283Sdimtemplate <class _Tp, unsigned _Ip> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], _Ip>
1143227825Stheraven    : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
1144261283Sdimtemplate <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], 0>
1145227825Stheraven    : public integral_constant<size_t, _Np> {};
1146261283Sdimtemplate <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], _Ip>
1147227825Stheraven    : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
1148227825Stheraven
1149300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1150300770Sdimtemplate <class _Tp, unsigned _Ip = 0> _LIBCPP_CONSTEXPR size_t extent_v
1151300770Sdim    = extent<_Tp, _Ip>::value;
1152300770Sdim#endif
1153300770Sdim
1154227825Stheraven// remove_extent
1155227825Stheraven
1156261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_extent
1157227825Stheraven    {typedef _Tp type;};
1158261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[]>
1159227825Stheraven    {typedef _Tp type;};
1160261283Sdimtemplate <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[_Np]>
1161227825Stheraven    {typedef _Tp type;};
1162227825Stheraven
1163253159Stheraven#if _LIBCPP_STD_VER > 11
1164253159Stheraventemplate <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type;
1165253159Stheraven#endif
1166253159Stheraven
1167227825Stheraven// remove_all_extents
1168227825Stheraven
1169261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents
1170227825Stheraven    {typedef _Tp type;};
1171261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[]>
1172227825Stheraven    {typedef typename remove_all_extents<_Tp>::type type;};
1173261283Sdimtemplate <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[_Np]>
1174227825Stheraven    {typedef typename remove_all_extents<_Tp>::type type;};
1175227825Stheraven
1176253159Stheraven#if _LIBCPP_STD_VER > 11
1177253159Stheraventemplate <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
1178253159Stheraven#endif
1179253159Stheraven
1180261283Sdim// decay
1181261283Sdim
1182261283Sdimtemplate <class _Tp>
1183261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY decay
1184261283Sdim{
1185261283Sdimprivate:
1186261283Sdim    typedef typename remove_reference<_Tp>::type _Up;
1187261283Sdimpublic:
1188261283Sdim    typedef typename conditional
1189261283Sdim                     <
1190261283Sdim                         is_array<_Up>::value,
1191261283Sdim                         typename remove_extent<_Up>::type*,
1192261283Sdim                         typename conditional
1193261283Sdim                         <
1194261283Sdim                              is_function<_Up>::value,
1195261283Sdim                              typename add_pointer<_Up>::type,
1196261283Sdim                              typename remove_cv<_Up>::type
1197261283Sdim                         >::type
1198261283Sdim                     >::type type;
1199261283Sdim};
1200261283Sdim
1201261283Sdim#if _LIBCPP_STD_VER > 11
1202261283Sdimtemplate <class _Tp> using decay_t = typename decay<_Tp>::type;
1203261283Sdim#endif
1204261283Sdim
1205227825Stheraven// is_abstract
1206227825Stheraven
1207227825Stheravennamespace __is_abstract_imp
1208227825Stheraven{
1209227825Stheraventemplate <class _Tp> char  __test(_Tp (*)[1]);
1210227825Stheraventemplate <class _Tp> __two __test(...);
1211227825Stheraven}
1212227825Stheraven
1213227825Stheraventemplate <class _Tp, bool = is_class<_Tp>::value>
1214227825Stheravenstruct __libcpp_abstract : public integral_constant<bool, sizeof(__is_abstract_imp::__test<_Tp>(0)) != 1> {};
1215227825Stheraven
1216227825Stheraventemplate <class _Tp> struct __libcpp_abstract<_Tp, false> : public false_type {};
1217227825Stheraven
1218261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_abstract : public __libcpp_abstract<_Tp> {};
1219227825Stheraven
1220300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1221300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_abstract_v
1222300770Sdim    = is_abstract<_Tp>::value;
1223300770Sdim#endif
1224300770Sdim
1225277217Sdim// is_final
1226277217Sdim
1227288943Sdim#if defined(_LIBCPP_HAS_IS_FINAL)
1228288943Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY
1229288943Sdim__libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {};
1230288943Sdim#else
1231288943Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY
1232288943Sdim__libcpp_is_final : public false_type {};
1233288943Sdim#endif
1234288943Sdim
1235288943Sdim#if defined(_LIBCPP_HAS_IS_FINAL) && _LIBCPP_STD_VER > 11
1236288943Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY
1237277217Sdimis_final : public integral_constant<bool, __is_final(_Tp)> {};
1238277217Sdim#endif
1239277217Sdim
1240300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1241300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_final_v
1242300770Sdim    = is_final<_Tp>::value;
1243300770Sdim#endif
1244300770Sdim
1245241903Sdim// is_base_of
1246241903Sdim
1247261283Sdim#ifdef _LIBCPP_HAS_IS_BASE_OF
1248241903Sdim
1249241903Sdimtemplate <class _Bp, class _Dp>
1250261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_base_of
1251241903Sdim    : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
1252241903Sdim
1253277217Sdim#else  // _LIBCPP_HAS_IS_BASE_OF
1254241903Sdim
1255246487Stheravennamespace __is_base_of_imp
1256246487Stheraven{
1257246487Stheraventemplate <class _Tp>
1258246487Stheravenstruct _Dst
1259246487Stheraven{
1260246487Stheraven    _Dst(const volatile _Tp &);
1261246487Stheraven};
1262246487Stheraventemplate <class _Tp>
1263246487Stheravenstruct _Src
1264246487Stheraven{
1265246487Stheraven    operator const volatile _Tp &();
1266246487Stheraven    template <class _Up> operator const _Dst<_Up> &();
1267246487Stheraven};
1268246487Stheraventemplate <size_t> struct __one { typedef char type; };
1269246487Stheraventemplate <class _Bp, class _Dp> typename __one<sizeof(_Dst<_Bp>(declval<_Src<_Dp> >()))>::type __test(int);
1270246487Stheraventemplate <class _Bp, class _Dp> __two __test(...);
1271246487Stheraven}
1272241903Sdim
1273246487Stheraventemplate <class _Bp, class _Dp>
1274261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_base_of
1275246487Stheraven    : public integral_constant<bool, is_class<_Bp>::value &&
1276246487Stheraven                                     sizeof(__is_base_of_imp::__test<_Bp, _Dp>(0)) == 2> {};
1277246487Stheraven
1278277217Sdim#endif  // _LIBCPP_HAS_IS_BASE_OF
1279241903Sdim
1280300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1281300770Sdimtemplate <class _Bp, class _Dp> _LIBCPP_CONSTEXPR bool is_base_of_v
1282300770Sdim    = is_base_of<_Bp, _Dp>::value;
1283300770Sdim#endif
1284300770Sdim
1285227825Stheraven// is_convertible
1286227825Stheraven
1287288943Sdim#if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
1288227825Stheraven
1289261283Sdimtemplate <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible
1290241903Sdim    : public integral_constant<bool, __is_convertible_to(_T1, _T2) &&
1291241903Sdim                                     !is_abstract<_T2>::value> {};
1292227825Stheraven
1293227825Stheraven#else  // __has_feature(is_convertible_to)
1294227825Stheraven
1295227825Stheravennamespace __is_convertible_imp
1296227825Stheraven{
1297280864Sdimtemplate <class _Tp> void  __test_convert(_Tp);
1298280864Sdim
1299280864Sdimtemplate <class _From, class _To, class = void>
1300280864Sdimstruct __is_convertible_test : public false_type {};
1301280864Sdim
1302280864Sdimtemplate <class _From, class _To>
1303280864Sdimstruct __is_convertible_test<_From, _To,
1304280864Sdim    decltype(__test_convert<_To>(_VSTD::declval<_From>()))> : public true_type
1305280864Sdim{};
1306280864Sdim
1307227825Stheraventemplate <class _Tp> __two __test(...);
1308227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1309227825Stheraventemplate <class _Tp> _Tp&& __source();
1310227825Stheraven#else
1311227825Stheraventemplate <class _Tp> typename remove_reference<_Tp>::type& __source();
1312227825Stheraven#endif
1313227825Stheraven
1314227825Stheraventemplate <class _Tp, bool _IsArray =    is_array<_Tp>::value,
1315227825Stheraven                     bool _IsFunction = is_function<_Tp>::value,
1316227825Stheraven                     bool _IsVoid =     is_void<_Tp>::value>
1317227825Stheraven                     struct __is_array_function_or_void                          {enum {value = 0};};
1318227825Stheraventemplate <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};};
1319227825Stheraventemplate <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};};
1320227825Stheraventemplate <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};};
1321227825Stheraven}
1322227825Stheraven
1323227825Stheraventemplate <class _Tp,
1324227825Stheraven    unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
1325227825Stheravenstruct __is_convertible_check
1326227825Stheraven{
1327227825Stheraven    static const size_t __v = 0;
1328227825Stheraven};
1329227825Stheraven
1330227825Stheraventemplate <class _Tp>
1331227825Stheravenstruct __is_convertible_check<_Tp, 0>
1332227825Stheraven{
1333227825Stheraven    static const size_t __v = sizeof(_Tp);
1334227825Stheraven};
1335227825Stheraven
1336227825Stheraventemplate <class _T1, class _T2,
1337227825Stheraven    unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value,
1338227825Stheraven    unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
1339227825Stheravenstruct __is_convertible
1340227825Stheraven    : public integral_constant<bool,
1341280864Sdim        __is_convertible_imp::__is_convertible_test<_T1, _T2>::value
1342280864Sdim#if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
1343241903Sdim         && !(!is_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value
1344241903Sdim              && (!is_const<typename remove_reference<_T2>::type>::value
1345241903Sdim                  || is_volatile<typename remove_reference<_T2>::type>::value)
1346241903Sdim                  && (is_same<typename remove_cv<_T1>::type,
1347241903Sdim                              typename remove_cv<typename remove_reference<_T2>::type>::type>::value
1348241903Sdim                      || is_base_of<typename remove_reference<_T2>::type, _T1>::value))
1349241903Sdim#endif
1350227825Stheraven    >
1351227825Stheraven{};
1352227825Stheraven
1353227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 0> : false_type {};
1354227825Stheraven
1355227825Stheraventemplate <class _T1> struct __is_convertible<_T1, const _T1&, 1, 0> : true_type {};
1356288943Sdimtemplate <class _T1> struct __is_convertible<const _T1, const _T1&, 1, 0> : true_type {};
1357227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1358227825Stheraventemplate <class _T1> struct __is_convertible<_T1, _T1&&, 1, 0> : true_type {};
1359227825Stheraventemplate <class _T1> struct __is_convertible<_T1, const _T1&&, 1, 0> : true_type {};
1360227825Stheraventemplate <class _T1> struct __is_convertible<_T1, volatile _T1&&, 1, 0> : true_type {};
1361227825Stheraventemplate <class _T1> struct __is_convertible<_T1, const volatile _T1&&, 1, 0> : true_type {};
1362227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1363227825Stheraven
1364227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2*, 1, 0>
1365227825Stheraven    : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*>::value> {};
1366227825Stheraven
1367227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2* const, 1, 0>
1368227825Stheraven    : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const>::value> {};
1369227825Stheraven
1370227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2* volatile, 1, 0>
1371227825Stheraven    : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*volatile>::value> {};
1372227825Stheraven
1373227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2* const volatile, 1, 0>
1374227825Stheraven    : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const volatile>::value> {};
1375227825Stheraven
1376227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 0>                : public false_type {};
1377227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1378227825Stheraventemplate <class _T1>            struct __is_convertible<_T1, _T1&&, 2, 0>               : public true_type {};
1379227825Stheraven#endif
1380241903Sdimtemplate <class _T1>            struct __is_convertible<_T1, _T1&, 2, 0>               : public true_type {};
1381227825Stheraventemplate <class _T1>            struct __is_convertible<_T1, _T1*, 2, 0>               : public true_type {};
1382227825Stheraventemplate <class _T1>            struct __is_convertible<_T1, _T1*const, 2, 0>          : public true_type {};
1383227825Stheraventemplate <class _T1>            struct __is_convertible<_T1, _T1*volatile, 2, 0>       : public true_type {};
1384227825Stheraventemplate <class _T1>            struct __is_convertible<_T1, _T1*const volatile, 2, 0> : public true_type {};
1385227825Stheraven
1386227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 0> : public false_type {};
1387227825Stheraven
1388227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
1389227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
1390227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
1391227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {};
1392227825Stheraven
1393227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {};
1394227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {};
1395227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {};
1396227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {};
1397227825Stheraven
1398227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {};
1399227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {};
1400227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {};
1401227825Stheraventemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {};
1402227825Stheraven
1403261283Sdimtemplate <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible
1404227825Stheraven    : public __is_convertible<_T1, _T2>
1405227825Stheraven{
1406227825Stheraven    static const size_t __complete_check1 = __is_convertible_check<_T1>::__v;
1407227825Stheraven    static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
1408227825Stheraven};
1409227825Stheraven
1410227825Stheraven#endif  // __has_feature(is_convertible_to)
1411227825Stheraven
1412300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1413300770Sdimtemplate <class _From, class _To> _LIBCPP_CONSTEXPR bool is_convertible_v
1414300770Sdim    = is_convertible<_From, _To>::value;
1415300770Sdim#endif
1416300770Sdim
1417227825Stheraven// is_empty
1418227825Stheraven
1419277217Sdim#if __has_feature(is_empty) || (_GNUC_VER >= 407)
1420232950Stheraven
1421227825Stheraventemplate <class _Tp>
1422261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_empty
1423232950Stheraven    : public integral_constant<bool, __is_empty(_Tp)> {};
1424232950Stheraven
1425232950Stheraven#else  // __has_feature(is_empty)
1426232950Stheraven
1427232950Stheraventemplate <class _Tp>
1428227825Stheravenstruct __is_empty1
1429227825Stheraven    : public _Tp
1430227825Stheraven{
1431242945Stheraven    double __lx;
1432227825Stheraven};
1433227825Stheraven
1434227825Stheravenstruct __is_empty2
1435227825Stheraven{
1436242945Stheraven    double __lx;
1437227825Stheraven};
1438227825Stheraven
1439227825Stheraventemplate <class _Tp, bool = is_class<_Tp>::value>
1440227825Stheravenstruct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {};
1441227825Stheraven
1442227825Stheraventemplate <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {};
1443227825Stheraven
1444261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_empty : public __libcpp_empty<_Tp> {};
1445227825Stheraven
1446232950Stheraven#endif  // __has_feature(is_empty)
1447232950Stheraven
1448300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1449300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_empty_v
1450300770Sdim    = is_empty<_Tp>::value;
1451300770Sdim#endif
1452300770Sdim
1453227825Stheraven// is_polymorphic
1454227825Stheraven
1455277217Sdim#if __has_feature(is_polymorphic) || defined(_LIBCPP_MSVC)
1456232950Stheraven
1457232950Stheraventemplate <class _Tp>
1458261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_polymorphic
1459232950Stheraven    : public integral_constant<bool, __is_polymorphic(_Tp)> {};
1460232950Stheraven
1461232950Stheraven#else
1462232950Stheraven
1463249998Sdimtemplate<typename _Tp> char &__is_polymorphic_impl(
1464249998Sdim    typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0,
1465249998Sdim                       int>::type);
1466249998Sdimtemplate<typename _Tp> __two &__is_polymorphic_impl(...);
1467227825Stheraven
1468261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic
1469249998Sdim    : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {};
1470227825Stheraven
1471232950Stheraven#endif // __has_feature(is_polymorphic)
1472232950Stheraven
1473300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1474300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_polymorphic_v
1475300770Sdim    = is_polymorphic<_Tp>::value;
1476300770Sdim#endif
1477300770Sdim
1478227825Stheraven// has_virtual_destructor
1479227825Stheraven
1480277217Sdim#if __has_feature(has_virtual_destructor) || (_GNUC_VER >= 403)
1481227825Stheraven
1482261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor
1483227825Stheraven    : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
1484227825Stheraven
1485277217Sdim#else
1486227825Stheraven
1487261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor
1488227825Stheraven    : public false_type {};
1489227825Stheraven
1490277217Sdim#endif
1491227825Stheraven
1492300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1493300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool has_virtual_destructor_v
1494300770Sdim    = has_virtual_destructor<_Tp>::value;
1495300770Sdim#endif
1496300770Sdim
1497227825Stheraven// alignment_of
1498227825Stheraven
1499261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY alignment_of
1500249998Sdim    : public integral_constant<size_t, __alignof__(_Tp)> {};
1501227825Stheraven
1502300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1503300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR size_t alignment_of_v
1504300770Sdim    = alignment_of<_Tp>::value;
1505300770Sdim#endif
1506300770Sdim
1507227825Stheraven// aligned_storage
1508227825Stheraven
1509227825Stheraventemplate <class _Hp, class _Tp>
1510227825Stheravenstruct __type_list
1511227825Stheraven{
1512227825Stheraven    typedef _Hp _Head;
1513227825Stheraven    typedef _Tp _Tail;
1514227825Stheraven};
1515227825Stheraven
1516227825Stheravenstruct __nat
1517227825Stheraven{
1518227825Stheraven#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
1519227825Stheraven    __nat() = delete;
1520227825Stheraven    __nat(const __nat&) = delete;
1521227825Stheraven    __nat& operator=(const __nat&) = delete;
1522227825Stheraven    ~__nat() = delete;
1523227825Stheraven#endif
1524227825Stheraven};
1525227825Stheraven
1526227825Stheraventemplate <class _Tp>
1527227825Stheravenstruct __align_type
1528227825Stheraven{
1529227825Stheraven    static const size_t value = alignment_of<_Tp>::value;
1530227825Stheraven    typedef _Tp type;
1531227825Stheraven};
1532227825Stheraven
1533242945Stheravenstruct __struct_double {long double __lx;};
1534242945Stheravenstruct __struct_double4 {double __lx[4];};
1535227825Stheraven
1536227825Stheraventypedef
1537227825Stheraven    __type_list<__align_type<unsigned char>,
1538227825Stheraven    __type_list<__align_type<unsigned short>,
1539227825Stheraven    __type_list<__align_type<unsigned int>,
1540227825Stheraven    __type_list<__align_type<unsigned long>,
1541227825Stheraven    __type_list<__align_type<unsigned long long>,
1542227825Stheraven    __type_list<__align_type<double>,
1543227825Stheraven    __type_list<__align_type<long double>,
1544227825Stheraven    __type_list<__align_type<__struct_double>,
1545227825Stheraven    __type_list<__align_type<__struct_double4>,
1546227825Stheraven    __type_list<__align_type<int*>,
1547227825Stheraven    __nat
1548227825Stheraven    > > > > > > > > > > __all_types;
1549227825Stheraven
1550227825Stheraventemplate <class _TL, size_t _Align> struct __find_pod;
1551227825Stheraven
1552227825Stheraventemplate <class _Hp, size_t _Align>
1553227825Stheravenstruct __find_pod<__type_list<_Hp, __nat>, _Align>
1554227825Stheraven{
1555227825Stheraven    typedef typename conditional<
1556227825Stheraven                             _Align == _Hp::value,
1557227825Stheraven                             typename _Hp::type,
1558227825Stheraven                             void
1559227825Stheraven                         >::type type;
1560227825Stheraven};
1561227825Stheraven
1562227825Stheraventemplate <class _Hp, class _Tp, size_t _Align>
1563227825Stheravenstruct __find_pod<__type_list<_Hp, _Tp>, _Align>
1564227825Stheraven{
1565227825Stheraven    typedef typename conditional<
1566227825Stheraven                             _Align == _Hp::value,
1567227825Stheraven                             typename _Hp::type,
1568227825Stheraven                             typename __find_pod<_Tp, _Align>::type
1569227825Stheraven                         >::type type;
1570227825Stheraven};
1571227825Stheraven
1572227825Stheraventemplate <class _TL, size_t _Len> struct __find_max_align;
1573227825Stheraven
1574227825Stheraventemplate <class _Hp, size_t _Len>
1575227825Stheravenstruct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
1576227825Stheraven
1577227825Stheraventemplate <size_t _Len, size_t _A1, size_t _A2>
1578227825Stheravenstruct __select_align
1579227825Stheraven{
1580227825Stheravenprivate:
1581227825Stheraven    static const size_t __min = _A2 < _A1 ? _A2 : _A1;
1582227825Stheraven    static const size_t __max = _A1 < _A2 ? _A2 : _A1;
1583227825Stheravenpublic:
1584227825Stheraven    static const size_t value = _Len < __max ? __min : __max;
1585227825Stheraven};
1586227825Stheraven
1587227825Stheraventemplate <class _Hp, class _Tp, size_t _Len>
1588227825Stheravenstruct __find_max_align<__type_list<_Hp, _Tp>, _Len>
1589227825Stheraven    : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
1590227825Stheraven
1591253159Stheraventemplate <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1592261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY aligned_storage
1593227825Stheraven{
1594227825Stheraven    typedef typename __find_pod<__all_types, _Align>::type _Aligner;
1595227825Stheraven    static_assert(!is_void<_Aligner>::value, "");
1596227825Stheraven    union type
1597227825Stheraven    {
1598227825Stheraven        _Aligner __align;
1599300770Sdim        unsigned char __data[(_Len + _Align - 1)/_Align * _Align];
1600227825Stheraven    };
1601227825Stheraven};
1602227825Stheraven
1603253159Stheraven#if _LIBCPP_STD_VER > 11
1604253159Stheraventemplate <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1605253159Stheraven    using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
1606253159Stheraven#endif
1607253159Stheraven
1608227825Stheraven#define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
1609227825Stheraventemplate <size_t _Len>\
1610261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY aligned_storage<_Len, n>\
1611227825Stheraven{\
1612227825Stheraven    struct _ALIGNAS(n) type\
1613227825Stheraven    {\
1614300770Sdim        unsigned char __lx[(_Len + n - 1)/n * n];\
1615227825Stheraven    };\
1616227825Stheraven}
1617227825Stheraven
1618227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
1619227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
1620227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
1621227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
1622227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
1623227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
1624227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
1625227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
1626227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
1627227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
1628227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
1629227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
1630227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
1631227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
1632227825Stheraven// MSDN says that MSVC does not support alignment beyond 8192 (=0x2000)
1633261283Sdim#if !defined(_LIBCPP_MSVC)
1634227825Stheraven_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
1635261283Sdim#endif // !_LIBCPP_MSVC
1636227825Stheraven
1637227825Stheraven#undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
1638227825Stheraven
1639249998Sdim#ifndef _LIBCPP_HAS_NO_VARIADICS
1640249998Sdim
1641249998Sdim// aligned_union
1642249998Sdim
1643249998Sdimtemplate <size_t _I0, size_t ..._In>
1644249998Sdimstruct __static_max;
1645249998Sdim
1646249998Sdimtemplate <size_t _I0>
1647249998Sdimstruct __static_max<_I0>
1648249998Sdim{
1649249998Sdim    static const size_t value = _I0;
1650249998Sdim};
1651249998Sdim
1652249998Sdimtemplate <size_t _I0, size_t _I1, size_t ..._In>
1653249998Sdimstruct __static_max<_I0, _I1, _In...>
1654249998Sdim{
1655249998Sdim    static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value :
1656249998Sdim                                             __static_max<_I1, _In...>::value;
1657249998Sdim};
1658249998Sdim
1659249998Sdimtemplate <size_t _Len, class _Type0, class ..._Types>
1660249998Sdimstruct aligned_union
1661249998Sdim{
1662249998Sdim    static const size_t alignment_value = __static_max<__alignof__(_Type0),
1663249998Sdim                                                       __alignof__(_Types)...>::value;
1664249998Sdim    static const size_t __len = __static_max<_Len, sizeof(_Type0),
1665249998Sdim                                             sizeof(_Types)...>::value;
1666249998Sdim    typedef typename aligned_storage<__len, alignment_value>::type type;
1667249998Sdim};
1668249998Sdim
1669253159Stheraven#if _LIBCPP_STD_VER > 11
1670253159Stheraventemplate <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
1671253159Stheraven#endif
1672253159Stheraven
1673249998Sdim#endif  // _LIBCPP_HAS_NO_VARIADICS
1674249998Sdim
1675277217Sdimtemplate <class _Tp>
1676277217Sdimstruct __numeric_type
1677277217Sdim{
1678277217Sdim   static void __test(...);
1679277217Sdim   static float __test(float);
1680277217Sdim   static double __test(char);
1681277217Sdim   static double __test(int);
1682277217Sdim   static double __test(unsigned);
1683277217Sdim   static double __test(long);
1684277217Sdim   static double __test(unsigned long);
1685277217Sdim   static double __test(long long);
1686277217Sdim   static double __test(unsigned long long);
1687277217Sdim   static double __test(double);
1688277217Sdim   static long double __test(long double);
1689277217Sdim
1690277217Sdim   typedef decltype(__test(declval<_Tp>())) type;
1691277217Sdim   static const bool value = !is_same<type, void>::value;
1692277217Sdim};
1693277217Sdim
1694277217Sdimtemplate <>
1695277217Sdimstruct __numeric_type<void>
1696277217Sdim{
1697277217Sdim   static const bool value = true;
1698277217Sdim};
1699277217Sdim
1700227825Stheraven// __promote
1701227825Stheraven
1702227825Stheraventemplate <class _A1, class _A2 = void, class _A3 = void,
1703277217Sdim          bool = __numeric_type<_A1>::value &&
1704277217Sdim                 __numeric_type<_A2>::value &&
1705277217Sdim                 __numeric_type<_A3>::value>
1706277217Sdimclass __promote_imp
1707277217Sdim{
1708277217Sdimpublic:
1709277217Sdim    static const bool value = false;
1710277217Sdim};
1711227825Stheraven
1712227825Stheraventemplate <class _A1, class _A2, class _A3>
1713277217Sdimclass __promote_imp<_A1, _A2, _A3, true>
1714227825Stheraven{
1715227825Stheravenprivate:
1716277217Sdim    typedef typename __promote_imp<_A1>::type __type1;
1717277217Sdim    typedef typename __promote_imp<_A2>::type __type2;
1718277217Sdim    typedef typename __promote_imp<_A3>::type __type3;
1719227825Stheravenpublic:
1720227825Stheraven    typedef decltype(__type1() + __type2() + __type3()) type;
1721277217Sdim    static const bool value = true;
1722227825Stheraven};
1723227825Stheraven
1724227825Stheraventemplate <class _A1, class _A2>
1725277217Sdimclass __promote_imp<_A1, _A2, void, true>
1726227825Stheraven{
1727227825Stheravenprivate:
1728277217Sdim    typedef typename __promote_imp<_A1>::type __type1;
1729277217Sdim    typedef typename __promote_imp<_A2>::type __type2;
1730227825Stheravenpublic:
1731227825Stheraven    typedef decltype(__type1() + __type2()) type;
1732277217Sdim    static const bool value = true;
1733227825Stheraven};
1734227825Stheraven
1735227825Stheraventemplate <class _A1>
1736277217Sdimclass __promote_imp<_A1, void, void, true>
1737227825Stheraven{
1738227825Stheravenpublic:
1739277217Sdim    typedef typename __numeric_type<_A1>::type type;
1740277217Sdim    static const bool value = true;
1741227825Stheraven};
1742227825Stheraven
1743277217Sdimtemplate <class _A1, class _A2 = void, class _A3 = void>
1744277217Sdimclass __promote : public __promote_imp<_A1, _A2, _A3> {};
1745277217Sdim
1746227825Stheraven// make_signed / make_unsigned
1747227825Stheraven
1748227825Stheraventypedef
1749227825Stheraven    __type_list<signed char,
1750227825Stheraven    __type_list<signed short,
1751227825Stheraven    __type_list<signed int,
1752227825Stheraven    __type_list<signed long,
1753227825Stheraven    __type_list<signed long long,
1754277217Sdim#ifndef _LIBCPP_HAS_NO_INT128
1755277217Sdim    __type_list<__int128_t,
1756277217Sdim#endif
1757227825Stheraven    __nat
1758277217Sdim#ifndef _LIBCPP_HAS_NO_INT128
1759277217Sdim    >
1760277217Sdim#endif
1761227825Stheraven    > > > > > __signed_types;
1762227825Stheraven
1763227825Stheraventypedef
1764227825Stheraven    __type_list<unsigned char,
1765227825Stheraven    __type_list<unsigned short,
1766227825Stheraven    __type_list<unsigned int,
1767227825Stheraven    __type_list<unsigned long,
1768227825Stheraven    __type_list<unsigned long long,
1769277217Sdim#ifndef _LIBCPP_HAS_NO_INT128
1770277217Sdim    __type_list<__uint128_t,
1771277217Sdim#endif
1772227825Stheraven    __nat
1773277217Sdim#ifndef _LIBCPP_HAS_NO_INT128
1774277217Sdim    >
1775277217Sdim#endif
1776227825Stheraven    > > > > > __unsigned_types;
1777227825Stheraven
1778227825Stheraventemplate <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
1779227825Stheraven
1780227825Stheraventemplate <class _Hp, class _Tp, size_t _Size>
1781227825Stheravenstruct __find_first<__type_list<_Hp, _Tp>, _Size, true>
1782227825Stheraven{
1783227825Stheraven    typedef _Hp type;
1784227825Stheraven};
1785227825Stheraven
1786227825Stheraventemplate <class _Hp, class _Tp, size_t _Size>
1787227825Stheravenstruct __find_first<__type_list<_Hp, _Tp>, _Size, false>
1788227825Stheraven{
1789227825Stheraven    typedef typename __find_first<_Tp, _Size>::type type;
1790227825Stheraven};
1791227825Stheraven
1792227825Stheraventemplate <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
1793227825Stheraven                             bool = is_volatile<typename remove_reference<_Tp>::type>::value>
1794227825Stheravenstruct __apply_cv
1795227825Stheraven{
1796227825Stheraven    typedef _Up type;
1797227825Stheraven};
1798227825Stheraven
1799227825Stheraventemplate <class _Tp, class _Up>
1800227825Stheravenstruct __apply_cv<_Tp, _Up, true, false>
1801227825Stheraven{
1802227825Stheraven    typedef const _Up type;
1803227825Stheraven};
1804227825Stheraven
1805227825Stheraventemplate <class _Tp, class _Up>
1806227825Stheravenstruct __apply_cv<_Tp, _Up, false, true>
1807227825Stheraven{
1808227825Stheraven    typedef volatile _Up type;
1809227825Stheraven};
1810227825Stheraven
1811227825Stheraventemplate <class _Tp, class _Up>
1812227825Stheravenstruct __apply_cv<_Tp, _Up, true, true>
1813227825Stheraven{
1814227825Stheraven    typedef const volatile _Up type;
1815227825Stheraven};
1816227825Stheraven
1817227825Stheraventemplate <class _Tp, class _Up>
1818227825Stheravenstruct __apply_cv<_Tp&, _Up, false, false>
1819227825Stheraven{
1820227825Stheraven    typedef _Up& type;
1821227825Stheraven};
1822227825Stheraven
1823227825Stheraventemplate <class _Tp, class _Up>
1824227825Stheravenstruct __apply_cv<_Tp&, _Up, true, false>
1825227825Stheraven{
1826227825Stheraven    typedef const _Up& type;
1827227825Stheraven};
1828227825Stheraven
1829227825Stheraventemplate <class _Tp, class _Up>
1830227825Stheravenstruct __apply_cv<_Tp&, _Up, false, true>
1831227825Stheraven{
1832227825Stheraven    typedef volatile _Up& type;
1833227825Stheraven};
1834227825Stheraven
1835227825Stheraventemplate <class _Tp, class _Up>
1836227825Stheravenstruct __apply_cv<_Tp&, _Up, true, true>
1837227825Stheraven{
1838227825Stheraven    typedef const volatile _Up& type;
1839227825Stheraven};
1840227825Stheraven
1841227825Stheraventemplate <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1842227825Stheravenstruct __make_signed {};
1843227825Stheraven
1844227825Stheraventemplate <class _Tp>
1845227825Stheravenstruct __make_signed<_Tp, true>
1846227825Stheraven{
1847227825Stheraven    typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
1848227825Stheraven};
1849227825Stheraven
1850227825Stheraventemplate <> struct __make_signed<bool,               true> {};
1851227825Stheraventemplate <> struct __make_signed<  signed short,     true> {typedef short     type;};
1852227825Stheraventemplate <> struct __make_signed<unsigned short,     true> {typedef short     type;};
1853227825Stheraventemplate <> struct __make_signed<  signed int,       true> {typedef int       type;};
1854227825Stheraventemplate <> struct __make_signed<unsigned int,       true> {typedef int       type;};
1855227825Stheraventemplate <> struct __make_signed<  signed long,      true> {typedef long      type;};
1856227825Stheraventemplate <> struct __make_signed<unsigned long,      true> {typedef long      type;};
1857227825Stheraventemplate <> struct __make_signed<  signed long long, true> {typedef long long type;};
1858227825Stheraventemplate <> struct __make_signed<unsigned long long, true> {typedef long long type;};
1859277217Sdim#ifndef _LIBCPP_HAS_NO_INT128
1860277217Sdimtemplate <> struct __make_signed<__int128_t,         true> {typedef __int128_t type;};
1861277217Sdimtemplate <> struct __make_signed<__uint128_t,        true> {typedef __int128_t type;};
1862277217Sdim#endif
1863227825Stheraven
1864227825Stheraventemplate <class _Tp>
1865261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY make_signed
1866227825Stheraven{
1867227825Stheraven    typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
1868227825Stheraven};
1869227825Stheraven
1870253159Stheraven#if _LIBCPP_STD_VER > 11
1871253159Stheraventemplate <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
1872253159Stheraven#endif
1873253159Stheraven
1874227825Stheraventemplate <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1875227825Stheravenstruct __make_unsigned {};
1876227825Stheraven
1877227825Stheraventemplate <class _Tp>
1878227825Stheravenstruct __make_unsigned<_Tp, true>
1879227825Stheraven{
1880227825Stheraven    typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
1881227825Stheraven};
1882227825Stheraven
1883227825Stheraventemplate <> struct __make_unsigned<bool,               true> {};
1884227825Stheraventemplate <> struct __make_unsigned<  signed short,     true> {typedef unsigned short     type;};
1885227825Stheraventemplate <> struct __make_unsigned<unsigned short,     true> {typedef unsigned short     type;};
1886227825Stheraventemplate <> struct __make_unsigned<  signed int,       true> {typedef unsigned int       type;};
1887227825Stheraventemplate <> struct __make_unsigned<unsigned int,       true> {typedef unsigned int       type;};
1888227825Stheraventemplate <> struct __make_unsigned<  signed long,      true> {typedef unsigned long      type;};
1889227825Stheraventemplate <> struct __make_unsigned<unsigned long,      true> {typedef unsigned long      type;};
1890227825Stheraventemplate <> struct __make_unsigned<  signed long long, true> {typedef unsigned long long type;};
1891227825Stheraventemplate <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
1892277217Sdim#ifndef _LIBCPP_HAS_NO_INT128
1893277217Sdimtemplate <> struct __make_unsigned<__int128_t,         true> {typedef __uint128_t        type;};
1894277217Sdimtemplate <> struct __make_unsigned<__uint128_t,        true> {typedef __uint128_t        type;};
1895277217Sdim#endif
1896227825Stheraven
1897227825Stheraventemplate <class _Tp>
1898261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY make_unsigned
1899227825Stheraven{
1900227825Stheraven    typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
1901227825Stheraven};
1902227825Stheraven
1903253159Stheraven#if _LIBCPP_STD_VER > 11
1904253159Stheraventemplate <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
1905253159Stheraven#endif
1906253159Stheraven
1907227825Stheraven#ifdef _LIBCPP_HAS_NO_VARIADICS
1908227825Stheraven
1909288943Sdimtemplate <class _Tp, class _Up = void, class _Vp = void>
1910261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY common_type
1911227825Stheraven{
1912227825Stheravenpublic:
1913288943Sdim    typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp>::type type;
1914227825Stheraven};
1915227825Stheraven
1916227825Stheraventemplate <class _Tp>
1917261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, void, void>
1918227825Stheraven{
1919227825Stheravenpublic:
1920277217Sdim    typedef typename decay<_Tp>::type type;
1921227825Stheraven};
1922227825Stheraven
1923227825Stheraventemplate <class _Tp, class _Up>
1924261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, void>
1925227825Stheraven{
1926300770Sdim    typedef typename decay<decltype(
1927300770Sdim        true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
1928300770Sdim      )>::type type;
1929227825Stheraven};
1930227825Stheraven
1931227825Stheraven#else  // _LIBCPP_HAS_NO_VARIADICS
1932227825Stheraven
1933300770Sdim// bullet 1 - sizeof...(Tp) == 0
1934227825Stheraven
1935300770Sdimtemplate <class ..._Tp>
1936300770Sdimstruct _LIBCPP_TYPE_VIS_ONLY common_type {};
1937300770Sdim
1938300770Sdim// bullet 2 - sizeof...(Tp) == 1
1939300770Sdim
1940227825Stheraventemplate <class _Tp>
1941261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp>
1942227825Stheraven{
1943261283Sdim    typedef typename decay<_Tp>::type type;
1944227825Stheraven};
1945227825Stheraven
1946300770Sdim// bullet 3 - sizeof...(Tp) == 2
1947300770Sdim
1948300770Sdimtemplate <class _Tp, class _Up, class = void>
1949300770Sdimstruct __common_type2 {};
1950300770Sdim
1951227825Stheraventemplate <class _Tp, class _Up>
1952300770Sdimstruct __common_type2<_Tp, _Up,
1953300770Sdim    typename __void_t<decltype(
1954300770Sdim        true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
1955300770Sdim    )>::type>
1956227825Stheraven{
1957300770Sdim    typedef typename decay<decltype(
1958300770Sdim        true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
1959300770Sdim    )>::type type;
1960227825Stheraven};
1961227825Stheraven
1962300770Sdimtemplate <class _Tp, class _Up>
1963300770Sdimstruct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up>
1964300770Sdim    : __common_type2<_Tp, _Up> {};
1965300770Sdim
1966300770Sdim// bullet 4 - sizeof...(Tp) > 2
1967300770Sdim
1968300770Sdimtemplate <class ...Tp> struct __common_types;
1969300770Sdim
1970300770Sdimtemplate <class, class = void>
1971300770Sdimstruct __common_type_impl {};
1972300770Sdim
1973227825Stheraventemplate <class _Tp, class _Up, class ..._Vp>
1974300770Sdimstruct __common_type_impl<__common_types<_Tp, _Up, _Vp...>,
1975300770Sdim    typename __void_t<typename common_type<_Tp, _Up>::type>::type>
1976227825Stheraven{
1977300770Sdim    typedef typename common_type<
1978300770Sdim        typename common_type<_Tp, _Up>::type, _Vp...
1979300770Sdim    >::type type;
1980227825Stheraven};
1981227825Stheraven
1982300770Sdimtemplate <class _Tp, class _Up, class ..._Vp>
1983300770Sdimstruct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, _Vp...>
1984300770Sdim    : __common_type_impl<__common_types<_Tp, _Up, _Vp...> > {};
1985300770Sdim
1986253159Stheraven#if _LIBCPP_STD_VER > 11
1987253159Stheraventemplate <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type;
1988253159Stheraven#endif
1989253159Stheraven
1990227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
1991227825Stheraven
1992227825Stheraven// is_assignable
1993227825Stheraven
1994261283Sdimtemplate<typename, typename _Tp> struct __select_2nd { typedef _Tp type; };
1995261283Sdim
1996227825Stheraventemplate <class _Tp, class _Arg>
1997261283Sdimtypename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type
1998227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1999227825Stheraven__is_assignable_test(_Tp&&, _Arg&&);
2000227825Stheraven#else
2001227825Stheraven__is_assignable_test(_Tp, _Arg&);
2002227825Stheraven#endif
2003227825Stheraven
2004227825Stheraventemplate <class _Arg>
2005227825Stheravenfalse_type
2006227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2007227825Stheraven__is_assignable_test(__any, _Arg&&);
2008227825Stheraven#else
2009227825Stheraven__is_assignable_test(__any, _Arg&);
2010227825Stheraven#endif
2011227825Stheraven
2012227825Stheraventemplate <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
2013227825Stheravenstruct __is_assignable_imp
2014227825Stheraven    : public common_type
2015227825Stheraven        <
2016288943Sdim            decltype(_VSTD::__is_assignable_test(declval<_Tp>(), declval<_Arg>()))
2017227825Stheraven        >::type {};
2018227825Stheraven
2019227825Stheraventemplate <class _Tp, class _Arg>
2020227825Stheravenstruct __is_assignable_imp<_Tp, _Arg, true>
2021227825Stheraven    : public false_type
2022227825Stheraven{
2023227825Stheraven};
2024227825Stheraven
2025227825Stheraventemplate <class _Tp, class _Arg>
2026227825Stheravenstruct is_assignable
2027227825Stheraven    : public __is_assignable_imp<_Tp, _Arg> {};
2028227825Stheraven
2029300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2030300770Sdimtemplate <class _Tp, class _Arg> _LIBCPP_CONSTEXPR bool is_assignable_v
2031300770Sdim    = is_assignable<_Tp, _Arg>::value;
2032300770Sdim#endif
2033300770Sdim
2034227825Stheraven// is_copy_assignable
2035227825Stheraven
2036261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_copy_assignable
2037227825Stheraven    : public is_assignable<typename add_lvalue_reference<_Tp>::type,
2038277217Sdim                  typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
2039227825Stheraven
2040300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2041300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_assignable_v
2042300770Sdim    = is_copy_assignable<_Tp>::value;
2043300770Sdim#endif
2044300770Sdim
2045227825Stheraven// is_move_assignable
2046227825Stheraven
2047261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_move_assignable
2048227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2049227825Stheraven    : public is_assignable<typename add_lvalue_reference<_Tp>::type,
2050227825Stheraven                     const typename add_rvalue_reference<_Tp>::type> {};
2051227825Stheraven#else
2052227825Stheraven    : public is_copy_assignable<_Tp> {};
2053227825Stheraven#endif
2054227825Stheraven
2055300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2056300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_move_assignable_v
2057300770Sdim    = is_move_assignable<_Tp>::value;
2058300770Sdim#endif
2059300770Sdim
2060227825Stheraven// is_destructible
2061227825Stheraven
2062277217Sdim//  if it's a reference, return true
2063277217Sdim//  if it's a function, return false
2064277217Sdim//  if it's   void,     return false
2065277217Sdim//  if it's an array of unknown bound, return false
2066277217Sdim//  Otherwise, return "std::declval<_Up&>().~_Up()" is well-formed
2067277217Sdim//    where _Up is remove_all_extents<_Tp>::type
2068277217Sdim
2069277217Sdimtemplate <class>
2070277217Sdimstruct __is_destructible_apply { typedef int type; };
2071277217Sdim
2072277217Sdimtemplate <typename _Tp>
2073277217Sdimstruct __is_destructor_wellformed {
2074277217Sdim    template <typename _Tp1>
2075277217Sdim    static char  __test (
2076277217Sdim        typename __is_destructible_apply<decltype(_VSTD::declval<_Tp1&>().~_Tp1())>::type
2077277217Sdim    );
2078277217Sdim
2079277217Sdim    template <typename _Tp1>
2080277217Sdim    static __two __test (...);
2081277217Sdim    
2082277217Sdim    static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char);
2083227825Stheraven};
2084227825Stheraven
2085277217Sdimtemplate <class _Tp, bool>
2086277217Sdimstruct __destructible_imp;
2087277217Sdim
2088227825Stheraventemplate <class _Tp>
2089277217Sdimstruct __destructible_imp<_Tp, false> 
2090277217Sdim   : public _VSTD::integral_constant<bool, 
2091277217Sdim        __is_destructor_wellformed<typename _VSTD::remove_all_extents<_Tp>::type>::value> {};
2092227825Stheraven
2093277217Sdimtemplate <class _Tp>
2094277217Sdimstruct __destructible_imp<_Tp, true>
2095277217Sdim    : public _VSTD::true_type {};
2096227825Stheraven
2097277217Sdimtemplate <class _Tp, bool>
2098277217Sdimstruct __destructible_false;
2099227825Stheraven
2100227825Stheraventemplate <class _Tp>
2101277217Sdimstruct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, _VSTD::is_reference<_Tp>::value> {};
2102227825Stheraven
2103227825Stheraventemplate <class _Tp>
2104277217Sdimstruct __destructible_false<_Tp, true> : public _VSTD::false_type {};
2105277217Sdim
2106277217Sdimtemplate <class _Tp>
2107227825Stheravenstruct is_destructible
2108277217Sdim    : public __destructible_false<_Tp, _VSTD::is_function<_Tp>::value> {};
2109227825Stheraven
2110261283Sdimtemplate <class _Tp>
2111261283Sdimstruct is_destructible<_Tp[]>
2112277217Sdim    : public _VSTD::false_type {};
2113261283Sdim
2114277217Sdimtemplate <>
2115277217Sdimstruct is_destructible<void>
2116277217Sdim    : public _VSTD::false_type {};
2117277217Sdim
2118300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2119300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_destructible_v
2120300770Sdim    = is_destructible<_Tp>::value;
2121300770Sdim#endif
2122300770Sdim
2123227825Stheraven// move
2124227825Stheraven
2125227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2126227825Stheraven
2127227825Stheraventemplate <class _Tp>
2128261283Sdiminline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
2129227825Stheraventypename remove_reference<_Tp>::type&&
2130227825Stheravenmove(_Tp&& __t) _NOEXCEPT
2131227825Stheraven{
2132227825Stheraven    typedef typename remove_reference<_Tp>::type _Up;
2133227825Stheraven    return static_cast<_Up&&>(__t);
2134227825Stheraven}
2135227825Stheraven
2136227825Stheraventemplate <class _Tp>
2137261283Sdiminline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
2138227825Stheraven_Tp&&
2139227825Stheravenforward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
2140227825Stheraven{
2141227825Stheraven    return static_cast<_Tp&&>(__t);
2142227825Stheraven}
2143227825Stheraven
2144227825Stheraventemplate <class _Tp>
2145261283Sdiminline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
2146227825Stheraven_Tp&&
2147227825Stheravenforward(typename std::remove_reference<_Tp>::type&& __t) _NOEXCEPT
2148227825Stheraven{
2149227825Stheraven    static_assert(!std::is_lvalue_reference<_Tp>::value,
2150227825Stheraven                  "Can not forward an rvalue as an lvalue.");
2151227825Stheraven    return static_cast<_Tp&&>(__t);
2152227825Stheraven}
2153227825Stheraven
2154227825Stheraven#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2155227825Stheraven
2156227825Stheraventemplate <class _Tp>
2157227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
2158234976Stheraven_Tp&
2159227825Stheravenmove(_Tp& __t)
2160227825Stheraven{
2161227825Stheraven    return __t;
2162227825Stheraven}
2163227825Stheraven
2164227825Stheraventemplate <class _Tp>
2165227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
2166234976Stheravenconst _Tp&
2167232950Stheravenmove(const _Tp& __t)
2168232950Stheraven{
2169232950Stheraven    return __t;
2170232950Stheraven}
2171232950Stheraven
2172232950Stheraventemplate <class _Tp>
2173232950Stheraveninline _LIBCPP_INLINE_VISIBILITY
2174234976Stheraven_Tp&
2175234976Stheravenforward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
2176227825Stheraven{
2177227825Stheraven    return __t;
2178227825Stheraven}
2179227825Stheraven
2180227825Stheraven
2181234976Stheraventemplate <class _Tp>
2182234976Stheravenclass __rv
2183227825Stheraven{
2184234976Stheraven    typedef typename remove_reference<_Tp>::type _Trr;
2185234976Stheraven    _Trr& t_;
2186234976Stheravenpublic:
2187234976Stheraven    _LIBCPP_INLINE_VISIBILITY
2188234976Stheraven    _Trr* operator->() {return &t_;}
2189234976Stheraven    _LIBCPP_INLINE_VISIBILITY
2190234976Stheraven    explicit __rv(_Trr& __t) : t_(__t) {}
2191234976Stheraven};
2192227825Stheraven
2193227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2194227825Stheraven
2195227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2196227825Stheraven
2197227825Stheraventemplate <class _Tp>
2198227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
2199227825Stheraventypename decay<_Tp>::type
2200227825Stheraven__decay_copy(_Tp&& __t)
2201227825Stheraven{
2202227825Stheraven    return _VSTD::forward<_Tp>(__t);
2203227825Stheraven}
2204227825Stheraven
2205227825Stheraven#else
2206227825Stheraven
2207227825Stheraventemplate <class _Tp>
2208227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
2209227825Stheraventypename decay<_Tp>::type
2210227825Stheraven__decay_copy(const _Tp& __t)
2211227825Stheraven{
2212227825Stheraven    return _VSTD::forward<_Tp>(__t);
2213227825Stheraven}
2214227825Stheraven
2215227825Stheraven#endif
2216227825Stheraven
2217227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
2218227825Stheraven
2219232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2220232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
2221227825Stheraven{
2222227825Stheraven    typedef _Class _ClassType;
2223232950Stheraven    typedef _Rp _ReturnType;
2224275366Sdim    typedef _Rp (_FnType) (_Param...);
2225227825Stheraven};
2226227825Stheraven
2227232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2228277217Sdimstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false>
2229277217Sdim{
2230277217Sdim    typedef _Class _ClassType;
2231277217Sdim    typedef _Rp _ReturnType;
2232277217Sdim    typedef _Rp (_FnType) (_Param..., ...);
2233277217Sdim};
2234277217Sdim
2235277217Sdimtemplate <class _Rp, class _Class, class ..._Param>
2236232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
2237227825Stheraven{
2238227825Stheraven    typedef _Class const _ClassType;
2239232950Stheraven    typedef _Rp _ReturnType;
2240275366Sdim    typedef _Rp (_FnType) (_Param...);
2241227825Stheraven};
2242227825Stheraven
2243232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2244277217Sdimstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false>
2245277217Sdim{
2246277217Sdim    typedef _Class const _ClassType;
2247277217Sdim    typedef _Rp _ReturnType;
2248277217Sdim    typedef _Rp (_FnType) (_Param..., ...);
2249277217Sdim};
2250277217Sdim
2251277217Sdimtemplate <class _Rp, class _Class, class ..._Param>
2252232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
2253227825Stheraven{
2254227825Stheraven    typedef _Class volatile _ClassType;
2255232950Stheraven    typedef _Rp _ReturnType;
2256275366Sdim    typedef _Rp (_FnType) (_Param...);
2257227825Stheraven};
2258227825Stheraven
2259232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2260277217Sdimstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false>
2261277217Sdim{
2262277217Sdim    typedef _Class volatile _ClassType;
2263277217Sdim    typedef _Rp _ReturnType;
2264277217Sdim    typedef _Rp (_FnType) (_Param..., ...);
2265277217Sdim};
2266277217Sdim
2267277217Sdimtemplate <class _Rp, class _Class, class ..._Param>
2268232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
2269227825Stheraven{
2270227825Stheraven    typedef _Class const volatile _ClassType;
2271232950Stheraven    typedef _Rp _ReturnType;
2272275366Sdim    typedef _Rp (_FnType) (_Param...);
2273227825Stheraven};
2274227825Stheraven
2275277217Sdimtemplate <class _Rp, class _Class, class ..._Param>
2276277217Sdimstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false>
2277277217Sdim{
2278277217Sdim    typedef _Class const volatile _ClassType;
2279277217Sdim    typedef _Rp _ReturnType;
2280277217Sdim    typedef _Rp (_FnType) (_Param..., ...);
2281277217Sdim};
2282277217Sdim
2283288943Sdim#if __has_feature(cxx_reference_qualified_functions) || \
2284288943Sdim    (defined(_GNUC_VER) && _GNUC_VER >= 409)
2285227825Stheraven
2286232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2287232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
2288227825Stheraven{
2289227825Stheraven    typedef _Class& _ClassType;
2290232950Stheraven    typedef _Rp _ReturnType;
2291275366Sdim    typedef _Rp (_FnType) (_Param...);
2292227825Stheraven};
2293227825Stheraven
2294232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2295277217Sdimstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false>
2296277217Sdim{
2297277217Sdim    typedef _Class& _ClassType;
2298277217Sdim    typedef _Rp _ReturnType;
2299277217Sdim    typedef _Rp (_FnType) (_Param..., ...);
2300277217Sdim};
2301277217Sdim
2302277217Sdimtemplate <class _Rp, class _Class, class ..._Param>
2303232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
2304227825Stheraven{
2305227825Stheraven    typedef _Class const& _ClassType;
2306232950Stheraven    typedef _Rp _ReturnType;
2307275366Sdim    typedef _Rp (_FnType) (_Param...);
2308227825Stheraven};
2309227825Stheraven
2310232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2311277217Sdimstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false>
2312277217Sdim{
2313277217Sdim    typedef _Class const& _ClassType;
2314277217Sdim    typedef _Rp _ReturnType;
2315277217Sdim    typedef _Rp (_FnType) (_Param..., ...);
2316277217Sdim};
2317277217Sdim
2318277217Sdimtemplate <class _Rp, class _Class, class ..._Param>
2319232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
2320227825Stheraven{
2321227825Stheraven    typedef _Class volatile& _ClassType;
2322232950Stheraven    typedef _Rp _ReturnType;
2323275366Sdim    typedef _Rp (_FnType) (_Param...);
2324227825Stheraven};
2325227825Stheraven
2326232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2327277217Sdimstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false>
2328277217Sdim{
2329277217Sdim    typedef _Class volatile& _ClassType;
2330277217Sdim    typedef _Rp _ReturnType;
2331277217Sdim    typedef _Rp (_FnType) (_Param..., ...);
2332277217Sdim};
2333277217Sdim
2334277217Sdimtemplate <class _Rp, class _Class, class ..._Param>
2335232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
2336227825Stheraven{
2337227825Stheraven    typedef _Class const volatile& _ClassType;
2338232950Stheraven    typedef _Rp _ReturnType;
2339275366Sdim    typedef _Rp (_FnType) (_Param...);
2340227825Stheraven};
2341227825Stheraven
2342232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2343277217Sdimstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false>
2344277217Sdim{
2345277217Sdim    typedef _Class const volatile& _ClassType;
2346277217Sdim    typedef _Rp _ReturnType;
2347277217Sdim    typedef _Rp (_FnType) (_Param..., ...);
2348277217Sdim};
2349277217Sdim
2350277217Sdimtemplate <class _Rp, class _Class, class ..._Param>
2351232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
2352227825Stheraven{
2353227825Stheraven    typedef _Class&& _ClassType;
2354232950Stheraven    typedef _Rp _ReturnType;
2355275366Sdim    typedef _Rp (_FnType) (_Param...);
2356227825Stheraven};
2357227825Stheraven
2358232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2359277217Sdimstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false>
2360277217Sdim{
2361277217Sdim    typedef _Class&& _ClassType;
2362277217Sdim    typedef _Rp _ReturnType;
2363277217Sdim    typedef _Rp (_FnType) (_Param..., ...);
2364277217Sdim};
2365277217Sdim
2366277217Sdimtemplate <class _Rp, class _Class, class ..._Param>
2367232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
2368227825Stheraven{
2369227825Stheraven    typedef _Class const&& _ClassType;
2370232950Stheraven    typedef _Rp _ReturnType;
2371275366Sdim    typedef _Rp (_FnType) (_Param...);
2372227825Stheraven};
2373227825Stheraven
2374232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2375277217Sdimstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false>
2376277217Sdim{
2377277217Sdim    typedef _Class const&& _ClassType;
2378277217Sdim    typedef _Rp _ReturnType;
2379277217Sdim    typedef _Rp (_FnType) (_Param..., ...);
2380277217Sdim};
2381277217Sdim
2382277217Sdimtemplate <class _Rp, class _Class, class ..._Param>
2383232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
2384227825Stheraven{
2385227825Stheraven    typedef _Class volatile&& _ClassType;
2386232950Stheraven    typedef _Rp _ReturnType;
2387275366Sdim    typedef _Rp (_FnType) (_Param...);
2388227825Stheraven};
2389227825Stheraven
2390232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
2391277217Sdimstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false>
2392277217Sdim{
2393277217Sdim    typedef _Class volatile&& _ClassType;
2394277217Sdim    typedef _Rp _ReturnType;
2395277217Sdim    typedef _Rp (_FnType) (_Param..., ...);
2396277217Sdim};
2397277217Sdim
2398277217Sdimtemplate <class _Rp, class _Class, class ..._Param>
2399232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
2400227825Stheraven{
2401227825Stheraven    typedef _Class const volatile&& _ClassType;
2402232950Stheraven    typedef _Rp _ReturnType;
2403275366Sdim    typedef _Rp (_FnType) (_Param...);
2404227825Stheraven};
2405227825Stheraven
2406277217Sdimtemplate <class _Rp, class _Class, class ..._Param>
2407277217Sdimstruct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false>
2408277217Sdim{
2409277217Sdim    typedef _Class const volatile&& _ClassType;
2410277217Sdim    typedef _Rp _ReturnType;
2411277217Sdim    typedef _Rp (_FnType) (_Param..., ...);
2412277217Sdim};
2413277217Sdim
2414288943Sdim#endif  // __has_feature(cxx_reference_qualified_functions) || _GNUC_VER >= 409
2415227825Stheraven
2416227825Stheraven#else  // _LIBCPP_HAS_NO_VARIADICS
2417227825Stheraven
2418232950Stheraventemplate <class _Rp, class _Class>
2419232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(), true, false>
2420227825Stheraven{
2421227825Stheraven    typedef _Class _ClassType;
2422232950Stheraven    typedef _Rp _ReturnType;
2423275366Sdim    typedef _Rp (_FnType) ();
2424227825Stheraven};
2425227825Stheraven
2426277217Sdimtemplate <class _Rp, class _Class>
2427277217Sdimstruct __member_pointer_traits_imp<_Rp (_Class::*)(...), true, false>
2428277217Sdim{
2429277217Sdim    typedef _Class _ClassType;
2430277217Sdim    typedef _Rp _ReturnType;
2431277217Sdim    typedef _Rp (_FnType) (...);
2432277217Sdim};
2433277217Sdim
2434232950Stheraventemplate <class _Rp, class _Class, class _P0>
2435232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false>
2436227825Stheraven{
2437227825Stheraven    typedef _Class _ClassType;
2438232950Stheraven    typedef _Rp _ReturnType;
2439275366Sdim    typedef _Rp (_FnType) (_P0);
2440227825Stheraven};
2441227825Stheraven
2442277217Sdimtemplate <class _Rp, class _Class, class _P0>
2443277217Sdimstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...), true, false>
2444277217Sdim{
2445277217Sdim    typedef _Class _ClassType;
2446277217Sdim    typedef _Rp _ReturnType;
2447277217Sdim    typedef _Rp (_FnType) (_P0, ...);
2448277217Sdim};
2449277217Sdim
2450232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1>
2451232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false>
2452227825Stheraven{
2453227825Stheraven    typedef _Class _ClassType;
2454232950Stheraven    typedef _Rp _ReturnType;
2455275366Sdim    typedef _Rp (_FnType) (_P0, _P1);
2456227825Stheraven};
2457227825Stheraven
2458277217Sdimtemplate <class _Rp, class _Class, class _P0, class _P1>
2459277217Sdimstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...), true, false>
2460277217Sdim{
2461277217Sdim    typedef _Class _ClassType;
2462277217Sdim    typedef _Rp _ReturnType;
2463277217Sdim    typedef _Rp (_FnType) (_P0, _P1, ...);
2464277217Sdim};
2465277217Sdim
2466232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1, class _P2>
2467232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false>
2468227825Stheraven{
2469227825Stheraven    typedef _Class _ClassType;
2470232950Stheraven    typedef _Rp _ReturnType;
2471275366Sdim    typedef _Rp (_FnType) (_P0, _P1, _P2);
2472227825Stheraven};
2473227825Stheraven
2474277217Sdimtemplate <class _Rp, class _Class, class _P0, class _P1, class _P2>
2475277217Sdimstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...), true, false>
2476277217Sdim{
2477277217Sdim    typedef _Class _ClassType;
2478277217Sdim    typedef _Rp _ReturnType;
2479277217Sdim    typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2480277217Sdim};
2481277217Sdim
2482232950Stheraventemplate <class _Rp, class _Class>
2483232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false>
2484227825Stheraven{
2485227825Stheraven    typedef _Class const _ClassType;
2486232950Stheraven    typedef _Rp _ReturnType;
2487275366Sdim    typedef _Rp (_FnType) ();
2488227825Stheraven};
2489227825Stheraven
2490277217Sdimtemplate <class _Rp, class _Class>
2491277217Sdimstruct __member_pointer_traits_imp<_Rp (_Class::*)(...) const, true, false>
2492277217Sdim{
2493277217Sdim    typedef _Class const _ClassType;
2494277217Sdim    typedef _Rp _ReturnType;
2495277217Sdim    typedef _Rp (_FnType) (...);
2496277217Sdim};
2497277217Sdim
2498232950Stheraventemplate <class _Rp, class _Class, class _P0>
2499232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false>
2500227825Stheraven{
2501227825Stheraven    typedef _Class const _ClassType;
2502232950Stheraven    typedef _Rp _ReturnType;
2503275366Sdim    typedef _Rp (_FnType) (_P0);
2504227825Stheraven};
2505227825Stheraven
2506277217Sdimtemplate <class _Rp, class _Class, class _P0>
2507277217Sdimstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const, true, false>
2508277217Sdim{
2509277217Sdim    typedef _Class const _ClassType;
2510277217Sdim    typedef _Rp _ReturnType;
2511277217Sdim    typedef _Rp (_FnType) (_P0, ...);
2512277217Sdim};
2513277217Sdim
2514232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1>
2515232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false>
2516227825Stheraven{
2517227825Stheraven    typedef _Class const _ClassType;
2518232950Stheraven    typedef _Rp _ReturnType;
2519275366Sdim    typedef _Rp (_FnType) (_P0, _P1);
2520227825Stheraven};
2521227825Stheraven
2522277217Sdimtemplate <class _Rp, class _Class, class _P0, class _P1>
2523277217Sdimstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const, true, false>
2524277217Sdim{
2525277217Sdim    typedef _Class const _ClassType;
2526277217Sdim    typedef _Rp _ReturnType;
2527277217Sdim    typedef _Rp (_FnType) (_P0, _P1, ...);
2528277217Sdim};
2529277217Sdim
2530232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1, class _P2>
2531232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, false>
2532227825Stheraven{
2533227825Stheraven    typedef _Class const _ClassType;
2534232950Stheraven    typedef _Rp _ReturnType;
2535275366Sdim    typedef _Rp (_FnType) (_P0, _P1, _P2);
2536227825Stheraven};
2537227825Stheraven
2538277217Sdimtemplate <class _Rp, class _Class, class _P0, class _P1, class _P2>
2539277217Sdimstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const, true, false>
2540277217Sdim{
2541277217Sdim    typedef _Class const _ClassType;
2542277217Sdim    typedef _Rp _ReturnType;
2543277217Sdim    typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2544277217Sdim};
2545277217Sdim
2546232950Stheraventemplate <class _Rp, class _Class>
2547232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false>
2548227825Stheraven{
2549227825Stheraven    typedef _Class volatile _ClassType;
2550232950Stheraven    typedef _Rp _ReturnType;
2551275366Sdim    typedef _Rp (_FnType) ();
2552227825Stheraven};
2553227825Stheraven
2554277217Sdimtemplate <class _Rp, class _Class>
2555277217Sdimstruct __member_pointer_traits_imp<_Rp (_Class::*)(...) volatile, true, false>
2556277217Sdim{
2557277217Sdim    typedef _Class volatile _ClassType;
2558277217Sdim    typedef _Rp _ReturnType;
2559277217Sdim    typedef _Rp (_FnType) (...);
2560277217Sdim};
2561277217Sdim
2562232950Stheraventemplate <class _Rp, class _Class, class _P0>
2563232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false>
2564227825Stheraven{
2565227825Stheraven    typedef _Class volatile _ClassType;
2566232950Stheraven    typedef _Rp _ReturnType;
2567275366Sdim    typedef _Rp (_FnType) (_P0);
2568227825Stheraven};
2569227825Stheraven
2570277217Sdimtemplate <class _Rp, class _Class, class _P0>
2571277217Sdimstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) volatile, true, false>
2572277217Sdim{
2573277217Sdim    typedef _Class volatile _ClassType;
2574277217Sdim    typedef _Rp _ReturnType;
2575277217Sdim    typedef _Rp (_FnType) (_P0, ...);
2576277217Sdim};
2577277217Sdim
2578232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1>
2579232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, false>
2580227825Stheraven{
2581227825Stheraven    typedef _Class volatile _ClassType;
2582232950Stheraven    typedef _Rp _ReturnType;
2583275366Sdim    typedef _Rp (_FnType) (_P0, _P1);
2584227825Stheraven};
2585227825Stheraven
2586277217Sdimtemplate <class _Rp, class _Class, class _P0, class _P1>
2587277217Sdimstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) volatile, true, false>
2588277217Sdim{
2589277217Sdim    typedef _Class volatile _ClassType;
2590277217Sdim    typedef _Rp _ReturnType;
2591277217Sdim    typedef _Rp (_FnType) (_P0, _P1, ...);
2592277217Sdim};
2593277217Sdim
2594232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1, class _P2>
2595232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true, false>
2596227825Stheraven{
2597227825Stheraven    typedef _Class volatile _ClassType;
2598232950Stheraven    typedef _Rp _ReturnType;
2599275366Sdim    typedef _Rp (_FnType) (_P0, _P1, _P2);
2600227825Stheraven};
2601227825Stheraven
2602277217Sdimtemplate <class _Rp, class _Class, class _P0, class _P1, class _P2>
2603277217Sdimstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) volatile, true, false>
2604277217Sdim{
2605277217Sdim    typedef _Class volatile _ClassType;
2606277217Sdim    typedef _Rp _ReturnType;
2607277217Sdim    typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2608277217Sdim};
2609277217Sdim
2610232950Stheraventemplate <class _Rp, class _Class>
2611232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false>
2612227825Stheraven{
2613227825Stheraven    typedef _Class const volatile _ClassType;
2614232950Stheraven    typedef _Rp _ReturnType;
2615275366Sdim    typedef _Rp (_FnType) ();
2616227825Stheraven};
2617227825Stheraven
2618277217Sdimtemplate <class _Rp, class _Class>
2619277217Sdimstruct __member_pointer_traits_imp<_Rp (_Class::*)(...) const volatile, true, false>
2620277217Sdim{
2621277217Sdim    typedef _Class const volatile _ClassType;
2622277217Sdim    typedef _Rp _ReturnType;
2623277217Sdim    typedef _Rp (_FnType) (...);
2624277217Sdim};
2625277217Sdim
2626232950Stheraventemplate <class _Rp, class _Class, class _P0>
2627232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, false>
2628227825Stheraven{
2629227825Stheraven    typedef _Class const volatile _ClassType;
2630232950Stheraven    typedef _Rp _ReturnType;
2631275366Sdim    typedef _Rp (_FnType) (_P0);
2632227825Stheraven};
2633227825Stheraven
2634277217Sdimtemplate <class _Rp, class _Class, class _P0>
2635277217Sdimstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const volatile, true, false>
2636277217Sdim{
2637277217Sdim    typedef _Class const volatile _ClassType;
2638277217Sdim    typedef _Rp _ReturnType;
2639277217Sdim    typedef _Rp (_FnType) (_P0, ...);
2640277217Sdim};
2641277217Sdim
2642232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1>
2643232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, true, false>
2644227825Stheraven{
2645227825Stheraven    typedef _Class const volatile _ClassType;
2646232950Stheraven    typedef _Rp _ReturnType;
2647275366Sdim    typedef _Rp (_FnType) (_P0, _P1);
2648227825Stheraven};
2649227825Stheraven
2650277217Sdimtemplate <class _Rp, class _Class, class _P0, class _P1>
2651277217Sdimstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const volatile, true, false>
2652277217Sdim{
2653277217Sdim    typedef _Class const volatile _ClassType;
2654277217Sdim    typedef _Rp _ReturnType;
2655277217Sdim    typedef _Rp (_FnType) (_P0, _P1, ...);
2656277217Sdim};
2657277217Sdim
2658232950Stheraventemplate <class _Rp, class _Class, class _P0, class _P1, class _P2>
2659232950Stheravenstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile, true, false>
2660227825Stheraven{
2661227825Stheraven    typedef _Class const volatile _ClassType;
2662232950Stheraven    typedef _Rp _ReturnType;
2663275366Sdim    typedef _Rp (_FnType) (_P0, _P1, _P2);
2664227825Stheraven};
2665227825Stheraven
2666277217Sdimtemplate <class _Rp, class _Class, class _P0, class _P1, class _P2>
2667277217Sdimstruct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const volatile, true, false>
2668277217Sdim{
2669277217Sdim    typedef _Class const volatile _ClassType;
2670277217Sdim    typedef _Rp _ReturnType;
2671277217Sdim    typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2672277217Sdim};
2673277217Sdim
2674227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
2675227825Stheraven
2676232950Stheraventemplate <class _Rp, class _Class>
2677232950Stheravenstruct __member_pointer_traits_imp<_Rp _Class::*, false, true>
2678227825Stheraven{
2679227825Stheraven    typedef _Class _ClassType;
2680232950Stheraven    typedef _Rp _ReturnType;
2681227825Stheraven};
2682227825Stheraven
2683227825Stheraventemplate <class _MP>
2684227825Stheravenstruct __member_pointer_traits
2685253159Stheraven    : public __member_pointer_traits_imp<typename remove_cv<_MP>::type,
2686227825Stheraven                    is_member_function_pointer<_MP>::value,
2687227825Stheraven                    is_member_object_pointer<_MP>::value>
2688227825Stheraven{
2689227825Stheraven//     typedef ... _ClassType;
2690227825Stheraven//     typedef ... _ReturnType;
2691275366Sdim//     typedef ... _FnType;
2692227825Stheraven};
2693227825Stheraven
2694227825Stheraven// result_of
2695227825Stheraven
2696227825Stheraventemplate <class _Callable> class result_of;
2697227825Stheraven
2698241903Sdim#ifdef _LIBCPP_HAS_NO_VARIADICS
2699241903Sdim
2700227825Stheraventemplate <class _Fn, bool, bool>
2701227825Stheravenclass __result_of
2702227825Stheraven{
2703227825Stheraven};
2704227825Stheraven
2705227825Stheraventemplate <class _Fn>
2706227825Stheravenclass __result_of<_Fn(), true, false>
2707227825Stheraven{
2708227825Stheravenpublic:
2709227825Stheraven    typedef decltype(declval<_Fn>()()) type;
2710227825Stheraven};
2711227825Stheraven
2712227825Stheraventemplate <class _Fn, class _A0>
2713227825Stheravenclass __result_of<_Fn(_A0), true, false>
2714227825Stheraven{
2715227825Stheravenpublic:
2716227825Stheraven    typedef decltype(declval<_Fn>()(declval<_A0>())) type;
2717227825Stheraven};
2718227825Stheraven
2719227825Stheraventemplate <class _Fn, class _A0, class _A1>
2720227825Stheravenclass __result_of<_Fn(_A0, _A1), true, false>
2721227825Stheraven{
2722227825Stheravenpublic:
2723227825Stheraven    typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type;
2724227825Stheraven};
2725227825Stheraven
2726227825Stheraventemplate <class _Fn, class _A0, class _A1, class _A2>
2727227825Stheravenclass __result_of<_Fn(_A0, _A1, _A2), true, false>
2728227825Stheraven{
2729227825Stheravenpublic:
2730227825Stheraven    typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type;
2731227825Stheraven};
2732227825Stheraven
2733227825Stheraventemplate <class _MP, class _Tp, bool _IsMemberFunctionPtr>
2734227825Stheravenstruct __result_of_mp;
2735227825Stheraven
2736227825Stheraven// member function pointer
2737227825Stheraven
2738227825Stheraventemplate <class _MP, class _Tp>
2739227825Stheravenstruct __result_of_mp<_MP, _Tp, true>
2740288943Sdim    : public __identity<typename __member_pointer_traits<_MP>::_ReturnType>
2741227825Stheraven{
2742227825Stheraven};
2743227825Stheraven
2744227825Stheraven// member data pointer
2745227825Stheraven
2746227825Stheraventemplate <class _MP, class _Tp, bool>
2747227825Stheravenstruct __result_of_mdp;
2748227825Stheraven
2749232950Stheraventemplate <class _Rp, class _Class, class _Tp>
2750232950Stheravenstruct __result_of_mdp<_Rp _Class::*, _Tp, false>
2751227825Stheraven{
2752232950Stheraven    typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type;
2753227825Stheraven};
2754227825Stheraven
2755232950Stheraventemplate <class _Rp, class _Class, class _Tp>
2756232950Stheravenstruct __result_of_mdp<_Rp _Class::*, _Tp, true>
2757227825Stheraven{
2758232950Stheraven    typedef typename __apply_cv<_Tp, _Rp>::type& type;
2759227825Stheraven};
2760227825Stheraven
2761232950Stheraventemplate <class _Rp, class _Class, class _Tp>
2762232950Stheravenstruct __result_of_mp<_Rp _Class::*, _Tp, false>
2763232950Stheraven    : public __result_of_mdp<_Rp _Class::*, _Tp,
2764227825Stheraven            is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
2765227825Stheraven{
2766227825Stheraven};
2767227825Stheraven
2768227825Stheraven
2769227825Stheraven
2770227825Stheraventemplate <class _Fn, class _Tp>
2771227825Stheravenclass __result_of<_Fn(_Tp), false, true>  // _Fn must be member pointer
2772227825Stheraven    : public __result_of_mp<typename remove_reference<_Fn>::type,
2773227825Stheraven                            _Tp,
2774227825Stheraven                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2775227825Stheraven{
2776227825Stheraven};
2777227825Stheraven
2778227825Stheraventemplate <class _Fn, class _Tp, class _A0>
2779227825Stheravenclass __result_of<_Fn(_Tp, _A0), false, true>  // _Fn must be member pointer
2780227825Stheraven    : public __result_of_mp<typename remove_reference<_Fn>::type,
2781227825Stheraven                            _Tp,
2782227825Stheraven                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2783227825Stheraven{
2784227825Stheraven};
2785227825Stheraven
2786227825Stheraventemplate <class _Fn, class _Tp, class _A0, class _A1>
2787227825Stheravenclass __result_of<_Fn(_Tp, _A0, _A1), false, true>  // _Fn must be member pointer
2788227825Stheraven    : public __result_of_mp<typename remove_reference<_Fn>::type,
2789227825Stheraven                            _Tp,
2790227825Stheraven                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2791227825Stheraven{
2792227825Stheraven};
2793227825Stheraven
2794227825Stheraventemplate <class _Fn, class _Tp, class _A0, class _A1, class _A2>
2795227825Stheravenclass __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true>  // _Fn must be member pointer
2796227825Stheraven    : public __result_of_mp<typename remove_reference<_Fn>::type,
2797227825Stheraven                            _Tp,
2798227825Stheraven                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2799227825Stheraven{
2800227825Stheraven};
2801227825Stheraven
2802227825Stheraven// result_of
2803227825Stheraven
2804227825Stheraventemplate <class _Fn>
2805261283Sdimclass _LIBCPP_TYPE_VIS_ONLY result_of<_Fn()>
2806227825Stheraven    : public __result_of<_Fn(),
2807227825Stheraven                         is_class<typename remove_reference<_Fn>::type>::value ||
2808288943Sdim                         is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2809227825Stheraven                         is_member_pointer<typename remove_reference<_Fn>::type>::value
2810227825Stheraven                        >
2811227825Stheraven{
2812227825Stheraven};
2813227825Stheraven
2814227825Stheraventemplate <class _Fn, class _A0>
2815261283Sdimclass _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0)>
2816227825Stheraven    : public __result_of<_Fn(_A0),
2817227825Stheraven                         is_class<typename remove_reference<_Fn>::type>::value ||
2818288943Sdim                         is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2819227825Stheraven                         is_member_pointer<typename remove_reference<_Fn>::type>::value
2820227825Stheraven                        >
2821227825Stheraven{
2822227825Stheraven};
2823227825Stheraven
2824227825Stheraventemplate <class _Fn, class _A0, class _A1>
2825261283Sdimclass _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1)>
2826227825Stheraven    : public __result_of<_Fn(_A0, _A1),
2827227825Stheraven                         is_class<typename remove_reference<_Fn>::type>::value ||
2828288943Sdim                         is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2829227825Stheraven                         is_member_pointer<typename remove_reference<_Fn>::type>::value
2830227825Stheraven                        >
2831227825Stheraven{
2832227825Stheraven};
2833227825Stheraven
2834227825Stheraventemplate <class _Fn, class _A0, class _A1, class _A2>
2835261283Sdimclass _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1, _A2)>
2836227825Stheraven    : public __result_of<_Fn(_A0, _A1, _A2),
2837227825Stheraven                         is_class<typename remove_reference<_Fn>::type>::value ||
2838288943Sdim                         is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2839227825Stheraven                         is_member_pointer<typename remove_reference<_Fn>::type>::value
2840227825Stheraven                        >
2841227825Stheraven{
2842227825Stheraven};
2843227825Stheraven
2844227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
2845227825Stheraven
2846276517Sdim// template <class T, class... Args> struct is_constructible;
2847276517Sdim
2848276517Sdimnamespace __is_construct
2849276517Sdim{
2850276517Sdimstruct __nat {};
2851276517Sdim}
2852276517Sdim
2853276517Sdim#if __has_feature(is_constructible)
2854276517Sdim
2855276517Sdimtemplate <class _Tp, class ..._Args>
2856276517Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_constructible
2857276517Sdim    : public integral_constant<bool, __is_constructible(_Tp, _Args...)>
2858276517Sdim    {};
2859276517Sdim
2860276517Sdim#else
2861276517Sdim
2862227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
2863227825Stheraven
2864227825Stheraven//      main is_constructible test
2865227825Stheraven
2866227825Stheraventemplate <class _Tp, class ..._Args>
2867242945Stheraventypename __select_2nd<decltype(_VSTD::move(_Tp(_VSTD::declval<_Args>()...))), true_type>::type
2868227825Stheraven__is_constructible_test(_Tp&&, _Args&& ...);
2869227825Stheraven
2870227825Stheraventemplate <class ..._Args>
2871227825Stheravenfalse_type
2872227825Stheraven__is_constructible_test(__any, _Args&& ...);
2873227825Stheraven
2874227825Stheraventemplate <bool, class _Tp, class... _Args>
2875276517Sdimstruct __libcpp_is_constructible // false, _Tp is not a scalar
2876227825Stheraven    : public common_type
2877227825Stheraven             <
2878227825Stheraven                 decltype(__is_constructible_test(declval<_Tp>(), declval<_Args>()...))
2879227825Stheraven             >::type
2880227825Stheraven    {};
2881227825Stheraven
2882227825Stheraven//      function types are not constructible
2883227825Stheraven
2884232950Stheraventemplate <class _Rp, class... _A1, class... _A2>
2885276517Sdimstruct __libcpp_is_constructible<false, _Rp(_A1...), _A2...>
2886227825Stheraven    : public false_type
2887227825Stheraven    {};
2888227825Stheraven
2889227825Stheraven//      handle scalars and reference types
2890227825Stheraven
2891227825Stheraven//      Scalars are default constructible, references are not
2892227825Stheraven
2893227825Stheraventemplate <class _Tp>
2894276517Sdimstruct __libcpp_is_constructible<true, _Tp>
2895227825Stheraven    : public is_scalar<_Tp>
2896227825Stheraven    {};
2897227825Stheraven
2898227825Stheraven//      Scalars and references are constructible from one arg if that arg is
2899227825Stheraven//          implicitly convertible to the scalar or reference.
2900227825Stheraven
2901227825Stheraventemplate <class _Tp>
2902227825Stheravenstruct __is_constructible_ref
2903227825Stheraven{
2904242945Stheraven    true_type static __lxx(_Tp);
2905242945Stheraven    false_type static __lxx(...);
2906227825Stheraven};
2907227825Stheraven
2908227825Stheraventemplate <class _Tp, class _A0>
2909276517Sdimstruct __libcpp_is_constructible<true, _Tp, _A0>
2910227825Stheraven    : public common_type
2911227825Stheraven             <
2912242945Stheraven                 decltype(__is_constructible_ref<_Tp>::__lxx(declval<_A0>()))
2913227825Stheraven             >::type
2914227825Stheraven    {};
2915227825Stheraven
2916227825Stheraven//      Scalars and references are not constructible from multiple args.
2917227825Stheraven
2918227825Stheraventemplate <class _Tp, class _A0, class ..._Args>
2919276517Sdimstruct __libcpp_is_constructible<true, _Tp, _A0, _Args...>
2920227825Stheraven    : public false_type
2921227825Stheraven    {};
2922227825Stheraven
2923227825Stheraven//      Treat scalars and reference types separately
2924227825Stheraven
2925227825Stheraventemplate <bool, class _Tp, class... _Args>
2926227825Stheravenstruct __is_constructible_void_check
2927276517Sdim    : public __libcpp_is_constructible<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2928227825Stheraven                                _Tp, _Args...>
2929227825Stheraven    {};
2930227825Stheraven
2931227825Stheraven//      If any of T or Args is void, is_constructible should be false
2932227825Stheraven
2933227825Stheraventemplate <class _Tp, class... _Args>
2934227825Stheravenstruct __is_constructible_void_check<true, _Tp, _Args...>
2935227825Stheraven    : public false_type
2936227825Stheraven    {};
2937227825Stheraven
2938227825Stheraventemplate <class ..._Args> struct __contains_void;
2939227825Stheraven
2940227825Stheraventemplate <> struct __contains_void<> : false_type {};
2941227825Stheraven
2942227825Stheraventemplate <class _A0, class ..._Args>
2943227825Stheravenstruct __contains_void<_A0, _Args...>
2944227825Stheraven{
2945227825Stheraven    static const bool value = is_void<_A0>::value ||
2946227825Stheraven                              __contains_void<_Args...>::value;
2947227825Stheraven};
2948227825Stheraven
2949227825Stheraven//      is_constructible entry point
2950227825Stheraven
2951227825Stheraventemplate <class _Tp, class... _Args>
2952261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_constructible
2953227825Stheraven    : public __is_constructible_void_check<__contains_void<_Tp, _Args...>::value
2954227825Stheraven                                        || is_abstract<_Tp>::value,
2955227825Stheraven                                           _Tp, _Args...>
2956227825Stheraven    {};
2957227825Stheraven
2958227825Stheraven//      Array types are default constructible if their element type
2959227825Stheraven//      is default constructible
2960227825Stheraven
2961232950Stheraventemplate <class _Ap, size_t _Np>
2962276517Sdimstruct __libcpp_is_constructible<false, _Ap[_Np]>
2963232950Stheraven    : public is_constructible<typename remove_all_extents<_Ap>::type>
2964227825Stheraven    {};
2965227825Stheraven
2966227825Stheraven//      Otherwise array types are not constructible by this syntax
2967227825Stheraven
2968232950Stheraventemplate <class _Ap, size_t _Np, class ..._Args>
2969276517Sdimstruct __libcpp_is_constructible<false, _Ap[_Np], _Args...>
2970227825Stheraven    : public false_type
2971227825Stheraven    {};
2972227825Stheraven
2973227825Stheraven//      Incomplete array types are not constructible
2974227825Stheraven
2975232950Stheraventemplate <class _Ap, class ..._Args>
2976276517Sdimstruct __libcpp_is_constructible<false, _Ap[], _Args...>
2977227825Stheraven    : public false_type
2978227825Stheraven    {};
2979227825Stheraven
2980227825Stheraven#else  // _LIBCPP_HAS_NO_VARIADICS
2981227825Stheraven
2982227825Stheraven// template <class T> struct is_constructible0;
2983227825Stheraven
2984227825Stheraven//      main is_constructible0 test
2985227825Stheraven
2986227825Stheraventemplate <class _Tp>
2987227825Stheravendecltype((_Tp(), true_type()))
2988227825Stheraven__is_constructible0_test(_Tp&);
2989227825Stheraven
2990227825Stheravenfalse_type
2991227825Stheraven__is_constructible0_test(__any);
2992227825Stheraven
2993227825Stheraventemplate <class _Tp, class _A0>
2994227825Stheravendecltype((_Tp(_VSTD::declval<_A0>()), true_type()))
2995227825Stheraven__is_constructible1_test(_Tp&, _A0&);
2996227825Stheraven
2997227825Stheraventemplate <class _A0>
2998227825Stheravenfalse_type
2999227825Stheraven__is_constructible1_test(__any, _A0&);
3000227825Stheraven
3001227825Stheraventemplate <class _Tp, class _A0, class _A1>
3002227825Stheravendecltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>()), true_type()))
3003227825Stheraven__is_constructible2_test(_Tp&, _A0&, _A1&);
3004227825Stheraven
3005227825Stheraventemplate <class _A0, class _A1>
3006227825Stheravenfalse_type
3007227825Stheraven__is_constructible2_test(__any, _A0&, _A1&);
3008227825Stheraven
3009227825Stheraventemplate <bool, class _Tp>
3010227825Stheravenstruct __is_constructible0_imp // false, _Tp is not a scalar
3011227825Stheraven    : public common_type
3012227825Stheraven             <
3013227825Stheraven                 decltype(__is_constructible0_test(declval<_Tp&>()))
3014227825Stheraven             >::type
3015227825Stheraven    {};
3016227825Stheraven
3017227825Stheraventemplate <bool, class _Tp, class _A0>
3018227825Stheravenstruct __is_constructible1_imp // false, _Tp is not a scalar
3019227825Stheraven    : public common_type
3020227825Stheraven             <
3021227825Stheraven                 decltype(__is_constructible1_test(declval<_Tp&>(), declval<_A0&>()))
3022227825Stheraven             >::type
3023227825Stheraven    {};
3024227825Stheraven
3025227825Stheraventemplate <bool, class _Tp, class _A0, class _A1>
3026227825Stheravenstruct __is_constructible2_imp // false, _Tp is not a scalar
3027227825Stheraven    : public common_type
3028227825Stheraven             <
3029227825Stheraven                 decltype(__is_constructible2_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>()))
3030227825Stheraven             >::type
3031227825Stheraven    {};
3032227825Stheraven
3033227825Stheraven//      handle scalars and reference types
3034227825Stheraven
3035227825Stheraven//      Scalars are default constructible, references are not
3036227825Stheraven
3037227825Stheraventemplate <class _Tp>
3038227825Stheravenstruct __is_constructible0_imp<true, _Tp>
3039227825Stheraven    : public is_scalar<_Tp>
3040227825Stheraven    {};
3041227825Stheraven
3042227825Stheraventemplate <class _Tp, class _A0>
3043227825Stheravenstruct __is_constructible1_imp<true, _Tp, _A0>
3044227825Stheraven    : public is_convertible<_A0, _Tp>
3045227825Stheraven    {};
3046227825Stheraven
3047227825Stheraventemplate <class _Tp, class _A0, class _A1>
3048227825Stheravenstruct __is_constructible2_imp<true, _Tp, _A0, _A1>
3049227825Stheraven    : public false_type
3050227825Stheraven    {};
3051227825Stheraven
3052227825Stheraven//      Treat scalars and reference types separately
3053227825Stheraven
3054227825Stheraventemplate <bool, class _Tp>
3055227825Stheravenstruct __is_constructible0_void_check
3056227825Stheraven    : public __is_constructible0_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
3057227825Stheraven                                _Tp>
3058227825Stheraven    {};
3059227825Stheraven
3060227825Stheraventemplate <bool, class _Tp, class _A0>
3061227825Stheravenstruct __is_constructible1_void_check
3062227825Stheraven    : public __is_constructible1_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
3063227825Stheraven                                _Tp, _A0>
3064227825Stheraven    {};
3065227825Stheraven
3066227825Stheraventemplate <bool, class _Tp, class _A0, class _A1>
3067227825Stheravenstruct __is_constructible2_void_check
3068227825Stheraven    : public __is_constructible2_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
3069227825Stheraven                                _Tp, _A0, _A1>
3070227825Stheraven    {};
3071227825Stheraven
3072227825Stheraven//      If any of T or Args is void, is_constructible should be false
3073227825Stheraven
3074227825Stheraventemplate <class _Tp>
3075227825Stheravenstruct __is_constructible0_void_check<true, _Tp>
3076227825Stheraven    : public false_type
3077227825Stheraven    {};
3078227825Stheraven
3079227825Stheraventemplate <class _Tp, class _A0>
3080227825Stheravenstruct __is_constructible1_void_check<true, _Tp, _A0>
3081227825Stheraven    : public false_type
3082227825Stheraven    {};
3083227825Stheraven
3084227825Stheraventemplate <class _Tp, class _A0, class _A1>
3085227825Stheravenstruct __is_constructible2_void_check<true, _Tp, _A0, _A1>
3086227825Stheraven    : public false_type
3087227825Stheraven    {};
3088227825Stheraven
3089227825Stheraven//      is_constructible entry point
3090227825Stheraven
3091227825Stheraventemplate <class _Tp, class _A0 = __is_construct::__nat,
3092227825Stheraven                     class _A1 = __is_construct::__nat>
3093261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_constructible
3094227825Stheraven    : public __is_constructible2_void_check<is_void<_Tp>::value
3095227825Stheraven                                        || is_abstract<_Tp>::value
3096227825Stheraven                                        || is_function<_Tp>::value
3097227825Stheraven                                        || is_void<_A0>::value
3098227825Stheraven                                        || is_void<_A1>::value,
3099227825Stheraven                                           _Tp, _A0, _A1>
3100227825Stheraven    {};
3101227825Stheraven
3102227825Stheraventemplate <class _Tp>
3103261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat>
3104227825Stheraven    : public __is_constructible0_void_check<is_void<_Tp>::value
3105227825Stheraven                                        || is_abstract<_Tp>::value
3106227825Stheraven                                        || is_function<_Tp>::value,
3107227825Stheraven                                           _Tp>
3108227825Stheraven    {};
3109227825Stheraven
3110227825Stheraventemplate <class _Tp, class _A0>
3111261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, _A0, __is_construct::__nat>
3112227825Stheraven    : public __is_constructible1_void_check<is_void<_Tp>::value
3113227825Stheraven                                        || is_abstract<_Tp>::value
3114227825Stheraven                                        || is_function<_Tp>::value
3115227825Stheraven                                        || is_void<_A0>::value,
3116227825Stheraven                                           _Tp, _A0>
3117227825Stheraven    {};
3118227825Stheraven
3119227825Stheraven//      Array types are default constructible if their element type
3120227825Stheraven//      is default constructible
3121227825Stheraven
3122232950Stheraventemplate <class _Ap, size_t _Np>
3123232950Stheravenstruct __is_constructible0_imp<false, _Ap[_Np]>
3124232950Stheraven    : public is_constructible<typename remove_all_extents<_Ap>::type>
3125227825Stheraven    {};
3126227825Stheraven
3127232950Stheraventemplate <class _Ap, size_t _Np, class _A0>
3128232950Stheravenstruct __is_constructible1_imp<false, _Ap[_Np], _A0>
3129227825Stheraven    : public false_type
3130227825Stheraven    {};
3131227825Stheraven
3132232950Stheraventemplate <class _Ap, size_t _Np, class _A0, class _A1>
3133232950Stheravenstruct __is_constructible2_imp<false, _Ap[_Np], _A0, _A1>
3134227825Stheraven    : public false_type
3135227825Stheraven    {};
3136227825Stheraven
3137227825Stheraven//      Incomplete array types are not constructible
3138227825Stheraven
3139232950Stheraventemplate <class _Ap>
3140232950Stheravenstruct __is_constructible0_imp<false, _Ap[]>
3141227825Stheraven    : public false_type
3142227825Stheraven    {};
3143227825Stheraven
3144232950Stheraventemplate <class _Ap, class _A0>
3145232950Stheravenstruct __is_constructible1_imp<false, _Ap[], _A0>
3146227825Stheraven    : public false_type
3147227825Stheraven    {};
3148227825Stheraven
3149232950Stheraventemplate <class _Ap, class _A0, class _A1>
3150232950Stheravenstruct __is_constructible2_imp<false, _Ap[], _A0, _A1>
3151227825Stheraven    : public false_type
3152227825Stheraven    {};
3153227825Stheraven
3154227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
3155276517Sdim#endif  // __has_feature(is_constructible)
3156227825Stheraven
3157300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
3158300770Sdimtemplate <class _Tp, class ..._Args> _LIBCPP_CONSTEXPR bool is_constructible_v
3159300770Sdim    = is_constructible<_Tp, _Args...>::value;
3160300770Sdim#endif
3161300770Sdim
3162227825Stheraven// is_default_constructible
3163227825Stheraven
3164227825Stheraventemplate <class _Tp>
3165261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_default_constructible
3166227825Stheraven    : public is_constructible<_Tp>
3167227825Stheraven    {};
3168227825Stheraven
3169300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3170300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_default_constructible_v
3171300770Sdim    = is_default_constructible<_Tp>::value;
3172300770Sdim#endif
3173300770Sdim
3174227825Stheraven// is_copy_constructible
3175227825Stheraven
3176227825Stheraventemplate <class _Tp>
3177261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_copy_constructible
3178277217Sdim    : public is_constructible<_Tp, 
3179277217Sdim                  typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3180227825Stheraven
3181300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3182300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_constructible_v
3183300770Sdim    = is_copy_constructible<_Tp>::value;
3184300770Sdim#endif
3185300770Sdim
3186227825Stheraven// is_move_constructible
3187227825Stheraven
3188227825Stheraventemplate <class _Tp>
3189261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_move_constructible
3190227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3191227825Stheraven    : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3192227825Stheraven#else
3193227825Stheraven    : public is_copy_constructible<_Tp>
3194227825Stheraven#endif
3195227825Stheraven    {};
3196227825Stheraven
3197300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3198300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_move_constructible_v
3199300770Sdim    = is_move_constructible<_Tp>::value;
3200300770Sdim#endif
3201300770Sdim
3202227825Stheraven// is_trivially_constructible
3203227825Stheraven
3204227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
3205227825Stheraven
3206288943Sdim#if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
3207232950Stheraven
3208227825Stheraventemplate <class _Tp, class... _Args>
3209261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
3210232950Stheraven    : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
3211232950Stheraven{
3212232950Stheraven};
3213232950Stheraven
3214232950Stheraven#else  // !__has_feature(is_trivially_constructible)
3215232950Stheraven
3216232950Stheraventemplate <class _Tp, class... _Args>
3217261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
3218227825Stheraven    : false_type
3219227825Stheraven{
3220227825Stheraven};
3221227825Stheraven
3222227825Stheraventemplate <class _Tp>
3223261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp>
3224277217Sdim#if __has_feature(has_trivial_constructor) || (_GNUC_VER >= 403)
3225227825Stheraven    : integral_constant<bool, __has_trivial_constructor(_Tp)>
3226227825Stheraven#else
3227227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
3228227825Stheraven#endif
3229227825Stheraven{
3230227825Stheraven};
3231227825Stheraven
3232227825Stheraventemplate <class _Tp>
3233227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3234261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&&>
3235227825Stheraven#else
3236261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp>
3237227825Stheraven#endif
3238227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
3239227825Stheraven{
3240227825Stheraven};
3241227825Stheraven
3242227825Stheraventemplate <class _Tp>
3243261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&>
3244227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
3245227825Stheraven{
3246227825Stheraven};
3247227825Stheraven
3248227825Stheraventemplate <class _Tp>
3249261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&>
3250227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
3251227825Stheraven{
3252227825Stheraven};
3253227825Stheraven
3254232950Stheraven#endif  // !__has_feature(is_trivially_constructible)
3255232950Stheraven
3256227825Stheraven#else  // _LIBCPP_HAS_NO_VARIADICS
3257227825Stheraven
3258227825Stheraventemplate <class _Tp, class _A0 = __is_construct::__nat,
3259227825Stheraven                     class _A1 = __is_construct::__nat>
3260261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
3261227825Stheraven    : false_type
3262227825Stheraven{
3263227825Stheraven};
3264227825Stheraven
3265288943Sdim#if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
3266232950Stheraven
3267227825Stheraventemplate <class _Tp>
3268261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat,
3269227825Stheraven                                                       __is_construct::__nat>
3270232950Stheraven    : integral_constant<bool, __is_trivially_constructible(_Tp)>
3271232950Stheraven{
3272232950Stheraven};
3273232950Stheraven
3274232950Stheraventemplate <class _Tp>
3275261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp,
3276232950Stheraven                                                       __is_construct::__nat>
3277232950Stheraven    : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp)>
3278232950Stheraven{
3279232950Stheraven};
3280232950Stheraven
3281232950Stheraventemplate <class _Tp>
3282261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&,
3283232950Stheraven                                                       __is_construct::__nat>
3284232950Stheraven    : integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)>
3285232950Stheraven{
3286232950Stheraven};
3287232950Stheraven
3288232950Stheraventemplate <class _Tp>
3289261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&,
3290232950Stheraven                                                       __is_construct::__nat>
3291232950Stheraven    : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&)>
3292232950Stheraven{
3293232950Stheraven};
3294232950Stheraven
3295232950Stheraven#else  // !__has_feature(is_trivially_constructible)
3296232950Stheraven
3297232950Stheraventemplate <class _Tp>
3298261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat,
3299232950Stheraven                                                       __is_construct::__nat>
3300227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
3301227825Stheraven{
3302227825Stheraven};
3303227825Stheraven
3304227825Stheraventemplate <class _Tp>
3305261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp,
3306227825Stheraven                                                       __is_construct::__nat>
3307227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
3308227825Stheraven{
3309227825Stheraven};
3310227825Stheraven
3311227825Stheraventemplate <class _Tp>
3312261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&,
3313227825Stheraven                                                       __is_construct::__nat>
3314227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
3315227825Stheraven{
3316227825Stheraven};
3317227825Stheraven
3318227825Stheraventemplate <class _Tp>
3319261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&,
3320227825Stheraven                                                       __is_construct::__nat>
3321227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
3322227825Stheraven{
3323227825Stheraven};
3324227825Stheraven
3325232950Stheraven#endif  // !__has_feature(is_trivially_constructible)
3326232950Stheraven
3327227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
3328227825Stheraven
3329300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
3330300770Sdimtemplate <class _Tp, class... _Args> _LIBCPP_CONSTEXPR bool is_trivially_constructible_v
3331300770Sdim    = is_trivially_constructible<_Tp, _Args...>::value;
3332300770Sdim#endif
3333300770Sdim
3334227825Stheraven// is_trivially_default_constructible
3335227825Stheraven
3336261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_default_constructible
3337227825Stheraven    : public is_trivially_constructible<_Tp>
3338227825Stheraven    {};
3339227825Stheraven
3340300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3341300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v
3342300770Sdim    = is_trivially_default_constructible<_Tp>::value;
3343300770Sdim#endif
3344300770Sdim
3345227825Stheraven// is_trivially_copy_constructible
3346227825Stheraven
3347261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_constructible
3348261283Sdim    : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type>
3349227825Stheraven    {};
3350227825Stheraven
3351300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3352300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v
3353300770Sdim    = is_trivially_copy_constructible<_Tp>::value;
3354300770Sdim#endif
3355300770Sdim
3356227825Stheraven// is_trivially_move_constructible
3357227825Stheraven
3358261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_constructible
3359227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3360227825Stheraven    : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3361227825Stheraven#else
3362227825Stheraven    : public is_trivially_copy_constructible<_Tp>
3363227825Stheraven#endif
3364227825Stheraven    {};
3365227825Stheraven
3366300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3367300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v
3368300770Sdim    = is_trivially_move_constructible<_Tp>::value;
3369300770Sdim#endif
3370300770Sdim
3371227825Stheraven// is_trivially_assignable
3372227825Stheraven
3373288943Sdim#if __has_feature(is_trivially_assignable) || _GNUC_VER >= 501
3374232950Stheraven
3375227825Stheraventemplate <class _Tp, class _Arg>
3376227825Stheravenstruct is_trivially_assignable
3377232950Stheraven    : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
3378232950Stheraven{
3379232950Stheraven};
3380232950Stheraven
3381277217Sdim#else  // !__has_feature(is_trivially_assignable)
3382232950Stheraven
3383232950Stheraventemplate <class _Tp, class _Arg>
3384232950Stheravenstruct is_trivially_assignable
3385227825Stheraven    : public false_type {};
3386227825Stheraven
3387227825Stheraventemplate <class _Tp>
3388227825Stheravenstruct is_trivially_assignable<_Tp&, _Tp>
3389227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
3390227825Stheraven
3391227825Stheraventemplate <class _Tp>
3392227825Stheravenstruct is_trivially_assignable<_Tp&, _Tp&>
3393227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
3394227825Stheraven
3395227825Stheraventemplate <class _Tp>
3396227825Stheravenstruct is_trivially_assignable<_Tp&, const _Tp&>
3397227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
3398227825Stheraven
3399227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3400227825Stheraven
3401227825Stheraventemplate <class _Tp>
3402227825Stheravenstruct is_trivially_assignable<_Tp&, _Tp&&>
3403227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
3404227825Stheraven
3405227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3406227825Stheraven
3407277217Sdim#endif  // !__has_feature(is_trivially_assignable)
3408232950Stheraven
3409300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3410300770Sdimtemplate <class _Tp, class _Arg> _LIBCPP_CONSTEXPR bool is_trivially_assignable_v
3411300770Sdim    = is_trivially_assignable<_Tp, _Arg>::value;
3412300770Sdim#endif
3413300770Sdim
3414227825Stheraven// is_trivially_copy_assignable
3415227825Stheraven
3416261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_assignable
3417227825Stheraven    : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
3418277217Sdim                  typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3419227825Stheraven
3420300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3421300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v
3422300770Sdim    = is_trivially_copy_assignable<_Tp>::value;
3423300770Sdim#endif
3424300770Sdim
3425227825Stheraven// is_trivially_move_assignable
3426227825Stheraven
3427261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_assignable
3428227825Stheraven    : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
3429227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3430227825Stheraven                                     typename add_rvalue_reference<_Tp>::type>
3431227825Stheraven#else
3432227825Stheraven                                     typename add_lvalue_reference<_Tp>::type>
3433227825Stheraven#endif
3434227825Stheraven    {};
3435227825Stheraven
3436300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3437300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v
3438300770Sdim    = is_trivially_move_assignable<_Tp>::value;
3439300770Sdim#endif
3440300770Sdim
3441227825Stheraven// is_trivially_destructible
3442227825Stheraven
3443277217Sdim#if __has_feature(has_trivial_destructor) || (_GNUC_VER >= 403)
3444227825Stheraven
3445261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible
3446277217Sdim    : public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {};
3447227825Stheraven
3448277217Sdim#else
3449227825Stheraven
3450227825Stheraventemplate <class _Tp> struct __libcpp_trivial_destructor
3451227825Stheraven    : public integral_constant<bool, is_scalar<_Tp>::value ||
3452227825Stheraven                                     is_reference<_Tp>::value> {};
3453227825Stheraven
3454261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible
3455227825Stheraven    : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
3456227825Stheraven
3457300770Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible<_Tp[]>
3458300770Sdim    : public false_type {};
3459300770Sdim
3460277217Sdim#endif
3461227825Stheraven
3462300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3463300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_destructible_v
3464300770Sdim    = is_trivially_destructible<_Tp>::value;
3465300770Sdim#endif
3466300770Sdim
3467227825Stheraven// is_nothrow_constructible
3468227825Stheraven
3469275366Sdim#if 0
3470275366Sdimtemplate <class _Tp, class... _Args>
3471275366Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
3472275366Sdim    : public integral_constant<bool, __is_nothrow_constructible(_Tp(_Args...))>
3473275366Sdim{
3474275366Sdim};
3475275366Sdim
3476275366Sdim#else
3477275366Sdim
3478227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
3479227825Stheraven
3480277217Sdim#if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
3481227825Stheraven
3482277217Sdimtemplate <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;
3483227825Stheraven
3484227825Stheraventemplate <class _Tp, class... _Args>
3485277217Sdimstruct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...>
3486227825Stheraven    : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
3487227825Stheraven{
3488227825Stheraven};
3489227825Stheraven
3490277217Sdimtemplate <class _Tp>
3491277217Sdimvoid __implicit_conversion_to(_Tp) noexcept { }
3492277217Sdim
3493277217Sdimtemplate <class _Tp, class _Arg>
3494277217Sdimstruct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg>
3495277217Sdim    : public integral_constant<bool, noexcept(__implicit_conversion_to<_Tp>(declval<_Arg>()))>
3496277217Sdim{
3497277217Sdim};
3498277217Sdim
3499277217Sdimtemplate <class _Tp, bool _IsReference, class... _Args>
3500277217Sdimstruct __libcpp_is_nothrow_constructible</*is constructible*/false, _IsReference, _Tp, _Args...>
3501227825Stheraven    : public false_type
3502227825Stheraven{
3503227825Stheraven};
3504227825Stheraven
3505227825Stheraventemplate <class _Tp, class... _Args>
3506261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
3507277217Sdim    : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...>
3508227825Stheraven{
3509227825Stheraven};
3510227825Stheraven
3511227825Stheraventemplate <class _Tp, size_t _Ns>
3512261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp[_Ns]>
3513277217Sdim    : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp>
3514227825Stheraven{
3515227825Stheraven};
3516227825Stheraven
3517227825Stheraven#else  // __has_feature(cxx_noexcept)
3518227825Stheraven
3519227825Stheraventemplate <class _Tp, class... _Args>
3520261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
3521227825Stheraven    : false_type
3522227825Stheraven{
3523227825Stheraven};
3524227825Stheraven
3525227825Stheraventemplate <class _Tp>
3526261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp>
3527277217Sdim#if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
3528227825Stheraven    : integral_constant<bool, __has_nothrow_constructor(_Tp)>
3529227825Stheraven#else
3530227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
3531227825Stheraven#endif
3532227825Stheraven{
3533227825Stheraven};
3534227825Stheraven
3535227825Stheraventemplate <class _Tp>
3536227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3537261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&&>
3538227825Stheraven#else
3539261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp>
3540227825Stheraven#endif
3541277217Sdim#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3542227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
3543227825Stheraven#else
3544227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
3545227825Stheraven#endif
3546227825Stheraven{
3547227825Stheraven};
3548227825Stheraven
3549227825Stheraventemplate <class _Tp>
3550261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&>
3551277217Sdim#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3552227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
3553227825Stheraven#else
3554227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
3555227825Stheraven#endif
3556227825Stheraven{
3557227825Stheraven};
3558227825Stheraven
3559227825Stheraventemplate <class _Tp>
3560261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&>
3561277217Sdim#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3562227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
3563227825Stheraven#else
3564227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
3565227825Stheraven#endif
3566227825Stheraven{
3567227825Stheraven};
3568227825Stheraven
3569227825Stheraven#endif  // __has_feature(cxx_noexcept)
3570227825Stheraven
3571227825Stheraven#else  // _LIBCPP_HAS_NO_VARIADICS
3572227825Stheraven
3573227825Stheraventemplate <class _Tp, class _A0 = __is_construct::__nat,
3574227825Stheraven                     class _A1 = __is_construct::__nat>
3575261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
3576227825Stheraven    : false_type
3577227825Stheraven{
3578227825Stheraven};
3579227825Stheraven
3580227825Stheraventemplate <class _Tp>
3581261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, __is_construct::__nat,
3582227825Stheraven                                                       __is_construct::__nat>
3583277217Sdim#if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
3584227825Stheraven    : integral_constant<bool, __has_nothrow_constructor(_Tp)>
3585227825Stheraven#else
3586227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
3587227825Stheraven#endif
3588227825Stheraven{
3589227825Stheraven};
3590227825Stheraven
3591227825Stheraventemplate <class _Tp>
3592261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp,
3593227825Stheraven                                                       __is_construct::__nat>
3594277217Sdim#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3595227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
3596227825Stheraven#else
3597227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
3598227825Stheraven#endif
3599227825Stheraven{
3600227825Stheraven};
3601227825Stheraven
3602227825Stheraventemplate <class _Tp>
3603261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&,
3604227825Stheraven                                                       __is_construct::__nat>
3605277217Sdim#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3606227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
3607227825Stheraven#else
3608227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
3609227825Stheraven#endif
3610227825Stheraven{
3611227825Stheraven};
3612227825Stheraven
3613227825Stheraventemplate <class _Tp>
3614261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&,
3615227825Stheraven                                                       __is_construct::__nat>
3616277217Sdim#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3617227825Stheraven    : integral_constant<bool, __has_nothrow_copy(_Tp)>
3618227825Stheraven#else
3619227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value>
3620227825Stheraven#endif
3621227825Stheraven{
3622227825Stheraven};
3623227825Stheraven
3624227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
3625275366Sdim#endif  // __has_feature(is_nothrow_constructible)
3626227825Stheraven
3627300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
3628300770Sdimtemplate <class _Tp, class ..._Args> _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v
3629300770Sdim    = is_nothrow_constructible<_Tp, _Args...>::value;
3630300770Sdim#endif
3631300770Sdim
3632227825Stheraven// is_nothrow_default_constructible
3633227825Stheraven
3634261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_default_constructible
3635227825Stheraven    : public is_nothrow_constructible<_Tp>
3636227825Stheraven    {};
3637227825Stheraven
3638300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3639300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v
3640300770Sdim    = is_nothrow_default_constructible<_Tp>::value;
3641300770Sdim#endif
3642300770Sdim
3643227825Stheraven// is_nothrow_copy_constructible
3644227825Stheraven
3645261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_constructible
3646277217Sdim    : public is_nothrow_constructible<_Tp,
3647277217Sdim                  typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3648227825Stheraven
3649300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3650300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v
3651300770Sdim    = is_nothrow_copy_constructible<_Tp>::value;
3652300770Sdim#endif
3653300770Sdim
3654227825Stheraven// is_nothrow_move_constructible
3655227825Stheraven
3656261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_constructible
3657227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3658227825Stheraven    : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3659227825Stheraven#else
3660227825Stheraven    : public is_nothrow_copy_constructible<_Tp>
3661227825Stheraven#endif
3662227825Stheraven    {};
3663227825Stheraven
3664300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3665300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v
3666300770Sdim    = is_nothrow_move_constructible<_Tp>::value;
3667300770Sdim#endif
3668300770Sdim
3669227825Stheraven// is_nothrow_assignable
3670227825Stheraven
3671277217Sdim#if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
3672227825Stheraven
3673276517Sdimtemplate <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable;
3674227825Stheraven
3675227825Stheraventemplate <class _Tp, class _Arg>
3676276517Sdimstruct __libcpp_is_nothrow_assignable<false, _Tp, _Arg>
3677227825Stheraven    : public false_type
3678227825Stheraven{
3679227825Stheraven};
3680227825Stheraven
3681227825Stheraventemplate <class _Tp, class _Arg>
3682276517Sdimstruct __libcpp_is_nothrow_assignable<true, _Tp, _Arg>
3683227825Stheraven    : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) >
3684227825Stheraven{
3685227825Stheraven};
3686227825Stheraven
3687227825Stheraventemplate <class _Tp, class _Arg>
3688261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable
3689276517Sdim    : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
3690227825Stheraven{
3691227825Stheraven};
3692227825Stheraven
3693227825Stheraven#else  // __has_feature(cxx_noexcept)
3694227825Stheraven
3695227825Stheraventemplate <class _Tp, class _Arg>
3696261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable
3697227825Stheraven    : public false_type {};
3698227825Stheraven
3699227825Stheraventemplate <class _Tp>
3700261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp>
3701277217Sdim#if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3702227825Stheraven    : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3703227825Stheraven#else
3704227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
3705227825Stheraven#endif
3706227825Stheraven
3707227825Stheraventemplate <class _Tp>
3708261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp&>
3709277217Sdim#if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3710227825Stheraven    : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3711227825Stheraven#else
3712227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
3713227825Stheraven#endif
3714227825Stheraven
3715227825Stheraventemplate <class _Tp>
3716261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, const _Tp&>
3717277217Sdim#if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3718227825Stheraven    : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3719227825Stheraven#else
3720227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
3721227825Stheraven#endif
3722227825Stheraven
3723227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3724227825Stheraven
3725227825Stheraventemplate <class _Tp>
3726227825Stheravenstruct is_nothrow_assignable<_Tp&, _Tp&&>
3727277217Sdim#if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3728227825Stheraven    : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3729227825Stheraven#else
3730227825Stheraven    : integral_constant<bool, is_scalar<_Tp>::value> {};
3731227825Stheraven#endif
3732227825Stheraven
3733227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3734227825Stheraven
3735227825Stheraven#endif  // __has_feature(cxx_noexcept)
3736227825Stheraven
3737300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3738300770Sdimtemplate <class _Tp, class _Arg> _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v
3739300770Sdim    = is_nothrow_assignable<_Tp, _Arg>::value;
3740300770Sdim#endif
3741300770Sdim
3742227825Stheraven// is_nothrow_copy_assignable
3743227825Stheraven
3744261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_assignable
3745227825Stheraven    : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3746277217Sdim                  typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3747227825Stheraven
3748300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3749300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v
3750300770Sdim    = is_nothrow_copy_assignable<_Tp>::value;
3751300770Sdim#endif
3752300770Sdim
3753227825Stheraven// is_nothrow_move_assignable
3754227825Stheraven
3755261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_assignable
3756227825Stheraven    : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3757227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3758227825Stheraven                                     typename add_rvalue_reference<_Tp>::type>
3759227825Stheraven#else
3760227825Stheraven                                     typename add_lvalue_reference<_Tp>::type>
3761227825Stheraven#endif
3762227825Stheraven    {};
3763227825Stheraven
3764300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3765300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v
3766300770Sdim    = is_nothrow_move_assignable<_Tp>::value;
3767300770Sdim#endif
3768300770Sdim
3769227825Stheraven// is_nothrow_destructible
3770227825Stheraven
3771277217Sdim#if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
3772227825Stheraven
3773276517Sdimtemplate <bool, class _Tp> struct __libcpp_is_nothrow_destructible;
3774227825Stheraven
3775227825Stheraventemplate <class _Tp>
3776276517Sdimstruct __libcpp_is_nothrow_destructible<false, _Tp>
3777227825Stheraven    : public false_type
3778227825Stheraven{
3779227825Stheraven};
3780227825Stheraven
3781227825Stheraventemplate <class _Tp>
3782276517Sdimstruct __libcpp_is_nothrow_destructible<true, _Tp>
3783227825Stheraven    : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) >
3784227825Stheraven{
3785227825Stheraven};
3786227825Stheraven
3787227825Stheraventemplate <class _Tp>
3788261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible
3789276517Sdim    : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
3790227825Stheraven{
3791227825Stheraven};
3792227825Stheraven
3793227825Stheraventemplate <class _Tp, size_t _Ns>
3794261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp[_Ns]>
3795227825Stheraven    : public is_nothrow_destructible<_Tp>
3796227825Stheraven{
3797227825Stheraven};
3798227825Stheraven
3799227825Stheraventemplate <class _Tp>
3800261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&>
3801227825Stheraven    : public true_type
3802227825Stheraven{
3803227825Stheraven};
3804227825Stheraven
3805227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3806227825Stheraven
3807227825Stheraventemplate <class _Tp>
3808261283Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&&>
3809227825Stheraven    : public true_type
3810227825Stheraven{
3811227825Stheraven};
3812227825Stheraven
3813227825Stheraven#endif
3814227825Stheraven
3815227825Stheraven#else
3816227825Stheraven
3817227825Stheraventemplate <class _Tp> struct __libcpp_nothrow_destructor
3818227825Stheraven    : public integral_constant<bool, is_scalar<_Tp>::value ||
3819227825Stheraven                                     is_reference<_Tp>::value> {};
3820227825Stheraven
3821261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible
3822227825Stheraven    : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
3823227825Stheraven
3824300770Sdimtemplate <class _Tp>
3825300770Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp[]>
3826300770Sdim    : public false_type {};
3827300770Sdim
3828227825Stheraven#endif
3829227825Stheraven
3830300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3831300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v
3832300770Sdim    = is_nothrow_destructible<_Tp>::value;
3833300770Sdim#endif
3834300770Sdim
3835227825Stheraven// is_pod
3836227825Stheraven
3837277217Sdim#if __has_feature(is_pod) || (_GNUC_VER >= 403)
3838227825Stheraven
3839261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod
3840227825Stheraven    : public integral_constant<bool, __is_pod(_Tp)> {};
3841227825Stheraven
3842277217Sdim#else
3843227825Stheraven
3844261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod
3845227825Stheraven    : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value   &&
3846227825Stheraven                                     is_trivially_copy_constructible<_Tp>::value      &&
3847227825Stheraven                                     is_trivially_copy_assignable<_Tp>::value    &&
3848227825Stheraven                                     is_trivially_destructible<_Tp>::value> {};
3849227825Stheraven
3850277217Sdim#endif
3851227825Stheraven
3852300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3853300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_pod_v
3854300770Sdim    = is_pod<_Tp>::value;
3855300770Sdim#endif
3856300770Sdim
3857227825Stheraven// is_literal_type;
3858227825Stheraven
3859261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_literal_type
3860277217Sdim#ifdef _LIBCPP_IS_LITERAL
3861277217Sdim    : public integral_constant<bool, _LIBCPP_IS_LITERAL(_Tp)>
3862227825Stheraven#else
3863227825Stheraven    : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value ||
3864227825Stheraven                              is_reference<typename remove_all_extents<_Tp>::type>::value>
3865227825Stheraven#endif
3866227825Stheraven    {};
3867227825Stheraven    
3868300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3869300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_literal_type_v
3870300770Sdim    = is_literal_type<_Tp>::value;
3871300770Sdim#endif
3872300770Sdim
3873227825Stheraven// is_standard_layout;
3874227825Stheraven
3875261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_standard_layout
3876277217Sdim#if __has_feature(is_standard_layout) || (_GNUC_VER >= 407)
3877227825Stheraven    : public integral_constant<bool, __is_standard_layout(_Tp)>
3878227825Stheraven#else
3879227825Stheraven    : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
3880227825Stheraven#endif
3881227825Stheraven    {};
3882227825Stheraven    
3883300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3884300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_standard_layout_v
3885300770Sdim    = is_standard_layout<_Tp>::value;
3886300770Sdim#endif
3887300770Sdim
3888227825Stheraven// is_trivially_copyable;
3889227825Stheraven
3890261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copyable
3891227825Stheraven#if __has_feature(is_trivially_copyable)
3892227825Stheraven    : public integral_constant<bool, __is_trivially_copyable(_Tp)>
3893288943Sdim#elif _GNUC_VER >= 501
3894288943Sdim    : public integral_constant<bool, !is_volatile<_Tp>::value && __is_trivially_copyable(_Tp)>
3895227825Stheraven#else
3896227825Stheraven    : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
3897227825Stheraven#endif
3898227825Stheraven    {};
3899227825Stheraven    
3900300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3901300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copyable_v
3902300770Sdim    = is_trivially_copyable<_Tp>::value;
3903300770Sdim#endif
3904300770Sdim
3905227825Stheraven// is_trivial;
3906227825Stheraven
3907261283Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivial
3908288943Sdim#if __has_feature(is_trivial) || _GNUC_VER >= 407
3909227825Stheraven    : public integral_constant<bool, __is_trivial(_Tp)>
3910227825Stheraven#else
3911227825Stheraven    : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
3912227825Stheraven                                 is_trivially_default_constructible<_Tp>::value>
3913227825Stheraven#endif
3914227825Stheraven    {};
3915227825Stheraven
3916300770Sdim#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3917300770Sdimtemplate <class _Tp> _LIBCPP_CONSTEXPR bool is_trivial_v
3918300770Sdim    = is_trivial<_Tp>::value;
3919300770Sdim#endif
3920300770Sdim
3921227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
3922227825Stheraven
3923227825Stheraven// Check for complete types
3924227825Stheraven
3925232950Stheraventemplate <class ..._Tp> struct __check_complete;
3926227825Stheraven
3927227825Stheraventemplate <>
3928227825Stheravenstruct __check_complete<>
3929227825Stheraven{
3930227825Stheraven};
3931227825Stheraven
3932232950Stheraventemplate <class _Hp, class _T0, class ..._Tp>
3933232950Stheravenstruct __check_complete<_Hp, _T0, _Tp...>
3934232950Stheraven    : private __check_complete<_Hp>,
3935232950Stheraven      private __check_complete<_T0, _Tp...>
3936227825Stheraven{
3937227825Stheraven};
3938227825Stheraven
3939232950Stheraventemplate <class _Hp>
3940232950Stheravenstruct __check_complete<_Hp, _Hp>
3941232950Stheraven    : private __check_complete<_Hp>
3942227825Stheraven{
3943227825Stheraven};
3944227825Stheraven
3945232950Stheraventemplate <class _Tp>
3946232950Stheravenstruct __check_complete<_Tp>
3947227825Stheraven{
3948232950Stheraven    static_assert(sizeof(_Tp) > 0, "Type must be complete.");
3949227825Stheraven};
3950227825Stheraven
3951232950Stheraventemplate <class _Tp>
3952232950Stheravenstruct __check_complete<_Tp&>
3953232950Stheraven    : private __check_complete<_Tp>
3954227825Stheraven{
3955227825Stheraven};
3956227825Stheraven
3957232950Stheraventemplate <class _Tp>
3958232950Stheravenstruct __check_complete<_Tp&&>
3959232950Stheraven    : private __check_complete<_Tp>
3960227825Stheraven{
3961227825Stheraven};
3962227825Stheraven
3963232950Stheraventemplate <class _Rp, class ..._Param>
3964232950Stheravenstruct __check_complete<_Rp (*)(_Param...)>
3965241903Sdim    : private __check_complete<_Rp>
3966227825Stheraven{
3967227825Stheraven};
3968227825Stheraven
3969261283Sdimtemplate <class ..._Param>
3970261283Sdimstruct __check_complete<void (*)(_Param...)>
3971261283Sdim{
3972261283Sdim};
3973261283Sdim
3974232950Stheraventemplate <class _Rp, class ..._Param>
3975232950Stheravenstruct __check_complete<_Rp (_Param...)>
3976241903Sdim    : private __check_complete<_Rp>
3977227825Stheraven{
3978227825Stheraven};
3979227825Stheraven
3980261283Sdimtemplate <class ..._Param>
3981261283Sdimstruct __check_complete<void (_Param...)>
3982261283Sdim{
3983261283Sdim};
3984261283Sdim
3985232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
3986232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...)>
3987241903Sdim    : private __check_complete<_Class>
3988227825Stheraven{
3989227825Stheraven};
3990227825Stheraven
3991232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
3992232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) const>
3993241903Sdim    : private __check_complete<_Class>
3994227825Stheraven{
3995227825Stheraven};
3996227825Stheraven
3997232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
3998232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) volatile>
3999241903Sdim    : private __check_complete<_Class>
4000227825Stheraven{
4001227825Stheraven};
4002227825Stheraven
4003232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
4004232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) const volatile>
4005241903Sdim    : private __check_complete<_Class>
4006227825Stheraven{
4007227825Stheraven};
4008227825Stheraven
4009227825Stheraven#if __has_feature(cxx_reference_qualified_functions)
4010227825Stheraven
4011232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
4012232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) &>
4013241903Sdim    : private __check_complete<_Class>
4014227825Stheraven{
4015227825Stheraven};
4016227825Stheraven
4017232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
4018232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) const&>
4019241903Sdim    : private __check_complete<_Class>
4020227825Stheraven{
4021227825Stheraven};
4022227825Stheraven
4023232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
4024232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) volatile&>
4025241903Sdim    : private __check_complete<_Class>
4026227825Stheraven{
4027227825Stheraven};
4028227825Stheraven
4029232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
4030232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) const volatile&>
4031241903Sdim    : private __check_complete<_Class>
4032227825Stheraven{
4033227825Stheraven};
4034227825Stheraven
4035232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
4036232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) &&>
4037241903Sdim    : private __check_complete<_Class>
4038227825Stheraven{
4039227825Stheraven};
4040227825Stheraven
4041232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
4042232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) const&&>
4043241903Sdim    : private __check_complete<_Class>
4044227825Stheraven{
4045227825Stheraven};
4046227825Stheraven
4047232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
4048232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) volatile&&>
4049241903Sdim    : private __check_complete<_Class>
4050227825Stheraven{
4051227825Stheraven};
4052227825Stheraven
4053232950Stheraventemplate <class _Rp, class _Class, class ..._Param>
4054232950Stheravenstruct __check_complete<_Rp (_Class::*)(_Param...) const volatile&&>
4055241903Sdim    : private __check_complete<_Class>
4056227825Stheraven{
4057227825Stheraven};
4058227825Stheraven
4059227825Stheraven#endif
4060227825Stheraven
4061232950Stheraventemplate <class _Rp, class _Class>
4062232950Stheravenstruct __check_complete<_Rp _Class::*>
4063227825Stheraven    : private __check_complete<_Class>
4064227825Stheraven{
4065227825Stheraven};
4066227825Stheraven
4067227825Stheraven// __invoke forward declarations
4068227825Stheraven
4069227825Stheraven// fall back - none of the bullets
4070227825Stheraven
4071227825Stheraventemplate <class ..._Args>
4072227825Stheravenauto
4073227825Stheraven__invoke(__any, _Args&& ...__args)
4074227825Stheraven    -> __nat;
4075227825Stheraven
4076227825Stheraven// bullets 1 and 2
4077227825Stheraven
4078253159Stheraventemplate <class _Fp, class _A0, class ..._Args,
4079253159Stheraven            class = typename enable_if
4080253159Stheraven            <
4081253159Stheraven                is_member_function_pointer<typename remove_reference<_Fp>::type>::value &&
4082277217Sdim                is_base_of<typename remove_reference<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType>::type,
4083253159Stheraven                           typename remove_reference<_A0>::type>::value
4084253159Stheraven            >::type
4085253159Stheraven         >
4086241903Sdim_LIBCPP_INLINE_VISIBILITY
4087227825Stheravenauto
4088232950Stheraven__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4089227825Stheraven    -> decltype((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...));
4090227825Stheraven
4091253159Stheraventemplate <class _Fp, class _A0, class ..._Args,
4092253159Stheraven            class = typename enable_if
4093253159Stheraven            <
4094253159Stheraven                is_member_function_pointer<typename remove_reference<_Fp>::type>::value &&
4095277217Sdim                !is_base_of<typename remove_reference<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType>::type,
4096253159Stheraven                           typename remove_reference<_A0>::type>::value
4097253159Stheraven            >::type
4098253159Stheraven         >
4099241903Sdim_LIBCPP_INLINE_VISIBILITY
4100227825Stheravenauto
4101232950Stheraven__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4102227825Stheraven    -> decltype(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...));
4103227825Stheraven
4104227825Stheraven// bullets 3 and 4
4105227825Stheraven
4106253159Stheraventemplate <class _Fp, class _A0,
4107253159Stheraven            class = typename enable_if
4108253159Stheraven            <
4109253159Stheraven                is_member_object_pointer<typename remove_reference<_Fp>::type>::value &&
4110253159Stheraven                is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType,
4111253159Stheraven                           typename remove_reference<_A0>::type>::value
4112253159Stheraven            >::type
4113253159Stheraven         >
4114241903Sdim_LIBCPP_INLINE_VISIBILITY
4115227825Stheravenauto
4116232950Stheraven__invoke(_Fp&& __f, _A0&& __a0)
4117227825Stheraven    -> decltype(_VSTD::forward<_A0>(__a0).*__f);
4118227825Stheraven
4119253159Stheraventemplate <class _Fp, class _A0,
4120253159Stheraven            class = typename enable_if
4121253159Stheraven            <
4122253159Stheraven                is_member_object_pointer<typename remove_reference<_Fp>::type>::value &&
4123253159Stheraven                !is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType,
4124253159Stheraven                           typename remove_reference<_A0>::type>::value
4125253159Stheraven            >::type
4126253159Stheraven         >
4127241903Sdim_LIBCPP_INLINE_VISIBILITY
4128227825Stheravenauto
4129232950Stheraven__invoke(_Fp&& __f, _A0&& __a0)
4130227825Stheraven    -> decltype((*_VSTD::forward<_A0>(__a0)).*__f);
4131227825Stheraven
4132227825Stheraven// bullet 5
4133227825Stheraven
4134232950Stheraventemplate <class _Fp, class ..._Args>
4135241903Sdim_LIBCPP_INLINE_VISIBILITY
4136227825Stheravenauto
4137232950Stheraven__invoke(_Fp&& __f, _Args&& ...__args)
4138232950Stheraven    -> decltype(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...));
4139227825Stheraven
4140227825Stheraven// __invokable
4141227825Stheraven
4142232950Stheraventemplate <class _Fp, class ..._Args>
4143227825Stheravenstruct __invokable_imp
4144241903Sdim    : private __check_complete<_Fp>
4145227825Stheraven{
4146227825Stheraven    typedef decltype(
4147232950Stheraven            __invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)
4148227825Stheraven                    ) type;
4149227825Stheraven    static const bool value = !is_same<type, __nat>::value;
4150227825Stheraven};
4151227825Stheraven
4152232950Stheraventemplate <class _Fp, class ..._Args>
4153227825Stheravenstruct __invokable
4154227825Stheraven    : public integral_constant<bool,
4155232950Stheraven          __invokable_imp<_Fp, _Args...>::value>
4156227825Stheraven{
4157227825Stheraven};
4158227825Stheraven
4159227825Stheraven// __invoke_of
4160227825Stheraven
4161232950Stheraventemplate <bool _Invokable, class _Fp, class ..._Args>
4162227825Stheravenstruct __invoke_of_imp  // false
4163227825Stheraven{
4164227825Stheraven};
4165227825Stheraven
4166232950Stheraventemplate <class _Fp, class ..._Args>
4167232950Stheravenstruct __invoke_of_imp<true, _Fp, _Args...>
4168227825Stheraven{
4169232950Stheraven    typedef typename __invokable_imp<_Fp, _Args...>::type type;
4170227825Stheraven};
4171227825Stheraven
4172232950Stheraventemplate <class _Fp, class ..._Args>
4173227825Stheravenstruct __invoke_of
4174232950Stheraven    : public __invoke_of_imp<__invokable<_Fp, _Args...>::value, _Fp, _Args...>
4175227825Stheraven{
4176227825Stheraven};
4177227825Stheraven
4178241903Sdimtemplate <class _Fp, class ..._Args>
4179261283Sdimclass _LIBCPP_TYPE_VIS_ONLY result_of<_Fp(_Args...)>
4180241903Sdim    : public __invoke_of<_Fp, _Args...>
4181241903Sdim{
4182241903Sdim};
4183241903Sdim
4184253159Stheraven#if _LIBCPP_STD_VER > 11
4185253159Stheraventemplate <class _Tp> using result_of_t = typename result_of<_Tp>::type;
4186253159Stheraven#endif
4187253159Stheraven
4188227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
4189227825Stheraven
4190227825Stheraventemplate <class _Tp>
4191227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
4192227825Stheraven#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
4193227825Stheraventypename enable_if
4194227825Stheraven<
4195227825Stheraven    is_move_constructible<_Tp>::value &&
4196227825Stheraven    is_move_assignable<_Tp>::value
4197227825Stheraven>::type
4198227825Stheraven#else
4199227825Stheravenvoid
4200227825Stheraven#endif
4201227825Stheravenswap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
4202227825Stheraven                                    is_nothrow_move_assignable<_Tp>::value)
4203227825Stheraven{
4204227825Stheraven    _Tp __t(_VSTD::move(__x));
4205227825Stheraven    __x = _VSTD::move(__y);
4206227825Stheraven    __y = _VSTD::move(__t);
4207227825Stheraven}
4208227825Stheraven
4209227825Stheraventemplate <class _ForwardIterator1, class _ForwardIterator2>
4210227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
4211227825Stheravenvoid
4212227825Stheraveniter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
4213227825Stheraven    //                                  _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
4214227825Stheraven               _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(),
4215227825Stheraven                                          *_VSTD::declval<_ForwardIterator2>())))
4216227825Stheraven{
4217227825Stheraven    swap(*__a, *__b);
4218227825Stheraven}
4219227825Stheraven
4220227825Stheraven// __swappable
4221227825Stheraven
4222227825Stheravennamespace __detail
4223227825Stheraven{
4224227825Stheraven
4225227825Stheravenusing _VSTD::swap;
4226227825Stheraven__nat swap(__any, __any);
4227227825Stheraven
4228227825Stheraventemplate <class _Tp>
4229227825Stheravenstruct __swappable
4230227825Stheraven{
4231227825Stheraven    typedef decltype(swap(_VSTD::declval<_Tp&>(), _VSTD::declval<_Tp&>())) type;
4232227825Stheraven    static const bool value = !is_same<type, __nat>::value;
4233227825Stheraven};
4234227825Stheraven
4235227825Stheraven}  // __detail
4236227825Stheraven
4237227825Stheraventemplate <class _Tp>
4238227825Stheravenstruct __is_swappable
4239227825Stheraven    : public integral_constant<bool, __detail::__swappable<_Tp>::value>
4240227825Stheraven{
4241227825Stheraven};
4242227825Stheraven
4243277217Sdim#if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
4244227825Stheraven
4245227825Stheraventemplate <bool, class _Tp>
4246227825Stheravenstruct __is_nothrow_swappable_imp
4247227825Stheraven    : public integral_constant<bool, noexcept(swap(_VSTD::declval<_Tp&>(),
4248227825Stheraven                                                   _VSTD::declval<_Tp&>()))>
4249227825Stheraven{
4250227825Stheraven};
4251227825Stheraven
4252227825Stheraventemplate <class _Tp>
4253227825Stheravenstruct __is_nothrow_swappable_imp<false, _Tp>
4254227825Stheraven    : public false_type
4255227825Stheraven{
4256227825Stheraven};
4257227825Stheraven
4258227825Stheraventemplate <class _Tp>
4259227825Stheravenstruct __is_nothrow_swappable
4260227825Stheraven    : public __is_nothrow_swappable_imp<__is_swappable<_Tp>::value, _Tp>
4261227825Stheraven{
4262227825Stheraven};
4263227825Stheraven
4264227825Stheraven#else  // __has_feature(cxx_noexcept)
4265227825Stheraven
4266227825Stheraventemplate <class _Tp>
4267227825Stheravenstruct __is_nothrow_swappable
4268227825Stheraven    : public false_type
4269227825Stheraven{
4270227825Stheraven};
4271227825Stheraven
4272227825Stheraven#endif  // __has_feature(cxx_noexcept)
4273227825Stheraven
4274277217Sdim#ifdef _LIBCPP_UNDERLYING_TYPE
4275227825Stheraven
4276227825Stheraventemplate <class _Tp>
4277227825Stheravenstruct underlying_type
4278227825Stheraven{
4279277217Sdim    typedef _LIBCPP_UNDERLYING_TYPE(_Tp) type;
4280227825Stheraven};
4281227825Stheraven
4282253159Stheraven#if _LIBCPP_STD_VER > 11
4283253159Stheraventemplate <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
4284253159Stheraven#endif
4285253159Stheraven
4286277217Sdim#else  // _LIBCPP_UNDERLYING_TYPE
4287227825Stheraven
4288227825Stheraventemplate <class _Tp, bool _Support = false>
4289227825Stheravenstruct underlying_type
4290227825Stheraven{
4291227825Stheraven    static_assert(_Support, "The underyling_type trait requires compiler "
4292227825Stheraven                            "support. Either no such support exists or "
4293227825Stheraven                            "libc++ does not know how to use it.");
4294227825Stheraven};
4295227825Stheraven
4296277217Sdim#endif // _LIBCPP_UNDERLYING_TYPE
4297227825Stheraven
4298288943Sdim
4299288943Sdimtemplate <class _Tp, bool = std::is_enum<_Tp>::value>
4300288943Sdimstruct __sfinae_underlying_type
4301288943Sdim{
4302288943Sdim    typedef typename underlying_type<_Tp>::type type;
4303288943Sdim    typedef decltype(((type)1) + 0) __promoted_type;
4304288943Sdim};
4305288943Sdim
4306288943Sdimtemplate <class _Tp>
4307288943Sdimstruct __sfinae_underlying_type<_Tp, false> {};
4308288943Sdim
4309300770Sdiminline _LIBCPP_INLINE_VISIBILITY
4310288943Sdimint __convert_to_integral(int __val) { return __val; }
4311288943Sdim
4312300770Sdiminline _LIBCPP_INLINE_VISIBILITY
4313288943Sdimunsigned __convert_to_integral(unsigned __val) { return __val; }
4314288943Sdim
4315300770Sdiminline _LIBCPP_INLINE_VISIBILITY
4316288943Sdimlong __convert_to_integral(long __val) { return __val; }
4317288943Sdim
4318300770Sdiminline _LIBCPP_INLINE_VISIBILITY
4319288943Sdimunsigned long __convert_to_integral(unsigned long __val) { return __val; }
4320288943Sdim
4321300770Sdiminline _LIBCPP_INLINE_VISIBILITY
4322288943Sdimlong long __convert_to_integral(long long __val) { return __val; }
4323288943Sdim
4324300770Sdiminline _LIBCPP_INLINE_VISIBILITY
4325288943Sdimunsigned long long __convert_to_integral(unsigned long long __val) {return __val; }
4326288943Sdim
4327288943Sdim#ifndef _LIBCPP_HAS_NO_INT128
4328300770Sdiminline _LIBCPP_INLINE_VISIBILITY
4329288943Sdim__int128_t __convert_to_integral(__int128_t __val) { return __val; }
4330288943Sdim
4331300770Sdiminline _LIBCPP_INLINE_VISIBILITY
4332288943Sdim__uint128_t __convert_to_integral(__uint128_t __val) { return __val; }
4333288943Sdim#endif
4334288943Sdim
4335288943Sdimtemplate <class _Tp>
4336300770Sdiminline _LIBCPP_INLINE_VISIBILITY
4337288943Sdimtypename __sfinae_underlying_type<_Tp>::__promoted_type
4338288943Sdim__convert_to_integral(_Tp __val) { return __val; }
4339288943Sdim
4340261283Sdim#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
4341261283Sdim
4342261283Sdimtemplate <class _Tp>
4343277217Sdimstruct __has_operator_addressof_member_imp
4344261283Sdim{
4345277217Sdim    template <class _Up>
4346277217Sdim        static auto __test(int)
4347277217Sdim            -> typename __select_2nd<decltype(_VSTD::declval<_Up>().operator&()), true_type>::type;
4348261283Sdim    template <class>
4349277217Sdim        static auto __test(long) -> false_type;
4350277217Sdim
4351277217Sdim    static const bool value = decltype(__test<_Tp>(0))::value;
4352277217Sdim};
4353277217Sdim
4354277217Sdimtemplate <class _Tp>
4355277217Sdimstruct __has_operator_addressof_free_imp
4356277217Sdim{
4357261283Sdim    template <class _Up>
4358277217Sdim        static auto __test(int)
4359277217Sdim            -> typename __select_2nd<decltype(operator&(_VSTD::declval<_Up>())), true_type>::type;
4360277217Sdim    template <class>
4361277217Sdim        static auto __test(long) -> false_type;
4362261283Sdim
4363277217Sdim    static const bool value = decltype(__test<_Tp>(0))::value;
4364261283Sdim};
4365261283Sdim
4366261283Sdimtemplate <class _Tp>
4367261283Sdimstruct __has_operator_addressof
4368277217Sdim    : public integral_constant<bool, __has_operator_addressof_member_imp<_Tp>::value
4369277217Sdim                                  || __has_operator_addressof_free_imp<_Tp>::value>
4370261283Sdim{};
4371261283Sdim
4372261283Sdim#endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
4373261283Sdim
4374277217Sdim#if _LIBCPP_STD_VER > 14
4375277217Sdimtemplate <class...> using void_t = void;
4376277217Sdim
4377300770Sdim# ifndef _LIBCPP_HAS_NO_VARIADICS
4378300770Sdimtemplate <class... _Args>
4379300770Sdimstruct conjunction : __and_<_Args...> {};
4380300770Sdimtemplate<class... _Args> constexpr bool conjunction_v = conjunction<_Args...>::value;
4381300770Sdim
4382300770Sdimtemplate <class... _Args>
4383300770Sdimstruct disjunction : __or_<_Args...> {};
4384300770Sdimtemplate<class... _Args> constexpr bool disjunction_v = disjunction<_Args...>::value;
4385300770Sdim
4386300770Sdimtemplate <class _Tp>
4387300770Sdimstruct negation : __not_<_Tp> {};
4388300770Sdimtemplate<class _Tp> constexpr bool negation_v = negation<_Tp>::value;
4389300770Sdim# endif // _LIBCPP_HAS_NO_VARIADICS
4390300770Sdim#endif  // _LIBCPP_STD_VER > 14
4391300770Sdim
4392227825Stheraven_LIBCPP_END_NAMESPACE_STD
4393227825Stheraven
4394227825Stheraven#endif  // _LIBCPP_TYPE_TRAITS
4395