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