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