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