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