1// -*- C++ -*- 2//===------------------------ type_traits ---------------------------------===// 3// 4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5// See https://llvm.org/LICENSE.txt for license information. 6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7// 8//===----------------------------------------------------------------------===// 9 10#ifndef _LIBCPP_TYPE_TRAITS 11#define _LIBCPP_TYPE_TRAITS 12 13/* 14 type_traits synopsis 15 16namespace std 17{ 18 19 // helper class: 20 template <class T, T v> struct integral_constant; 21 typedef integral_constant<bool, true> true_type; // C++11 22 typedef integral_constant<bool, false> false_type; // C++11 23 24 template <bool B> // C++14 25 using bool_constant = integral_constant<bool, B>; // C++14 26 typedef bool_constant<true> true_type; // C++14 27 typedef bool_constant<false> false_type; // C++14 28 29 // helper traits 30 template <bool, class T = void> struct enable_if; 31 template <bool, class T, class F> struct conditional; 32 33 // Primary classification traits: 34 template <class T> struct is_void; 35 template <class T> struct is_null_pointer; // C++14 36 template <class T> struct is_integral; 37 template <class T> struct is_floating_point; 38 template <class T> struct is_array; 39 template <class T> struct is_pointer; 40 template <class T> struct is_lvalue_reference; 41 template <class T> struct is_rvalue_reference; 42 template <class T> struct is_member_object_pointer; 43 template <class T> struct is_member_function_pointer; 44 template <class T> struct is_enum; 45 template <class T> struct is_union; 46 template <class T> struct is_class; 47 template <class T> struct is_function; 48 49 // Secondary classification traits: 50 template <class T> struct is_reference; 51 template <class T> struct is_arithmetic; 52 template <class T> struct is_fundamental; 53 template <class T> struct is_member_pointer; 54 template <class T> struct is_scalar; 55 template <class T> struct is_object; 56 template <class T> struct is_compound; 57 58 // Const-volatile properties and transformations: 59 template <class T> struct is_const; 60 template <class T> struct is_volatile; 61 template <class T> struct remove_const; 62 template <class T> struct remove_volatile; 63 template <class T> struct remove_cv; 64 template <class T> struct add_const; 65 template <class T> struct add_volatile; 66 template <class T> struct add_cv; 67 68 // Reference transformations: 69 template <class T> struct remove_reference; 70 template <class T> struct add_lvalue_reference; 71 template <class T> struct add_rvalue_reference; 72 73 // Pointer transformations: 74 template <class T> struct remove_pointer; 75 template <class T> struct add_pointer; 76 77 template<class T> struct type_identity; // C++20 78 template<class T> 79 using type_identity_t = typename type_identity<T>::type; // C++20 80 81 // Integral properties: 82 template <class T> struct is_signed; 83 template <class T> struct is_unsigned; 84 template <class T> struct make_signed; 85 template <class T> struct make_unsigned; 86 87 // Array properties and transformations: 88 template <class T> struct rank; 89 template <class T, unsigned I = 0> struct extent; 90 template <class T> struct remove_extent; 91 template <class T> struct remove_all_extents; 92 93 template <class T> struct is_bounded_array; // C++20 94 template <class T> struct is_unbounded_array; // C++20 95 96 // Member introspection: 97 template <class T> struct is_pod; 98 template <class T> struct is_trivial; 99 template <class T> struct is_trivially_copyable; 100 template <class T> struct is_standard_layout; 101 template <class T> struct is_literal_type; 102 template <class T> struct is_empty; 103 template <class T> struct is_polymorphic; 104 template <class T> struct is_abstract; 105 template <class T> struct is_final; // C++14 106 template <class T> struct is_aggregate; // C++17 107 108 template <class T, class... Args> struct is_constructible; 109 template <class T> struct is_default_constructible; 110 template <class T> struct is_copy_constructible; 111 template <class T> struct is_move_constructible; 112 template <class T, class U> struct is_assignable; 113 template <class T> struct is_copy_assignable; 114 template <class T> struct is_move_assignable; 115 template <class T, class U> struct is_swappable_with; // C++17 116 template <class T> struct is_swappable; // C++17 117 template <class T> struct is_destructible; 118 119 template <class T, class... Args> struct is_trivially_constructible; 120 template <class T> struct is_trivially_default_constructible; 121 template <class T> struct is_trivially_copy_constructible; 122 template <class T> struct is_trivially_move_constructible; 123 template <class T, class U> struct is_trivially_assignable; 124 template <class T> struct is_trivially_copy_assignable; 125 template <class T> struct is_trivially_move_assignable; 126 template <class T> struct is_trivially_destructible; 127 128 template <class T, class... Args> struct is_nothrow_constructible; 129 template <class T> struct is_nothrow_default_constructible; 130 template <class T> struct is_nothrow_copy_constructible; 131 template <class T> struct is_nothrow_move_constructible; 132 template <class T, class U> struct is_nothrow_assignable; 133 template <class T> struct is_nothrow_copy_assignable; 134 template <class T> struct is_nothrow_move_assignable; 135 template <class T, class U> struct is_nothrow_swappable_with; // C++17 136 template <class T> struct is_nothrow_swappable; // C++17 137 template <class T> struct is_nothrow_destructible; 138 139 template <class T> struct has_virtual_destructor; 140 141 template<class T> struct has_unique_object_representations; // C++17 142 143 // Relationships between types: 144 template <class T, class U> struct is_same; 145 template <class Base, class Derived> struct is_base_of; 146 147 template <class From, class To> struct is_convertible; 148 template <typename From, typename To> struct is_nothrow_convertible; // C++20 149 template <typename From, typename To> inline constexpr bool is_nothrow_convertible_v; // C++20 150 151 template <class Fn, class... ArgTypes> struct is_invocable; 152 template <class R, class Fn, class... ArgTypes> struct is_invocable_r; 153 154 template <class Fn, class... ArgTypes> struct is_nothrow_invocable; 155 template <class R, class Fn, class... ArgTypes> struct is_nothrow_invocable_r; 156 157 // Alignment properties and transformations: 158 template <class T> struct alignment_of; 159 template <size_t Len, size_t Align = most_stringent_alignment_requirement> 160 struct aligned_storage; 161 template <size_t Len, class... Types> struct aligned_union; 162 template <class T> struct remove_cvref; // C++20 163 164 template <class T> struct decay; 165 template <class... T> struct common_type; 166 template <class T> struct underlying_type; 167 template <class> class result_of; // undefined 168 template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>; 169 template <class Fn, class... ArgTypes> struct invoke_result; // C++17 170 171 // const-volatile modifications: 172 template <class T> 173 using remove_const_t = typename remove_const<T>::type; // C++14 174 template <class T> 175 using remove_volatile_t = typename remove_volatile<T>::type; // C++14 176 template <class T> 177 using remove_cv_t = typename remove_cv<T>::type; // C++14 178 template <class T> 179 using add_const_t = typename add_const<T>::type; // C++14 180 template <class T> 181 using add_volatile_t = typename add_volatile<T>::type; // C++14 182 template <class T> 183 using add_cv_t = typename add_cv<T>::type; // C++14 184 185 // reference modifications: 186 template <class T> 187 using remove_reference_t = typename remove_reference<T>::type; // C++14 188 template <class T> 189 using add_lvalue_reference_t = typename add_lvalue_reference<T>::type; // C++14 190 template <class T> 191 using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; // C++14 192 193 // sign modifications: 194 template <class T> 195 using make_signed_t = typename make_signed<T>::type; // C++14 196 template <class T> 197 using make_unsigned_t = typename make_unsigned<T>::type; // C++14 198 199 // array modifications: 200 template <class T> 201 using remove_extent_t = typename remove_extent<T>::type; // C++14 202 template <class T> 203 using remove_all_extents_t = typename remove_all_extents<T>::type; // C++14 204 205 template <class T> 206 inline constexpr bool is_bounded_array_v 207 = is_bounded_array<T>::value; // C++20 208 inline constexpr bool is_unbounded_array_v 209 = is_unbounded_array<T>::value; // C++20 210 211 // pointer modifications: 212 template <class T> 213 using remove_pointer_t = typename remove_pointer<T>::type; // C++14 214 template <class T> 215 using add_pointer_t = typename add_pointer<T>::type; // C++14 216 217 // other transformations: 218 template <size_t Len, std::size_t Align=default-alignment> 219 using aligned_storage_t = typename aligned_storage<Len,Align>::type; // C++14 220 template <std::size_t Len, class... Types> 221 using aligned_union_t = typename aligned_union<Len,Types...>::type; // C++14 222 template <class T> 223 using remove_cvref_t = typename remove_cvref<T>::type; // C++20 224 template <class T> 225 using decay_t = typename decay<T>::type; // C++14 226 template <bool b, class T=void> 227 using enable_if_t = typename enable_if<b,T>::type; // C++14 228 template <bool b, class T, class F> 229 using conditional_t = typename conditional<b,T,F>::type; // C++14 230 template <class... T> 231 using common_type_t = typename common_type<T...>::type; // C++14 232 template <class T> 233 using underlying_type_t = typename underlying_type<T>::type; // C++14 234 template <class T> 235 using result_of_t = typename result_of<T>::type; // C++14 236 template <class Fn, class... ArgTypes> 237 using invoke_result_t = typename invoke_result<Fn, ArgTypes...>::type; // C++17 238 239 template <class...> 240 using void_t = void; // C++17 241 242 // See C++14 20.10.4.1, primary type categories 243 template <class T> inline constexpr bool is_void_v 244 = is_void<T>::value; // C++17 245 template <class T> inline constexpr bool is_null_pointer_v 246 = is_null_pointer<T>::value; // C++17 247 template <class T> inline constexpr bool is_integral_v 248 = is_integral<T>::value; // C++17 249 template <class T> inline constexpr bool is_floating_point_v 250 = is_floating_point<T>::value; // C++17 251 template <class T> inline constexpr bool is_array_v 252 = is_array<T>::value; // C++17 253 template <class T> inline constexpr bool is_pointer_v 254 = is_pointer<T>::value; // C++17 255 template <class T> inline constexpr bool is_lvalue_reference_v 256 = is_lvalue_reference<T>::value; // C++17 257 template <class T> inline constexpr bool is_rvalue_reference_v 258 = is_rvalue_reference<T>::value; // C++17 259 template <class T> inline constexpr bool is_member_object_pointer_v 260 = is_member_object_pointer<T>::value; // C++17 261 template <class T> inline constexpr bool is_member_function_pointer_v 262 = is_member_function_pointer<T>::value; // C++17 263 template <class T> inline constexpr bool is_enum_v 264 = is_enum<T>::value; // C++17 265 template <class T> inline constexpr bool is_union_v 266 = is_union<T>::value; // C++17 267 template <class T> inline constexpr bool is_class_v 268 = is_class<T>::value; // C++17 269 template <class T> inline constexpr bool is_function_v 270 = is_function<T>::value; // C++17 271 272 // See C++14 20.10.4.2, composite type categories 273 template <class T> inline constexpr bool is_reference_v 274 = is_reference<T>::value; // C++17 275 template <class T> inline constexpr bool is_arithmetic_v 276 = is_arithmetic<T>::value; // C++17 277 template <class T> inline constexpr bool is_fundamental_v 278 = is_fundamental<T>::value; // C++17 279 template <class T> inline constexpr bool is_object_v 280 = is_object<T>::value; // C++17 281 template <class T> inline constexpr bool is_scalar_v 282 = is_scalar<T>::value; // C++17 283 template <class T> inline constexpr bool is_compound_v 284 = is_compound<T>::value; // C++17 285 template <class T> inline constexpr bool is_member_pointer_v 286 = is_member_pointer<T>::value; // C++17 287 288 // See C++14 20.10.4.3, type properties 289 template <class T> inline constexpr bool is_const_v 290 = is_const<T>::value; // C++17 291 template <class T> inline constexpr bool is_volatile_v 292 = is_volatile<T>::value; // C++17 293 template <class T> inline constexpr bool is_trivial_v 294 = is_trivial<T>::value; // C++17 295 template <class T> inline constexpr bool is_trivially_copyable_v 296 = is_trivially_copyable<T>::value; // C++17 297 template <class T> inline constexpr bool is_standard_layout_v 298 = is_standard_layout<T>::value; // C++17 299 template <class T> inline constexpr bool is_pod_v 300 = is_pod<T>::value; // C++17 301 template <class T> inline constexpr bool is_literal_type_v 302 = is_literal_type<T>::value; // C++17 303 template <class T> inline constexpr bool is_empty_v 304 = is_empty<T>::value; // C++17 305 template <class T> inline constexpr bool is_polymorphic_v 306 = is_polymorphic<T>::value; // C++17 307 template <class T> inline constexpr bool is_abstract_v 308 = is_abstract<T>::value; // C++17 309 template <class T> inline constexpr bool is_final_v 310 = is_final<T>::value; // C++17 311 template <class T> inline constexpr bool is_aggregate_v 312 = is_aggregate<T>::value; // C++17 313 template <class T> inline constexpr bool is_signed_v 314 = is_signed<T>::value; // C++17 315 template <class T> inline constexpr bool is_unsigned_v 316 = is_unsigned<T>::value; // C++17 317 template <class T, class... Args> inline constexpr bool is_constructible_v 318 = is_constructible<T, Args...>::value; // C++17 319 template <class T> inline constexpr bool is_default_constructible_v 320 = is_default_constructible<T>::value; // C++17 321 template <class T> inline constexpr bool is_copy_constructible_v 322 = is_copy_constructible<T>::value; // C++17 323 template <class T> inline constexpr bool is_move_constructible_v 324 = is_move_constructible<T>::value; // C++17 325 template <class T, class U> inline constexpr bool is_assignable_v 326 = is_assignable<T, U>::value; // C++17 327 template <class T> inline constexpr bool is_copy_assignable_v 328 = is_copy_assignable<T>::value; // C++17 329 template <class T> inline constexpr bool is_move_assignable_v 330 = is_move_assignable<T>::value; // C++17 331 template <class T, class U> inline constexpr bool is_swappable_with_v 332 = is_swappable_with<T, U>::value; // C++17 333 template <class T> inline constexpr bool is_swappable_v 334 = is_swappable<T>::value; // C++17 335 template <class T> inline constexpr bool is_destructible_v 336 = is_destructible<T>::value; // C++17 337 template <class T, class... Args> inline constexpr bool is_trivially_constructible_v 338 = is_trivially_constructible<T, Args...>::value; // C++17 339 template <class T> inline constexpr bool is_trivially_default_constructible_v 340 = is_trivially_default_constructible<T>::value; // C++17 341 template <class T> inline constexpr bool is_trivially_copy_constructible_v 342 = is_trivially_copy_constructible<T>::value; // C++17 343 template <class T> inline constexpr bool is_trivially_move_constructible_v 344 = is_trivially_move_constructible<T>::value; // C++17 345 template <class T, class U> inline constexpr bool is_trivially_assignable_v 346 = is_trivially_assignable<T, U>::value; // C++17 347 template <class T> inline constexpr bool is_trivially_copy_assignable_v 348 = is_trivially_copy_assignable<T>::value; // C++17 349 template <class T> inline constexpr bool is_trivially_move_assignable_v 350 = is_trivially_move_assignable<T>::value; // C++17 351 template <class T> inline constexpr bool is_trivially_destructible_v 352 = is_trivially_destructible<T>::value; // C++17 353 template <class T, class... Args> inline constexpr bool is_nothrow_constructible_v 354 = is_nothrow_constructible<T, Args...>::value; // C++17 355 template <class T> inline constexpr bool is_nothrow_default_constructible_v 356 = is_nothrow_default_constructible<T>::value; // C++17 357 template <class T> inline constexpr bool is_nothrow_copy_constructible_v 358 = is_nothrow_copy_constructible<T>::value; // C++17 359 template <class T> inline constexpr bool is_nothrow_move_constructible_v 360 = is_nothrow_move_constructible<T>::value; // C++17 361 template <class T, class U> inline constexpr bool is_nothrow_assignable_v 362 = is_nothrow_assignable<T, U>::value; // C++17 363 template <class T> inline constexpr bool is_nothrow_copy_assignable_v 364 = is_nothrow_copy_assignable<T>::value; // C++17 365 template <class T> inline constexpr bool is_nothrow_move_assignable_v 366 = is_nothrow_move_assignable<T>::value; // C++17 367 template <class T, class U> inline constexpr bool is_nothrow_swappable_with_v 368 = is_nothrow_swappable_with<T, U>::value; // C++17 369 template <class T> inline constexpr bool is_nothrow_swappable_v 370 = is_nothrow_swappable<T>::value; // C++17 371 template <class T> inline constexpr bool is_nothrow_destructible_v 372 = is_nothrow_destructible<T>::value; // C++17 373 template <class T> inline constexpr bool has_virtual_destructor_v 374 = has_virtual_destructor<T>::value; // C++17 375 template<class T> inline constexpr bool has_unique_object_representations_v // C++17 376 = has_unique_object_representations<T>::value; 377 378 // See C++14 20.10.5, type property queries 379 template <class T> inline constexpr size_t alignment_of_v 380 = alignment_of<T>::value; // C++17 381 template <class T> inline constexpr size_t rank_v 382 = rank<T>::value; // C++17 383 template <class T, unsigned I = 0> inline constexpr size_t extent_v 384 = extent<T, I>::value; // C++17 385 386 // See C++14 20.10.6, type relations 387 template <class T, class U> inline constexpr bool is_same_v 388 = is_same<T, U>::value; // C++17 389 template <class Base, class Derived> inline constexpr bool is_base_of_v 390 = is_base_of<Base, Derived>::value; // C++17 391 template <class From, class To> inline constexpr bool is_convertible_v 392 = is_convertible<From, To>::value; // C++17 393 template <class Fn, class... ArgTypes> inline constexpr bool is_invocable_v 394 = is_invocable<Fn, ArgTypes...>::value; // C++17 395 template <class R, class Fn, class... ArgTypes> inline constexpr bool is_invocable_r_v 396 = is_invocable_r<R, Fn, ArgTypes...>::value; // C++17 397 template <class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_v 398 = is_nothrow_invocable<Fn, ArgTypes...>::value; // C++17 399 template <class R, class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_r_v 400 = is_nothrow_invocable_r<R, Fn, ArgTypes...>::value; // C++17 401 402 // [meta.logical], logical operator traits: 403 template<class... B> struct conjunction; // C++17 404 template<class... B> 405 inline constexpr bool conjunction_v = conjunction<B...>::value; // C++17 406 template<class... B> struct disjunction; // C++17 407 template<class... B> 408 inline constexpr bool disjunction_v = disjunction<B...>::value; // C++17 409 template<class B> struct negation; // C++17 410 template<class B> 411 inline constexpr bool negation_v = negation<B>::value; // C++17 412 413} 414 415*/ 416#include <__config> 417#include <cstddef> 418#include <version> 419 420#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 421#pragma GCC system_header 422#endif 423 424_LIBCPP_BEGIN_NAMESPACE_STD 425 426template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS pair; 427template <class _Tp> class _LIBCPP_TEMPLATE_VIS reference_wrapper; 428template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash; 429 430template <class _Tp, _Tp __v> 431struct _LIBCPP_TEMPLATE_VIS integral_constant 432{ 433 static _LIBCPP_CONSTEXPR const _Tp value = __v; 434 typedef _Tp value_type; 435 typedef integral_constant type; 436 _LIBCPP_INLINE_VISIBILITY 437 _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT {return value;} 438#if _LIBCPP_STD_VER > 11 439 _LIBCPP_INLINE_VISIBILITY 440 constexpr value_type operator ()() const _NOEXCEPT {return value;} 441#endif 442}; 443 444template <class _Tp, _Tp __v> 445_LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value; 446 447#if _LIBCPP_STD_VER > 14 448template <bool __b> 449using bool_constant = integral_constant<bool, __b>; 450#define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)> 451#else 452#define _LIBCPP_BOOL_CONSTANT(__b) integral_constant<bool,(__b)> 453#endif 454 455typedef _LIBCPP_BOOL_CONSTANT(true) true_type; 456typedef _LIBCPP_BOOL_CONSTANT(false) false_type; 457 458template <bool _Val> 459using _BoolConstant _LIBCPP_NODEBUG_TYPE = integral_constant<bool, _Val>; 460 461template <bool> struct _MetaBase; 462template <> 463struct _MetaBase<true> { 464 template <class _Tp, class _Up> 465 using _SelectImpl _LIBCPP_NODEBUG_TYPE = _Tp; 466 template <template <class...> class _FirstFn, template <class...> class, class ..._Args> 467 using _SelectApplyImpl _LIBCPP_NODEBUG_TYPE = _FirstFn<_Args...>; 468 template <class _First, class...> 469 using _FirstImpl _LIBCPP_NODEBUG_TYPE = _First; 470 template <class, class _Second, class...> 471 using _SecondImpl _LIBCPP_NODEBUG_TYPE = _Second; 472 template <class _Tp = void> 473 using _EnableIfImpl _LIBCPP_NODEBUG_TYPE = _Tp; 474 template <class _Result, class _First, class ..._Rest> 475 using _OrImpl _LIBCPP_NODEBUG_TYPE = typename _MetaBase<_First::value != true && sizeof...(_Rest) != 0>::template _OrImpl<_First, _Rest...>; 476 template <class _Result, class _First, class ..._Rest> 477 using _AndImpl _LIBCPP_NODEBUG_TYPE = typename _MetaBase<_First::value == true && sizeof...(_Rest) != 0>::template _AndImpl<_First, _Rest...>; 478}; 479 480template <> 481struct _MetaBase<false> { 482 template <class _Tp, class _Up> 483 using _SelectImpl _LIBCPP_NODEBUG_TYPE = _Up; 484 template <template <class...> class, template <class...> class _SecondFn, class ..._Args> 485 using _SelectApplyImpl _LIBCPP_NODEBUG_TYPE = _SecondFn<_Args...>; 486 template <class _Result, class ...> 487 using _OrImpl _LIBCPP_NODEBUG_TYPE = _Result; 488 template <class _Result, class ...> 489 using _AndImpl _LIBCPP_NODEBUG_TYPE = _Result; 490}; 491template <bool _Cond, class _Ret = void> 492using _EnableIf _LIBCPP_NODEBUG_TYPE = typename _MetaBase<_Cond>::template _EnableIfImpl<_Ret>; 493template <bool _Cond, class _IfRes, class _ElseRes> 494using _If _LIBCPP_NODEBUG_TYPE = typename _MetaBase<_Cond>::template _SelectImpl<_IfRes, _ElseRes>; 495template <class ..._Rest> 496using _Or _LIBCPP_NODEBUG_TYPE = typename _MetaBase< sizeof...(_Rest) != 0 >::template _OrImpl<false_type, _Rest...>; 497template <class ..._Rest> 498using _And _LIBCPP_NODEBUG_TYPE = typename _MetaBase< sizeof...(_Rest) != 0 >::template _AndImpl<true_type, _Rest...>; 499template <class _Pred> 500struct _Not : _BoolConstant<!_Pred::value> {}; 501template <class ..._Args> 502using _FirstType _LIBCPP_NODEBUG_TYPE = typename _MetaBase<(sizeof...(_Args) >= 1)>::template _FirstImpl<_Args...>; 503template <class ..._Args> 504using _SecondType _LIBCPP_NODEBUG_TYPE = typename _MetaBase<(sizeof...(_Args) >= 2)>::template _SecondImpl<_Args...>; 505 506template <template <class...> class _Func, class ..._Args> 507struct _Lazy : _Func<_Args...> {}; 508 509// Member detector base 510 511template <template <class...> class _Templ, class ..._Args, class = _Templ<_Args...> > 512true_type __sfinae_test_impl(int); 513template <template <class...> class, class ...> 514false_type __sfinae_test_impl(...); 515 516template <template <class ...> class _Templ, class ..._Args> 517using _IsValidExpansion _LIBCPP_NODEBUG_TYPE = decltype(std::__sfinae_test_impl<_Templ, _Args...>(0)); 518 519template <class> 520struct __void_t { typedef void type; }; 521 522template <class _Tp> 523struct __identity { typedef _Tp type; }; 524 525template <class _Tp, bool> 526struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {}; 527 528 529template <bool _Bp, class _If, class _Then> 530 struct _LIBCPP_TEMPLATE_VIS conditional {typedef _If type;}; 531template <class _If, class _Then> 532 struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> {typedef _Then type;}; 533 534#if _LIBCPP_STD_VER > 11 535template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type; 536#endif 537 538template <bool, class _Tp = void> struct _LIBCPP_TEMPLATE_VIS enable_if {}; 539template <class _Tp> struct _LIBCPP_TEMPLATE_VIS enable_if<true, _Tp> {typedef _Tp type;}; 540 541#if _LIBCPP_STD_VER > 11 542template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type; 543#endif 544 545// is_same 546 547template <class _Tp, class _Up> struct _LIBCPP_TEMPLATE_VIS is_same : public false_type {}; 548template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_same<_Tp, _Tp> : public true_type {}; 549 550#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 551template <class _Tp, class _Up> 552_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_same_v 553 = is_same<_Tp, _Up>::value; 554#endif 555 556template <class _Tp, class _Up> 557using _IsSame = _BoolConstant< 558#ifdef __clang__ 559 __is_same(_Tp, _Up) 560#else 561 _VSTD::is_same<_Tp, _Up>::value 562#endif 563>; 564 565template <class _Tp, class _Up> 566using _IsNotSame = _BoolConstant< 567#ifdef __clang__ 568 !__is_same(_Tp, _Up) 569#else 570 !_VSTD::is_same<_Tp, _Up>::value 571#endif 572>; 573 574 575template <class _Tp> 576using __test_for_primary_template = _EnableIf< 577 _IsSame<_Tp, typename _Tp::__primary_template>::value 578 >; 579template <class _Tp> 580using __is_primary_template = _IsValidExpansion< 581 __test_for_primary_template, _Tp 582 >; 583 584// addressof 585#ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF 586 587template <class _Tp> 588inline _LIBCPP_CONSTEXPR_AFTER_CXX14 589_LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY 590_Tp* 591addressof(_Tp& __x) _NOEXCEPT 592{ 593 return __builtin_addressof(__x); 594} 595 596#else 597 598template <class _Tp> 599inline _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY 600_Tp* 601addressof(_Tp& __x) _NOEXCEPT 602{ 603 return reinterpret_cast<_Tp *>( 604 const_cast<char *>(&reinterpret_cast<const volatile char &>(__x))); 605} 606 607#endif // _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF 608 609#if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF) 610// Objective-C++ Automatic Reference Counting uses qualified pointers 611// that require special addressof() signatures. When 612// _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler 613// itself is providing these definitions. Otherwise, we provide them. 614template <class _Tp> 615inline _LIBCPP_INLINE_VISIBILITY 616__strong _Tp* 617addressof(__strong _Tp& __x) _NOEXCEPT 618{ 619 return &__x; 620} 621 622#ifdef _LIBCPP_HAS_OBJC_ARC_WEAK 623template <class _Tp> 624inline _LIBCPP_INLINE_VISIBILITY 625__weak _Tp* 626addressof(__weak _Tp& __x) _NOEXCEPT 627{ 628 return &__x; 629} 630#endif 631 632template <class _Tp> 633inline _LIBCPP_INLINE_VISIBILITY 634__autoreleasing _Tp* 635addressof(__autoreleasing _Tp& __x) _NOEXCEPT 636{ 637 return &__x; 638} 639 640template <class _Tp> 641inline _LIBCPP_INLINE_VISIBILITY 642__unsafe_unretained _Tp* 643addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT 644{ 645 return &__x; 646} 647#endif 648 649#if !defined(_LIBCPP_CXX03_LANG) 650template <class _Tp> _Tp* addressof(const _Tp&&) noexcept = delete; 651#endif 652 653struct __two {char __lx[2];}; 654 655// helper class: 656 657// is_const 658 659template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const : public false_type {}; 660template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const<_Tp const> : public true_type {}; 661 662#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 663template <class _Tp> 664_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_const_v 665 = is_const<_Tp>::value; 666#endif 667 668// is_volatile 669 670template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile : public false_type {}; 671template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile<_Tp volatile> : public true_type {}; 672 673#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 674template <class _Tp> 675_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_volatile_v 676 = is_volatile<_Tp>::value; 677#endif 678 679// remove_const 680 681template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const {typedef _Tp type;}; 682template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const<const _Tp> {typedef _Tp type;}; 683#if _LIBCPP_STD_VER > 11 684template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type; 685#endif 686 687// remove_volatile 688 689template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef _Tp type;}; 690template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile<volatile _Tp> {typedef _Tp type;}; 691#if _LIBCPP_STD_VER > 11 692template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type; 693#endif 694 695// remove_cv 696 697template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv 698{typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;}; 699#if _LIBCPP_STD_VER > 11 700template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type; 701#endif 702 703// is_void 704 705template <class _Tp> struct __libcpp_is_void : public false_type {}; 706template <> struct __libcpp_is_void<void> : public true_type {}; 707 708template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_void 709 : public __libcpp_is_void<typename remove_cv<_Tp>::type> {}; 710 711#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 712template <class _Tp> 713_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_void_v 714 = is_void<_Tp>::value; 715#endif 716 717// __is_nullptr_t 718 719template <class _Tp> struct __is_nullptr_t_impl : public false_type {}; 720template <> struct __is_nullptr_t_impl<nullptr_t> : public true_type {}; 721 722template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __is_nullptr_t 723 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {}; 724 725#if _LIBCPP_STD_VER > 11 726template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_null_pointer 727 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {}; 728 729#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 730template <class _Tp> 731_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_null_pointer_v 732 = is_null_pointer<_Tp>::value; 733#endif 734#endif // _LIBCPP_STD_VER > 11 735 736// is_integral 737 738template <class _Tp> struct __libcpp_is_integral : public false_type {}; 739template <> struct __libcpp_is_integral<bool> : public true_type {}; 740template <> struct __libcpp_is_integral<char> : public true_type {}; 741template <> struct __libcpp_is_integral<signed char> : public true_type {}; 742template <> struct __libcpp_is_integral<unsigned char> : public true_type {}; 743template <> struct __libcpp_is_integral<wchar_t> : public true_type {}; 744#ifndef _LIBCPP_NO_HAS_CHAR8_T 745template <> struct __libcpp_is_integral<char8_t> : public true_type {}; 746#endif 747#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS 748template <> struct __libcpp_is_integral<char16_t> : public true_type {}; 749template <> struct __libcpp_is_integral<char32_t> : public true_type {}; 750#endif // _LIBCPP_HAS_NO_UNICODE_CHARS 751template <> struct __libcpp_is_integral<short> : public true_type {}; 752template <> struct __libcpp_is_integral<unsigned short> : public true_type {}; 753template <> struct __libcpp_is_integral<int> : public true_type {}; 754template <> struct __libcpp_is_integral<unsigned int> : public true_type {}; 755template <> struct __libcpp_is_integral<long> : public true_type {}; 756template <> struct __libcpp_is_integral<unsigned long> : public true_type {}; 757template <> struct __libcpp_is_integral<long long> : public true_type {}; 758template <> struct __libcpp_is_integral<unsigned long long> : public true_type {}; 759#ifndef _LIBCPP_HAS_NO_INT128 760template <> struct __libcpp_is_integral<__int128_t> : public true_type {}; 761template <> struct __libcpp_is_integral<__uint128_t> : public true_type {}; 762#endif 763 764template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_integral 765 : public __libcpp_is_integral<typename remove_cv<_Tp>::type> {}; 766 767#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 768template <class _Tp> 769_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_integral_v 770 = is_integral<_Tp>::value; 771#endif 772 773// is_floating_point 774 775template <class _Tp> struct __libcpp_is_floating_point : public false_type {}; 776template <> struct __libcpp_is_floating_point<float> : public true_type {}; 777template <> struct __libcpp_is_floating_point<double> : public true_type {}; 778template <> struct __libcpp_is_floating_point<long double> : public true_type {}; 779 780template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_floating_point 781 : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {}; 782 783#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 784template <class _Tp> 785_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_floating_point_v 786 = is_floating_point<_Tp>::value; 787#endif 788 789// is_array 790 791template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array 792 : public false_type {}; 793template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[]> 794 : public true_type {}; 795template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[_Np]> 796 : public true_type {}; 797 798#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 799template <class _Tp> 800_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_array_v 801 = is_array<_Tp>::value; 802#endif 803 804// is_pointer 805 806template <class _Tp> struct __libcpp_is_pointer : public false_type {}; 807template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {}; 808 809template <class _Tp> struct __libcpp_remove_objc_qualifiers { typedef _Tp type; }; 810#if defined(_LIBCPP_HAS_OBJC_ARC) 811template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __strong> { typedef _Tp type; }; 812template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __weak> { typedef _Tp type; }; 813template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __autoreleasing> { typedef _Tp type; }; 814template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __unsafe_unretained> { typedef _Tp type; }; 815#endif 816 817template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pointer 818 : public __libcpp_is_pointer<typename __libcpp_remove_objc_qualifiers<typename remove_cv<_Tp>::type>::type> {}; 819 820#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 821template <class _Tp> 822_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pointer_v 823 = is_pointer<_Tp>::value; 824#endif 825 826// is_reference 827 828template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {}; 829template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {}; 830 831template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : public false_type {}; 832template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {}; 833 834template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference : public false_type {}; 835template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&> : public true_type {}; 836template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&&> : public true_type {}; 837 838#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 839template <class _Tp> 840_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_reference_v 841 = is_reference<_Tp>::value; 842 843template <class _Tp> 844_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_lvalue_reference_v 845 = is_lvalue_reference<_Tp>::value; 846 847template <class _Tp> 848_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_rvalue_reference_v 849 = is_rvalue_reference<_Tp>::value; 850#endif 851// is_union 852 853#if __has_feature(is_union) || defined(_LIBCPP_COMPILER_GCC) 854 855template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union 856 : public integral_constant<bool, __is_union(_Tp)> {}; 857 858#else 859 860template <class _Tp> struct __libcpp_union : public false_type {}; 861template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union 862 : public __libcpp_union<typename remove_cv<_Tp>::type> {}; 863 864#endif 865 866#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 867template <class _Tp> 868_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_union_v 869 = is_union<_Tp>::value; 870#endif 871 872// is_class 873 874#if __has_feature(is_class) || defined(_LIBCPP_COMPILER_GCC) 875 876template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class 877 : public integral_constant<bool, __is_class(_Tp)> {}; 878 879#else 880 881namespace __is_class_imp 882{ 883template <class _Tp> char __test(int _Tp::*); 884template <class _Tp> __two __test(...); 885} 886 887template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class 888 : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {}; 889 890#endif 891 892#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 893template <class _Tp> 894_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_class_v 895 = is_class<_Tp>::value; 896#endif 897 898// is_function 899 900template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_function 901 : public _BoolConstant< 902#ifdef __clang__ 903 __is_function(_Tp) 904#else 905 !(is_reference<_Tp>::value || is_const<const _Tp>::value) 906#endif 907 > {}; 908 909 910#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 911template <class _Tp> 912_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_function_v 913 = is_function<_Tp>::value; 914#endif 915 916template <class _Tp> struct __libcpp_is_member_pointer { 917 enum { 918 __is_member = false, 919 __is_func = false, 920 __is_obj = false 921 }; 922}; 923template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> { 924 enum { 925 __is_member = true, 926 __is_func = is_function<_Tp>::value, 927 __is_obj = !__is_func, 928 }; 929}; 930 931 932template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer 933 : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_func > {}; 934 935#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 936template <class _Tp> 937_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_function_pointer_v 938 = is_member_function_pointer<_Tp>::value; 939#endif 940 941// is_member_pointer 942 943template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_pointer 944 : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_member > {}; 945 946#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 947template <class _Tp> 948_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_pointer_v 949 = is_member_pointer<_Tp>::value; 950#endif 951 952// is_member_object_pointer 953 954template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer 955 : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_obj > {}; 956 957#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 958template <class _Tp> 959_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_object_pointer_v 960 = is_member_object_pointer<_Tp>::value; 961#endif 962 963// is_enum 964 965#if __has_feature(is_enum) || defined(_LIBCPP_COMPILER_GCC) 966 967template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum 968 : public integral_constant<bool, __is_enum(_Tp)> {}; 969 970#else 971 972template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum 973 : public integral_constant<bool, !is_void<_Tp>::value && 974 !is_integral<_Tp>::value && 975 !is_floating_point<_Tp>::value && 976 !is_array<_Tp>::value && 977 !is_pointer<_Tp>::value && 978 !is_reference<_Tp>::value && 979 !is_member_pointer<_Tp>::value && 980 !is_union<_Tp>::value && 981 !is_class<_Tp>::value && 982 !is_function<_Tp>::value > {}; 983 984#endif 985 986#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 987template <class _Tp> 988_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_enum_v 989 = is_enum<_Tp>::value; 990#endif 991 992// is_arithmetic 993 994template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_arithmetic 995 : public integral_constant<bool, is_integral<_Tp>::value || 996 is_floating_point<_Tp>::value> {}; 997 998#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 999template <class _Tp> 1000_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_arithmetic_v 1001 = is_arithmetic<_Tp>::value; 1002#endif 1003 1004// is_fundamental 1005 1006template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_fundamental 1007 : public integral_constant<bool, is_void<_Tp>::value || 1008 __is_nullptr_t<_Tp>::value || 1009 is_arithmetic<_Tp>::value> {}; 1010 1011#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1012template <class _Tp> 1013_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_fundamental_v 1014 = is_fundamental<_Tp>::value; 1015#endif 1016 1017// is_scalar 1018 1019template <class _Tp> struct __is_block : false_type {}; 1020#if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) 1021template <class _Rp, class ..._Args> struct __is_block<_Rp (^)(_Args...)> : true_type {}; 1022#endif 1023 1024template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_scalar 1025 : public integral_constant<bool, is_arithmetic<_Tp>::value || 1026 is_member_pointer<_Tp>::value || 1027 is_pointer<_Tp>::value || 1028 __is_nullptr_t<_Tp>::value || 1029 __is_block<_Tp>::value || 1030 is_enum<_Tp>::value > {}; 1031 1032template <> struct _LIBCPP_TEMPLATE_VIS is_scalar<nullptr_t> : public true_type {}; 1033 1034#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1035template <class _Tp> 1036_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_scalar_v 1037 = is_scalar<_Tp>::value; 1038#endif 1039 1040// is_object 1041 1042template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_object 1043 : public integral_constant<bool, is_scalar<_Tp>::value || 1044 is_array<_Tp>::value || 1045 is_union<_Tp>::value || 1046 is_class<_Tp>::value > {}; 1047 1048#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1049template <class _Tp> 1050_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_object_v 1051 = is_object<_Tp>::value; 1052#endif 1053 1054// is_compound 1055 1056template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_compound 1057 : public integral_constant<bool, !is_fundamental<_Tp>::value> {}; 1058 1059#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1060template <class _Tp> 1061_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_compound_v 1062 = is_compound<_Tp>::value; 1063#endif 1064 1065 1066// __is_referenceable [defns.referenceable] 1067 1068struct __is_referenceable_impl { 1069 template <class _Tp> static _Tp& __test(int); 1070 template <class _Tp> static __two __test(...); 1071}; 1072 1073template <class _Tp> 1074struct __is_referenceable : integral_constant<bool, 1075 _IsNotSame<decltype(__is_referenceable_impl::__test<_Tp>(0)), __two>::value> {}; 1076 1077 1078// add_const 1079 1080template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_const { 1081 typedef _LIBCPP_NODEBUG_TYPE const _Tp type; 1082}; 1083 1084#if _LIBCPP_STD_VER > 11 1085template <class _Tp> using add_const_t = typename add_const<_Tp>::type; 1086#endif 1087 1088// add_volatile 1089 1090template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_volatile { 1091 typedef _LIBCPP_NODEBUG_TYPE volatile _Tp type; 1092}; 1093 1094#if _LIBCPP_STD_VER > 11 1095template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type; 1096#endif 1097 1098// add_cv 1099template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_cv { 1100 typedef _LIBCPP_NODEBUG_TYPE const volatile _Tp type; 1101}; 1102 1103#if _LIBCPP_STD_VER > 11 1104template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type; 1105#endif 1106 1107// remove_reference 1108 1109template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _LIBCPP_NODEBUG_TYPE _Tp type;}; 1110template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;}; 1111template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;}; 1112 1113#if _LIBCPP_STD_VER > 11 1114template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type; 1115#endif 1116 1117// add_lvalue_reference 1118 1119template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _LIBCPP_NODEBUG_TYPE _Tp type; }; 1120template <class _Tp > struct __add_lvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG_TYPE _Tp& type; }; 1121 1122template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_lvalue_reference 1123{typedef _LIBCPP_NODEBUG_TYPE typename __add_lvalue_reference_impl<_Tp>::type type;}; 1124 1125#if _LIBCPP_STD_VER > 11 1126template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type; 1127#endif 1128 1129template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl { typedef _LIBCPP_NODEBUG_TYPE _Tp type; }; 1130template <class _Tp > struct __add_rvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG_TYPE _Tp&& type; }; 1131 1132template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_rvalue_reference 1133{typedef _LIBCPP_NODEBUG_TYPE typename __add_rvalue_reference_impl<_Tp>::type type;}; 1134 1135#if _LIBCPP_STD_VER > 11 1136template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type; 1137#endif 1138 1139// Suppress deprecation notice for volatile-qualified return type resulting 1140// from volatile-qualified types _Tp. 1141_LIBCPP_SUPPRESS_DEPRECATED_PUSH 1142template <class _Tp> _Tp&& __declval(int); 1143template <class _Tp> _Tp __declval(long); 1144_LIBCPP_SUPPRESS_DEPRECATED_POP 1145 1146template <class _Tp> 1147decltype(_VSTD::__declval<_Tp>(0)) 1148declval() _NOEXCEPT; 1149 1150// __uncvref 1151 1152template <class _Tp> 1153struct __uncvref { 1154 typedef _LIBCPP_NODEBUG_TYPE typename remove_cv<typename remove_reference<_Tp>::type>::type type; 1155}; 1156 1157template <class _Tp> 1158struct __unconstref { 1159 typedef _LIBCPP_NODEBUG_TYPE typename remove_const<typename remove_reference<_Tp>::type>::type type; 1160}; 1161 1162#ifndef _LIBCPP_CXX03_LANG 1163template <class _Tp> 1164using __uncvref_t _LIBCPP_NODEBUG_TYPE = typename __uncvref<_Tp>::type; 1165#endif 1166 1167// __is_same_uncvref 1168 1169template <class _Tp, class _Up> 1170struct __is_same_uncvref : _IsSame<typename __uncvref<_Tp>::type, 1171 typename __uncvref<_Up>::type> {}; 1172 1173#if _LIBCPP_STD_VER > 17 1174// remove_cvref - same as __uncvref 1175template <class _Tp> 1176struct remove_cvref : public __uncvref<_Tp> {}; 1177 1178template <class _Tp> using remove_cvref_t = typename remove_cvref<_Tp>::type; 1179#endif 1180 1181 1182struct __any 1183{ 1184 __any(...); 1185}; 1186 1187// remove_pointer 1188 1189template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {typedef _LIBCPP_NODEBUG_TYPE _Tp type;}; 1190template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;}; 1191template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;}; 1192template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;}; 1193template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const volatile> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;}; 1194 1195#if _LIBCPP_STD_VER > 11 1196template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type; 1197#endif 1198 1199// add_pointer 1200 1201template <class _Tp, 1202 bool = __is_referenceable<_Tp>::value || 1203 _IsSame<typename remove_cv<_Tp>::type, void>::value> 1204struct __add_pointer_impl 1205 {typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tp>::type* type;}; 1206template <class _Tp> struct __add_pointer_impl<_Tp, false> 1207 {typedef _LIBCPP_NODEBUG_TYPE _Tp type;}; 1208 1209template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_pointer 1210 {typedef _LIBCPP_NODEBUG_TYPE typename __add_pointer_impl<_Tp>::type type;}; 1211 1212#if _LIBCPP_STD_VER > 11 1213template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type; 1214#endif 1215 1216// type_identity 1217#if _LIBCPP_STD_VER > 17 1218template<class _Tp> struct type_identity { typedef _Tp type; }; 1219template<class _Tp> using type_identity_t = typename type_identity<_Tp>::type; 1220#endif 1221 1222// is_signed 1223 1224template <class _Tp, bool = is_integral<_Tp>::value> 1225struct __libcpp_is_signed_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(-1) < _Tp(0)) {}; 1226 1227template <class _Tp> 1228struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point 1229 1230template <class _Tp, bool = is_arithmetic<_Tp>::value> 1231struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {}; 1232 1233template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {}; 1234 1235template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_signed : public __libcpp_is_signed<_Tp> {}; 1236 1237#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1238template <class _Tp> 1239_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_signed_v 1240 = is_signed<_Tp>::value; 1241#endif 1242 1243// is_unsigned 1244 1245template <class _Tp, bool = is_integral<_Tp>::value> 1246struct __libcpp_is_unsigned_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(0) < _Tp(-1)) {}; 1247 1248template <class _Tp> 1249struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point 1250 1251template <class _Tp, bool = is_arithmetic<_Tp>::value> 1252struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {}; 1253 1254template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {}; 1255 1256template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unsigned : public __libcpp_is_unsigned<_Tp> {}; 1257 1258#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1259template <class _Tp> 1260_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_unsigned_v 1261 = is_unsigned<_Tp>::value; 1262#endif 1263 1264// rank 1265 1266template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank 1267 : public integral_constant<size_t, 0> {}; 1268template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]> 1269 : public integral_constant<size_t, rank<_Tp>::value + 1> {}; 1270template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]> 1271 : public integral_constant<size_t, rank<_Tp>::value + 1> {}; 1272 1273#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1274template <class _Tp> 1275_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t rank_v 1276 = rank<_Tp>::value; 1277#endif 1278 1279// extent 1280 1281template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TEMPLATE_VIS extent 1282 : public integral_constant<size_t, 0> {}; 1283template <class _Tp> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], 0> 1284 : public integral_constant<size_t, 0> {}; 1285template <class _Tp, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], _Ip> 1286 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {}; 1287template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], 0> 1288 : public integral_constant<size_t, _Np> {}; 1289template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], _Ip> 1290 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {}; 1291 1292#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1293template <class _Tp, unsigned _Ip = 0> 1294_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t extent_v 1295 = extent<_Tp, _Ip>::value; 1296#endif 1297 1298// remove_extent 1299 1300template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent 1301 {typedef _Tp type;}; 1302template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]> 1303 {typedef _Tp type;}; 1304template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[_Np]> 1305 {typedef _Tp type;}; 1306 1307#if _LIBCPP_STD_VER > 11 1308template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type; 1309#endif 1310 1311// remove_all_extents 1312 1313template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents 1314 {typedef _Tp type;}; 1315template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[]> 1316 {typedef typename remove_all_extents<_Tp>::type type;}; 1317template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[_Np]> 1318 {typedef typename remove_all_extents<_Tp>::type type;}; 1319 1320#if _LIBCPP_STD_VER > 11 1321template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type; 1322#endif 1323 1324#if _LIBCPP_STD_VER > 17 1325// is_bounded_array 1326 1327template <class> struct _LIBCPP_TEMPLATE_VIS is_bounded_array : false_type {}; 1328template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_bounded_array<_Tp[_Np]> : true_type {}; 1329 1330template <class _Tp> 1331_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR 1332bool is_bounded_array_v = is_bounded_array<_Tp>::value; 1333 1334// is_unbounded_array 1335 1336template <class> struct _LIBCPP_TEMPLATE_VIS is_unbounded_array : false_type {}; 1337template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unbounded_array<_Tp[]> : true_type {}; 1338 1339template <class _Tp> 1340_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR 1341bool is_unbounded_array_v = is_unbounded_array<_Tp>::value; 1342#endif 1343 1344// decay 1345 1346template <class _Up, bool> 1347struct __decay { 1348 typedef _LIBCPP_NODEBUG_TYPE typename remove_cv<_Up>::type type; 1349}; 1350 1351template <class _Up> 1352struct __decay<_Up, true> { 1353public: 1354 typedef _LIBCPP_NODEBUG_TYPE typename conditional 1355 < 1356 is_array<_Up>::value, 1357 typename remove_extent<_Up>::type*, 1358 typename conditional 1359 < 1360 is_function<_Up>::value, 1361 typename add_pointer<_Up>::type, 1362 typename remove_cv<_Up>::type 1363 >::type 1364 >::type type; 1365}; 1366 1367template <class _Tp> 1368struct _LIBCPP_TEMPLATE_VIS decay 1369{ 1370private: 1371 typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tp>::type _Up; 1372public: 1373 typedef _LIBCPP_NODEBUG_TYPE typename __decay<_Up, __is_referenceable<_Up>::value>::type type; 1374}; 1375 1376#if _LIBCPP_STD_VER > 11 1377template <class _Tp> using decay_t = typename decay<_Tp>::type; 1378#endif 1379 1380// is_abstract 1381 1382template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_abstract 1383 : public integral_constant<bool, __is_abstract(_Tp)> {}; 1384 1385#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1386template <class _Tp> 1387_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_abstract_v 1388 = is_abstract<_Tp>::value; 1389#endif 1390 1391// is_final 1392 1393template <class _Tp> struct _LIBCPP_TEMPLATE_VIS 1394__libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {}; 1395 1396#if _LIBCPP_STD_VER > 11 1397template <class _Tp> struct _LIBCPP_TEMPLATE_VIS 1398is_final : public integral_constant<bool, __is_final(_Tp)> {}; 1399#endif 1400 1401#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1402template <class _Tp> 1403_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_final_v 1404 = is_final<_Tp>::value; 1405#endif 1406 1407// is_aggregate 1408#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE) 1409 1410template <class _Tp> struct _LIBCPP_TEMPLATE_VIS 1411is_aggregate : public integral_constant<bool, __is_aggregate(_Tp)> {}; 1412 1413#if !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1414template <class _Tp> 1415_LIBCPP_INLINE_VAR constexpr bool is_aggregate_v 1416 = is_aggregate<_Tp>::value; 1417#endif 1418 1419#endif // _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE) 1420 1421// is_base_of 1422 1423template <class _Bp, class _Dp> 1424struct _LIBCPP_TEMPLATE_VIS is_base_of 1425 : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {}; 1426 1427#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1428template <class _Bp, class _Dp> 1429_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_base_of_v 1430 = is_base_of<_Bp, _Dp>::value; 1431#endif 1432 1433// is_convertible 1434 1435#if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK) 1436 1437template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible 1438 : public integral_constant<bool, __is_convertible_to(_T1, _T2)> {}; 1439 1440#else // __has_feature(is_convertible_to) 1441 1442namespace __is_convertible_imp 1443{ 1444template <class _Tp> void __test_convert(_Tp); 1445 1446template <class _From, class _To, class = void> 1447struct __is_convertible_test : public false_type {}; 1448 1449template <class _From, class _To> 1450struct __is_convertible_test<_From, _To, 1451 decltype(_VSTD::__is_convertible_imp::__test_convert<_To>(_VSTD::declval<_From>()))> : public true_type 1452{}; 1453 1454template <class _Tp, bool _IsArray = is_array<_Tp>::value, 1455 bool _IsFunction = is_function<_Tp>::value, 1456 bool _IsVoid = is_void<_Tp>::value> 1457 struct __is_array_function_or_void {enum {value = 0};}; 1458template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};}; 1459template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};}; 1460template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};}; 1461} 1462 1463template <class _Tp, 1464 unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value> 1465struct __is_convertible_check 1466{ 1467 static const size_t __v = 0; 1468}; 1469 1470template <class _Tp> 1471struct __is_convertible_check<_Tp, 0> 1472{ 1473 static const size_t __v = sizeof(_Tp); 1474}; 1475 1476template <class _T1, class _T2, 1477 unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value, 1478 unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value> 1479struct __is_convertible 1480 : public integral_constant<bool, 1481 __is_convertible_imp::__is_convertible_test<_T1, _T2>::value 1482 > 1483{}; 1484 1485template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {}; 1486template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {}; 1487template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {}; 1488template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {}; 1489 1490template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {}; 1491template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {}; 1492template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {}; 1493template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {}; 1494 1495template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {}; 1496template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {}; 1497template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {}; 1498template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {}; 1499 1500template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible 1501 : public __is_convertible<_T1, _T2> 1502{ 1503 static const size_t __complete_check1 = __is_convertible_check<_T1>::__v; 1504 static const size_t __complete_check2 = __is_convertible_check<_T2>::__v; 1505}; 1506 1507#endif // __has_feature(is_convertible_to) 1508 1509#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1510template <class _From, class _To> 1511_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_convertible_v 1512 = is_convertible<_From, _To>::value; 1513#endif 1514 1515// is_nothrow_convertible 1516 1517#if _LIBCPP_STD_VER > 17 1518 1519template <typename _Tp> 1520static void __test_noexcept(_Tp) noexcept; 1521 1522template<typename _Fm, typename _To> 1523static bool_constant<noexcept(__test_noexcept<_To>(declval<_Fm>()))> 1524__is_nothrow_convertible_test(); 1525 1526template <typename _Fm, typename _To> 1527struct __is_nothrow_convertible_helper: decltype(__is_nothrow_convertible_test<_Fm, _To>()) 1528{ }; 1529 1530template <typename _Fm, typename _To> 1531struct is_nothrow_convertible : _Or< 1532 _And<is_void<_To>, is_void<_Fm>>, 1533 _Lazy<_And, is_convertible<_Fm, _To>, __is_nothrow_convertible_helper<_Fm, _To>> 1534>::type { }; 1535 1536template <typename _Fm, typename _To> 1537inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<_Fm, _To>::value; 1538 1539#endif // _LIBCPP_STD_VER > 17 1540 1541// is_empty 1542 1543#if __has_feature(is_empty) || defined(_LIBCPP_COMPILER_GCC) 1544 1545template <class _Tp> 1546struct _LIBCPP_TEMPLATE_VIS is_empty 1547 : public integral_constant<bool, __is_empty(_Tp)> {}; 1548 1549#else // __has_feature(is_empty) 1550 1551template <class _Tp> 1552struct __is_empty1 1553 : public _Tp 1554{ 1555 double __lx; 1556}; 1557 1558struct __is_empty2 1559{ 1560 double __lx; 1561}; 1562 1563template <class _Tp, bool = is_class<_Tp>::value> 1564struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {}; 1565 1566template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {}; 1567 1568template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_empty : public __libcpp_empty<_Tp> {}; 1569 1570#endif // __has_feature(is_empty) 1571 1572#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1573template <class _Tp> 1574_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_empty_v 1575 = is_empty<_Tp>::value; 1576#endif 1577 1578// is_polymorphic 1579 1580#if __has_feature(is_polymorphic) || defined(_LIBCPP_COMPILER_MSVC) 1581 1582template <class _Tp> 1583struct _LIBCPP_TEMPLATE_VIS is_polymorphic 1584 : public integral_constant<bool, __is_polymorphic(_Tp)> {}; 1585 1586#else 1587 1588template<typename _Tp> char &__is_polymorphic_impl( 1589 typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0, 1590 int>::type); 1591template<typename _Tp> __two &__is_polymorphic_impl(...); 1592 1593template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_polymorphic 1594 : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {}; 1595 1596#endif // __has_feature(is_polymorphic) 1597 1598#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1599template <class _Tp> 1600_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_polymorphic_v 1601 = is_polymorphic<_Tp>::value; 1602#endif 1603 1604// has_virtual_destructor 1605 1606#if __has_feature(has_virtual_destructor) || defined(_LIBCPP_COMPILER_GCC) 1607 1608template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor 1609 : public integral_constant<bool, __has_virtual_destructor(_Tp)> {}; 1610 1611#else 1612 1613template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor 1614 : public false_type {}; 1615 1616#endif 1617 1618#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1619template <class _Tp> 1620_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool has_virtual_destructor_v 1621 = has_virtual_destructor<_Tp>::value; 1622#endif 1623 1624// has_unique_object_representations 1625 1626#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS) 1627 1628template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_unique_object_representations 1629 : public integral_constant<bool, 1630 __has_unique_object_representations(remove_cv_t<remove_all_extents_t<_Tp>>)> {}; 1631 1632#if !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1633template <class _Tp> 1634_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool has_unique_object_representations_v 1635 = has_unique_object_representations<_Tp>::value; 1636#endif 1637 1638#endif 1639 1640// alignment_of 1641 1642template <class _Tp> struct _LIBCPP_TEMPLATE_VIS alignment_of 1643 : public integral_constant<size_t, _LIBCPP_ALIGNOF(_Tp)> {}; 1644 1645#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1646template <class _Tp> 1647_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t alignment_of_v 1648 = alignment_of<_Tp>::value; 1649#endif 1650 1651// aligned_storage 1652 1653template <class _Hp, class _Tp> 1654struct __type_list 1655{ 1656 typedef _Hp _Head; 1657 typedef _Tp _Tail; 1658}; 1659 1660struct __nat 1661{ 1662#ifndef _LIBCPP_CXX03_LANG 1663 __nat() = delete; 1664 __nat(const __nat&) = delete; 1665 __nat& operator=(const __nat&) = delete; 1666 ~__nat() = delete; 1667#endif 1668}; 1669 1670template <class _Tp> 1671struct __align_type 1672{ 1673 static const size_t value = _LIBCPP_PREFERRED_ALIGNOF(_Tp); 1674 typedef _Tp type; 1675}; 1676 1677struct __struct_double {long double __lx;}; 1678struct __struct_double4 {double __lx[4];}; 1679 1680typedef 1681 __type_list<__align_type<unsigned char>, 1682 __type_list<__align_type<unsigned short>, 1683 __type_list<__align_type<unsigned int>, 1684 __type_list<__align_type<unsigned long>, 1685 __type_list<__align_type<unsigned long long>, 1686 __type_list<__align_type<double>, 1687 __type_list<__align_type<long double>, 1688 __type_list<__align_type<__struct_double>, 1689 __type_list<__align_type<__struct_double4>, 1690 __type_list<__align_type<int*>, 1691 __nat 1692 > > > > > > > > > > __all_types; 1693 1694template <size_t _Align> 1695struct _ALIGNAS(_Align) __fallback_overaligned {}; 1696 1697template <class _TL, size_t _Align> struct __find_pod; 1698 1699template <class _Hp, size_t _Align> 1700struct __find_pod<__type_list<_Hp, __nat>, _Align> 1701{ 1702 typedef typename conditional< 1703 _Align == _Hp::value, 1704 typename _Hp::type, 1705 __fallback_overaligned<_Align> 1706 >::type type; 1707}; 1708 1709template <class _Hp, class _Tp, size_t _Align> 1710struct __find_pod<__type_list<_Hp, _Tp>, _Align> 1711{ 1712 typedef typename conditional< 1713 _Align == _Hp::value, 1714 typename _Hp::type, 1715 typename __find_pod<_Tp, _Align>::type 1716 >::type type; 1717}; 1718 1719template <class _TL, size_t _Len> struct __find_max_align; 1720 1721template <class _Hp, size_t _Len> 1722struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {}; 1723 1724template <size_t _Len, size_t _A1, size_t _A2> 1725struct __select_align 1726{ 1727private: 1728 static const size_t __min = _A2 < _A1 ? _A2 : _A1; 1729 static const size_t __max = _A1 < _A2 ? _A2 : _A1; 1730public: 1731 static const size_t value = _Len < __max ? __min : __max; 1732}; 1733 1734template <class _Hp, class _Tp, size_t _Len> 1735struct __find_max_align<__type_list<_Hp, _Tp>, _Len> 1736 : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {}; 1737 1738template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value> 1739struct _LIBCPP_TEMPLATE_VIS aligned_storage 1740{ 1741 typedef typename __find_pod<__all_types, _Align>::type _Aligner; 1742 union type 1743 { 1744 _Aligner __align; 1745 unsigned char __data[(_Len + _Align - 1)/_Align * _Align]; 1746 }; 1747}; 1748 1749#if _LIBCPP_STD_VER > 11 1750template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value> 1751 using aligned_storage_t = typename aligned_storage<_Len, _Align>::type; 1752#endif 1753 1754#define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \ 1755template <size_t _Len>\ 1756struct _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\ 1757{\ 1758 struct _ALIGNAS(n) type\ 1759 {\ 1760 unsigned char __lx[(_Len + n - 1)/n * n];\ 1761 };\ 1762} 1763 1764_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1); 1765_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2); 1766_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4); 1767_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8); 1768_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10); 1769_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20); 1770_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40); 1771_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80); 1772_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100); 1773_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200); 1774_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400); 1775_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800); 1776_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000); 1777_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000); 1778// PE/COFF does not support alignment beyond 8192 (=0x2000) 1779#if !defined(_LIBCPP_OBJECT_FORMAT_COFF) 1780_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000); 1781#endif // !defined(_LIBCPP_OBJECT_FORMAT_COFF) 1782 1783#undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION 1784 1785 1786// aligned_union 1787 1788template <size_t _I0, size_t ..._In> 1789struct __static_max; 1790 1791template <size_t _I0> 1792struct __static_max<_I0> 1793{ 1794 static const size_t value = _I0; 1795}; 1796 1797template <size_t _I0, size_t _I1, size_t ..._In> 1798struct __static_max<_I0, _I1, _In...> 1799{ 1800 static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value : 1801 __static_max<_I1, _In...>::value; 1802}; 1803 1804template <size_t _Len, class _Type0, class ..._Types> 1805struct aligned_union 1806{ 1807 static const size_t alignment_value = __static_max<_LIBCPP_PREFERRED_ALIGNOF(_Type0), 1808 _LIBCPP_PREFERRED_ALIGNOF(_Types)...>::value; 1809 static const size_t __len = __static_max<_Len, sizeof(_Type0), 1810 sizeof(_Types)...>::value; 1811 typedef typename aligned_storage<__len, alignment_value>::type type; 1812}; 1813 1814#if _LIBCPP_STD_VER > 11 1815template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type; 1816#endif 1817 1818template <class _Tp> 1819struct __numeric_type 1820{ 1821 static void __test(...); 1822 static float __test(float); 1823 static double __test(char); 1824 static double __test(int); 1825 static double __test(unsigned); 1826 static double __test(long); 1827 static double __test(unsigned long); 1828 static double __test(long long); 1829 static double __test(unsigned long long); 1830 static double __test(double); 1831 static long double __test(long double); 1832 1833 typedef decltype(__test(declval<_Tp>())) type; 1834 static const bool value = _IsNotSame<type, void>::value; 1835}; 1836 1837template <> 1838struct __numeric_type<void> 1839{ 1840 static const bool value = true; 1841}; 1842 1843// __promote 1844 1845template <class _A1, class _A2 = void, class _A3 = void, 1846 bool = __numeric_type<_A1>::value && 1847 __numeric_type<_A2>::value && 1848 __numeric_type<_A3>::value> 1849class __promote_imp 1850{ 1851public: 1852 static const bool value = false; 1853}; 1854 1855template <class _A1, class _A2, class _A3> 1856class __promote_imp<_A1, _A2, _A3, true> 1857{ 1858private: 1859 typedef typename __promote_imp<_A1>::type __type1; 1860 typedef typename __promote_imp<_A2>::type __type2; 1861 typedef typename __promote_imp<_A3>::type __type3; 1862public: 1863 typedef decltype(__type1() + __type2() + __type3()) type; 1864 static const bool value = true; 1865}; 1866 1867template <class _A1, class _A2> 1868class __promote_imp<_A1, _A2, void, true> 1869{ 1870private: 1871 typedef typename __promote_imp<_A1>::type __type1; 1872 typedef typename __promote_imp<_A2>::type __type2; 1873public: 1874 typedef decltype(__type1() + __type2()) type; 1875 static const bool value = true; 1876}; 1877 1878template <class _A1> 1879class __promote_imp<_A1, void, void, true> 1880{ 1881public: 1882 typedef typename __numeric_type<_A1>::type type; 1883 static const bool value = true; 1884}; 1885 1886template <class _A1, class _A2 = void, class _A3 = void> 1887class __promote : public __promote_imp<_A1, _A2, _A3> {}; 1888 1889// make_signed / make_unsigned 1890 1891typedef 1892 __type_list<signed char, 1893 __type_list<signed short, 1894 __type_list<signed int, 1895 __type_list<signed long, 1896 __type_list<signed long long, 1897#ifndef _LIBCPP_HAS_NO_INT128 1898 __type_list<__int128_t, 1899#endif 1900 __nat 1901#ifndef _LIBCPP_HAS_NO_INT128 1902 > 1903#endif 1904 > > > > > __signed_types; 1905 1906typedef 1907 __type_list<unsigned char, 1908 __type_list<unsigned short, 1909 __type_list<unsigned int, 1910 __type_list<unsigned long, 1911 __type_list<unsigned long long, 1912#ifndef _LIBCPP_HAS_NO_INT128 1913 __type_list<__uint128_t, 1914#endif 1915 __nat 1916#ifndef _LIBCPP_HAS_NO_INT128 1917 > 1918#endif 1919 > > > > > __unsigned_types; 1920 1921template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first; 1922 1923template <class _Hp, class _Tp, size_t _Size> 1924struct __find_first<__type_list<_Hp, _Tp>, _Size, true> 1925{ 1926 typedef _LIBCPP_NODEBUG_TYPE _Hp type; 1927}; 1928 1929template <class _Hp, class _Tp, size_t _Size> 1930struct __find_first<__type_list<_Hp, _Tp>, _Size, false> 1931{ 1932 typedef _LIBCPP_NODEBUG_TYPE typename __find_first<_Tp, _Size>::type type; 1933}; 1934 1935template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value, 1936 bool = is_volatile<typename remove_reference<_Tp>::type>::value> 1937struct __apply_cv 1938{ 1939 typedef _LIBCPP_NODEBUG_TYPE _Up type; 1940}; 1941 1942template <class _Tp, class _Up> 1943struct __apply_cv<_Tp, _Up, true, false> 1944{ 1945 typedef _LIBCPP_NODEBUG_TYPE const _Up type; 1946}; 1947 1948template <class _Tp, class _Up> 1949struct __apply_cv<_Tp, _Up, false, true> 1950{ 1951 typedef volatile _Up type; 1952}; 1953 1954template <class _Tp, class _Up> 1955struct __apply_cv<_Tp, _Up, true, true> 1956{ 1957 typedef const volatile _Up type; 1958}; 1959 1960template <class _Tp, class _Up> 1961struct __apply_cv<_Tp&, _Up, false, false> 1962{ 1963 typedef _Up& type; 1964}; 1965 1966template <class _Tp, class _Up> 1967struct __apply_cv<_Tp&, _Up, true, false> 1968{ 1969 typedef const _Up& type; 1970}; 1971 1972template <class _Tp, class _Up> 1973struct __apply_cv<_Tp&, _Up, false, true> 1974{ 1975 typedef volatile _Up& type; 1976}; 1977 1978template <class _Tp, class _Up> 1979struct __apply_cv<_Tp&, _Up, true, true> 1980{ 1981 typedef const volatile _Up& type; 1982}; 1983 1984template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value> 1985struct __make_signed {}; 1986 1987template <class _Tp> 1988struct __make_signed<_Tp, true> 1989{ 1990 typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type; 1991}; 1992 1993template <> struct __make_signed<bool, true> {}; 1994template <> struct __make_signed< signed short, true> {typedef short type;}; 1995template <> struct __make_signed<unsigned short, true> {typedef short type;}; 1996template <> struct __make_signed< signed int, true> {typedef int type;}; 1997template <> struct __make_signed<unsigned int, true> {typedef int type;}; 1998template <> struct __make_signed< signed long, true> {typedef long type;}; 1999template <> struct __make_signed<unsigned long, true> {typedef long type;}; 2000template <> struct __make_signed< signed long long, true> {typedef long long type;}; 2001template <> struct __make_signed<unsigned long long, true> {typedef long long type;}; 2002#ifndef _LIBCPP_HAS_NO_INT128 2003template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;}; 2004template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;}; 2005#endif 2006 2007template <class _Tp> 2008struct _LIBCPP_TEMPLATE_VIS make_signed 2009{ 2010 typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type; 2011}; 2012 2013#if _LIBCPP_STD_VER > 11 2014template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type; 2015#endif 2016 2017template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value> 2018struct __make_unsigned {}; 2019 2020template <class _Tp> 2021struct __make_unsigned<_Tp, true> 2022{ 2023 typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type; 2024}; 2025 2026template <> struct __make_unsigned<bool, true> {}; 2027template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;}; 2028template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;}; 2029template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;}; 2030template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;}; 2031template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;}; 2032template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;}; 2033template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;}; 2034template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;}; 2035#ifndef _LIBCPP_HAS_NO_INT128 2036template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;}; 2037template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;}; 2038#endif 2039 2040template <class _Tp> 2041struct _LIBCPP_TEMPLATE_VIS make_unsigned 2042{ 2043 typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type; 2044}; 2045 2046#if _LIBCPP_STD_VER > 11 2047template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type; 2048#endif 2049 2050template <class _Tp, class _Up, class = void> 2051struct __common_type2_imp {}; 2052 2053template <class _Tp, class _Up> 2054struct __common_type2_imp<_Tp, _Up, 2055 typename __void_t<decltype( 2056 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>() 2057 )>::type> 2058{ 2059 typedef _LIBCPP_NODEBUG_TYPE typename decay<decltype( 2060 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>() 2061 )>::type type; 2062}; 2063 2064template <class, class = void> 2065struct __common_type_impl {}; 2066 2067// Clang provides variadic templates in C++03 as an extension. 2068#if !defined(_LIBCPP_CXX03_LANG) || defined(__clang__) 2069# define _LIBCPP_OPTIONAL_PACK(...) , __VA_ARGS__ 2070template <class... Tp> 2071struct __common_types; 2072template <class... _Tp> 2073struct _LIBCPP_TEMPLATE_VIS common_type; 2074#else 2075# define _LIBCPP_OPTIONAL_PACK(...) 2076struct __no_arg; 2077template <class _Tp, class _Up, class = __no_arg> 2078struct __common_types; 2079template <class _Tp = __no_arg, class _Up = __no_arg, class _Vp = __no_arg, 2080 class _Unused = __no_arg> 2081struct common_type { 2082 static_assert(sizeof(_Unused) == 0, 2083 "common_type accepts at most 3 arguments in C++03"); 2084}; 2085#endif // _LIBCPP_CXX03_LANG 2086 2087template <class _Tp, class _Up> 2088struct __common_type_impl< 2089 __common_types<_Tp, _Up>, 2090 typename __void_t<typename common_type<_Tp, _Up>::type>::type> 2091{ 2092 typedef typename common_type<_Tp, _Up>::type type; 2093}; 2094 2095template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)> 2096struct __common_type_impl< 2097 __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)>, 2098 typename __void_t<typename common_type<_Tp, _Up>::type>::type> 2099 : __common_type_impl<__common_types<typename common_type<_Tp, _Up>::type, 2100 _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > { 2101}; 2102 2103// bullet 1 - sizeof...(Tp) == 0 2104 2105template <> 2106struct _LIBCPP_TEMPLATE_VIS common_type<> {}; 2107 2108// bullet 2 - sizeof...(Tp) == 1 2109 2110template <class _Tp> 2111struct _LIBCPP_TEMPLATE_VIS common_type<_Tp> 2112 : public common_type<_Tp, _Tp> {}; 2113 2114// bullet 3 - sizeof...(Tp) == 2 2115 2116template <class _Tp, class _Up> 2117struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up> 2118 : conditional< 2119 _IsSame<_Tp, typename decay<_Tp>::type>::value && _IsSame<_Up, typename decay<_Up>::type>::value, 2120 __common_type2_imp<_Tp, _Up>, 2121 common_type<typename decay<_Tp>::type, typename decay<_Up>::type> 2122 >::type 2123{}; 2124 2125// bullet 4 - sizeof...(Tp) > 2 2126 2127template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)> 2128struct _LIBCPP_TEMPLATE_VIS 2129 common_type<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> 2130 : __common_type_impl< 2131 __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {}; 2132 2133#undef _LIBCPP_OPTIONAL_PACK 2134 2135#if _LIBCPP_STD_VER > 11 2136template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type; 2137#endif 2138 2139// is_assignable 2140 2141template<typename, typename _Tp> struct __select_2nd { typedef _LIBCPP_NODEBUG_TYPE _Tp type; }; 2142 2143template <class _Tp, class _Arg> 2144typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type 2145__is_assignable_test(int); 2146 2147template <class, class> 2148false_type __is_assignable_test(...); 2149 2150 2151template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value> 2152struct __is_assignable_imp 2153 : public decltype((_VSTD::__is_assignable_test<_Tp, _Arg>(0))) {}; 2154 2155template <class _Tp, class _Arg> 2156struct __is_assignable_imp<_Tp, _Arg, true> 2157 : public false_type 2158{ 2159}; 2160 2161template <class _Tp, class _Arg> 2162struct is_assignable 2163 : public __is_assignable_imp<_Tp, _Arg> {}; 2164 2165#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 2166template <class _Tp, class _Arg> 2167_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_assignable_v 2168 = is_assignable<_Tp, _Arg>::value; 2169#endif 2170 2171// is_copy_assignable 2172 2173template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_copy_assignable 2174 : public is_assignable<typename add_lvalue_reference<_Tp>::type, 2175 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; 2176 2177#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 2178template <class _Tp> 2179_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_copy_assignable_v 2180 = is_copy_assignable<_Tp>::value; 2181#endif 2182 2183// is_move_assignable 2184 2185template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_move_assignable 2186 : public is_assignable<typename add_lvalue_reference<_Tp>::type, 2187 typename add_rvalue_reference<_Tp>::type> {}; 2188 2189#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 2190template <class _Tp> 2191_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_move_assignable_v 2192 = is_move_assignable<_Tp>::value; 2193#endif 2194 2195// is_destructible 2196 2197// if it's a reference, return true 2198// if it's a function, return false 2199// if it's void, return false 2200// if it's an array of unknown bound, return false 2201// Otherwise, return "std::declval<_Up&>().~_Up()" is well-formed 2202// where _Up is remove_all_extents<_Tp>::type 2203 2204template <class> 2205struct __is_destructible_apply { typedef int type; }; 2206 2207template <typename _Tp> 2208struct __is_destructor_wellformed { 2209 template <typename _Tp1> 2210 static char __test ( 2211 typename __is_destructible_apply<decltype(_VSTD::declval<_Tp1&>().~_Tp1())>::type 2212 ); 2213 2214 template <typename _Tp1> 2215 static __two __test (...); 2216 2217 static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char); 2218}; 2219 2220template <class _Tp, bool> 2221struct __destructible_imp; 2222 2223template <class _Tp> 2224struct __destructible_imp<_Tp, false> 2225 : public _VSTD::integral_constant<bool, 2226 __is_destructor_wellformed<typename _VSTD::remove_all_extents<_Tp>::type>::value> {}; 2227 2228template <class _Tp> 2229struct __destructible_imp<_Tp, true> 2230 : public _VSTD::true_type {}; 2231 2232template <class _Tp, bool> 2233struct __destructible_false; 2234 2235template <class _Tp> 2236struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, _VSTD::is_reference<_Tp>::value> {}; 2237 2238template <class _Tp> 2239struct __destructible_false<_Tp, true> : public _VSTD::false_type {}; 2240 2241template <class _Tp> 2242struct is_destructible 2243 : public __destructible_false<_Tp, _VSTD::is_function<_Tp>::value> {}; 2244 2245template <class _Tp> 2246struct is_destructible<_Tp[]> 2247 : public _VSTD::false_type {}; 2248 2249template <> 2250struct is_destructible<void> 2251 : public _VSTD::false_type {}; 2252 2253#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 2254template <class _Tp> 2255_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_destructible_v 2256 = is_destructible<_Tp>::value; 2257#endif 2258 2259// move 2260 2261template <class _Tp> 2262inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 2263typename remove_reference<_Tp>::type&& 2264move(_Tp&& __t) _NOEXCEPT 2265{ 2266 typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tp>::type _Up; 2267 return static_cast<_Up&&>(__t); 2268} 2269 2270template <class _Tp> 2271inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 2272_Tp&& 2273forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT 2274{ 2275 return static_cast<_Tp&&>(__t); 2276} 2277 2278template <class _Tp> 2279inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 2280_Tp&& 2281forward(typename remove_reference<_Tp>::type&& __t) _NOEXCEPT 2282{ 2283 static_assert(!is_lvalue_reference<_Tp>::value, 2284 "can not forward an rvalue as an lvalue"); 2285 return static_cast<_Tp&&>(__t); 2286} 2287 2288template <class _Tp> 2289inline _LIBCPP_INLINE_VISIBILITY 2290typename decay<_Tp>::type 2291__decay_copy(_Tp&& __t) 2292{ 2293 return _VSTD::forward<_Tp>(__t); 2294} 2295 2296template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr> 2297struct __member_pointer_traits_imp 2298{ 2299}; 2300 2301template <class _Rp, class _Class, class ..._Param> 2302struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false> 2303{ 2304 typedef _Class _ClassType; 2305 typedef _Rp _ReturnType; 2306 typedef _Rp (_FnType) (_Param...); 2307}; 2308 2309template <class _Rp, class _Class, class ..._Param> 2310struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false> 2311{ 2312 typedef _Class _ClassType; 2313 typedef _Rp _ReturnType; 2314 typedef _Rp (_FnType) (_Param..., ...); 2315}; 2316 2317template <class _Rp, class _Class, class ..._Param> 2318struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false> 2319{ 2320 typedef _Class const _ClassType; 2321 typedef _Rp _ReturnType; 2322 typedef _Rp (_FnType) (_Param...); 2323}; 2324 2325template <class _Rp, class _Class, class ..._Param> 2326struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false> 2327{ 2328 typedef _Class const _ClassType; 2329 typedef _Rp _ReturnType; 2330 typedef _Rp (_FnType) (_Param..., ...); 2331}; 2332 2333template <class _Rp, class _Class, class ..._Param> 2334struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false> 2335{ 2336 typedef _Class volatile _ClassType; 2337 typedef _Rp _ReturnType; 2338 typedef _Rp (_FnType) (_Param...); 2339}; 2340 2341template <class _Rp, class _Class, class ..._Param> 2342struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false> 2343{ 2344 typedef _Class volatile _ClassType; 2345 typedef _Rp _ReturnType; 2346 typedef _Rp (_FnType) (_Param..., ...); 2347}; 2348 2349template <class _Rp, class _Class, class ..._Param> 2350struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false> 2351{ 2352 typedef _Class const volatile _ClassType; 2353 typedef _Rp _ReturnType; 2354 typedef _Rp (_FnType) (_Param...); 2355}; 2356 2357template <class _Rp, class _Class, class ..._Param> 2358struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false> 2359{ 2360 typedef _Class const volatile _ClassType; 2361 typedef _Rp _ReturnType; 2362 typedef _Rp (_FnType) (_Param..., ...); 2363}; 2364 2365#if __has_feature(cxx_reference_qualified_functions) || defined(_LIBCPP_COMPILER_GCC) 2366 2367template <class _Rp, class _Class, class ..._Param> 2368struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false> 2369{ 2370 typedef _Class& _ClassType; 2371 typedef _Rp _ReturnType; 2372 typedef _Rp (_FnType) (_Param...); 2373}; 2374 2375template <class _Rp, class _Class, class ..._Param> 2376struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false> 2377{ 2378 typedef _Class& _ClassType; 2379 typedef _Rp _ReturnType; 2380 typedef _Rp (_FnType) (_Param..., ...); 2381}; 2382 2383template <class _Rp, class _Class, class ..._Param> 2384struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false> 2385{ 2386 typedef _Class const& _ClassType; 2387 typedef _Rp _ReturnType; 2388 typedef _Rp (_FnType) (_Param...); 2389}; 2390 2391template <class _Rp, class _Class, class ..._Param> 2392struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false> 2393{ 2394 typedef _Class const& _ClassType; 2395 typedef _Rp _ReturnType; 2396 typedef _Rp (_FnType) (_Param..., ...); 2397}; 2398 2399template <class _Rp, class _Class, class ..._Param> 2400struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false> 2401{ 2402 typedef _Class volatile& _ClassType; 2403 typedef _Rp _ReturnType; 2404 typedef _Rp (_FnType) (_Param...); 2405}; 2406 2407template <class _Rp, class _Class, class ..._Param> 2408struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false> 2409{ 2410 typedef _Class volatile& _ClassType; 2411 typedef _Rp _ReturnType; 2412 typedef _Rp (_FnType) (_Param..., ...); 2413}; 2414 2415template <class _Rp, class _Class, class ..._Param> 2416struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false> 2417{ 2418 typedef _Class const volatile& _ClassType; 2419 typedef _Rp _ReturnType; 2420 typedef _Rp (_FnType) (_Param...); 2421}; 2422 2423template <class _Rp, class _Class, class ..._Param> 2424struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false> 2425{ 2426 typedef _Class const volatile& _ClassType; 2427 typedef _Rp _ReturnType; 2428 typedef _Rp (_FnType) (_Param..., ...); 2429}; 2430 2431template <class _Rp, class _Class, class ..._Param> 2432struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false> 2433{ 2434 typedef _Class&& _ClassType; 2435 typedef _Rp _ReturnType; 2436 typedef _Rp (_FnType) (_Param...); 2437}; 2438 2439template <class _Rp, class _Class, class ..._Param> 2440struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false> 2441{ 2442 typedef _Class&& _ClassType; 2443 typedef _Rp _ReturnType; 2444 typedef _Rp (_FnType) (_Param..., ...); 2445}; 2446 2447template <class _Rp, class _Class, class ..._Param> 2448struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false> 2449{ 2450 typedef _Class const&& _ClassType; 2451 typedef _Rp _ReturnType; 2452 typedef _Rp (_FnType) (_Param...); 2453}; 2454 2455template <class _Rp, class _Class, class ..._Param> 2456struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false> 2457{ 2458 typedef _Class const&& _ClassType; 2459 typedef _Rp _ReturnType; 2460 typedef _Rp (_FnType) (_Param..., ...); 2461}; 2462 2463template <class _Rp, class _Class, class ..._Param> 2464struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false> 2465{ 2466 typedef _Class volatile&& _ClassType; 2467 typedef _Rp _ReturnType; 2468 typedef _Rp (_FnType) (_Param...); 2469}; 2470 2471template <class _Rp, class _Class, class ..._Param> 2472struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false> 2473{ 2474 typedef _Class volatile&& _ClassType; 2475 typedef _Rp _ReturnType; 2476 typedef _Rp (_FnType) (_Param..., ...); 2477}; 2478 2479template <class _Rp, class _Class, class ..._Param> 2480struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false> 2481{ 2482 typedef _Class const volatile&& _ClassType; 2483 typedef _Rp _ReturnType; 2484 typedef _Rp (_FnType) (_Param...); 2485}; 2486 2487template <class _Rp, class _Class, class ..._Param> 2488struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false> 2489{ 2490 typedef _Class const volatile&& _ClassType; 2491 typedef _Rp _ReturnType; 2492 typedef _Rp (_FnType) (_Param..., ...); 2493}; 2494 2495#endif // __has_feature(cxx_reference_qualified_functions) || defined(_LIBCPP_COMPILER_GCC) 2496 2497 2498template <class _Rp, class _Class> 2499struct __member_pointer_traits_imp<_Rp _Class::*, false, true> 2500{ 2501 typedef _Class _ClassType; 2502 typedef _Rp _ReturnType; 2503}; 2504 2505template <class _MP> 2506struct __member_pointer_traits 2507 : public __member_pointer_traits_imp<typename remove_cv<_MP>::type, 2508 is_member_function_pointer<_MP>::value, 2509 is_member_object_pointer<_MP>::value> 2510{ 2511// typedef ... _ClassType; 2512// typedef ... _ReturnType; 2513// typedef ... _FnType; 2514}; 2515 2516 2517template <class _DecayedFp> 2518struct __member_pointer_class_type {}; 2519 2520template <class _Ret, class _ClassType> 2521struct __member_pointer_class_type<_Ret _ClassType::*> { 2522 typedef _ClassType type; 2523}; 2524 2525// result_of 2526 2527template <class _Callable> class result_of; 2528 2529#ifdef _LIBCPP_HAS_NO_VARIADICS 2530 2531template <class _Fn, bool, bool> 2532class __result_of 2533{ 2534}; 2535 2536template <class _Fn> 2537class __result_of<_Fn(), true, false> 2538{ 2539public: 2540 typedef decltype(declval<_Fn>()()) type; 2541}; 2542 2543template <class _Fn, class _A0> 2544class __result_of<_Fn(_A0), true, false> 2545{ 2546public: 2547 typedef decltype(declval<_Fn>()(declval<_A0>())) type; 2548}; 2549 2550template <class _Fn, class _A0, class _A1> 2551class __result_of<_Fn(_A0, _A1), true, false> 2552{ 2553public: 2554 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type; 2555}; 2556 2557template <class _Fn, class _A0, class _A1, class _A2> 2558class __result_of<_Fn(_A0, _A1, _A2), true, false> 2559{ 2560public: 2561 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type; 2562}; 2563 2564template <class _MP, class _Tp, bool _IsMemberFunctionPtr> 2565struct __result_of_mp; 2566 2567// member function pointer 2568 2569template <class _MP, class _Tp> 2570struct __result_of_mp<_MP, _Tp, true> 2571 : public __identity<typename __member_pointer_traits<_MP>::_ReturnType> 2572{ 2573}; 2574 2575// member data pointer 2576 2577template <class _MP, class _Tp, bool> 2578struct __result_of_mdp; 2579 2580template <class _Rp, class _Class, class _Tp> 2581struct __result_of_mdp<_Rp _Class::*, _Tp, false> 2582{ 2583 typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type; 2584}; 2585 2586template <class _Rp, class _Class, class _Tp> 2587struct __result_of_mdp<_Rp _Class::*, _Tp, true> 2588{ 2589 typedef typename __apply_cv<_Tp, _Rp>::type& type; 2590}; 2591 2592template <class _Rp, class _Class, class _Tp> 2593struct __result_of_mp<_Rp _Class::*, _Tp, false> 2594 : public __result_of_mdp<_Rp _Class::*, _Tp, 2595 is_base_of<_Class, typename remove_reference<_Tp>::type>::value> 2596{ 2597}; 2598 2599 2600 2601template <class _Fn, class _Tp> 2602class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer 2603 : public __result_of_mp<typename remove_reference<_Fn>::type, 2604 _Tp, 2605 is_member_function_pointer<typename remove_reference<_Fn>::type>::value> 2606{ 2607}; 2608 2609template <class _Fn, class _Tp, class _A0> 2610class __result_of<_Fn(_Tp, _A0), false, true> // _Fn must be member pointer 2611 : public __result_of_mp<typename remove_reference<_Fn>::type, 2612 _Tp, 2613 is_member_function_pointer<typename remove_reference<_Fn>::type>::value> 2614{ 2615}; 2616 2617template <class _Fn, class _Tp, class _A0, class _A1> 2618class __result_of<_Fn(_Tp, _A0, _A1), false, true> // _Fn must be member pointer 2619 : public __result_of_mp<typename remove_reference<_Fn>::type, 2620 _Tp, 2621 is_member_function_pointer<typename remove_reference<_Fn>::type>::value> 2622{ 2623}; 2624 2625template <class _Fn, class _Tp, class _A0, class _A1, class _A2> 2626class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true> // _Fn must be member pointer 2627 : public __result_of_mp<typename remove_reference<_Fn>::type, 2628 _Tp, 2629 is_member_function_pointer<typename remove_reference<_Fn>::type>::value> 2630{ 2631}; 2632 2633// result_of 2634 2635template <class _Fn> 2636class _LIBCPP_TEMPLATE_VIS result_of<_Fn()> 2637 : public __result_of<_Fn(), 2638 is_class<typename remove_reference<_Fn>::type>::value || 2639 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value, 2640 is_member_pointer<typename remove_reference<_Fn>::type>::value 2641 > 2642{ 2643}; 2644 2645template <class _Fn, class _A0> 2646class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0)> 2647 : public __result_of<_Fn(_A0), 2648 is_class<typename remove_reference<_Fn>::type>::value || 2649 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value, 2650 is_member_pointer<typename remove_reference<_Fn>::type>::value 2651 > 2652{ 2653}; 2654 2655template <class _Fn, class _A0, class _A1> 2656class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1)> 2657 : public __result_of<_Fn(_A0, _A1), 2658 is_class<typename remove_reference<_Fn>::type>::value || 2659 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value, 2660 is_member_pointer<typename remove_reference<_Fn>::type>::value 2661 > 2662{ 2663}; 2664 2665template <class _Fn, class _A0, class _A1, class _A2> 2666class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1, _A2)> 2667 : public __result_of<_Fn(_A0, _A1, _A2), 2668 is_class<typename remove_reference<_Fn>::type>::value || 2669 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value, 2670 is_member_pointer<typename remove_reference<_Fn>::type>::value 2671 > 2672{ 2673}; 2674 2675#endif // _LIBCPP_HAS_NO_VARIADICS 2676 2677// template <class T, class... Args> struct is_constructible; 2678 2679namespace __is_construct 2680{ 2681struct __nat {}; 2682} 2683 2684#if !defined(_LIBCPP_CXX03_LANG) && (!__has_feature(is_constructible) || \ 2685 defined(_LIBCPP_TESTING_FALLBACK_IS_CONSTRUCTIBLE)) 2686 2687template <class _Tp, class... _Args> 2688struct __libcpp_is_constructible; 2689 2690template <class _To, class _From> 2691struct __is_invalid_base_to_derived_cast { 2692 static_assert(is_reference<_To>::value, "Wrong specialization"); 2693 using _RawFrom = __uncvref_t<_From>; 2694 using _RawTo = __uncvref_t<_To>; 2695 static const bool value = _And< 2696 _IsNotSame<_RawFrom, _RawTo>, 2697 is_base_of<_RawFrom, _RawTo>, 2698 _Not<__libcpp_is_constructible<_RawTo, _From>> 2699 >::value; 2700}; 2701 2702template <class _To, class _From> 2703struct __is_invalid_lvalue_to_rvalue_cast : false_type { 2704 static_assert(is_reference<_To>::value, "Wrong specialization"); 2705}; 2706 2707template <class _ToRef, class _FromRef> 2708struct __is_invalid_lvalue_to_rvalue_cast<_ToRef&&, _FromRef&> { 2709 using _RawFrom = __uncvref_t<_FromRef>; 2710 using _RawTo = __uncvref_t<_ToRef>; 2711 static const bool value = _And< 2712 _Not<is_function<_RawTo>>, 2713 _Or< 2714 _IsSame<_RawFrom, _RawTo>, 2715 is_base_of<_RawTo, _RawFrom>> 2716 >::value; 2717}; 2718 2719struct __is_constructible_helper 2720{ 2721 template <class _To> 2722 static void __eat(_To); 2723 2724 // This overload is needed to work around a Clang bug that disallows 2725 // static_cast<T&&>(e) for non-reference-compatible types. 2726 // Example: static_cast<int&&>(declval<double>()); 2727 // NOTE: The static_cast implementation below is required to support 2728 // classes with explicit conversion operators. 2729 template <class _To, class _From, 2730 class = decltype(__eat<_To>(_VSTD::declval<_From>()))> 2731 static true_type __test_cast(int); 2732 2733 template <class _To, class _From, 2734 class = decltype(static_cast<_To>(_VSTD::declval<_From>()))> 2735 static integral_constant<bool, 2736 !__is_invalid_base_to_derived_cast<_To, _From>::value && 2737 !__is_invalid_lvalue_to_rvalue_cast<_To, _From>::value 2738 > __test_cast(long); 2739 2740 template <class, class> 2741 static false_type __test_cast(...); 2742 2743 template <class _Tp, class ..._Args, 2744 class = decltype(_Tp(_VSTD::declval<_Args>()...))> 2745 static true_type __test_nary(int); 2746 template <class _Tp, class...> 2747 static false_type __test_nary(...); 2748 2749 template <class _Tp, class _A0, class = decltype(::new _Tp(_VSTD::declval<_A0>()))> 2750 static is_destructible<_Tp> __test_unary(int); 2751 template <class, class> 2752 static false_type __test_unary(...); 2753}; 2754 2755template <class _Tp, bool = is_void<_Tp>::value> 2756struct __is_default_constructible 2757 : decltype(__is_constructible_helper::__test_nary<_Tp>(0)) 2758{}; 2759 2760template <class _Tp> 2761struct __is_default_constructible<_Tp, true> : false_type {}; 2762 2763template <class _Tp> 2764struct __is_default_constructible<_Tp[], false> : false_type {}; 2765 2766template <class _Tp, size_t _Nx> 2767struct __is_default_constructible<_Tp[_Nx], false> 2768 : __is_default_constructible<typename remove_all_extents<_Tp>::type> {}; 2769 2770template <class _Tp, class... _Args> 2771struct __libcpp_is_constructible 2772{ 2773 static_assert(sizeof...(_Args) > 1, "Wrong specialization"); 2774 typedef decltype(__is_constructible_helper::__test_nary<_Tp, _Args...>(0)) 2775 type; 2776}; 2777 2778template <class _Tp> 2779struct __libcpp_is_constructible<_Tp> : __is_default_constructible<_Tp> {}; 2780 2781template <class _Tp, class _A0> 2782struct __libcpp_is_constructible<_Tp, _A0> 2783 : public decltype(__is_constructible_helper::__test_unary<_Tp, _A0>(0)) 2784{}; 2785 2786template <class _Tp, class _A0> 2787struct __libcpp_is_constructible<_Tp&, _A0> 2788 : public decltype(__is_constructible_helper:: 2789 __test_cast<_Tp&, _A0>(0)) 2790{}; 2791 2792template <class _Tp, class _A0> 2793struct __libcpp_is_constructible<_Tp&&, _A0> 2794 : public decltype(__is_constructible_helper:: 2795 __test_cast<_Tp&&, _A0>(0)) 2796{}; 2797 2798#endif 2799 2800#if __has_feature(is_constructible) 2801template <class _Tp, class ..._Args> 2802struct _LIBCPP_TEMPLATE_VIS is_constructible 2803 : public integral_constant<bool, __is_constructible(_Tp, _Args...)> 2804 {}; 2805#else 2806template <class _Tp, class... _Args> 2807struct _LIBCPP_TEMPLATE_VIS is_constructible 2808 : public __libcpp_is_constructible<_Tp, _Args...>::type {}; 2809#endif 2810 2811#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 2812template <class _Tp, class ..._Args> 2813_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_constructible_v 2814 = is_constructible<_Tp, _Args...>::value; 2815#endif 2816 2817// is_default_constructible 2818 2819template <class _Tp> 2820struct _LIBCPP_TEMPLATE_VIS is_default_constructible 2821 : public is_constructible<_Tp> 2822 {}; 2823 2824#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 2825template <class _Tp> 2826_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_default_constructible_v 2827 = is_default_constructible<_Tp>::value; 2828#endif 2829 2830#ifndef _LIBCPP_CXX03_LANG 2831// First of all, we can't implement this check in C++03 mode because the {} 2832// default initialization syntax isn't valid. 2833// Second, we implement the trait in a funny manner with two defaulted template 2834// arguments to workaround Clang's PR43454. 2835template <class _Tp> 2836void __test_implicit_default_constructible(_Tp); 2837 2838template <class _Tp, class = void, bool = is_default_constructible<_Tp>::value> 2839struct __is_implicitly_default_constructible 2840 : false_type 2841{ }; 2842 2843template <class _Tp> 2844struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({})), true> 2845 : true_type 2846{ }; 2847 2848template <class _Tp> 2849struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({})), false> 2850 : false_type 2851{ }; 2852#endif // !C++03 2853 2854// is_copy_constructible 2855 2856template <class _Tp> 2857struct _LIBCPP_TEMPLATE_VIS is_copy_constructible 2858 : public is_constructible<_Tp, 2859 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; 2860 2861#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 2862template <class _Tp> 2863_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_copy_constructible_v 2864 = is_copy_constructible<_Tp>::value; 2865#endif 2866 2867// is_move_constructible 2868 2869template <class _Tp> 2870struct _LIBCPP_TEMPLATE_VIS is_move_constructible 2871 : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> 2872 {}; 2873 2874#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 2875template <class _Tp> 2876_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_move_constructible_v 2877 = is_move_constructible<_Tp>::value; 2878#endif 2879 2880// is_trivially_constructible 2881 2882#if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501 2883 2884template <class _Tp, class... _Args> 2885struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible 2886 : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)> 2887{ 2888}; 2889 2890#else // !__has_feature(is_trivially_constructible) 2891 2892template <class _Tp, class... _Args> 2893struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible 2894 : false_type 2895{ 2896}; 2897 2898template <class _Tp> 2899struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp> 2900#if __has_feature(has_trivial_constructor) || defined(_LIBCPP_COMPILER_GCC) 2901 : integral_constant<bool, __has_trivial_constructor(_Tp)> 2902#else 2903 : integral_constant<bool, is_scalar<_Tp>::value> 2904#endif 2905{ 2906}; 2907 2908template <class _Tp> 2909struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&&> 2910 : integral_constant<bool, is_scalar<_Tp>::value> 2911{ 2912}; 2913 2914template <class _Tp> 2915struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&> 2916 : integral_constant<bool, is_scalar<_Tp>::value> 2917{ 2918}; 2919 2920template <class _Tp> 2921struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&> 2922 : integral_constant<bool, is_scalar<_Tp>::value> 2923{ 2924}; 2925 2926#endif // !__has_feature(is_trivially_constructible) 2927 2928 2929#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 2930template <class _Tp, class... _Args> 2931_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_constructible_v 2932 = is_trivially_constructible<_Tp, _Args...>::value; 2933#endif 2934 2935// is_trivially_default_constructible 2936 2937template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructible 2938 : public is_trivially_constructible<_Tp> 2939 {}; 2940 2941#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 2942template <class _Tp> 2943_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v 2944 = is_trivially_default_constructible<_Tp>::value; 2945#endif 2946 2947// is_trivially_copy_constructible 2948 2949template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible 2950 : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type> 2951 {}; 2952 2953#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 2954template <class _Tp> 2955_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v 2956 = is_trivially_copy_constructible<_Tp>::value; 2957#endif 2958 2959// is_trivially_move_constructible 2960 2961template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible 2962 : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> 2963 {}; 2964 2965#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 2966template <class _Tp> 2967_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v 2968 = is_trivially_move_constructible<_Tp>::value; 2969#endif 2970 2971// is_trivially_assignable 2972 2973#if __has_feature(is_trivially_assignable) || _GNUC_VER >= 501 2974 2975template <class _Tp, class _Arg> 2976struct is_trivially_assignable 2977 : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)> 2978{ 2979}; 2980 2981#else // !__has_feature(is_trivially_assignable) 2982 2983template <class _Tp, class _Arg> 2984struct is_trivially_assignable 2985 : public false_type {}; 2986 2987template <class _Tp> 2988struct is_trivially_assignable<_Tp&, _Tp> 2989 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2990 2991template <class _Tp> 2992struct is_trivially_assignable<_Tp&, _Tp&> 2993 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2994 2995template <class _Tp> 2996struct is_trivially_assignable<_Tp&, const _Tp&> 2997 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2998 2999template <class _Tp> 3000struct is_trivially_assignable<_Tp&, _Tp&&> 3001 : integral_constant<bool, is_scalar<_Tp>::value> {}; 3002 3003#endif // !__has_feature(is_trivially_assignable) 3004 3005#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 3006template <class _Tp, class _Arg> 3007_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_assignable_v 3008 = is_trivially_assignable<_Tp, _Arg>::value; 3009#endif 3010 3011// is_trivially_copy_assignable 3012 3013template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable 3014 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type, 3015 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; 3016 3017#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 3018template <class _Tp> 3019_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v 3020 = is_trivially_copy_assignable<_Tp>::value; 3021#endif 3022 3023// is_trivially_move_assignable 3024 3025template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable 3026 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type, 3027 typename add_rvalue_reference<_Tp>::type> 3028 {}; 3029 3030#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 3031template <class _Tp> 3032_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v 3033 = is_trivially_move_assignable<_Tp>::value; 3034#endif 3035 3036// is_trivially_destructible 3037 3038#if __has_keyword(__is_trivially_destructible) 3039 3040template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible 3041 : public integral_constant<bool, __is_trivially_destructible(_Tp)> {}; 3042 3043#elif __has_feature(has_trivial_destructor) || defined(_LIBCPP_COMPILER_GCC) 3044 3045template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible 3046 : public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {}; 3047 3048#else 3049 3050template <class _Tp> struct __libcpp_trivial_destructor 3051 : public integral_constant<bool, is_scalar<_Tp>::value || 3052 is_reference<_Tp>::value> {}; 3053 3054template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible 3055 : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {}; 3056 3057template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible<_Tp[]> 3058 : public false_type {}; 3059 3060#endif 3061 3062#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 3063template <class _Tp> 3064_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_destructible_v 3065 = is_trivially_destructible<_Tp>::value; 3066#endif 3067 3068// is_nothrow_constructible 3069 3070#if __has_keyword(__is_nothrow_constructible) 3071 3072template <class _Tp, class... _Args> 3073struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible 3074 : public integral_constant<bool, __is_nothrow_constructible(_Tp, _Args...)> {}; 3075 3076#else 3077 3078template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible; 3079 3080template <class _Tp, class... _Args> 3081struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...> 3082 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))> 3083{ 3084}; 3085 3086template <class _Tp> 3087void __implicit_conversion_to(_Tp) noexcept { } 3088 3089template <class _Tp, class _Arg> 3090struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg> 3091 : public integral_constant<bool, noexcept(__implicit_conversion_to<_Tp>(declval<_Arg>()))> 3092{ 3093}; 3094 3095template <class _Tp, bool _IsReference, class... _Args> 3096struct __libcpp_is_nothrow_constructible</*is constructible*/false, _IsReference, _Tp, _Args...> 3097 : public false_type 3098{ 3099}; 3100 3101template <class _Tp, class... _Args> 3102struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible 3103 : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...> 3104{ 3105}; 3106 3107template <class _Tp, size_t _Ns> 3108struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp[_Ns]> 3109 : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp> 3110{ 3111}; 3112 3113#endif // _LIBCPP_HAS_NO_NOEXCEPT 3114 3115 3116#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 3117template <class _Tp, class ..._Args> 3118_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v 3119 = is_nothrow_constructible<_Tp, _Args...>::value; 3120#endif 3121 3122// is_nothrow_default_constructible 3123 3124template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible 3125 : public is_nothrow_constructible<_Tp> 3126 {}; 3127 3128#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 3129template <class _Tp> 3130_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v 3131 = is_nothrow_default_constructible<_Tp>::value; 3132#endif 3133 3134// is_nothrow_copy_constructible 3135 3136template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible 3137 : public is_nothrow_constructible<_Tp, 3138 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; 3139 3140#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 3141template <class _Tp> 3142_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v 3143 = is_nothrow_copy_constructible<_Tp>::value; 3144#endif 3145 3146// is_nothrow_move_constructible 3147 3148template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible 3149 : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> 3150 {}; 3151 3152#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 3153template <class _Tp> 3154_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v 3155 = is_nothrow_move_constructible<_Tp>::value; 3156#endif 3157 3158// is_nothrow_assignable 3159 3160#if __has_keyword(__is_nothrow_assignable) 3161 3162template <class _Tp, class _Arg> 3163struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable 3164 : public integral_constant<bool, __is_nothrow_assignable(_Tp, _Arg)> {}; 3165 3166#else 3167 3168template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable; 3169 3170template <class _Tp, class _Arg> 3171struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg> 3172 : public false_type 3173{ 3174}; 3175 3176template <class _Tp, class _Arg> 3177struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg> 3178 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) > 3179{ 3180}; 3181 3182template <class _Tp, class _Arg> 3183struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable 3184 : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg> 3185{ 3186}; 3187 3188#endif // _LIBCPP_HAS_NO_NOEXCEPT 3189 3190#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 3191template <class _Tp, class _Arg> 3192_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v 3193 = is_nothrow_assignable<_Tp, _Arg>::value; 3194#endif 3195 3196// is_nothrow_copy_assignable 3197 3198template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable 3199 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type, 3200 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; 3201 3202#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 3203template <class _Tp> 3204_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v 3205 = is_nothrow_copy_assignable<_Tp>::value; 3206#endif 3207 3208// is_nothrow_move_assignable 3209 3210template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable 3211 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type, 3212 typename add_rvalue_reference<_Tp>::type> 3213 {}; 3214 3215#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 3216template <class _Tp> 3217_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v 3218 = is_nothrow_move_assignable<_Tp>::value; 3219#endif 3220 3221// is_nothrow_destructible 3222 3223#if !defined(_LIBCPP_CXX03_LANG) 3224 3225template <bool, class _Tp> struct __libcpp_is_nothrow_destructible; 3226 3227template <class _Tp> 3228struct __libcpp_is_nothrow_destructible<false, _Tp> 3229 : public false_type 3230{ 3231}; 3232 3233template <class _Tp> 3234struct __libcpp_is_nothrow_destructible<true, _Tp> 3235 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) > 3236{ 3237}; 3238 3239template <class _Tp> 3240struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible 3241 : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp> 3242{ 3243}; 3244 3245template <class _Tp, size_t _Ns> 3246struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[_Ns]> 3247 : public is_nothrow_destructible<_Tp> 3248{ 3249}; 3250 3251template <class _Tp> 3252struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&> 3253 : public true_type 3254{ 3255}; 3256 3257template <class _Tp> 3258struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&> 3259 : public true_type 3260{ 3261}; 3262 3263#else 3264 3265template <class _Tp> struct __libcpp_nothrow_destructor 3266 : public integral_constant<bool, is_scalar<_Tp>::value || 3267 is_reference<_Tp>::value> {}; 3268 3269template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible 3270 : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {}; 3271 3272template <class _Tp> 3273struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[]> 3274 : public false_type {}; 3275 3276#endif 3277 3278#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 3279template <class _Tp> 3280_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v 3281 = is_nothrow_destructible<_Tp>::value; 3282#endif 3283 3284// is_pod 3285 3286#if __has_feature(is_pod) || defined(_LIBCPP_COMPILER_GCC) 3287 3288template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod 3289 : public integral_constant<bool, __is_pod(_Tp)> {}; 3290 3291#else 3292 3293template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod 3294 : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value && 3295 is_trivially_copy_constructible<_Tp>::value && 3296 is_trivially_copy_assignable<_Tp>::value && 3297 is_trivially_destructible<_Tp>::value> {}; 3298 3299#endif 3300 3301#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 3302template <class _Tp> 3303_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pod_v 3304 = is_pod<_Tp>::value; 3305#endif 3306 3307// is_literal_type; 3308 3309template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_literal_type 3310 : public integral_constant<bool, __is_literal_type(_Tp)> 3311 {}; 3312 3313#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 3314template <class _Tp> 3315_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_literal_type_v 3316 = is_literal_type<_Tp>::value; 3317#endif 3318 3319// is_standard_layout; 3320 3321template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_standard_layout 3322#if __has_feature(is_standard_layout) || defined(_LIBCPP_COMPILER_GCC) 3323 : public integral_constant<bool, __is_standard_layout(_Tp)> 3324#else 3325 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value> 3326#endif 3327 {}; 3328 3329#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 3330template <class _Tp> 3331_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_standard_layout_v 3332 = is_standard_layout<_Tp>::value; 3333#endif 3334 3335// is_trivially_copyable; 3336 3337template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copyable 3338#if __has_feature(is_trivially_copyable) 3339 : public integral_constant<bool, __is_trivially_copyable(_Tp)> 3340#elif _GNUC_VER >= 501 3341 : public integral_constant<bool, !is_volatile<_Tp>::value && __is_trivially_copyable(_Tp)> 3342#else 3343 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value> 3344#endif 3345 {}; 3346 3347#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 3348template <class _Tp> 3349_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copyable_v 3350 = is_trivially_copyable<_Tp>::value; 3351#endif 3352 3353// is_trivial; 3354 3355template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivial 3356#if __has_feature(is_trivial) || defined(_LIBCPP_COMPILER_GCC) 3357 : public integral_constant<bool, __is_trivial(_Tp)> 3358#else 3359 : integral_constant<bool, is_trivially_copyable<_Tp>::value && 3360 is_trivially_default_constructible<_Tp>::value> 3361#endif 3362 {}; 3363 3364#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 3365template <class _Tp> 3366_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivial_v 3367 = is_trivial<_Tp>::value; 3368#endif 3369 3370template <class _Tp> struct __is_reference_wrapper_impl : public false_type {}; 3371template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {}; 3372template <class _Tp> struct __is_reference_wrapper 3373 : public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {}; 3374 3375#ifndef _LIBCPP_CXX03_LANG 3376 3377template <class _Fp, class _A0, 3378 class _DecayFp = typename decay<_Fp>::type, 3379 class _DecayA0 = typename decay<_A0>::type, 3380 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type> 3381using __enable_if_bullet1 = typename enable_if 3382 < 3383 is_member_function_pointer<_DecayFp>::value 3384 && is_base_of<_ClassT, _DecayA0>::value 3385 >::type; 3386 3387template <class _Fp, class _A0, 3388 class _DecayFp = typename decay<_Fp>::type, 3389 class _DecayA0 = typename decay<_A0>::type> 3390using __enable_if_bullet2 = typename enable_if 3391 < 3392 is_member_function_pointer<_DecayFp>::value 3393 && __is_reference_wrapper<_DecayA0>::value 3394 >::type; 3395 3396template <class _Fp, class _A0, 3397 class _DecayFp = typename decay<_Fp>::type, 3398 class _DecayA0 = typename decay<_A0>::type, 3399 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type> 3400using __enable_if_bullet3 = typename enable_if 3401 < 3402 is_member_function_pointer<_DecayFp>::value 3403 && !is_base_of<_ClassT, _DecayA0>::value 3404 && !__is_reference_wrapper<_DecayA0>::value 3405 >::type; 3406 3407template <class _Fp, class _A0, 3408 class _DecayFp = typename decay<_Fp>::type, 3409 class _DecayA0 = typename decay<_A0>::type, 3410 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type> 3411using __enable_if_bullet4 = typename enable_if 3412 < 3413 is_member_object_pointer<_DecayFp>::value 3414 && is_base_of<_ClassT, _DecayA0>::value 3415 >::type; 3416 3417template <class _Fp, class _A0, 3418 class _DecayFp = typename decay<_Fp>::type, 3419 class _DecayA0 = typename decay<_A0>::type> 3420using __enable_if_bullet5 = typename enable_if 3421 < 3422 is_member_object_pointer<_DecayFp>::value 3423 && __is_reference_wrapper<_DecayA0>::value 3424 >::type; 3425 3426template <class _Fp, class _A0, 3427 class _DecayFp = typename decay<_Fp>::type, 3428 class _DecayA0 = typename decay<_A0>::type, 3429 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type> 3430using __enable_if_bullet6 = typename enable_if 3431 < 3432 is_member_object_pointer<_DecayFp>::value 3433 && !is_base_of<_ClassT, _DecayA0>::value 3434 && !__is_reference_wrapper<_DecayA0>::value 3435 >::type; 3436 3437// __invoke forward declarations 3438 3439// fall back - none of the bullets 3440 3441#define _LIBCPP_INVOKE_RETURN(...) \ 3442 noexcept(noexcept(__VA_ARGS__)) -> decltype(__VA_ARGS__) \ 3443 { return __VA_ARGS__; } 3444 3445template <class ..._Args> 3446auto __invoke(__any, _Args&& ...__args) -> __nat; 3447 3448template <class ..._Args> 3449auto __invoke_constexpr(__any, _Args&& ...__args) -> __nat; 3450 3451// bullets 1, 2 and 3 3452 3453template <class _Fp, class _A0, class ..._Args, 3454 class = __enable_if_bullet1<_Fp, _A0>> 3455inline _LIBCPP_INLINE_VISIBILITY 3456auto 3457__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args) 3458_LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...)) 3459 3460template <class _Fp, class _A0, class ..._Args, 3461 class = __enable_if_bullet1<_Fp, _A0>> 3462inline _LIBCPP_INLINE_VISIBILITY 3463_LIBCPP_CONSTEXPR auto 3464__invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args) 3465_LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...)) 3466 3467template <class _Fp, class _A0, class ..._Args, 3468 class = __enable_if_bullet2<_Fp, _A0>> 3469inline _LIBCPP_INLINE_VISIBILITY 3470auto 3471__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args) 3472_LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...)) 3473 3474template <class _Fp, class _A0, class ..._Args, 3475 class = __enable_if_bullet2<_Fp, _A0>> 3476inline _LIBCPP_INLINE_VISIBILITY 3477_LIBCPP_CONSTEXPR auto 3478__invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args) 3479_LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...)) 3480 3481template <class _Fp, class _A0, class ..._Args, 3482 class = __enable_if_bullet3<_Fp, _A0>> 3483inline _LIBCPP_INLINE_VISIBILITY 3484auto 3485__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args) 3486_LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...)) 3487 3488template <class _Fp, class _A0, class ..._Args, 3489 class = __enable_if_bullet3<_Fp, _A0>> 3490inline _LIBCPP_INLINE_VISIBILITY 3491_LIBCPP_CONSTEXPR auto 3492__invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args) 3493_LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...)) 3494 3495// bullets 4, 5 and 6 3496 3497template <class _Fp, class _A0, 3498 class = __enable_if_bullet4<_Fp, _A0>> 3499inline _LIBCPP_INLINE_VISIBILITY 3500auto 3501__invoke(_Fp&& __f, _A0&& __a0) 3502_LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f) 3503 3504template <class _Fp, class _A0, 3505 class = __enable_if_bullet4<_Fp, _A0>> 3506inline _LIBCPP_INLINE_VISIBILITY 3507_LIBCPP_CONSTEXPR auto 3508__invoke_constexpr(_Fp&& __f, _A0&& __a0) 3509_LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f) 3510 3511template <class _Fp, class _A0, 3512 class = __enable_if_bullet5<_Fp, _A0>> 3513inline _LIBCPP_INLINE_VISIBILITY 3514auto 3515__invoke(_Fp&& __f, _A0&& __a0) 3516_LIBCPP_INVOKE_RETURN(__a0.get().*__f) 3517 3518template <class _Fp, class _A0, 3519 class = __enable_if_bullet5<_Fp, _A0>> 3520inline _LIBCPP_INLINE_VISIBILITY 3521_LIBCPP_CONSTEXPR auto 3522__invoke_constexpr(_Fp&& __f, _A0&& __a0) 3523_LIBCPP_INVOKE_RETURN(__a0.get().*__f) 3524 3525template <class _Fp, class _A0, 3526 class = __enable_if_bullet6<_Fp, _A0>> 3527inline _LIBCPP_INLINE_VISIBILITY 3528auto 3529__invoke(_Fp&& __f, _A0&& __a0) 3530_LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f) 3531 3532template <class _Fp, class _A0, 3533 class = __enable_if_bullet6<_Fp, _A0>> 3534inline _LIBCPP_INLINE_VISIBILITY 3535_LIBCPP_CONSTEXPR auto 3536__invoke_constexpr(_Fp&& __f, _A0&& __a0) 3537_LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f) 3538 3539// bullet 7 3540 3541template <class _Fp, class ..._Args> 3542inline _LIBCPP_INLINE_VISIBILITY 3543auto 3544__invoke(_Fp&& __f, _Args&& ...__args) 3545_LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...)) 3546 3547template <class _Fp, class ..._Args> 3548inline _LIBCPP_INLINE_VISIBILITY 3549_LIBCPP_CONSTEXPR auto 3550__invoke_constexpr(_Fp&& __f, _Args&& ...__args) 3551_LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...)) 3552 3553#undef _LIBCPP_INVOKE_RETURN 3554 3555// __invokable 3556template <class _Ret, class _Fp, class ..._Args> 3557struct __invokable_r 3558{ 3559 template <class _XFp, class ..._XArgs> 3560 static auto __try_call(int) -> decltype( 3561 _VSTD::__invoke(_VSTD::declval<_XFp>(), _VSTD::declval<_XArgs>()...)); 3562 template <class _XFp, class ..._XArgs> 3563 static __nat __try_call(...); 3564 3565 // FIXME: Check that _Ret, _Fp, and _Args... are all complete types, cv void, 3566 // or incomplete array types as required by the standard. 3567 using _Result = decltype(__try_call<_Fp, _Args...>(0)); 3568 3569 using type = 3570 typename conditional< 3571 _IsNotSame<_Result, __nat>::value, 3572 typename conditional< 3573 is_void<_Ret>::value, 3574 true_type, 3575 is_convertible<_Result, _Ret> 3576 >::type, 3577 false_type 3578 >::type; 3579 static const bool value = type::value; 3580}; 3581template <class _Fp, class ..._Args> 3582using __invokable = __invokable_r<void, _Fp, _Args...>; 3583 3584template <bool _IsInvokable, bool _IsCVVoid, class _Ret, class _Fp, class ..._Args> 3585struct __nothrow_invokable_r_imp { 3586 static const bool value = false; 3587}; 3588 3589template <class _Ret, class _Fp, class ..._Args> 3590struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...> 3591{ 3592 typedef __nothrow_invokable_r_imp _ThisT; 3593 3594 template <class _Tp> 3595 static void __test_noexcept(_Tp) noexcept; 3596 3597 static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>( 3598 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...))); 3599}; 3600 3601template <class _Ret, class _Fp, class ..._Args> 3602struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...> 3603{ 3604 static const bool value = noexcept( 3605 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)); 3606}; 3607 3608template <class _Ret, class _Fp, class ..._Args> 3609using __nothrow_invokable_r = 3610 __nothrow_invokable_r_imp< 3611 __invokable_r<_Ret, _Fp, _Args...>::value, 3612 is_void<_Ret>::value, 3613 _Ret, _Fp, _Args... 3614 >; 3615 3616template <class _Fp, class ..._Args> 3617using __nothrow_invokable = 3618 __nothrow_invokable_r_imp< 3619 __invokable<_Fp, _Args...>::value, 3620 true, void, _Fp, _Args... 3621 >; 3622 3623template <class _Fp, class ..._Args> 3624struct __invoke_of 3625 : public enable_if< 3626 __invokable<_Fp, _Args...>::value, 3627 typename __invokable_r<void, _Fp, _Args...>::_Result> 3628{ 3629}; 3630 3631// result_of 3632 3633template <class _Fp, class ..._Args> 3634class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)> 3635 : public __invoke_of<_Fp, _Args...> 3636{ 3637}; 3638 3639#if _LIBCPP_STD_VER > 11 3640template <class _Tp> using result_of_t = typename result_of<_Tp>::type; 3641#endif 3642 3643#if _LIBCPP_STD_VER > 14 3644 3645// invoke_result 3646 3647template <class _Fn, class... _Args> 3648struct _LIBCPP_TEMPLATE_VIS invoke_result 3649 : __invoke_of<_Fn, _Args...> 3650{ 3651}; 3652 3653template <class _Fn, class... _Args> 3654using invoke_result_t = typename invoke_result<_Fn, _Args...>::type; 3655 3656// is_invocable 3657 3658template <class _Fn, class ..._Args> 3659struct _LIBCPP_TEMPLATE_VIS is_invocable 3660 : integral_constant<bool, __invokable<_Fn, _Args...>::value> {}; 3661 3662template <class _Ret, class _Fn, class ..._Args> 3663struct _LIBCPP_TEMPLATE_VIS is_invocable_r 3664 : integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value> {}; 3665 3666template <class _Fn, class ..._Args> 3667_LIBCPP_INLINE_VAR constexpr bool is_invocable_v 3668 = is_invocable<_Fn, _Args...>::value; 3669 3670template <class _Ret, class _Fn, class ..._Args> 3671_LIBCPP_INLINE_VAR constexpr bool is_invocable_r_v 3672 = is_invocable_r<_Ret, _Fn, _Args...>::value; 3673 3674// is_nothrow_invocable 3675 3676template <class _Fn, class ..._Args> 3677struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable 3678 : integral_constant<bool, __nothrow_invokable<_Fn, _Args...>::value> {}; 3679 3680template <class _Ret, class _Fn, class ..._Args> 3681struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable_r 3682 : integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value> {}; 3683 3684template <class _Fn, class ..._Args> 3685_LIBCPP_INLINE_VAR constexpr bool is_nothrow_invocable_v 3686 = is_nothrow_invocable<_Fn, _Args...>::value; 3687 3688template <class _Ret, class _Fn, class ..._Args> 3689_LIBCPP_INLINE_VAR constexpr bool is_nothrow_invocable_r_v 3690 = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value; 3691 3692#endif // _LIBCPP_STD_VER > 14 3693 3694#endif // !defined(_LIBCPP_CXX03_LANG) 3695 3696template <class _Tp> struct __is_swappable; 3697template <class _Tp> struct __is_nothrow_swappable; 3698 3699// swap, swap_ranges 3700 3701template <class _ForwardIterator1, class _ForwardIterator2> 3702inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 3703_ForwardIterator2 3704swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2); 3705 3706template <class _Tp> 3707inline _LIBCPP_INLINE_VISIBILITY 3708#ifndef _LIBCPP_CXX03_LANG 3709typename enable_if 3710< 3711 is_move_constructible<_Tp>::value && 3712 is_move_assignable<_Tp>::value 3713>::type 3714#else 3715void 3716#endif 3717_LIBCPP_CONSTEXPR_AFTER_CXX17 3718swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value && 3719 is_nothrow_move_assignable<_Tp>::value) 3720{ 3721 _Tp __t(_VSTD::move(__x)); 3722 __x = _VSTD::move(__y); 3723 __y = _VSTD::move(__t); 3724} 3725 3726template<class _Tp, size_t _Np> 3727inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 3728typename enable_if< 3729 __is_swappable<_Tp>::value 3730>::type 3731swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) 3732{ 3733 _VSTD::swap_ranges(__a, __a + _Np, __b); 3734} 3735 3736template <class _ForwardIterator1, class _ForwardIterator2> 3737inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 3738_ForwardIterator2 3739swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) 3740{ 3741 for(; __first1 != __last1; ++__first1, (void) ++__first2) 3742 swap(*__first1, *__first2); 3743 return __first2; 3744} 3745 3746// iter_swap 3747 3748template <class _ForwardIterator1, class _ForwardIterator2> 3749inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 3750void 3751iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b) 3752 // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b))) 3753 _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(), 3754 *_VSTD::declval<_ForwardIterator2>()))) 3755{ 3756 swap(*__a, *__b); 3757} 3758 3759// __swappable 3760 3761namespace __detail 3762{ 3763// ALL generic swap overloads MUST already have a declaration available at this point. 3764 3765template <class _Tp, class _Up = _Tp, 3766 bool _NotVoid = !is_void<_Tp>::value && !is_void<_Up>::value> 3767struct __swappable_with 3768{ 3769 template <class _LHS, class _RHS> 3770 static decltype(swap(_VSTD::declval<_LHS>(), _VSTD::declval<_RHS>())) 3771 __test_swap(int); 3772 template <class, class> 3773 static __nat __test_swap(long); 3774 3775 // Extra parens are needed for the C++03 definition of decltype. 3776 typedef decltype((__test_swap<_Tp, _Up>(0))) __swap1; 3777 typedef decltype((__test_swap<_Up, _Tp>(0))) __swap2; 3778 3779 static const bool value = _IsNotSame<__swap1, __nat>::value 3780 && _IsNotSame<__swap2, __nat>::value; 3781}; 3782 3783template <class _Tp, class _Up> 3784struct __swappable_with<_Tp, _Up, false> : false_type {}; 3785 3786template <class _Tp, class _Up = _Tp, bool _Swappable = __swappable_with<_Tp, _Up>::value> 3787struct __nothrow_swappable_with { 3788 static const bool value = 3789#ifndef _LIBCPP_HAS_NO_NOEXCEPT 3790 noexcept(swap(_VSTD::declval<_Tp>(), _VSTD::declval<_Up>())) 3791 && noexcept(swap(_VSTD::declval<_Up>(), _VSTD::declval<_Tp>())); 3792#else 3793 false; 3794#endif 3795}; 3796 3797template <class _Tp, class _Up> 3798struct __nothrow_swappable_with<_Tp, _Up, false> : false_type {}; 3799 3800} // __detail 3801 3802template <class _Tp> 3803struct __is_swappable 3804 : public integral_constant<bool, __detail::__swappable_with<_Tp&>::value> 3805{ 3806}; 3807 3808template <class _Tp> 3809struct __is_nothrow_swappable 3810 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp&>::value> 3811{ 3812}; 3813 3814#if _LIBCPP_STD_VER > 14 3815 3816template <class _Tp, class _Up> 3817struct _LIBCPP_TEMPLATE_VIS is_swappable_with 3818 : public integral_constant<bool, __detail::__swappable_with<_Tp, _Up>::value> 3819{ 3820}; 3821 3822template <class _Tp> 3823struct _LIBCPP_TEMPLATE_VIS is_swappable 3824 : public conditional< 3825 __is_referenceable<_Tp>::value, 3826 is_swappable_with< 3827 typename add_lvalue_reference<_Tp>::type, 3828 typename add_lvalue_reference<_Tp>::type>, 3829 false_type 3830 >::type 3831{ 3832}; 3833 3834template <class _Tp, class _Up> 3835struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable_with 3836 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp, _Up>::value> 3837{ 3838}; 3839 3840template <class _Tp> 3841struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable 3842 : public conditional< 3843 __is_referenceable<_Tp>::value, 3844 is_nothrow_swappable_with< 3845 typename add_lvalue_reference<_Tp>::type, 3846 typename add_lvalue_reference<_Tp>::type>, 3847 false_type 3848 >::type 3849{ 3850}; 3851 3852template <class _Tp, class _Up> 3853_LIBCPP_INLINE_VAR constexpr bool is_swappable_with_v 3854 = is_swappable_with<_Tp, _Up>::value; 3855 3856template <class _Tp> 3857_LIBCPP_INLINE_VAR constexpr bool is_swappable_v 3858 = is_swappable<_Tp>::value; 3859 3860template <class _Tp, class _Up> 3861_LIBCPP_INLINE_VAR constexpr bool is_nothrow_swappable_with_v 3862 = is_nothrow_swappable_with<_Tp, _Up>::value; 3863 3864template <class _Tp> 3865_LIBCPP_INLINE_VAR constexpr bool is_nothrow_swappable_v 3866 = is_nothrow_swappable<_Tp>::value; 3867 3868#endif // _LIBCPP_STD_VER > 14 3869 3870template <class _Tp, bool = is_enum<_Tp>::value> struct __underlying_type_impl; 3871 3872template <class _Tp> 3873struct __underlying_type_impl<_Tp, false> {}; 3874 3875template <class _Tp> 3876struct __underlying_type_impl<_Tp, true> 3877{ 3878 typedef __underlying_type(_Tp) type; 3879}; 3880 3881template <class _Tp> 3882struct underlying_type : __underlying_type_impl<_Tp, is_enum<_Tp>::value> {}; 3883 3884#if _LIBCPP_STD_VER > 11 3885template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type; 3886#endif 3887 3888 3889template <class _Tp, bool = is_enum<_Tp>::value> 3890struct __sfinae_underlying_type 3891{ 3892 typedef typename underlying_type<_Tp>::type type; 3893 typedef decltype(((type)1) + 0) __promoted_type; 3894}; 3895 3896template <class _Tp> 3897struct __sfinae_underlying_type<_Tp, false> {}; 3898 3899inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 3900int __convert_to_integral(int __val) { return __val; } 3901 3902inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 3903unsigned __convert_to_integral(unsigned __val) { return __val; } 3904 3905inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 3906long __convert_to_integral(long __val) { return __val; } 3907 3908inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 3909unsigned long __convert_to_integral(unsigned long __val) { return __val; } 3910 3911inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 3912long long __convert_to_integral(long long __val) { return __val; } 3913 3914inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 3915unsigned long long __convert_to_integral(unsigned long long __val) {return __val; } 3916 3917template<typename _Fp> 3918inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 3919typename enable_if<is_floating_point<_Fp>::value, long long>::type 3920 __convert_to_integral(_Fp __val) { return __val; } 3921 3922#ifndef _LIBCPP_HAS_NO_INT128 3923inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 3924__int128_t __convert_to_integral(__int128_t __val) { return __val; } 3925 3926inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 3927__uint128_t __convert_to_integral(__uint128_t __val) { return __val; } 3928#endif 3929 3930template <class _Tp> 3931inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 3932typename __sfinae_underlying_type<_Tp>::__promoted_type 3933__convert_to_integral(_Tp __val) { return __val; } 3934 3935#ifndef _LIBCPP_CXX03_LANG 3936 3937template <class _Tp> 3938struct __has_operator_addressof_member_imp 3939{ 3940 template <class _Up> 3941 static auto __test(int) 3942 -> typename __select_2nd<decltype(_VSTD::declval<_Up>().operator&()), true_type>::type; 3943 template <class> 3944 static auto __test(long) -> false_type; 3945 3946 static const bool value = decltype(__test<_Tp>(0))::value; 3947}; 3948 3949template <class _Tp> 3950struct __has_operator_addressof_free_imp 3951{ 3952 template <class _Up> 3953 static auto __test(int) 3954 -> typename __select_2nd<decltype(operator&(_VSTD::declval<_Up>())), true_type>::type; 3955 template <class> 3956 static auto __test(long) -> false_type; 3957 3958 static const bool value = decltype(__test<_Tp>(0))::value; 3959}; 3960 3961template <class _Tp> 3962struct __has_operator_addressof 3963 : public integral_constant<bool, __has_operator_addressof_member_imp<_Tp>::value 3964 || __has_operator_addressof_free_imp<_Tp>::value> 3965{}; 3966 3967#endif // _LIBCPP_CXX03_LANG 3968 3969#if _LIBCPP_STD_VER > 14 3970 3971template <class...> using void_t = void; 3972 3973template <class... _Args> 3974struct conjunction : _And<_Args...> {}; 3975template<class... _Args> 3976_LIBCPP_INLINE_VAR constexpr bool conjunction_v 3977 = conjunction<_Args...>::value; 3978 3979template <class... _Args> 3980struct disjunction : _Or<_Args...> {}; 3981template<class... _Args> 3982_LIBCPP_INLINE_VAR constexpr bool disjunction_v 3983 = disjunction<_Args...>::value; 3984 3985template <class _Tp> 3986struct negation : _Not<_Tp> {}; 3987template<class _Tp> 3988_LIBCPP_INLINE_VAR constexpr bool negation_v 3989 = negation<_Tp>::value; 3990#endif // _LIBCPP_STD_VER > 14 3991 3992// These traits are used in __tree and __hash_table 3993#ifndef _LIBCPP_CXX03_LANG 3994struct __extract_key_fail_tag {}; 3995struct __extract_key_self_tag {}; 3996struct __extract_key_first_tag {}; 3997 3998template <class _ValTy, class _Key, 3999 class _RawValTy = typename __unconstref<_ValTy>::type> 4000struct __can_extract_key 4001 : conditional<_IsSame<_RawValTy, _Key>::value, __extract_key_self_tag, 4002 __extract_key_fail_tag>::type {}; 4003 4004template <class _Pair, class _Key, class _First, class _Second> 4005struct __can_extract_key<_Pair, _Key, pair<_First, _Second>> 4006 : conditional<_IsSame<typename remove_const<_First>::type, _Key>::value, 4007 __extract_key_first_tag, __extract_key_fail_tag>::type {}; 4008 4009// __can_extract_map_key uses true_type/false_type instead of the tags. 4010// It returns true if _Key != _ContainerValueTy (the container is a map not a set) 4011// and _ValTy == _Key. 4012template <class _ValTy, class _Key, class _ContainerValueTy, 4013 class _RawValTy = typename __unconstref<_ValTy>::type> 4014struct __can_extract_map_key 4015 : integral_constant<bool, _IsSame<_RawValTy, _Key>::value> {}; 4016 4017// This specialization returns __extract_key_fail_tag for non-map containers 4018// because _Key == _ContainerValueTy 4019template <class _ValTy, class _Key, class _RawValTy> 4020struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy> 4021 : false_type {}; 4022 4023#endif 4024 4025#ifndef _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED 4026#if _LIBCPP_STD_VER > 17 4027_LIBCPP_INLINE_VISIBILITY 4028inline constexpr bool is_constant_evaluated() noexcept { 4029 return __builtin_is_constant_evaluated(); 4030} 4031#endif 4032 4033inline _LIBCPP_CONSTEXPR 4034bool __libcpp_is_constant_evaluated() _NOEXCEPT { return __builtin_is_constant_evaluated(); } 4035#else 4036inline _LIBCPP_CONSTEXPR 4037bool __libcpp_is_constant_evaluated() _NOEXCEPT { return false; } 4038#endif 4039 4040template <class _CharT> 4041using _IsCharLikeType = _And<is_standard_layout<_CharT>, is_trivial<_CharT> >; 4042 4043_LIBCPP_END_NAMESPACE_STD 4044 4045#if _LIBCPP_STD_VER > 14 4046// std::byte 4047namespace std // purposefully not versioned 4048{ 4049template <class _Integer> 4050 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type & 4051 operator<<=(byte& __lhs, _Integer __shift) noexcept 4052 { return __lhs = __lhs << __shift; } 4053 4054template <class _Integer> 4055 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type 4056 operator<< (byte __lhs, _Integer __shift) noexcept 4057 { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) << __shift)); } 4058 4059template <class _Integer> 4060 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type & 4061 operator>>=(byte& __lhs, _Integer __shift) noexcept 4062 { return __lhs = __lhs >> __shift; } 4063 4064template <class _Integer> 4065 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type 4066 operator>> (byte __lhs, _Integer __shift) noexcept 4067 { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) >> __shift)); } 4068 4069template <class _Integer> 4070 constexpr typename enable_if<is_integral_v<_Integer>, _Integer>::type 4071 to_integer(byte __b) noexcept { return static_cast<_Integer>(__b); } 4072 4073} 4074#endif 4075 4076#endif // _LIBCPP_TYPE_TRAITS 4077