| author | |
| committer | |
| log | 54b67c20259f697f1e0c4532a5ee7e5d3f01eb1e |
| tree | d91b41ddd5dd4b9b941691722ce6427b3b82fe59 |
| parent | 16513fee6c9c229e40f5abd82220a6f30e8e2180 |
68 files changed, 4215 insertions(+), 1565 deletions(-)
lib/libcxx/include/__bit_reference+15| ... | @@ -1122,6 +1122,21 @@ public: | ... | @@ -1122,6 +1122,21 @@ public: |
| 1122 | __bit_iterator(const __type_for_copy_to_const& __it) _NOEXCEPT | 1122 | __bit_iterator(const __type_for_copy_to_const& __it) _NOEXCEPT |
| 1123 | : __seg_(__it.__seg_), __ctz_(__it.__ctz_) {} | 1123 | : __seg_(__it.__seg_), __ctz_(__it.__ctz_) {} |
| 1124 | 1124 | ||
| 1125 | // The non-const __bit_iterator has historically had a non-trivial | ||
| 1126 | // copy constructor (as a quirk of its construction). We need to maintain | ||
| 1127 | // this for ABI purposes. | ||
| 1128 | using __type_for_abi_non_trivial_copy_ctor = | ||
| 1129 | _If<!_IsConst, __bit_iterator, struct __private_nat>; | ||
| 1130 | |||
| 1131 | _LIBCPP_INLINE_VISIBILITY | ||
| 1132 | __bit_iterator(__type_for_abi_non_trivial_copy_ctor const& __it) _NOEXCEPT | ||
| 1133 | : __seg_(__it.__seg_), __ctz_(__it.__ctz_) {} | ||
| 1134 | |||
| 1135 | // Always declare the copy assignment operator since the implicit declaration | ||
| 1136 | // is deprecated. | ||
| 1137 | _LIBCPP_INLINE_VISIBILITY | ||
| 1138 | __bit_iterator& operator=(__bit_iterator const&) = default; | ||
| 1139 | |||
| 1125 | _LIBCPP_INLINE_VISIBILITY reference operator*() const _NOEXCEPT | 1140 | _LIBCPP_INLINE_VISIBILITY reference operator*() const _NOEXCEPT |
| 1126 | {return reference(__seg_, __storage_type(1) << __ctz_);} | 1141 | {return reference(__seg_, __storage_type(1) << __ctz_);} |
| 1127 | 1142 |
lib/libcxx/include/__config+71-42| ... | @@ -32,7 +32,7 @@ | ... | @@ -32,7 +32,7 @@ |
| 32 | # define _GNUC_VER_NEW 0 | 32 | # define _GNUC_VER_NEW 0 |
| 33 | #endif | 33 | #endif |
| 34 | 34 | ||
| 35 | #define _LIBCPP_VERSION 10000 | 35 | #define _LIBCPP_VERSION 11000 |
| 36 | 36 | ||
| 37 | #ifndef _LIBCPP_ABI_VERSION | 37 | #ifndef _LIBCPP_ABI_VERSION |
| 38 | # define _LIBCPP_ABI_VERSION 1 | 38 | # define _LIBCPP_ABI_VERSION 1 |
| ... | @@ -102,6 +102,9 @@ | ... | @@ -102,6 +102,9 @@ |
| 102 | # define _LIBCPP_ABI_OPTIMIZED_FUNCTION | 102 | # define _LIBCPP_ABI_OPTIMIZED_FUNCTION |
| 103 | // All the regex constants must be distinct and nonzero. | 103 | // All the regex constants must be distinct and nonzero. |
| 104 | # define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO | 104 | # define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO |
| 105 | // Re-worked external template instantiations for std::string with a focus on | ||
| 106 | // performance and fast-path inlining. | ||
| 107 | # define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION | ||
| 105 | #elif _LIBCPP_ABI_VERSION == 1 | 108 | #elif _LIBCPP_ABI_VERSION == 1 |
| 106 | # if !defined(_LIBCPP_OBJECT_FORMAT_COFF) | 109 | # if !defined(_LIBCPP_OBJECT_FORMAT_COFF) |
| 107 | // Enable compiling copies of now inline methods into the dylib to support | 110 | // Enable compiling copies of now inline methods into the dylib to support |
| ... | @@ -395,12 +398,12 @@ | ... | @@ -395,12 +398,12 @@ |
| 395 | 398 | ||
| 396 | #if defined(_LIBCPP_COMPILER_CLANG) | 399 | #if defined(_LIBCPP_COMPILER_CLANG) |
| 397 | 400 | ||
| 398 | // _LIBCPP_ALTERNATE_STRING_LAYOUT is an old name for | 401 | #if defined(_LIBCPP_ALTERNATE_STRING_LAYOUT) |
| 399 | // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT left here for backward compatibility. | 402 | # error _LIBCPP_ALTERNATE_STRING_LAYOUT is deprecated, please use _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT instead |
| 400 | #if (defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && \ | 403 | #endif |
| 401 | (!defined(__arm__) || __ARM_ARCH_7K__ >= 2)) || \ | 404 | #if defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && \ |
| 402 | defined(_LIBCPP_ALTERNATE_STRING_LAYOUT) | 405 | (!defined(__arm__) || __ARM_ARCH_7K__ >= 2) |
| 403 | #define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | 406 | # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT |
| 404 | #endif | 407 | #endif |
| 405 | 408 | ||
| 406 | #if __has_feature(cxx_alignas) | 409 | #if __has_feature(cxx_alignas) |
| ... | @@ -416,12 +419,8 @@ typedef __char16_t char16_t; | ... | @@ -416,12 +419,8 @@ typedef __char16_t char16_t; |
| 416 | typedef __char32_t char32_t; | 419 | typedef __char32_t char32_t; |
| 417 | #endif | 420 | #endif |
| 418 | 421 | ||
| 419 | #if !(__has_feature(cxx_exceptions)) && !defined(_LIBCPP_NO_EXCEPTIONS) | 422 | #if !__has_feature(cxx_exceptions) |
| 420 | #define _LIBCPP_NO_EXCEPTIONS | 423 | # define _LIBCPP_NO_EXCEPTIONS |
| 421 | #endif | ||
| 422 | |||
| 423 | #if !(__has_feature(cxx_rtti)) && !defined(_LIBCPP_NO_RTTI) | ||
| 424 | #define _LIBCPP_NO_RTTI | ||
| 425 | #endif | 424 | #endif |
| 426 | 425 | ||
| 427 | #if !(__has_feature(cxx_strong_enums)) | 426 | #if !(__has_feature(cxx_strong_enums)) |
| ... | @@ -467,6 +466,14 @@ typedef __char32_t char32_t; | ... | @@ -467,6 +466,14 @@ typedef __char32_t char32_t; |
| 467 | #define _LIBCPP_HAS_OBJC_ARC_WEAK | 466 | #define _LIBCPP_HAS_OBJC_ARC_WEAK |
| 468 | #endif | 467 | #endif |
| 469 | 468 | ||
| 469 | #if __has_extension(blocks) | ||
| 470 | # define _LIBCPP_HAS_EXTENSION_BLOCKS | ||
| 471 | #endif | ||
| 472 | |||
| 473 | #if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__) | ||
| 474 | # define _LIBCPP_HAS_BLOCKS_RUNTIME | ||
| 475 | #endif | ||
| 476 | |||
| 470 | #if !(__has_feature(cxx_relaxed_constexpr)) | 477 | #if !(__has_feature(cxx_relaxed_constexpr)) |
| 471 | #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR | 478 | #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR |
| 472 | #endif | 479 | #endif |
| ... | @@ -492,6 +499,10 @@ typedef __char32_t char32_t; | ... | @@ -492,6 +499,10 @@ typedef __char32_t char32_t; |
| 492 | #define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER | 499 | #define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER |
| 493 | #endif | 500 | #endif |
| 494 | 501 | ||
| 502 | #if __has_builtin(__builtin_constant_p) | ||
| 503 | #define _LIBCPP_COMPILER_HAS_BUILTIN_CONSTANT_P | ||
| 504 | #endif | ||
| 505 | |||
| 495 | #if !__is_identifier(__has_unique_object_representations) | 506 | #if !__is_identifier(__has_unique_object_representations) |
| 496 | #define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS | 507 | #define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS |
| 497 | #endif | 508 | #endif |
| ... | @@ -513,8 +524,8 @@ typedef __char32_t char32_t; | ... | @@ -513,8 +524,8 @@ typedef __char32_t char32_t; |
| 513 | 524 | ||
| 514 | #define _LIBCPP_NORETURN __attribute__((noreturn)) | 525 | #define _LIBCPP_NORETURN __attribute__((noreturn)) |
| 515 | 526 | ||
| 516 | #if !__EXCEPTIONS && !defined(_LIBCPP_NO_EXCEPTIONS) | 527 | #if !__EXCEPTIONS |
| 517 | #define _LIBCPP_NO_EXCEPTIONS | 528 | # define _LIBCPP_NO_EXCEPTIONS |
| 518 | #endif | 529 | #endif |
| 519 | 530 | ||
| 520 | // Determine if GCC supports relaxed constexpr | 531 | // Determine if GCC supports relaxed constexpr |
| ... | @@ -533,9 +544,7 @@ typedef __char32_t char32_t; | ... | @@ -533,9 +544,7 @@ typedef __char32_t char32_t; |
| 533 | 544 | ||
| 534 | #if _GNUC_VER >= 700 | 545 | #if _GNUC_VER >= 700 |
| 535 | #define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER | 546 | #define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER |
| 536 | #endif | 547 | #define _LIBCPP_COMPILER_HAS_BUILTIN_CONSTANT_P |
| 537 | |||
| 538 | #if _GNUC_VER >= 700 | ||
| 539 | #define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS | 548 | #define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS |
| 540 | #endif | 549 | #endif |
| 541 | 550 | ||
| ... | @@ -745,14 +754,14 @@ typedef __char32_t char32_t; | ... | @@ -745,14 +754,14 @@ typedef __char32_t char32_t; |
| 745 | # endif | 754 | # endif |
| 746 | #endif | 755 | #endif |
| 747 | 756 | ||
| 748 | #ifndef _LIBCPP_HAS_MERGED_TYPEINFO_NAMES_DEFAULT | 757 | #ifndef _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION |
| 749 | # ifdef _LIBCPP_OBJECT_FORMAT_COFF // Windows binaries can't merge typeinfos. | 758 | # ifdef _LIBCPP_OBJECT_FORMAT_COFF // Windows binaries can't merge typeinfos. |
| 750 | # define _LIBCPP_HAS_MERGED_TYPEINFO_NAMES_DEFAULT 0 | 759 | # define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 2 |
| 751 | #else | 760 | # else |
| 752 | // TODO: This isn't strictly correct on ELF platforms due to llvm.org/PR37398 | 761 | // TODO: This isn't strictly correct on ELF platforms due to llvm.org/PR37398 |
| 753 | // And we should consider defaulting to OFF. | 762 | // And we should consider defaulting to OFF. |
| 754 | # define _LIBCPP_HAS_MERGED_TYPEINFO_NAMES_DEFAULT 1 | 763 | # define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 1 |
| 755 | #endif | 764 | # endif |
| 756 | #endif | 765 | #endif |
| 757 | 766 | ||
| 758 | #ifndef _LIBCPP_HIDE_FROM_ABI | 767 | #ifndef _LIBCPP_HIDE_FROM_ABI |
| ... | @@ -901,6 +910,10 @@ typedef unsigned int char32_t; | ... | @@ -901,6 +910,10 @@ typedef unsigned int char32_t; |
| 901 | #define _LIBCPP_EXTERN_TEMPLATE2(...) extern template __VA_ARGS__; | 910 | #define _LIBCPP_EXTERN_TEMPLATE2(...) extern template __VA_ARGS__; |
| 902 | #endif | 911 | #endif |
| 903 | 912 | ||
| 913 | #ifndef _LIBCPP_EXTERN_TEMPLATE_DEFINE | ||
| 914 | #define _LIBCPP_EXTERN_TEMPLATE_DEFINE(...) template __VA_ARGS__; | ||
| 915 | #endif | ||
| 916 | |||
| 904 | #if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || \ | 917 | #if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || \ |
| 905 | defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__) | 918 | defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__) |
| 906 | #define _LIBCPP_LOCALE__L_EXTENSIONS 1 | 919 | #define _LIBCPP_LOCALE__L_EXTENSIONS 1 |
| ... | @@ -1092,17 +1105,12 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container( | ... | @@ -1092,17 +1105,12 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container( |
| 1092 | #endif | 1105 | #endif |
| 1093 | 1106 | ||
| 1094 | // Try to find out if RTTI is disabled. | 1107 | // Try to find out if RTTI is disabled. |
| 1095 | // g++ and cl.exe have RTTI on by default and define a macro when it is. | 1108 | #if defined(_LIBCPP_COMPILER_CLANG) && !__has_feature(cxx_rtti) |
| 1096 | // g++ only defines the macro in 4.3.2 and onwards. | 1109 | # define _LIBCPP_NO_RTTI |
| 1097 | #if !defined(_LIBCPP_NO_RTTI) | 1110 | #elif defined(__GNUC__) && !defined(__GXX_RTTI) |
| 1098 | # if defined(__GNUC__) && \ | 1111 | # define _LIBCPP_NO_RTTI |
| 1099 | ((__GNUC__ >= 5) || \ | 1112 | #elif defined(_LIBCPP_COMPILER_MSVC) && !defined(_CPPRTTI) |
| 1100 | (__GNUC__ == 4 && (__GNUC_MINOR__ >= 3 || __GNUC_PATCHLEVEL__ >= 2))) && \ | 1113 | # define _LIBCPP_NO_RTTI |
| 1101 | !defined(__GXX_RTTI) | ||
| 1102 | # define _LIBCPP_NO_RTTI | ||
| 1103 | # elif defined(_LIBCPP_COMPILER_MSVC) && !defined(_CPPRTTI) | ||
| 1104 | # define _LIBCPP_NO_RTTI | ||
| 1105 | # endif | ||
| 1106 | #endif | 1114 | #endif |
| 1107 | 1115 | ||
| 1108 | #ifndef _LIBCPP_WEAK | 1116 | #ifndef _LIBCPP_WEAK |
| ... | @@ -1125,7 +1133,8 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container( | ... | @@ -1125,7 +1133,8 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container( |
| 1125 | (defined(__MINGW32__) && __has_include(<pthread.h>)) | 1133 | (defined(__MINGW32__) && __has_include(<pthread.h>)) |
| 1126 | # define _LIBCPP_HAS_THREAD_API_PTHREAD | 1134 | # define _LIBCPP_HAS_THREAD_API_PTHREAD |
| 1127 | # elif defined(__Fuchsia__) | 1135 | # elif defined(__Fuchsia__) |
| 1128 | # define _LIBCPP_HAS_THREAD_API_C11 | 1136 | // TODO(44575): Switch to C11 thread API when possible. |
| 1137 | # define _LIBCPP_HAS_THREAD_API_PTHREAD | ||
| 1129 | # elif defined(_LIBCPP_WIN32API) | 1138 | # elif defined(_LIBCPP_WIN32API) |
| 1130 | # define _LIBCPP_HAS_THREAD_API_WIN32 | 1139 | # define _LIBCPP_HAS_THREAD_API_WIN32 |
| 1131 | # else | 1140 | # else |
| ... | @@ -1360,6 +1369,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container( | ... | @@ -1360,6 +1369,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container( |
| 1360 | 1369 | ||
| 1361 | // Decide whether to use availability macros. | 1370 | // Decide whether to use availability macros. |
| 1362 | #if !defined(_LIBCPP_BUILDING_LIBRARY) && \ | 1371 | #if !defined(_LIBCPP_BUILDING_LIBRARY) && \ |
| 1372 | !defined(_LIBCXXABI_BUILDING_LIBRARY) && \ | ||
| 1363 | !defined(_LIBCPP_DISABLE_AVAILABILITY) && \ | 1373 | !defined(_LIBCPP_DISABLE_AVAILABILITY) && \ |
| 1364 | __has_feature(attribute_availability_with_strict) && \ | 1374 | __has_feature(attribute_availability_with_strict) && \ |
| 1365 | __has_feature(attribute_availability_in_templates) && \ | 1375 | __has_feature(attribute_availability_in_templates) && \ |
| ... | @@ -1377,10 +1387,10 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container( | ... | @@ -1377,10 +1387,10 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container( |
| 1377 | __attribute__((availability(tvos,strict,introduced=10.0))) \ | 1387 | __attribute__((availability(tvos,strict,introduced=10.0))) \ |
| 1378 | __attribute__((availability(watchos,strict,introduced=3.0))) | 1388 | __attribute__((availability(watchos,strict,introduced=3.0))) |
| 1379 | # define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS \ | 1389 | # define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS \ |
| 1380 | __attribute__((availability(macosx,strict,introduced=10.14))) \ | 1390 | __attribute__((availability(macosx,strict,introduced=10.13))) \ |
| 1381 | __attribute__((availability(ios,strict,introduced=12.0))) \ | 1391 | __attribute__((availability(ios,strict,introduced=11.0))) \ |
| 1382 | __attribute__((availability(tvos,strict,introduced=12.0))) \ | 1392 | __attribute__((availability(tvos,strict,introduced=11.0))) \ |
| 1383 | __attribute__((availability(watchos,strict,introduced=5.0))) | 1393 | __attribute__((availability(watchos,strict,introduced=4.0))) |
| 1384 | # define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS \ | 1394 | # define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS \ |
| 1385 | _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS | 1395 | _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS |
| 1386 | # define _LIBCPP_AVAILABILITY_BAD_ANY_CAST \ | 1396 | # define _LIBCPP_AVAILABILITY_BAD_ANY_CAST \ |
| ... | @@ -1421,6 +1431,10 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container( | ... | @@ -1421,6 +1431,10 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container( |
| 1421 | _Pragma("clang attribute pop") \ | 1431 | _Pragma("clang attribute pop") \ |
| 1422 | _Pragma("clang attribute pop") \ | 1432 | _Pragma("clang attribute pop") \ |
| 1423 | _Pragma("clang attribute pop") | 1433 | _Pragma("clang attribute pop") |
| 1434 | # define _LIBCPP_AVAILABILITY_TO_CHARS \ | ||
| 1435 | _LIBCPP_AVAILABILITY_FILESYSTEM | ||
| 1436 | # define _LIBCPP_AVAILABILITY_SYNC \ | ||
| 1437 | __attribute__((unavailable)) | ||
| 1424 | #else | 1438 | #else |
| 1425 | # define _LIBCPP_AVAILABILITY_SHARED_MUTEX | 1439 | # define _LIBCPP_AVAILABILITY_SHARED_MUTEX |
| 1426 | # define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS | 1440 | # define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS |
| ... | @@ -1435,6 +1449,8 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container( | ... | @@ -1435,6 +1449,8 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container( |
| 1435 | # define _LIBCPP_AVAILABILITY_FILESYSTEM | 1449 | # define _LIBCPP_AVAILABILITY_FILESYSTEM |
| 1436 | # define _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH | 1450 | # define _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH |
| 1437 | # define _LIBCPP_AVAILABILITY_FILESYSTEM_POP | 1451 | # define _LIBCPP_AVAILABILITY_FILESYSTEM_POP |
| 1452 | # define _LIBCPP_AVAILABILITY_TO_CHARS | ||
| 1453 | # define _LIBCPP_AVAILABILITY_SYNC | ||
| 1438 | #endif | 1454 | #endif |
| 1439 | 1455 | ||
| 1440 | // Define availability that depends on _LIBCPP_NO_EXCEPTIONS. | 1456 | // Define availability that depends on _LIBCPP_NO_EXCEPTIONS. |
| ... | @@ -1518,6 +1534,19 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container( | ... | @@ -1518,6 +1534,19 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container( |
| 1518 | # define _LIBCPP_FOPEN_CLOEXEC_MODE | 1534 | # define _LIBCPP_FOPEN_CLOEXEC_MODE |
| 1519 | #endif | 1535 | #endif |
| 1520 | 1536 | ||
| 1537 | #ifdef _LIBCPP_COMPILER_HAS_BUILTIN_CONSTANT_P | ||
| 1538 | #define _LIBCPP_BUILTIN_CONSTANT_P(x) __builtin_constant_p(x) | ||
| 1539 | #else | ||
| 1540 | #define _LIBCPP_BUILTIN_CONSTANT_P(x) false | ||
| 1541 | #endif | ||
| 1542 | |||
| 1543 | // Support for _FILE_OFFSET_BITS=64 landed gradually in Android, so the full set | ||
| 1544 | // of functions used in cstdio may not be available for low API levels when | ||
| 1545 | // using 64-bit file offsets on LP32. | ||
| 1546 | #if defined(__BIONIC__) && defined(__USE_FILE_OFFSET64) && __ANDROID_API__ < 24 | ||
| 1547 | #define _LIBCPP_HAS_NO_FGETPOS_FSETPOS | ||
| 1548 | #endif | ||
| 1549 | |||
| 1521 | #endif // __cplusplus | 1550 | #endif // __cplusplus |
| 1522 | 1551 | ||
| 1523 | #endif // _LIBCPP_CONFIG | 1552 | #endif // _LIBCPP_CONFIG |
lib/libcxx/include/__config_site.in+3-1| ... | @@ -27,7 +27,9 @@ | ... | @@ -27,7 +27,9 @@ |
| 27 | #cmakedefine _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL | 27 | #cmakedefine _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL |
| 28 | #cmakedefine _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS | 28 | #cmakedefine _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS |
| 29 | #cmakedefine _LIBCPP_NO_VCRUNTIME | 29 | #cmakedefine _LIBCPP_NO_VCRUNTIME |
| 30 | #cmakedefine01 _LIBCPP_HAS_MERGED_TYPEINFO_NAMES_DEFAULT | 30 | #ifndef _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION |
| 31 | #cmakedefine _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION @_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION@ | ||
| 32 | #endif | ||
| 31 | #cmakedefine _LIBCPP_ABI_NAMESPACE @_LIBCPP_ABI_NAMESPACE@ | 33 | #cmakedefine _LIBCPP_ABI_NAMESPACE @_LIBCPP_ABI_NAMESPACE@ |
| 32 | #cmakedefine _LIBCPP_HAS_PARALLEL_ALGORITHMS | 34 | #cmakedefine _LIBCPP_HAS_PARALLEL_ALGORITHMS |
| 33 | 35 |
lib/libcxx/include/__functional_base+2-2| ... | @@ -522,7 +522,7 @@ inline _LIBCPP_INLINE_VISIBILITY | ... | @@ -522,7 +522,7 @@ inline _LIBCPP_INLINE_VISIBILITY |
| 522 | reference_wrapper<_Tp> | 522 | reference_wrapper<_Tp> |
| 523 | ref(reference_wrapper<_Tp> __t) _NOEXCEPT | 523 | ref(reference_wrapper<_Tp> __t) _NOEXCEPT |
| 524 | { | 524 | { |
| 525 | return ref(__t.get()); | 525 | return _VSTD::ref(__t.get()); |
| 526 | } | 526 | } |
| 527 | 527 | ||
| 528 | template <class _Tp> | 528 | template <class _Tp> |
| ... | @@ -538,7 +538,7 @@ inline _LIBCPP_INLINE_VISIBILITY | ... | @@ -538,7 +538,7 @@ inline _LIBCPP_INLINE_VISIBILITY |
| 538 | reference_wrapper<const _Tp> | 538 | reference_wrapper<const _Tp> |
| 539 | cref(reference_wrapper<_Tp> __t) _NOEXCEPT | 539 | cref(reference_wrapper<_Tp> __t) _NOEXCEPT |
| 540 | { | 540 | { |
| 541 | return cref(__t.get()); | 541 | return _VSTD::cref(__t.get()); |
| 542 | } | 542 | } |
| 543 | 543 | ||
| 544 | #ifndef _LIBCPP_CXX03_LANG | 544 | #ifndef _LIBCPP_CXX03_LANG |
lib/libcxx/include/__libcpp_version+1-1| ... | @@ -1 +1 @@ | ... | @@ -1 +1 @@ |
| 1 | 10000 | 1 | 11000 |
lib/libcxx/include/__locale+6| ... | @@ -496,7 +496,13 @@ public: | ... | @@ -496,7 +496,13 @@ public: |
| 496 | static const mask punct = 1<<7; | 496 | static const mask punct = 1<<7; |
| 497 | static const mask xdigit = 1<<8; | 497 | static const mask xdigit = 1<<8; |
| 498 | static const mask blank = 1<<9; | 498 | static const mask blank = 1<<9; |
| 499 | #if defined(__BIONIC__) | ||
| 500 | // Historically this was a part of regex_traits rather than ctype_base. The | ||
| 501 | // historical value of the constant is preserved for ABI compatibility. | ||
| 502 | static const mask __regex_word = 0x8000; | ||
| 503 | #else | ||
| 499 | static const mask __regex_word = 1<<10; | 504 | static const mask __regex_word = 1<<10; |
| 505 | #endif // defined(__BIONIC__) | ||
| 500 | #endif | 506 | #endif |
| 501 | static const mask alnum = alpha | digit; | 507 | static const mask alnum = alpha | digit; |
| 502 | static const mask graph = alnum | punct; | 508 | static const mask graph = alnum | punct; |
lib/libcxx/include/__string+117| ... | @@ -70,6 +70,123 @@ _LIBCPP_PUSH_MACROS | ... | @@ -70,6 +70,123 @@ _LIBCPP_PUSH_MACROS |
| 70 | 70 | ||
| 71 | _LIBCPP_BEGIN_NAMESPACE_STD | 71 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 72 | 72 | ||
| 73 | // The the extern template ABI lists are kept outside of <string> to improve the | ||
| 74 | // readability of that header. | ||
| 75 | |||
| 76 | // The extern template ABI lists are kept outside of <string> to improve the | ||
| 77 | // readability of that header. We maintain 2 ABI lists: | ||
| 78 | // - _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST | ||
| 79 | // - _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST | ||
| 80 | // As the name implies, the ABI lists define the V1 (Stable) and unstable ABI. | ||
| 81 | // | ||
| 82 | // For unstable, we may explicitly remove function that are external in V1, | ||
| 83 | // and add (new) external functions to better control inlining and compiler | ||
| 84 | // optimization opportunities. | ||
| 85 | // | ||
| 86 | // For stable, the ABI list should rarely change, except for adding new | ||
| 87 | // functions supporting new c++ version / API changes. Typically entries | ||
| 88 | // must never be removed from the stable list. | ||
| 89 | #define _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_Func, _CharType) \ | ||
| 90 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*, size_type)) \ | ||
| 91 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type const*, size_type, size_type) const) \ | ||
| 92 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type, size_type)) \ | ||
| 93 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&)) \ | ||
| 94 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*)) \ | ||
| 95 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, std::allocator<_CharType> const&)) \ | ||
| 96 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_not_of(value_type const*, size_type, size_type) const) \ | ||
| 97 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::~basic_string()) \ | ||
| 98 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_not_of(value_type const*, size_type, size_type) const) \ | ||
| 99 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, size_type, value_type)) \ | ||
| 100 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::operator=(value_type)) \ | ||
| 101 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type)) \ | ||
| 102 | _Func(_LIBCPP_FUNC_VIS const _CharType& basic_string<_CharType>::at(size_type) const) \ | ||
| 103 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*, size_type)) \ | ||
| 104 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_of(value_type const*, size_type, size_type) const) \ | ||
| 105 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, size_type, value_type)) \ | ||
| 106 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(value_type const*, size_type)) \ | ||
| 107 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::reserve(size_type)) \ | ||
| 108 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*, size_type)) \ | ||
| 109 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(basic_string const&, size_type, size_type)) \ | ||
| 110 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::copy(value_type*, size_type, size_type) const) \ | ||
| 111 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, size_type, size_type, std::allocator<_CharType> const&)) \ | ||
| 112 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type, size_type) const) \ | ||
| 113 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(size_type, value_type)) \ | ||
| 114 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*)) \ | ||
| 115 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_of(value_type const*, size_type, size_type) const) \ | ||
| 116 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by(size_type, size_type, size_type, size_type, size_type, size_type)) \ | ||
| 117 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by_and_replace(size_type, size_type, size_type, size_type, size_type, size_type, value_type const*)) \ | ||
| 118 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::push_back(value_type)) \ | ||
| 119 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(size_type, value_type)) \ | ||
| 120 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type, size_type) const) \ | ||
| 121 | _Func(_LIBCPP_FUNC_VIS const basic_string<_CharType>::size_type basic_string<_CharType>::npos) \ | ||
| 122 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(size_type, value_type)) \ | ||
| 123 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::erase(size_type, size_type)) \ | ||
| 124 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(basic_string const&, size_type, size_type)) \ | ||
| 125 | _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(value_type const*) const) \ | ||
| 126 | _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*) const) \ | ||
| 127 | _Func(_LIBCPP_FUNC_VIS _CharType& basic_string<_CharType>::at(size_type)) \ | ||
| 128 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(value_type const*)) \ | ||
| 129 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type const*, size_type, size_type) const) \ | ||
| 130 | _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, basic_string const&, size_type, size_type) const) \ | ||
| 131 | _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*, size_type) const) \ | ||
| 132 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::operator=(basic_string const&)) \ | ||
| 133 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*)) \ | ||
| 134 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, basic_string const&, size_type, size_type)) \ | ||
| 135 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::iterator basic_string<_CharType>::insert(basic_string::const_iterator, value_type)) \ | ||
| 136 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::resize(size_type, value_type)) \ | ||
| 137 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, basic_string const&, size_type, size_type)) | ||
| 138 | |||
| 139 | #define _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_Func, _CharType) \ | ||
| 140 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*, size_type)) \ | ||
| 141 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type const*, size_type, size_type) const) \ | ||
| 142 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type, size_type)) \ | ||
| 143 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*)) \ | ||
| 144 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_not_of(value_type const*, size_type, size_type) const) \ | ||
| 145 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::~basic_string()) \ | ||
| 146 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_not_of(value_type const*, size_type, size_type) const) \ | ||
| 147 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, size_type, value_type)) \ | ||
| 148 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::operator=(value_type)) \ | ||
| 149 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type)) \ | ||
| 150 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init_copy_ctor_external(value_type const*, size_type)) \ | ||
| 151 | _Func(_LIBCPP_FUNC_VIS const _CharType& basic_string<_CharType>::at(size_type) const) \ | ||
| 152 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*, size_type)) \ | ||
| 153 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_of(value_type const*, size_type, size_type) const) \ | ||
| 154 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, size_type, value_type)) \ | ||
| 155 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_external(value_type const*, size_type)) \ | ||
| 156 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_external(value_type const*)) \ | ||
| 157 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::reserve(size_type)) \ | ||
| 158 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*, size_type)) \ | ||
| 159 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(basic_string const&, size_type, size_type)) \ | ||
| 160 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::copy(value_type*, size_type, size_type) const) \ | ||
| 161 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, size_type, size_type, std::allocator<_CharType> const&)) \ | ||
| 162 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type, size_type) const) \ | ||
| 163 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(size_type, value_type)) \ | ||
| 164 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*)) \ | ||
| 165 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_of(value_type const*, size_type, size_type) const) \ | ||
| 166 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by(size_type, size_type, size_type, size_type, size_type, size_type)) \ | ||
| 167 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by_and_replace(size_type, size_type, size_type, size_type, size_type, size_type, value_type const*)) \ | ||
| 168 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_no_alias<false>(value_type const*, size_type)) \ | ||
| 169 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_no_alias<true>(value_type const*, size_type)) \ | ||
| 170 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::push_back(value_type)) \ | ||
| 171 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(size_type, value_type)) \ | ||
| 172 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type, size_type) const) \ | ||
| 173 | _Func(_LIBCPP_FUNC_VIS const basic_string<_CharType>::size_type basic_string<_CharType>::npos) \ | ||
| 174 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(size_type, value_type)) \ | ||
| 175 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__erase_external_with_move(size_type, size_type)) \ | ||
| 176 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(basic_string const&, size_type, size_type)) \ | ||
| 177 | _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(value_type const*) const) \ | ||
| 178 | _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*) const) \ | ||
| 179 | _Func(_LIBCPP_FUNC_VIS _CharType& basic_string<_CharType>::at(size_type)) \ | ||
| 180 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type const*, size_type, size_type) const) \ | ||
| 181 | _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, basic_string const&, size_type, size_type) const) \ | ||
| 182 | _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*, size_type) const) \ | ||
| 183 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*)) \ | ||
| 184 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, basic_string const&, size_type, size_type)) \ | ||
| 185 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::iterator basic_string<_CharType>::insert(basic_string::const_iterator, value_type)) \ | ||
| 186 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::resize(size_type, value_type)) \ | ||
| 187 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, basic_string const&, size_type, size_type)) | ||
| 188 | |||
| 189 | |||
| 73 | // char_traits | 190 | // char_traits |
| 74 | 191 | ||
| 75 | template <class _CharT> | 192 | template <class _CharT> |
lib/libcxx/include/__threading_support+111| ... | @@ -26,6 +26,12 @@ | ... | @@ -26,6 +26,12 @@ |
| 26 | #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) | 26 | #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) |
| 27 | # include <pthread.h> | 27 | # include <pthread.h> |
| 28 | # include <sched.h> | 28 | # include <sched.h> |
| 29 | # ifdef __APPLE__ | ||
| 30 | # define _LIBCPP_NO_NATIVE_SEMAPHORES | ||
| 31 | # endif | ||
| 32 | # ifndef _LIBCPP_NO_NATIVE_SEMAPHORES | ||
| 33 | # include <semaphore.h> | ||
| 34 | # endif | ||
| 29 | #elif defined(_LIBCPP_HAS_THREAD_API_C11) | 35 | #elif defined(_LIBCPP_HAS_THREAD_API_C11) |
| 30 | # include <threads.h> | 36 | # include <threads.h> |
| 31 | #endif | 37 | #endif |
| ... | @@ -65,6 +71,12 @@ typedef pthread_mutex_t __libcpp_recursive_mutex_t; | ... | @@ -65,6 +71,12 @@ typedef pthread_mutex_t __libcpp_recursive_mutex_t; |
| 65 | typedef pthread_cond_t __libcpp_condvar_t; | 71 | typedef pthread_cond_t __libcpp_condvar_t; |
| 66 | #define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER | 72 | #define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER |
| 67 | 73 | ||
| 74 | #ifndef _LIBCPP_NO_NATIVE_SEMAPHORES | ||
| 75 | // Semaphore | ||
| 76 | typedef sem_t __libcpp_semaphore_t; | ||
| 77 | # define _LIBCPP_SEMAPHORE_MAX SEM_VALUE_MAX | ||
| 78 | #endif | ||
| 79 | |||
| 68 | // Execute once | 80 | // Execute once |
| 69 | typedef pthread_once_t __libcpp_exec_once_flag; | 81 | typedef pthread_once_t __libcpp_exec_once_flag; |
| 70 | #define _LIBCPP_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT | 82 | #define _LIBCPP_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT |
| ... | @@ -127,6 +139,9 @@ typedef void* __libcpp_recursive_mutex_t[5]; | ... | @@ -127,6 +139,9 @@ typedef void* __libcpp_recursive_mutex_t[5]; |
| 127 | typedef void* __libcpp_condvar_t; | 139 | typedef void* __libcpp_condvar_t; |
| 128 | #define _LIBCPP_CONDVAR_INITIALIZER 0 | 140 | #define _LIBCPP_CONDVAR_INITIALIZER 0 |
| 129 | 141 | ||
| 142 | // Semaphore | ||
| 143 | typedef void* __libcpp_semaphore_t; | ||
| 144 | |||
| 130 | // Execute Once | 145 | // Execute Once |
| 131 | typedef void* __libcpp_exec_once_flag; | 146 | typedef void* __libcpp_exec_once_flag; |
| 132 | #define _LIBCPP_EXEC_ONCE_INITIALIZER 0 | 147 | #define _LIBCPP_EXEC_ONCE_INITIALIZER 0 |
| ... | @@ -191,6 +206,26 @@ int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m, | ... | @@ -191,6 +206,26 @@ int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m, |
| 191 | _LIBCPP_THREAD_ABI_VISIBILITY | 206 | _LIBCPP_THREAD_ABI_VISIBILITY |
| 192 | int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv); | 207 | int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv); |
| 193 | 208 | ||
| 209 | #ifndef _LIBCPP_NO_NATIVE_SEMAPHORES | ||
| 210 | |||
| 211 | // Semaphore | ||
| 212 | _LIBCPP_THREAD_ABI_VISIBILITY | ||
| 213 | bool __libcpp_semaphore_init(__libcpp_semaphore_t* __sem, int __init); | ||
| 214 | |||
| 215 | _LIBCPP_THREAD_ABI_VISIBILITY | ||
| 216 | bool __libcpp_semaphore_destroy(__libcpp_semaphore_t* __sem); | ||
| 217 | |||
| 218 | _LIBCPP_THREAD_ABI_VISIBILITY | ||
| 219 | bool __libcpp_semaphore_post(__libcpp_semaphore_t* __sem); | ||
| 220 | |||
| 221 | _LIBCPP_THREAD_ABI_VISIBILITY | ||
| 222 | bool __libcpp_semaphore_wait(__libcpp_semaphore_t* __sem); | ||
| 223 | |||
| 224 | _LIBCPP_THREAD_ABI_VISIBILITY | ||
| 225 | bool __libcpp_semaphore_wait_timed(__libcpp_semaphore_t* __sem, chrono::nanoseconds const& __ns); | ||
| 226 | |||
| 227 | #endif // _LIBCPP_NO_NATIVE_SEMAPHORES | ||
| 228 | |||
| 194 | // Execute once | 229 | // Execute once |
| 195 | _LIBCPP_THREAD_ABI_VISIBILITY | 230 | _LIBCPP_THREAD_ABI_VISIBILITY |
| 196 | int __libcpp_execute_once(__libcpp_exec_once_flag *flag, | 231 | int __libcpp_execute_once(__libcpp_exec_once_flag *flag, |
| ... | @@ -242,9 +277,52 @@ int __libcpp_tls_set(__libcpp_tls_key __key, void *__p); | ... | @@ -242,9 +277,52 @@ int __libcpp_tls_set(__libcpp_tls_key __key, void *__p); |
| 242 | 277 | ||
| 243 | #endif // !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) | 278 | #endif // !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) |
| 244 | 279 | ||
| 280 | struct __libcpp_timed_backoff_policy { | ||
| 281 | _LIBCPP_THREAD_ABI_VISIBILITY | ||
| 282 | bool operator()(chrono::nanoseconds __elapsed) const; | ||
| 283 | }; | ||
| 284 | |||
| 285 | inline _LIBCPP_INLINE_VISIBILITY | ||
| 286 | bool __libcpp_timed_backoff_policy::operator()(chrono::nanoseconds __elapsed) const | ||
| 287 | { | ||
| 288 | if(__elapsed > chrono::milliseconds(128)) | ||
| 289 | __libcpp_thread_sleep_for(chrono::milliseconds(8)); | ||
| 290 | else if(__elapsed > chrono::microseconds(64)) | ||
| 291 | __libcpp_thread_sleep_for(__elapsed / 2); | ||
| 292 | else if(__elapsed > chrono::microseconds(4)) | ||
| 293 | __libcpp_thread_yield(); | ||
| 294 | else | ||
| 295 | ; // poll | ||
| 296 | return false; | ||
| 297 | } | ||
| 298 | |||
| 299 | static _LIBCPP_CONSTEXPR const int __libcpp_polling_count = 64; | ||
| 300 | |||
| 301 | template<class _Fn, class _BFn> | ||
| 302 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 303 | bool __libcpp_thread_poll_with_backoff( | ||
| 304 | _Fn && __f, _BFn && __bf, chrono::nanoseconds __max_elapsed = chrono::nanoseconds::zero()) | ||
| 305 | { | ||
| 306 | auto const __start = chrono::high_resolution_clock::now(); | ||
| 307 | for(int __count = 0;;) { | ||
| 308 | if(__f()) | ||
| 309 | return true; // _Fn completion means success | ||
| 310 | if(__count < __libcpp_polling_count) { | ||
| 311 | __count += 1; | ||
| 312 | continue; | ||
| 313 | } | ||
| 314 | chrono::nanoseconds const __elapsed = chrono::high_resolution_clock::now() - __start; | ||
| 315 | if(__max_elapsed != chrono::nanoseconds::zero() && __max_elapsed < __elapsed) | ||
| 316 | return false; // timeout failure | ||
| 317 | if(__bf(__elapsed)) | ||
| 318 | return false; // _BFn completion means failure | ||
| 319 | } | ||
| 320 | } | ||
| 321 | |||
| 245 | #if (!defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \ | 322 | #if (!defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \ |
| 246 | defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL)) | 323 | defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL)) |
| 247 | 324 | ||
| 325 | |||
| 248 | namespace __thread_detail { | 326 | namespace __thread_detail { |
| 249 | 327 | ||
| 250 | inline __libcpp_timespec_t __convert_to_timespec(const chrono::nanoseconds& __ns) | 328 | inline __libcpp_timespec_t __convert_to_timespec(const chrono::nanoseconds& __ns) |
| ... | @@ -364,6 +442,38 @@ int __libcpp_condvar_destroy(__libcpp_condvar_t *__cv) | ... | @@ -364,6 +442,38 @@ int __libcpp_condvar_destroy(__libcpp_condvar_t *__cv) |
| 364 | return pthread_cond_destroy(__cv); | 442 | return pthread_cond_destroy(__cv); |
| 365 | } | 443 | } |
| 366 | 444 | ||
| 445 | #ifndef _LIBCPP_NO_NATIVE_SEMAPHORES | ||
| 446 | |||
| 447 | // Semaphore | ||
| 448 | bool __libcpp_semaphore_init(__libcpp_semaphore_t* __sem, int __init) | ||
| 449 | { | ||
| 450 | return sem_init(__sem, 0, __init) == 0; | ||
| 451 | } | ||
| 452 | |||
| 453 | bool __libcpp_semaphore_destroy(__libcpp_semaphore_t* __sem) | ||
| 454 | { | ||
| 455 | return sem_destroy(__sem) == 0; | ||
| 456 | } | ||
| 457 | |||
| 458 | bool __libcpp_semaphore_post(__libcpp_semaphore_t* __sem) | ||
| 459 | { | ||
| 460 | return sem_post(__sem) == 0; | ||
| 461 | } | ||
| 462 | |||
| 463 | bool __libcpp_semaphore_wait(__libcpp_semaphore_t* __sem) | ||
| 464 | { | ||
| 465 | return sem_wait(__sem) == 0; | ||
| 466 | } | ||
| 467 | |||
| 468 | bool __libcpp_semaphore_wait_timed(__libcpp_semaphore_t* __sem, chrono::nanoseconds const& __ns) | ||
| 469 | { | ||
| 470 | auto const __abs_time = chrono::system_clock::now().time_since_epoch() + __ns; | ||
| 471 | __libcpp_timespec_t __ts = __thread_detail::__convert_to_timespec(__abs_time); | ||
| 472 | return sem_timedwait(__sem, &__ts) == 0; | ||
| 473 | } | ||
| 474 | |||
| 475 | #endif //_LIBCPP_NO_NATIVE_SEMAPHORES | ||
| 476 | |||
| 367 | // Execute once | 477 | // Execute once |
| 368 | int __libcpp_execute_once(__libcpp_exec_once_flag *flag, | 478 | int __libcpp_execute_once(__libcpp_exec_once_flag *flag, |
| 369 | void (*init_routine)()) { | 479 | void (*init_routine)()) { |
| ... | @@ -600,6 +710,7 @@ int __libcpp_tls_set(__libcpp_tls_key __key, void *__p) | ... | @@ -600,6 +710,7 @@ int __libcpp_tls_set(__libcpp_tls_key __key, void *__p) |
| 600 | 710 | ||
| 601 | #endif | 711 | #endif |
| 602 | 712 | ||
| 713 | |||
| 603 | #endif // !_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL || _LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL | 714 | #endif // !_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL || _LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL |
| 604 | 715 | ||
| 605 | class _LIBCPP_TYPE_VIS thread; | 716 | class _LIBCPP_TYPE_VIS thread; |
lib/libcxx/include/array+144-101| ... | @@ -32,24 +32,24 @@ struct array | ... | @@ -32,24 +32,24 @@ struct array |
| 32 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; | 32 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; |
| 33 | 33 | ||
| 34 | // No explicit construct/copy/destroy for aggregate type | 34 | // No explicit construct/copy/destroy for aggregate type |
| 35 | void fill(const T& u); | 35 | void fill(const T& u); // constexpr in C++20 |
| 36 | void swap(array& a) noexcept(is_nothrow_swappable_v<T>); | 36 | void swap(array& a) noexcept(is_nothrow_swappable_v<T>); // constexpr in C++20 |
| 37 | 37 | ||
| 38 | // iterators: | 38 | // iterators: |
| 39 | iterator begin() noexcept; | 39 | iterator begin() noexcept; // constexpr in C++17 |
| 40 | const_iterator begin() const noexcept; | 40 | const_iterator begin() const noexcept; // constexpr in C++17 |
| 41 | iterator end() noexcept; | 41 | iterator end() noexcept; // constexpr in C++17 |
| 42 | const_iterator end() const noexcept; | 42 | const_iterator end() const noexcept; // constexpr in C++17 |
| 43 | 43 | ||
| 44 | reverse_iterator rbegin() noexcept; | 44 | reverse_iterator rbegin() noexcept; // constexpr in C++17 |
| 45 | const_reverse_iterator rbegin() const noexcept; | 45 | const_reverse_iterator rbegin() const noexcept; // constexpr in C++17 |
| 46 | reverse_iterator rend() noexcept; | 46 | reverse_iterator rend() noexcept; // constexpr in C++17 |
| 47 | const_reverse_iterator rend() const noexcept; | 47 | const_reverse_iterator rend() const noexcept; // constexpr in C++17 |
| 48 | 48 | ||
| 49 | const_iterator cbegin() const noexcept; | 49 | const_iterator cbegin() const noexcept; // constexpr in C++17 |
| 50 | const_iterator cend() const noexcept; | 50 | const_iterator cend() const noexcept; // constexpr in C++17 |
| 51 | const_reverse_iterator crbegin() const noexcept; | 51 | const_reverse_iterator crbegin() const noexcept; // constexpr in C++17 |
| 52 | const_reverse_iterator crend() const noexcept; | 52 | const_reverse_iterator crend() const noexcept; // constexpr in C++17 |
| 53 | 53 | ||
| 54 | // capacity: | 54 | // capacity: |
| 55 | constexpr size_type size() const noexcept; | 55 | constexpr size_type size() const noexcept; |
| ... | @@ -57,46 +57,51 @@ struct array | ... | @@ -57,46 +57,51 @@ struct array |
| 57 | constexpr bool empty() const noexcept; | 57 | constexpr bool empty() const noexcept; |
| 58 | 58 | ||
| 59 | // element access: | 59 | // element access: |
| 60 | reference operator[](size_type n); | 60 | reference operator[](size_type n); // constexpr in C++17 |
| 61 | const_reference operator[](size_type n) const; // constexpr in C++14 | 61 | const_reference operator[](size_type n) const; // constexpr in C++14 |
| 62 | const_reference at(size_type n) const; // constexpr in C++14 | 62 | reference at(size_type n); // constexpr in C++17 |
| 63 | reference at(size_type n); | 63 | const_reference at(size_type n) const; // constexpr in C++14 |
| 64 | 64 | ||
| 65 | reference front(); | 65 | reference front(); // constexpr in C++17 |
| 66 | const_reference front() const; // constexpr in C++14 | 66 | const_reference front() const; // constexpr in C++14 |
| 67 | reference back(); | 67 | reference back(); // constexpr in C++17 |
| 68 | const_reference back() const; // constexpr in C++14 | 68 | const_reference back() const; // constexpr in C++14 |
| 69 | 69 | ||
| 70 | T* data() noexcept; | 70 | T* data() noexcept; // constexpr in C++17 |
| 71 | const T* data() const noexcept; | 71 | const T* data() const noexcept; // constexpr in C++17 |
| 72 | }; | 72 | }; |
| 73 | 73 | ||
| 74 | template <class T, class... U> | 74 | template <class T, class... U> |
| 75 | array(T, U...) -> array<T, 1 + sizeof...(U)>; | 75 | array(T, U...) -> array<T, 1 + sizeof...(U)>; // C++17 |
| 76 | 76 | ||
| 77 | template <class T, size_t N> | 77 | template <class T, size_t N> |
| 78 | bool operator==(const array<T,N>& x, const array<T,N>& y); | 78 | bool operator==(const array<T,N>& x, const array<T,N>& y); // constexpr in C++20 |
| 79 | template <class T, size_t N> | 79 | template <class T, size_t N> |
| 80 | bool operator!=(const array<T,N>& x, const array<T,N>& y); | 80 | bool operator!=(const array<T,N>& x, const array<T,N>& y); // constexpr in C++20 |
| 81 | template <class T, size_t N> | 81 | template <class T, size_t N> |
| 82 | bool operator<(const array<T,N>& x, const array<T,N>& y); | 82 | bool operator<(const array<T,N>& x, const array<T,N>& y); // constexpr in C++20 |
| 83 | template <class T, size_t N> | 83 | template <class T, size_t N> |
| 84 | bool operator>(const array<T,N>& x, const array<T,N>& y); | 84 | bool operator>(const array<T,N>& x, const array<T,N>& y); // constexpr in C++20 |
| 85 | template <class T, size_t N> | 85 | template <class T, size_t N> |
| 86 | bool operator<=(const array<T,N>& x, const array<T,N>& y); | 86 | bool operator<=(const array<T,N>& x, const array<T,N>& y); // constexpr in C++20 |
| 87 | template <class T, size_t N> | 87 | template <class T, size_t N> |
| 88 | bool operator>=(const array<T,N>& x, const array<T,N>& y); | 88 | bool operator>=(const array<T,N>& x, const array<T,N>& y); // constexpr in C++20 |
| 89 | 89 | ||
| 90 | template <class T, size_t N > | 90 | template <class T, size_t N > |
| 91 | void swap(array<T,N>& x, array<T,N>& y) noexcept(noexcept(x.swap(y))); // C++17 | 91 | void swap(array<T,N>& x, array<T,N>& y) noexcept(noexcept(x.swap(y))); // constexpr in C++20 |
| 92 | |||
| 93 | template <class T, size_t N> | ||
| 94 | constexpr array<remove_cv_t<T>, N> to_array(T (&a)[N]); // C++20 | ||
| 95 | template <class T, size_t N> | ||
| 96 | constexpr array<remove_cv_t<T>, N> to_array(T (&&a)[N]); // C++20 | ||
| 92 | 97 | ||
| 93 | template <class T> struct tuple_size; | 98 | template <class T> struct tuple_size; |
| 94 | template <size_t I, class T> struct tuple_element; | 99 | template <size_t I, class T> struct tuple_element; |
| 95 | template <class T, size_t N> struct tuple_size<array<T, N>>; | 100 | template <class T, size_t N> struct tuple_size<array<T, N>>; |
| 96 | template <size_t I, class T, size_t N> struct tuple_element<I, array<T, N>>; | 101 | template <size_t I, class T, size_t N> struct tuple_element<I, array<T, N>>; |
| 97 | template <size_t I, class T, size_t N> T& get(array<T, N>&) noexcept; // constexpr in C++14 | 102 | template <size_t I, class T, size_t N> T& get(array<T, N>&) noexcept; // constexpr in C++14 |
| 98 | template <size_t I, class T, size_t N> const T& get(const array<T, N>&) noexcept; // constexpr in C++14 | 103 | template <size_t I, class T, size_t N> const T& get(const array<T, N>&) noexcept; // constexpr in C++14 |
| 99 | template <size_t I, class T, size_t N> T&& get(array<T, N>&&) noexcept; // constexpr in C++14 | 104 | template <size_t I, class T, size_t N> T&& get(array<T, N>&&) noexcept; // constexpr in C++14 |
| 100 | template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexcept; // constexpr in C++14 | 105 | template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexcept; // constexpr in C++14 |
| 101 | 106 | ||
| 102 | } // std | 107 | } // std |
| ... | @@ -143,13 +148,14 @@ struct _LIBCPP_TEMPLATE_VIS array | ... | @@ -143,13 +148,14 @@ struct _LIBCPP_TEMPLATE_VIS array |
| 143 | _Tp __elems_[_Size]; | 148 | _Tp __elems_[_Size]; |
| 144 | 149 | ||
| 145 | // No explicit construct/copy/destroy for aggregate type | 150 | // No explicit construct/copy/destroy for aggregate type |
| 146 | _LIBCPP_INLINE_VISIBILITY void fill(const value_type& __u) { | 151 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 147 | _VSTD::fill_n(__elems_, _Size, __u); | 152 | void fill(const value_type& __u) { |
| 153 | _VSTD::fill_n(data(), _Size, __u); | ||
| 148 | } | 154 | } |
| 149 | 155 | ||
| 150 | _LIBCPP_INLINE_VISIBILITY | 156 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 151 | void swap(array& __a) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) { | 157 | void swap(array& __a) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) { |
| 152 | std::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_); | 158 | std::swap_ranges(data(), data() + _Size, __a.data()); |
| 153 | } | 159 | } |
| 154 | 160 | ||
| 155 | // iterators: | 161 | // iterators: |
| ... | @@ -186,21 +192,38 @@ struct _LIBCPP_TEMPLATE_VIS array | ... | @@ -186,21 +192,38 @@ struct _LIBCPP_TEMPLATE_VIS array |
| 186 | _LIBCPP_INLINE_VISIBILITY | 192 | _LIBCPP_INLINE_VISIBILITY |
| 187 | _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT {return _Size;} | 193 | _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT {return _Size;} |
| 188 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | 194 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY |
| 189 | _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return false; } | 195 | _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return _Size == 0;} |
| 190 | 196 | ||
| 191 | // element access: | 197 | // element access: |
| 192 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | 198 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 193 | reference operator[](size_type __n) _NOEXCEPT {return __elems_[__n];} | 199 | reference operator[](size_type __n) _NOEXCEPT { |
| 200 | _LIBCPP_ASSERT(__n < _Size, "out-of-bounds access in std::array<T, N>"); | ||
| 201 | return __elems_[__n]; | ||
| 202 | } | ||
| 194 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | 203 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 195 | const_reference operator[](size_type __n) const _NOEXCEPT {return __elems_[__n];} | 204 | const_reference operator[](size_type __n) const _NOEXCEPT { |
| 205 | _LIBCPP_ASSERT(__n < _Size, "out-of-bounds access in std::array<T, N>"); | ||
| 206 | return __elems_[__n]; | ||
| 207 | } | ||
| 196 | 208 | ||
| 197 | _LIBCPP_CONSTEXPR_AFTER_CXX14 reference at(size_type __n); | 209 | _LIBCPP_CONSTEXPR_AFTER_CXX14 reference at(size_type __n) |
| 198 | _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference at(size_type __n) const; | 210 | { |
| 211 | if (__n >= _Size) | ||
| 212 | __throw_out_of_range("array::at"); | ||
| 213 | return __elems_[__n]; | ||
| 214 | } | ||
| 199 | 215 | ||
| 200 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference front() _NOEXCEPT {return __elems_[0];} | 216 | _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference at(size_type __n) const |
| 201 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference front() const _NOEXCEPT {return __elems_[0];} | 217 | { |
| 202 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference back() _NOEXCEPT {return __elems_[_Size - 1];} | 218 | if (__n >= _Size) |
| 203 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference back() const _NOEXCEPT {return __elems_[_Size - 1];} | 219 | __throw_out_of_range("array::at"); |
| 220 | return __elems_[__n]; | ||
| 221 | } | ||
| 222 | |||
| 223 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference front() _NOEXCEPT {return (*this)[0];} | ||
| 224 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference front() const _NOEXCEPT {return (*this)[0];} | ||
| 225 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference back() _NOEXCEPT {return (*this)[_Size - 1];} | ||
| 226 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference back() const _NOEXCEPT {return (*this)[_Size - 1];} | ||
| 204 | 227 | ||
| 205 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | 228 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 206 | value_type* data() _NOEXCEPT {return __elems_;} | 229 | value_type* data() _NOEXCEPT {return __elems_;} |
| ... | @@ -208,28 +231,6 @@ struct _LIBCPP_TEMPLATE_VIS array | ... | @@ -208,28 +231,6 @@ struct _LIBCPP_TEMPLATE_VIS array |
| 208 | const value_type* data() const _NOEXCEPT {return __elems_;} | 231 | const value_type* data() const _NOEXCEPT {return __elems_;} |
| 209 | }; | 232 | }; |
| 210 | 233 | ||
| 211 | |||
| 212 | template <class _Tp, size_t _Size> | ||
| 213 | _LIBCPP_CONSTEXPR_AFTER_CXX14 | ||
| 214 | typename array<_Tp, _Size>::reference | ||
| 215 | array<_Tp, _Size>::at(size_type __n) | ||
| 216 | { | ||
| 217 | if (__n >= _Size) | ||
| 218 | __throw_out_of_range("array::at"); | ||
| 219 | |||
| 220 | return __elems_[__n]; | ||
| 221 | } | ||
| 222 | |||
| 223 | template <class _Tp, size_t _Size> | ||
| 224 | _LIBCPP_CONSTEXPR_AFTER_CXX11 | ||
| 225 | typename array<_Tp, _Size>::const_reference | ||
| 226 | array<_Tp, _Size>::at(size_type __n) const | ||
| 227 | { | ||
| 228 | if (__n >= _Size) | ||
| 229 | __throw_out_of_range("array::at"); | ||
| 230 | return __elems_[__n]; | ||
| 231 | } | ||
| 232 | |||
| 233 | template <class _Tp> | 234 | template <class _Tp> |
| 234 | struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> | 235 | struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> |
| 235 | { | 236 | { |
| ... | @@ -253,44 +254,50 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> | ... | @@ -253,44 +254,50 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> |
| 253 | struct _ArrayInStructT { _Tp __data_[1]; }; | 254 | struct _ArrayInStructT { _Tp __data_[1]; }; |
| 254 | _ALIGNAS_TYPE(_ArrayInStructT) _CharType __elems_[sizeof(_ArrayInStructT)]; | 255 | _ALIGNAS_TYPE(_ArrayInStructT) _CharType __elems_[sizeof(_ArrayInStructT)]; |
| 255 | 256 | ||
| 257 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | ||
| 258 | value_type* data() _NOEXCEPT {return nullptr;} | ||
| 259 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | ||
| 260 | const value_type* data() const _NOEXCEPT {return nullptr;} | ||
| 261 | |||
| 256 | // No explicit construct/copy/destroy for aggregate type | 262 | // No explicit construct/copy/destroy for aggregate type |
| 257 | _LIBCPP_INLINE_VISIBILITY void fill(const value_type&) { | 263 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 264 | void fill(const value_type&) { | ||
| 258 | static_assert(!is_const<_Tp>::value, | 265 | static_assert(!is_const<_Tp>::value, |
| 259 | "cannot fill zero-sized array of type 'const T'"); | 266 | "cannot fill zero-sized array of type 'const T'"); |
| 260 | } | 267 | } |
| 261 | 268 | ||
| 262 | _LIBCPP_INLINE_VISIBILITY | 269 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 263 | void swap(array&) _NOEXCEPT { | 270 | void swap(array&) _NOEXCEPT { |
| 264 | static_assert(!is_const<_Tp>::value, | 271 | static_assert(!is_const<_Tp>::value, |
| 265 | "cannot swap zero-sized array of type 'const T'"); | 272 | "cannot swap zero-sized array of type 'const T'"); |
| 266 | } | 273 | } |
| 267 | 274 | ||
| 268 | // iterators: | 275 | // iterators: |
| 269 | _LIBCPP_INLINE_VISIBILITY | 276 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 270 | iterator begin() _NOEXCEPT {return iterator(data());} | 277 | iterator begin() _NOEXCEPT {return iterator(data());} |
| 271 | _LIBCPP_INLINE_VISIBILITY | 278 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 272 | const_iterator begin() const _NOEXCEPT {return const_iterator(data());} | 279 | const_iterator begin() const _NOEXCEPT {return const_iterator(data());} |
| 273 | _LIBCPP_INLINE_VISIBILITY | 280 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 274 | iterator end() _NOEXCEPT {return iterator(data());} | 281 | iterator end() _NOEXCEPT {return iterator(data());} |
| 275 | _LIBCPP_INLINE_VISIBILITY | 282 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 276 | const_iterator end() const _NOEXCEPT {return const_iterator(data());} | 283 | const_iterator end() const _NOEXCEPT {return const_iterator(data());} |
| 277 | 284 | ||
| 278 | _LIBCPP_INLINE_VISIBILITY | 285 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 279 | reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());} | 286 | reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());} |
| 280 | _LIBCPP_INLINE_VISIBILITY | 287 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 281 | const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());} | 288 | const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());} |
| 282 | _LIBCPP_INLINE_VISIBILITY | 289 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 283 | reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());} | 290 | reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());} |
| 284 | _LIBCPP_INLINE_VISIBILITY | 291 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 285 | const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());} | 292 | const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());} |
| 286 | 293 | ||
| 287 | _LIBCPP_INLINE_VISIBILITY | 294 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 288 | const_iterator cbegin() const _NOEXCEPT {return begin();} | 295 | const_iterator cbegin() const _NOEXCEPT {return begin();} |
| 289 | _LIBCPP_INLINE_VISIBILITY | 296 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 290 | const_iterator cend() const _NOEXCEPT {return end();} | 297 | const_iterator cend() const _NOEXCEPT {return end();} |
| 291 | _LIBCPP_INLINE_VISIBILITY | 298 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 292 | const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} | 299 | const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} |
| 293 | _LIBCPP_INLINE_VISIBILITY | 300 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 294 | const_reverse_iterator crend() const _NOEXCEPT {return rend();} | 301 | const_reverse_iterator crend() const _NOEXCEPT {return rend();} |
| 295 | 302 | ||
| 296 | // capacity: | 303 | // capacity: |
| ... | @@ -302,7 +309,7 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> | ... | @@ -302,7 +309,7 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> |
| 302 | _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return true;} | 309 | _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return true;} |
| 303 | 310 | ||
| 304 | // element access: | 311 | // element access: |
| 305 | _LIBCPP_INLINE_VISIBILITY | 312 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 306 | reference operator[](size_type) _NOEXCEPT { | 313 | reference operator[](size_type) _NOEXCEPT { |
| 307 | _LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array"); | 314 | _LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array"); |
| 308 | _LIBCPP_UNREACHABLE(); | 315 | _LIBCPP_UNREACHABLE(); |
| ... | @@ -314,52 +321,47 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> | ... | @@ -314,52 +321,47 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> |
| 314 | _LIBCPP_UNREACHABLE(); | 321 | _LIBCPP_UNREACHABLE(); |
| 315 | } | 322 | } |
| 316 | 323 | ||
| 317 | _LIBCPP_INLINE_VISIBILITY | 324 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 318 | reference at(size_type) { | 325 | reference at(size_type) { |
| 319 | __throw_out_of_range("array<T, 0>::at"); | 326 | __throw_out_of_range("array<T, 0>::at"); |
| 320 | _LIBCPP_UNREACHABLE(); | 327 | _LIBCPP_UNREACHABLE(); |
| 321 | } | 328 | } |
| 322 | 329 | ||
| 323 | _LIBCPP_INLINE_VISIBILITY | 330 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 324 | const_reference at(size_type) const { | 331 | const_reference at(size_type) const { |
| 325 | __throw_out_of_range("array<T, 0>::at"); | 332 | __throw_out_of_range("array<T, 0>::at"); |
| 326 | _LIBCPP_UNREACHABLE(); | 333 | _LIBCPP_UNREACHABLE(); |
| 327 | } | 334 | } |
| 328 | 335 | ||
| 329 | _LIBCPP_INLINE_VISIBILITY | 336 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 330 | reference front() _NOEXCEPT { | 337 | reference front() _NOEXCEPT { |
| 331 | _LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array"); | 338 | _LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array"); |
| 332 | _LIBCPP_UNREACHABLE(); | 339 | _LIBCPP_UNREACHABLE(); |
| 333 | } | 340 | } |
| 334 | 341 | ||
| 335 | _LIBCPP_INLINE_VISIBILITY | 342 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 336 | const_reference front() const _NOEXCEPT { | 343 | const_reference front() const _NOEXCEPT { |
| 337 | _LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array"); | 344 | _LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array"); |
| 338 | _LIBCPP_UNREACHABLE(); | 345 | _LIBCPP_UNREACHABLE(); |
| 339 | } | 346 | } |
| 340 | 347 | ||
| 341 | _LIBCPP_INLINE_VISIBILITY | 348 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 342 | reference back() _NOEXCEPT { | 349 | reference back() _NOEXCEPT { |
| 343 | _LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array"); | 350 | _LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array"); |
| 344 | _LIBCPP_UNREACHABLE(); | 351 | _LIBCPP_UNREACHABLE(); |
| 345 | } | 352 | } |
| 346 | 353 | ||
| 347 | _LIBCPP_INLINE_VISIBILITY | 354 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 348 | const_reference back() const _NOEXCEPT { | 355 | const_reference back() const _NOEXCEPT { |
| 349 | _LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array"); | 356 | _LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array"); |
| 350 | _LIBCPP_UNREACHABLE(); | 357 | _LIBCPP_UNREACHABLE(); |
| 351 | } | 358 | } |
| 352 | |||
| 353 | _LIBCPP_INLINE_VISIBILITY | ||
| 354 | value_type* data() _NOEXCEPT {return reinterpret_cast<value_type*>(__elems_);} | ||
| 355 | _LIBCPP_INLINE_VISIBILITY | ||
| 356 | const value_type* data() const _NOEXCEPT {return reinterpret_cast<const value_type*>(__elems_);} | ||
| 357 | }; | 359 | }; |
| 358 | 360 | ||
| 359 | 361 | ||
| 360 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | 362 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES |
| 361 | template<class _Tp, class... _Args, | 363 | template<class _Tp, class... _Args, |
| 362 | class = typename enable_if<(is_same_v<_Tp, _Args> && ...), void>::type | 364 | class = _EnableIf<__all<_IsSame<_Tp, _Args>::value...>::value> |
| 363 | > | 365 | > |
| 364 | array(_Tp, _Args...) | 366 | array(_Tp, _Args...) |
| 365 | -> array<_Tp, 1 + sizeof...(_Args)>; | 367 | -> array<_Tp, 1 + sizeof...(_Args)>; |
| ... | @@ -415,7 +417,7 @@ operator>=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) | ... | @@ -415,7 +417,7 @@ operator>=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) |
| 415 | } | 417 | } |
| 416 | 418 | ||
| 417 | template <class _Tp, size_t _Size> | 419 | template <class _Tp, size_t _Size> |
| 418 | inline _LIBCPP_INLINE_VISIBILITY | 420 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 419 | typename enable_if | 421 | typename enable_if |
| 420 | < | 422 | < |
| 421 | _Size == 0 || | 423 | _Size == 0 || |
| ... | @@ -479,6 +481,47 @@ get(const array<_Tp, _Size>&& __a) _NOEXCEPT | ... | @@ -479,6 +481,47 @@ get(const array<_Tp, _Size>&& __a) _NOEXCEPT |
| 479 | 481 | ||
| 480 | #endif // !_LIBCPP_CXX03_LANG | 482 | #endif // !_LIBCPP_CXX03_LANG |
| 481 | 483 | ||
| 484 | #if _LIBCPP_STD_VER > 17 | ||
| 485 | |||
| 486 | template <typename _Tp, size_t _Size, size_t... _Index> | ||
| 487 | _LIBCPP_INLINE_VISIBILITY constexpr array<remove_cv_t<_Tp>, _Size> | ||
| 488 | __to_array_lvalue_impl(_Tp (&__arr)[_Size], index_sequence<_Index...>) { | ||
| 489 | return {{__arr[_Index]...}}; | ||
| 490 | } | ||
| 491 | |||
| 492 | template <typename _Tp, size_t _Size, size_t... _Index> | ||
| 493 | _LIBCPP_INLINE_VISIBILITY constexpr array<remove_cv_t<_Tp>, _Size> | ||
| 494 | __to_array_rvalue_impl(_Tp(&&__arr)[_Size], index_sequence<_Index...>) { | ||
| 495 | return {{_VSTD::move(__arr[_Index])...}}; | ||
| 496 | } | ||
| 497 | |||
| 498 | template <typename _Tp, size_t _Size> | ||
| 499 | _LIBCPP_INLINE_VISIBILITY constexpr array<remove_cv_t<_Tp>, _Size> | ||
| 500 | to_array(_Tp (&__arr)[_Size]) noexcept(is_nothrow_constructible_v<_Tp, _Tp&>) { | ||
| 501 | static_assert( | ||
| 502 | !is_array_v<_Tp>, | ||
| 503 | "[array.creation]/1: to_array does not accept multidimensional arrays."); | ||
| 504 | static_assert( | ||
| 505 | is_constructible_v<_Tp, _Tp&>, | ||
| 506 | "[array.creation]/1: to_array requires copy constructible elements."); | ||
| 507 | return __to_array_lvalue_impl(__arr, make_index_sequence<_Size>()); | ||
| 508 | } | ||
| 509 | |||
| 510 | template <typename _Tp, size_t _Size> | ||
| 511 | _LIBCPP_INLINE_VISIBILITY constexpr array<remove_cv_t<_Tp>, _Size> | ||
| 512 | to_array(_Tp(&&__arr)[_Size]) noexcept(is_nothrow_move_constructible_v<_Tp>) { | ||
| 513 | static_assert( | ||
| 514 | !is_array_v<_Tp>, | ||
| 515 | "[array.creation]/4: to_array does not accept multidimensional arrays."); | ||
| 516 | static_assert( | ||
| 517 | is_move_constructible_v<_Tp>, | ||
| 518 | "[array.creation]/4: to_array requires move constructible elements."); | ||
| 519 | return __to_array_rvalue_impl(_VSTD::move(__arr), | ||
| 520 | make_index_sequence<_Size>()); | ||
| 521 | } | ||
| 522 | |||
| 523 | #endif // _LIBCPP_STD_VER > 17 | ||
| 524 | |||
| 482 | _LIBCPP_END_NAMESPACE_STD | 525 | _LIBCPP_END_NAMESPACE_STD |
| 483 | 526 | ||
| 484 | #endif // _LIBCPP_ARRAY | 527 | #endif // _LIBCPP_ARRAY |
lib/libcxx/include/atomic+553-207| ... | @@ -54,60 +54,30 @@ template <class T> T kill_dependency(T y) noexcept; | ... | @@ -54,60 +54,30 @@ template <class T> T kill_dependency(T y) noexcept; |
| 54 | #define ATOMIC_LLONG_LOCK_FREE unspecified | 54 | #define ATOMIC_LLONG_LOCK_FREE unspecified |
| 55 | #define ATOMIC_POINTER_LOCK_FREE unspecified | 55 | #define ATOMIC_POINTER_LOCK_FREE unspecified |
| 56 | 56 | ||
| 57 | // flag type and operations | ||
| 58 | |||
| 59 | typedef struct atomic_flag | ||
| 60 | { | ||
| 61 | bool test_and_set(memory_order m = memory_order_seq_cst) volatile noexcept; | ||
| 62 | bool test_and_set(memory_order m = memory_order_seq_cst) noexcept; | ||
| 63 | void clear(memory_order m = memory_order_seq_cst) volatile noexcept; | ||
| 64 | void clear(memory_order m = memory_order_seq_cst) noexcept; | ||
| 65 | atomic_flag() noexcept = default; | ||
| 66 | atomic_flag(const atomic_flag&) = delete; | ||
| 67 | atomic_flag& operator=(const atomic_flag&) = delete; | ||
| 68 | atomic_flag& operator=(const atomic_flag&) volatile = delete; | ||
| 69 | } atomic_flag; | ||
| 70 | |||
| 71 | bool | ||
| 72 | atomic_flag_test_and_set(volatile atomic_flag* obj) noexcept; | ||
| 73 | |||
| 74 | bool | ||
| 75 | atomic_flag_test_and_set(atomic_flag* obj) noexcept; | ||
| 76 | |||
| 77 | bool | ||
| 78 | atomic_flag_test_and_set_explicit(volatile atomic_flag* obj, | ||
| 79 | memory_order m) noexcept; | ||
| 80 | |||
| 81 | bool | ||
| 82 | atomic_flag_test_and_set_explicit(atomic_flag* obj, memory_order m) noexcept; | ||
| 83 | |||
| 84 | void | ||
| 85 | atomic_flag_clear(volatile atomic_flag* obj) noexcept; | ||
| 86 | |||
| 87 | void | ||
| 88 | atomic_flag_clear(atomic_flag* obj) noexcept; | ||
| 89 | |||
| 90 | void | ||
| 91 | atomic_flag_clear_explicit(volatile atomic_flag* obj, memory_order m) noexcept; | ||
| 92 | |||
| 93 | void | ||
| 94 | atomic_flag_clear_explicit(atomic_flag* obj, memory_order m) noexcept; | ||
| 95 | |||
| 96 | #define ATOMIC_FLAG_INIT see below | ||
| 97 | #define ATOMIC_VAR_INIT(value) see below | ||
| 98 | |||
| 99 | template <class T> | 57 | template <class T> |
| 100 | struct atomic | 58 | struct atomic |
| 101 | { | 59 | { |
| 60 | using value_type = T; | ||
| 61 | |||
| 102 | static constexpr bool is_always_lock_free; | 62 | static constexpr bool is_always_lock_free; |
| 103 | bool is_lock_free() const volatile noexcept; | 63 | bool is_lock_free() const volatile noexcept; |
| 104 | bool is_lock_free() const noexcept; | 64 | bool is_lock_free() const noexcept; |
| 105 | void store(T desr, memory_order m = memory_order_seq_cst) volatile noexcept; | 65 | |
| 106 | void store(T desr, memory_order m = memory_order_seq_cst) noexcept; | 66 | atomic() noexcept = default; |
| 67 | constexpr atomic(T desr) noexcept; | ||
| 68 | atomic(const atomic&) = delete; | ||
| 69 | atomic& operator=(const atomic&) = delete; | ||
| 70 | atomic& operator=(const atomic&) volatile = delete; | ||
| 71 | |||
| 107 | T load(memory_order m = memory_order_seq_cst) const volatile noexcept; | 72 | T load(memory_order m = memory_order_seq_cst) const volatile noexcept; |
| 108 | T load(memory_order m = memory_order_seq_cst) const noexcept; | 73 | T load(memory_order m = memory_order_seq_cst) const noexcept; |
| 109 | operator T() const volatile noexcept; | 74 | operator T() const volatile noexcept; |
| 110 | operator T() const noexcept; | 75 | operator T() const noexcept; |
| 76 | void store(T desr, memory_order m = memory_order_seq_cst) volatile noexcept; | ||
| 77 | void store(T desr, memory_order m = memory_order_seq_cst) noexcept; | ||
| 78 | T operator=(T) volatile noexcept; | ||
| 79 | T operator=(T) noexcept; | ||
| 80 | |||
| 111 | T exchange(T desr, memory_order m = memory_order_seq_cst) volatile noexcept; | 81 | T exchange(T desr, memory_order m = memory_order_seq_cst) volatile noexcept; |
| 112 | T exchange(T desr, memory_order m = memory_order_seq_cst) noexcept; | 82 | T exchange(T desr, memory_order m = memory_order_seq_cst) noexcept; |
| 113 | bool compare_exchange_weak(T& expc, T desr, | 83 | bool compare_exchange_weak(T& expc, T desr, |
| ... | @@ -126,27 +96,38 @@ struct atomic | ... | @@ -126,27 +96,38 @@ struct atomic |
| 126 | bool compare_exchange_strong(T& expc, T desr, | 96 | bool compare_exchange_strong(T& expc, T desr, |
| 127 | memory_order m = memory_order_seq_cst) noexcept; | 97 | memory_order m = memory_order_seq_cst) noexcept; |
| 128 | 98 | ||
| 129 | atomic() noexcept = default; | 99 | void wait(T, memory_order = memory_order::seq_cst) const volatile noexcept; |
| 130 | constexpr atomic(T desr) noexcept; | 100 | void wait(T, memory_order = memory_order::seq_cst) const noexcept; |
| 131 | atomic(const atomic&) = delete; | 101 | void notify_one() volatile noexcept; |
| 132 | atomic& operator=(const atomic&) = delete; | 102 | void notify_one() noexcept; |
| 133 | atomic& operator=(const atomic&) volatile = delete; | 103 | void notify_all() volatile noexcept; |
| 134 | T operator=(T) volatile noexcept; | 104 | void notify_all() noexcept; |
| 135 | T operator=(T) noexcept; | ||
| 136 | }; | 105 | }; |
| 137 | 106 | ||
| 138 | template <> | 107 | template <> |
| 139 | struct atomic<integral> | 108 | struct atomic<integral> |
| 140 | { | 109 | { |
| 110 | using value_type = integral; | ||
| 111 | |||
| 141 | static constexpr bool is_always_lock_free; | 112 | static constexpr bool is_always_lock_free; |
| 142 | bool is_lock_free() const volatile noexcept; | 113 | bool is_lock_free() const volatile noexcept; |
| 143 | bool is_lock_free() const noexcept; | 114 | bool is_lock_free() const noexcept; |
| 144 | void store(integral desr, memory_order m = memory_order_seq_cst) volatile noexcept; | 115 | |
| 145 | void store(integral desr, memory_order m = memory_order_seq_cst) noexcept; | 116 | atomic() noexcept = default; |
| 117 | constexpr atomic(integral desr) noexcept; | ||
| 118 | atomic(const atomic&) = delete; | ||
| 119 | atomic& operator=(const atomic&) = delete; | ||
| 120 | atomic& operator=(const atomic&) volatile = delete; | ||
| 121 | |||
| 146 | integral load(memory_order m = memory_order_seq_cst) const volatile noexcept; | 122 | integral load(memory_order m = memory_order_seq_cst) const volatile noexcept; |
| 147 | integral load(memory_order m = memory_order_seq_cst) const noexcept; | 123 | integral load(memory_order m = memory_order_seq_cst) const noexcept; |
| 148 | operator integral() const volatile noexcept; | 124 | operator integral() const volatile noexcept; |
| 149 | operator integral() const noexcept; | 125 | operator integral() const noexcept; |
| 126 | void store(integral desr, memory_order m = memory_order_seq_cst) volatile noexcept; | ||
| 127 | void store(integral desr, memory_order m = memory_order_seq_cst) noexcept; | ||
| 128 | integral operator=(integral desr) volatile noexcept; | ||
| 129 | integral operator=(integral desr) noexcept; | ||
| 130 | |||
| 150 | integral exchange(integral desr, | 131 | integral exchange(integral desr, |
| 151 | memory_order m = memory_order_seq_cst) volatile noexcept; | 132 | memory_order m = memory_order_seq_cst) volatile noexcept; |
| 152 | integral exchange(integral desr, memory_order m = memory_order_seq_cst) noexcept; | 133 | integral exchange(integral desr, memory_order m = memory_order_seq_cst) noexcept; |
| ... | @@ -167,30 +148,17 @@ struct atomic<integral> | ... | @@ -167,30 +148,17 @@ struct atomic<integral> |
| 167 | bool compare_exchange_strong(integral& expc, integral desr, | 148 | bool compare_exchange_strong(integral& expc, integral desr, |
| 168 | memory_order m = memory_order_seq_cst) noexcept; | 149 | memory_order m = memory_order_seq_cst) noexcept; |
| 169 | 150 | ||
| 170 | integral | 151 | integral fetch_add(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; |
| 171 | fetch_add(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; | ||
| 172 | integral fetch_add(integral op, memory_order m = memory_order_seq_cst) noexcept; | 152 | integral fetch_add(integral op, memory_order m = memory_order_seq_cst) noexcept; |
| 173 | integral | 153 | integral fetch_sub(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; |
| 174 | fetch_sub(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; | ||
| 175 | integral fetch_sub(integral op, memory_order m = memory_order_seq_cst) noexcept; | 154 | integral fetch_sub(integral op, memory_order m = memory_order_seq_cst) noexcept; |
| 176 | integral | 155 | integral fetch_and(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; |
| 177 | fetch_and(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; | ||
| 178 | integral fetch_and(integral op, memory_order m = memory_order_seq_cst) noexcept; | 156 | integral fetch_and(integral op, memory_order m = memory_order_seq_cst) noexcept; |
| 179 | integral | 157 | integral fetch_or(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; |
| 180 | fetch_or(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; | ||
| 181 | integral fetch_or(integral op, memory_order m = memory_order_seq_cst) noexcept; | 158 | integral fetch_or(integral op, memory_order m = memory_order_seq_cst) noexcept; |
| 182 | integral | 159 | integral fetch_xor(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; |
| 183 | fetch_xor(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; | ||
| 184 | integral fetch_xor(integral op, memory_order m = memory_order_seq_cst) noexcept; | 160 | integral fetch_xor(integral op, memory_order m = memory_order_seq_cst) noexcept; |
| 185 | 161 | ||
| 186 | atomic() noexcept = default; | ||
| 187 | constexpr atomic(integral desr) noexcept; | ||
| 188 | atomic(const atomic&) = delete; | ||
| 189 | atomic& operator=(const atomic&) = delete; | ||
| 190 | atomic& operator=(const atomic&) volatile = delete; | ||
| 191 | integral operator=(integral desr) volatile noexcept; | ||
| 192 | integral operator=(integral desr) noexcept; | ||
| 193 | |||
| 194 | integral operator++(int) volatile noexcept; | 162 | integral operator++(int) volatile noexcept; |
| 195 | integral operator++(int) noexcept; | 163 | integral operator++(int) noexcept; |
| 196 | integral operator--(int) volatile noexcept; | 164 | integral operator--(int) volatile noexcept; |
| ... | @@ -209,20 +177,39 @@ struct atomic<integral> | ... | @@ -209,20 +177,39 @@ struct atomic<integral> |
| 209 | integral operator|=(integral op) noexcept; | 177 | integral operator|=(integral op) noexcept; |
| 210 | integral operator^=(integral op) volatile noexcept; | 178 | integral operator^=(integral op) volatile noexcept; |
| 211 | integral operator^=(integral op) noexcept; | 179 | integral operator^=(integral op) noexcept; |
| 180 | |||
| 181 | void wait(integral, memory_order = memory_order::seq_cst) const volatile noexcept; | ||
| 182 | void wait(integral, memory_order = memory_order::seq_cst) const noexcept; | ||
| 183 | void notify_one() volatile noexcept; | ||
| 184 | void notify_one() noexcept; | ||
| 185 | void notify_all() volatile noexcept; | ||
| 186 | void notify_all() noexcept; | ||
| 212 | }; | 187 | }; |
| 213 | 188 | ||
| 214 | template <class T> | 189 | template <class T> |
| 215 | struct atomic<T*> | 190 | struct atomic<T*> |
| 216 | { | 191 | { |
| 192 | using value_type = T*; | ||
| 193 | |||
| 217 | static constexpr bool is_always_lock_free; | 194 | static constexpr bool is_always_lock_free; |
| 218 | bool is_lock_free() const volatile noexcept; | 195 | bool is_lock_free() const volatile noexcept; |
| 219 | bool is_lock_free() const noexcept; | 196 | bool is_lock_free() const noexcept; |
| 220 | void store(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept; | 197 | |
| 221 | void store(T* desr, memory_order m = memory_order_seq_cst) noexcept; | 198 | atomic() noexcept = default; |
| 199 | constexpr atomic(T* desr) noexcept; | ||
| 200 | atomic(const atomic&) = delete; | ||
| 201 | atomic& operator=(const atomic&) = delete; | ||
| 202 | atomic& operator=(const atomic&) volatile = delete; | ||
| 203 | |||
| 222 | T* load(memory_order m = memory_order_seq_cst) const volatile noexcept; | 204 | T* load(memory_order m = memory_order_seq_cst) const volatile noexcept; |
| 223 | T* load(memory_order m = memory_order_seq_cst) const noexcept; | 205 | T* load(memory_order m = memory_order_seq_cst) const noexcept; |
| 224 | operator T*() const volatile noexcept; | 206 | operator T*() const volatile noexcept; |
| 225 | operator T*() const noexcept; | 207 | operator T*() const noexcept; |
| 208 | void store(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept; | ||
| 209 | void store(T* desr, memory_order m = memory_order_seq_cst) noexcept; | ||
| 210 | T* operator=(T*) volatile noexcept; | ||
| 211 | T* operator=(T*) noexcept; | ||
| 212 | |||
| 226 | T* exchange(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept; | 213 | T* exchange(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept; |
| 227 | T* exchange(T* desr, memory_order m = memory_order_seq_cst) noexcept; | 214 | T* exchange(T* desr, memory_order m = memory_order_seq_cst) noexcept; |
| 228 | bool compare_exchange_weak(T*& expc, T* desr, | 215 | bool compare_exchange_weak(T*& expc, T* desr, |
| ... | @@ -246,14 +233,6 @@ struct atomic<T*> | ... | @@ -246,14 +233,6 @@ struct atomic<T*> |
| 246 | T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile noexcept; | 233 | T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile noexcept; |
| 247 | T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) noexcept; | 234 | T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) noexcept; |
| 248 | 235 | ||
| 249 | atomic() noexcept = default; | ||
| 250 | constexpr atomic(T* desr) noexcept; | ||
| 251 | atomic(const atomic&) = delete; | ||
| 252 | atomic& operator=(const atomic&) = delete; | ||
| 253 | atomic& operator=(const atomic&) volatile = delete; | ||
| 254 | |||
| 255 | T* operator=(T*) volatile noexcept; | ||
| 256 | T* operator=(T*) noexcept; | ||
| 257 | T* operator++(int) volatile noexcept; | 236 | T* operator++(int) volatile noexcept; |
| 258 | T* operator++(int) noexcept; | 237 | T* operator++(int) noexcept; |
| 259 | T* operator--(int) volatile noexcept; | 238 | T* operator--(int) volatile noexcept; |
| ... | @@ -266,224 +245,206 @@ struct atomic<T*> | ... | @@ -266,224 +245,206 @@ struct atomic<T*> |
| 266 | T* operator+=(ptrdiff_t op) noexcept; | 245 | T* operator+=(ptrdiff_t op) noexcept; |
| 267 | T* operator-=(ptrdiff_t op) volatile noexcept; | 246 | T* operator-=(ptrdiff_t op) volatile noexcept; |
| 268 | T* operator-=(ptrdiff_t op) noexcept; | 247 | T* operator-=(ptrdiff_t op) noexcept; |
| 248 | |||
| 249 | void wait(T*, memory_order = memory_order::seq_cst) const volatile noexcept; | ||
| 250 | void wait(T*, memory_order = memory_order::seq_cst) const noexcept; | ||
| 251 | void notify_one() volatile noexcept; | ||
| 252 | void notify_one() noexcept; | ||
| 253 | void notify_all() volatile noexcept; | ||
| 254 | void notify_all() noexcept; | ||
| 269 | }; | 255 | }; |
| 270 | 256 | ||
| 271 | 257 | ||
| 272 | template <class T> | 258 | template <class T> |
| 273 | bool | 259 | bool atomic_is_lock_free(const volatile atomic<T>* obj) noexcept; |
| 274 | atomic_is_lock_free(const volatile atomic<T>* obj) noexcept; | 260 | |
| 261 | template <class T> | ||
| 262 | bool atomic_is_lock_free(const atomic<T>* obj) noexcept; | ||
| 263 | |||
| 264 | template <class T> | ||
| 265 | void atomic_store(volatile atomic<T>* obj, T desr) noexcept; | ||
| 266 | |||
| 267 | template <class T> | ||
| 268 | void atomic_store(atomic<T>* obj, T desr) noexcept; | ||
| 269 | |||
| 270 | template <class T> | ||
| 271 | void atomic_store_explicit(volatile atomic<T>* obj, T desr, memory_order m) noexcept; | ||
| 272 | |||
| 273 | template <class T> | ||
| 274 | void atomic_store_explicit(atomic<T>* obj, T desr, memory_order m) noexcept; | ||
| 275 | |||
| 276 | template <class T> | ||
| 277 | T atomic_load(const volatile atomic<T>* obj) noexcept; | ||
| 275 | 278 | ||
| 276 | template <class T> | 279 | template <class T> |
| 277 | bool | 280 | T atomic_load(const atomic<T>* obj) noexcept; |
| 278 | atomic_is_lock_free(const atomic<T>* obj) noexcept; | ||
| 279 | 281 | ||
| 280 | template <class T> | 282 | template <class T> |
| 281 | void | 283 | T atomic_load_explicit(const volatile atomic<T>* obj, memory_order m) noexcept; |
| 282 | atomic_init(volatile atomic<T>* obj, T desr) noexcept; | ||
| 283 | 284 | ||
| 284 | template <class T> | 285 | template <class T> |
| 285 | void | 286 | T atomic_load_explicit(const atomic<T>* obj, memory_order m) noexcept; |
| 286 | atomic_init(atomic<T>* obj, T desr) noexcept; | ||
| 287 | 287 | ||
| 288 | template <class T> | 288 | template <class T> |
| 289 | void | 289 | T atomic_exchange(volatile atomic<T>* obj, T desr) noexcept; |
| 290 | atomic_store(volatile atomic<T>* obj, T desr) noexcept; | ||
| 291 | 290 | ||
| 292 | template <class T> | 291 | template <class T> |
| 293 | void | 292 | T atomic_exchange(atomic<T>* obj, T desr) noexcept; |
| 294 | atomic_store(atomic<T>* obj, T desr) noexcept; | ||
| 295 | 293 | ||
| 296 | template <class T> | 294 | template <class T> |
| 297 | void | 295 | T atomic_exchange_explicit(volatile atomic<T>* obj, T desr, memory_order m) noexcept; |
| 298 | atomic_store_explicit(volatile atomic<T>* obj, T desr, memory_order m) noexcept; | ||
| 299 | 296 | ||
| 300 | template <class T> | 297 | template <class T> |
| 301 | void | 298 | T atomic_exchange_explicit(atomic<T>* obj, T desr, memory_order m) noexcept; |
| 302 | atomic_store_explicit(atomic<T>* obj, T desr, memory_order m) noexcept; | ||
| 303 | 299 | ||
| 304 | template <class T> | 300 | template <class T> |
| 305 | T | 301 | bool atomic_compare_exchange_weak(volatile atomic<T>* obj, T* expc, T desr) noexcept; |
| 306 | atomic_load(const volatile atomic<T>* obj) noexcept; | ||
| 307 | 302 | ||
| 308 | template <class T> | 303 | template <class T> |
| 309 | T | 304 | bool atomic_compare_exchange_weak(atomic<T>* obj, T* expc, T desr) noexcept; |
| 310 | atomic_load(const atomic<T>* obj) noexcept; | ||
| 311 | 305 | ||
| 312 | template <class T> | 306 | template <class T> |
| 313 | T | 307 | bool atomic_compare_exchange_strong(volatile atomic<T>* obj, T* expc, T desr) noexcept; |
| 314 | atomic_load_explicit(const volatile atomic<T>* obj, memory_order m) noexcept; | ||
| 315 | 308 | ||
| 316 | template <class T> | 309 | template <class T> |
| 317 | T | 310 | bool atomic_compare_exchange_strong(atomic<T>* obj, T* expc, T desr) noexcept; |
| 318 | atomic_load_explicit(const atomic<T>* obj, memory_order m) noexcept; | ||
| 319 | 311 | ||
| 320 | template <class T> | 312 | template <class T> |
| 321 | T | 313 | bool atomic_compare_exchange_weak_explicit(volatile atomic<T>* obj, T* expc, |
| 322 | atomic_exchange(volatile atomic<T>* obj, T desr) noexcept; | 314 | T desr, |
| 315 | memory_order s, memory_order f) noexcept; | ||
| 323 | 316 | ||
| 324 | template <class T> | 317 | template <class T> |
| 325 | T | 318 | bool atomic_compare_exchange_weak_explicit(atomic<T>* obj, T* expc, T desr, |
| 326 | atomic_exchange(atomic<T>* obj, T desr) noexcept; | 319 | memory_order s, memory_order f) noexcept; |
| 327 | 320 | ||
| 328 | template <class T> | 321 | template <class T> |
| 329 | T | 322 | bool atomic_compare_exchange_strong_explicit(volatile atomic<T>* obj, |
| 330 | atomic_exchange_explicit(volatile atomic<T>* obj, T desr, memory_order m) noexcept; | 323 | T* expc, T desr, |
| 324 | memory_order s, memory_order f) noexcept; | ||
| 331 | 325 | ||
| 332 | template <class T> | 326 | template <class T> |
| 333 | T | 327 | bool atomic_compare_exchange_strong_explicit(atomic<T>* obj, T* expc, |
| 334 | atomic_exchange_explicit(atomic<T>* obj, T desr, memory_order m) noexcept; | 328 | T desr, |
| 329 | memory_order s, memory_order f) noexcept; | ||
| 335 | 330 | ||
| 336 | template <class T> | 331 | template <class T> |
| 337 | bool | 332 | void atomic_wait(const volatile atomic<T>* obj, T old) noexcept; |
| 338 | atomic_compare_exchange_weak(volatile atomic<T>* obj, T* expc, T desr) noexcept; | ||
| 339 | 333 | ||
| 340 | template <class T> | 334 | template <class T> |
| 341 | bool | 335 | void atomic_wait(const atomic<T>* obj, T old) noexcept; |
| 342 | atomic_compare_exchange_weak(atomic<T>* obj, T* expc, T desr) noexcept; | ||
| 343 | 336 | ||
| 344 | template <class T> | 337 | template <class T> |
| 345 | bool | 338 | void atomic_wait_explicit(const volatile atomic<T>* obj, T old, memory_order m) noexcept; |
| 346 | atomic_compare_exchange_strong(volatile atomic<T>* obj, T* expc, T desr) noexcept; | ||
| 347 | 339 | ||
| 348 | template <class T> | 340 | template <class T> |
| 349 | bool | 341 | void atomic_wait_explicit(const atomic<T>* obj, T old, memory_order m) noexcept; |
| 350 | atomic_compare_exchange_strong(atomic<T>* obj, T* expc, T desr) noexcept; | ||
| 351 | 342 | ||
| 352 | template <class T> | 343 | template <class T> |
| 353 | bool | 344 | void atomic_one(volatile atomic<T>* obj) noexcept; |
| 354 | atomic_compare_exchange_weak_explicit(volatile atomic<T>* obj, T* expc, | ||
| 355 | T desr, | ||
| 356 | memory_order s, memory_order f) noexcept; | ||
| 357 | 345 | ||
| 358 | template <class T> | 346 | template <class T> |
| 359 | bool | 347 | void atomic_one(atomic<T>* obj) noexcept; |
| 360 | atomic_compare_exchange_weak_explicit(atomic<T>* obj, T* expc, T desr, | ||
| 361 | memory_order s, memory_order f) noexcept; | ||
| 362 | 348 | ||
| 363 | template <class T> | 349 | template <class T> |
| 364 | bool | 350 | void atomic_all(volatile atomic<T>* obj) noexcept; |
| 365 | atomic_compare_exchange_strong_explicit(volatile atomic<T>* obj, | ||
| 366 | T* expc, T desr, | ||
| 367 | memory_order s, memory_order f) noexcept; | ||
| 368 | 351 | ||
| 369 | template <class T> | 352 | template <class T> |
| 370 | bool | 353 | void atomic_all(atomic<T>* obj) noexcept; |
| 371 | atomic_compare_exchange_strong_explicit(atomic<T>* obj, T* expc, | ||
| 372 | T desr, | ||
| 373 | memory_order s, memory_order f) noexcept; | ||
| 374 | 354 | ||
| 375 | template <class Integral> | 355 | template <class Integral> |
| 376 | Integral | 356 | Integral atomic_fetch_add(volatile atomic<Integral>* obj, Integral op) noexcept; |
| 377 | atomic_fetch_add(volatile atomic<Integral>* obj, Integral op) noexcept; | ||
| 378 | 357 | ||
| 379 | template <class Integral> | 358 | template <class Integral> |
| 380 | Integral | 359 | Integral atomic_fetch_add(atomic<Integral>* obj, Integral op) noexcept; |
| 381 | atomic_fetch_add(atomic<Integral>* obj, Integral op) noexcept; | ||
| 382 | 360 | ||
| 383 | template <class Integral> | 361 | template <class Integral> |
| 384 | Integral | 362 | Integral atomic_fetch_add_explicit(volatile atomic<Integral>* obj, Integral op, |
| 385 | atomic_fetch_add_explicit(volatile atomic<Integral>* obj, Integral op, | ||
| 386 | memory_order m) noexcept; | 363 | memory_order m) noexcept; |
| 387 | template <class Integral> | 364 | template <class Integral> |
| 388 | Integral | 365 | Integral atomic_fetch_add_explicit(atomic<Integral>* obj, Integral op, |
| 389 | atomic_fetch_add_explicit(atomic<Integral>* obj, Integral op, | ||
| 390 | memory_order m) noexcept; | 366 | memory_order m) noexcept; |
| 391 | template <class Integral> | 367 | template <class Integral> |
| 392 | Integral | 368 | Integral atomic_fetch_sub(volatile atomic<Integral>* obj, Integral op) noexcept; |
| 393 | atomic_fetch_sub(volatile atomic<Integral>* obj, Integral op) noexcept; | ||
| 394 | 369 | ||
| 395 | template <class Integral> | 370 | template <class Integral> |
| 396 | Integral | 371 | Integral atomic_fetch_sub(atomic<Integral>* obj, Integral op) noexcept; |
| 397 | atomic_fetch_sub(atomic<Integral>* obj, Integral op) noexcept; | ||
| 398 | 372 | ||
| 399 | template <class Integral> | 373 | template <class Integral> |
| 400 | Integral | 374 | Integral atomic_fetch_sub_explicit(volatile atomic<Integral>* obj, Integral op, |
| 401 | atomic_fetch_sub_explicit(volatile atomic<Integral>* obj, Integral op, | 375 | memory_order m) noexcept; |
| 402 | memory_order m) noexcept; | 376 | |
| 403 | template <class Integral> | 377 | template <class Integral> |
| 404 | Integral | 378 | Integral atomic_fetch_sub_explicit(atomic<Integral>* obj, Integral op, |
| 405 | atomic_fetch_sub_explicit(atomic<Integral>* obj, Integral op, | 379 | memory_order m) noexcept; |
| 406 | memory_order m) noexcept; | 380 | |
| 407 | template <class Integral> | 381 | template <class Integral> |
| 408 | Integral | 382 | Integral atomic_fetch_and(volatile atomic<Integral>* obj, Integral op) noexcept; |
| 409 | atomic_fetch_and(volatile atomic<Integral>* obj, Integral op) noexcept; | ||
| 410 | 383 | ||
| 411 | template <class Integral> | 384 | template <class Integral> |
| 412 | Integral | 385 | Integral atomic_fetch_and(atomic<Integral>* obj, Integral op) noexcept; |
| 413 | atomic_fetch_and(atomic<Integral>* obj, Integral op) noexcept; | ||
| 414 | 386 | ||
| 415 | template <class Integral> | 387 | template <class Integral> |
| 416 | Integral | 388 | Integral atomic_fetch_and_explicit(volatile atomic<Integral>* obj, Integral op, |
| 417 | atomic_fetch_and_explicit(volatile atomic<Integral>* obj, Integral op, | 389 | memory_order m) noexcept; |
| 418 | memory_order m) noexcept; | 390 | |
| 419 | template <class Integral> | 391 | template <class Integral> |
| 420 | Integral | 392 | Integral atomic_fetch_and_explicit(atomic<Integral>* obj, Integral op, |
| 421 | atomic_fetch_and_explicit(atomic<Integral>* obj, Integral op, | 393 | memory_order m) noexcept; |
| 422 | memory_order m) noexcept; | 394 | |
| 423 | template <class Integral> | 395 | template <class Integral> |
| 424 | Integral | 396 | Integral atomic_fetch_or(volatile atomic<Integral>* obj, Integral op) noexcept; |
| 425 | atomic_fetch_or(volatile atomic<Integral>* obj, Integral op) noexcept; | ||
| 426 | 397 | ||
| 427 | template <class Integral> | 398 | template <class Integral> |
| 428 | Integral | 399 | Integral atomic_fetch_or(atomic<Integral>* obj, Integral op) noexcept; |
| 429 | atomic_fetch_or(atomic<Integral>* obj, Integral op) noexcept; | ||
| 430 | 400 | ||
| 431 | template <class Integral> | 401 | template <class Integral> |
| 432 | Integral | 402 | Integral atomic_fetch_or_explicit(volatile atomic<Integral>* obj, Integral op, |
| 433 | atomic_fetch_or_explicit(volatile atomic<Integral>* obj, Integral op, | ||
| 434 | memory_order m) noexcept; | 403 | memory_order m) noexcept; |
| 404 | |||
| 435 | template <class Integral> | 405 | template <class Integral> |
| 436 | Integral | 406 | Integral atomic_fetch_or_explicit(atomic<Integral>* obj, Integral op, |
| 437 | atomic_fetch_or_explicit(atomic<Integral>* obj, Integral op, | ||
| 438 | memory_order m) noexcept; | 407 | memory_order m) noexcept; |
| 408 | |||
| 439 | template <class Integral> | 409 | template <class Integral> |
| 440 | Integral | 410 | Integral atomic_fetch_xor(volatile atomic<Integral>* obj, Integral op) noexcept; |
| 441 | atomic_fetch_xor(volatile atomic<Integral>* obj, Integral op) noexcept; | ||
| 442 | 411 | ||
| 443 | template <class Integral> | 412 | template <class Integral> |
| 444 | Integral | 413 | Integral atomic_fetch_xor(atomic<Integral>* obj, Integral op) noexcept; |
| 445 | atomic_fetch_xor(atomic<Integral>* obj, Integral op) noexcept; | ||
| 446 | 414 | ||
| 447 | template <class Integral> | 415 | template <class Integral> |
| 448 | Integral | 416 | Integral atomic_fetch_xor_explicit(volatile atomic<Integral>* obj, Integral op, |
| 449 | atomic_fetch_xor_explicit(volatile atomic<Integral>* obj, Integral op, | 417 | memory_order m) noexcept; |
| 450 | memory_order m) noexcept; | 418 | |
| 451 | template <class Integral> | 419 | template <class Integral> |
| 452 | Integral | 420 | Integral atomic_fetch_xor_explicit(atomic<Integral>* obj, Integral op, |
| 453 | atomic_fetch_xor_explicit(atomic<Integral>* obj, Integral op, | 421 | memory_order m) noexcept; |
| 454 | memory_order m) noexcept; | ||
| 455 | 422 | ||
| 456 | template <class T> | 423 | template <class T> |
| 457 | T* | 424 | T* atomic_fetch_add(volatile atomic<T*>* obj, ptrdiff_t op) noexcept; |
| 458 | atomic_fetch_add(volatile atomic<T*>* obj, ptrdiff_t op) noexcept; | ||
| 459 | 425 | ||
| 460 | template <class T> | 426 | template <class T> |
| 461 | T* | 427 | T* atomic_fetch_add(atomic<T*>* obj, ptrdiff_t op) noexcept; |
| 462 | atomic_fetch_add(atomic<T*>* obj, ptrdiff_t op) noexcept; | ||
| 463 | 428 | ||
| 464 | template <class T> | 429 | template <class T> |
| 465 | T* | 430 | T* atomic_fetch_add_explicit(volatile atomic<T*>* obj, ptrdiff_t op, |
| 466 | atomic_fetch_add_explicit(volatile atomic<T*>* obj, ptrdiff_t op, | 431 | memory_order m) noexcept; |
| 467 | memory_order m) noexcept; | 432 | |
| 468 | template <class T> | 433 | template <class T> |
| 469 | T* | 434 | T* atomic_fetch_add_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m) noexcept; |
| 470 | atomic_fetch_add_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m) noexcept; | ||
| 471 | 435 | ||
| 472 | template <class T> | 436 | template <class T> |
| 473 | T* | 437 | T* atomic_fetch_sub(volatile atomic<T*>* obj, ptrdiff_t op) noexcept; |
| 474 | atomic_fetch_sub(volatile atomic<T*>* obj, ptrdiff_t op) noexcept; | ||
| 475 | 438 | ||
| 476 | template <class T> | 439 | template <class T> |
| 477 | T* | 440 | T* atomic_fetch_sub(atomic<T*>* obj, ptrdiff_t op) noexcept; |
| 478 | atomic_fetch_sub(atomic<T*>* obj, ptrdiff_t op) noexcept; | ||
| 479 | 441 | ||
| 480 | template <class T> | 442 | template <class T> |
| 481 | T* | 443 | T* atomic_fetch_sub_explicit(volatile atomic<T*>* obj, ptrdiff_t op, |
| 482 | atomic_fetch_sub_explicit(volatile atomic<T*>* obj, ptrdiff_t op, | 444 | memory_order m) noexcept; |
| 483 | memory_order m) noexcept; | 445 | |
| 484 | template <class T> | 446 | template <class T> |
| 485 | T* | 447 | T* atomic_fetch_sub_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m) noexcept; |
| 486 | atomic_fetch_sub_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m) noexcept; | ||
| 487 | 448 | ||
| 488 | // Atomics for standard typedef types | 449 | // Atomics for standard typedef types |
| 489 | 450 | ||
| ... | @@ -516,7 +477,7 @@ typedef atomic<int_fast8_t> atomic_int_fast8_t; | ... | @@ -516,7 +477,7 @@ typedef atomic<int_fast8_t> atomic_int_fast8_t; |
| 516 | typedef atomic<uint_fast8_t> atomic_uint_fast8_t; | 477 | typedef atomic<uint_fast8_t> atomic_uint_fast8_t; |
| 517 | typedef atomic<int_fast16_t> atomic_int_fast16_t; | 478 | typedef atomic<int_fast16_t> atomic_int_fast16_t; |
| 518 | typedef atomic<uint_fast16_t> atomic_uint_fast16_t; | 479 | typedef atomic<uint_fast16_t> atomic_uint_fast16_t; |
| 519 | typedef atomic<int_fast32_t> atomic_int_fast32_t; | 480 | typedef atomic<int_fast32_t> atomic_int_fast32_t; |
| 520 | typedef atomic<uint_fast32_t> atomic_uint_fast32_t; | 481 | typedef atomic<uint_fast32_t> atomic_uint_fast32_t; |
| 521 | typedef atomic<int_fast64_t> atomic_int_fast64_t; | 482 | typedef atomic<int_fast64_t> atomic_int_fast64_t; |
| 522 | typedef atomic<uint_fast64_t> atomic_uint_fast64_t; | 483 | typedef atomic<uint_fast64_t> atomic_uint_fast64_t; |
| ... | @@ -537,18 +498,80 @@ typedef atomic<ptrdiff_t> atomic_ptrdiff_t; | ... | @@ -537,18 +498,80 @@ typedef atomic<ptrdiff_t> atomic_ptrdiff_t; |
| 537 | typedef atomic<intmax_t> atomic_intmax_t; | 498 | typedef atomic<intmax_t> atomic_intmax_t; |
| 538 | typedef atomic<uintmax_t> atomic_uintmax_t; | 499 | typedef atomic<uintmax_t> atomic_uintmax_t; |
| 539 | 500 | ||
| 501 | // flag type and operations | ||
| 502 | |||
| 503 | typedef struct atomic_flag | ||
| 504 | { | ||
| 505 | atomic_flag() noexcept = default; | ||
| 506 | atomic_flag(const atomic_flag&) = delete; | ||
| 507 | atomic_flag& operator=(const atomic_flag&) = delete; | ||
| 508 | atomic_flag& operator=(const atomic_flag&) volatile = delete; | ||
| 509 | |||
| 510 | bool test(memory_order m = memory_order_seq_cst) volatile noexcept; | ||
| 511 | bool test(memory_order m = memory_order_seq_cst) noexcept; | ||
| 512 | bool test_and_set(memory_order m = memory_order_seq_cst) volatile noexcept; | ||
| 513 | bool test_and_set(memory_order m = memory_order_seq_cst) noexcept; | ||
| 514 | void clear(memory_order m = memory_order_seq_cst) volatile noexcept; | ||
| 515 | void clear(memory_order m = memory_order_seq_cst) noexcept; | ||
| 516 | |||
| 517 | void wait(bool, memory_order = memory_order::seq_cst) const volatile noexcept; | ||
| 518 | void wait(bool, memory_order = memory_order::seq_cst) const noexcept; | ||
| 519 | void notify_one() volatile noexcept; | ||
| 520 | void notify_one() noexcept; | ||
| 521 | void notify_all() volatile noexcept; | ||
| 522 | void notify_all() noexcept; | ||
| 523 | } atomic_flag; | ||
| 524 | |||
| 525 | bool atomic_flag_test(volatile atomic_flag* obj) noexcept; | ||
| 526 | bool atomic_flag_test(atomic_flag* obj) noexcept; | ||
| 527 | bool atomic_flag_test_explicit(volatile atomic_flag* obj, | ||
| 528 | memory_order m) noexcept; | ||
| 529 | bool atomic_flag_test_explicit(atomic_flag* obj, memory_order m) noexcept; | ||
| 530 | bool atomic_flag_test_and_set(volatile atomic_flag* obj) noexcept; | ||
| 531 | bool atomic_flag_test_and_set(atomic_flag* obj) noexcept; | ||
| 532 | bool atomic_flag_test_and_set_explicit(volatile atomic_flag* obj, | ||
| 533 | memory_order m) noexcept; | ||
| 534 | bool atomic_flag_test_and_set_explicit(atomic_flag* obj, memory_order m) noexcept; | ||
| 535 | void atomic_flag_clear(volatile atomic_flag* obj) noexcept; | ||
| 536 | void atomic_flag_clear(atomic_flag* obj) noexcept; | ||
| 537 | void atomic_flag_clear_explicit(volatile atomic_flag* obj, memory_order m) noexcept; | ||
| 538 | void atomic_flag_clear_explicit(atomic_flag* obj, memory_order m) noexcept; | ||
| 539 | |||
| 540 | void atomic_wait(const volatile atomic_flag* obj, T old) noexcept; | ||
| 541 | void atomic_wait(const atomic_flag* obj, T old) noexcept; | ||
| 542 | void atomic_wait_explicit(const volatile atomic_flag* obj, T old, memory_order m) noexcept; | ||
| 543 | void atomic_wait_explicit(const atomic_flag* obj, T old, memory_order m) noexcept; | ||
| 544 | void atomic_one(volatile atomic_flag* obj) noexcept; | ||
| 545 | void atomic_one(atomic_flag* obj) noexcept; | ||
| 546 | void atomic_all(volatile atomic_flag* obj) noexcept; | ||
| 547 | void atomic_all(atomic_flag* obj) noexcept; | ||
| 548 | |||
| 540 | // fences | 549 | // fences |
| 541 | 550 | ||
| 542 | void atomic_thread_fence(memory_order m) noexcept; | 551 | void atomic_thread_fence(memory_order m) noexcept; |
| 543 | void atomic_signal_fence(memory_order m) noexcept; | 552 | void atomic_signal_fence(memory_order m) noexcept; |
| 544 | 553 | ||
| 554 | // deprecated | ||
| 555 | |||
| 556 | template <class T> | ||
| 557 | void atomic_init(volatile atomic<T>* obj, typename atomic<T>::value_type desr) noexcept; | ||
| 558 | |||
| 559 | template <class T> | ||
| 560 | void atomic_init(atomic<T>* obj, typename atomic<T>::value_type desr) noexcept; | ||
| 561 | |||
| 562 | #define ATOMIC_VAR_INIT(value) see below | ||
| 563 | |||
| 564 | #define ATOMIC_FLAG_INIT see below | ||
| 565 | |||
| 545 | } // std | 566 | } // std |
| 546 | 567 | ||
| 547 | */ | 568 | */ |
| 548 | 569 | ||
| 549 | #include <__config> | 570 | #include <__config> |
| 571 | #include <__threading_support> | ||
| 550 | #include <cstddef> | 572 | #include <cstddef> |
| 551 | #include <cstdint> | 573 | #include <cstdint> |
| 574 | #include <cstring> | ||
| 552 | #include <type_traits> | 575 | #include <type_traits> |
| 553 | #include <version> | 576 | #include <version> |
| 554 | 577 | ||
| ... | @@ -629,6 +652,11 @@ typedef enum memory_order { | ... | @@ -629,6 +652,11 @@ typedef enum memory_order { |
| 629 | 652 | ||
| 630 | #endif // _LIBCPP_STD_VER > 17 | 653 | #endif // _LIBCPP_STD_VER > 17 |
| 631 | 654 | ||
| 655 | template <typename _Tp> _LIBCPP_INLINE_VISIBILITY | ||
| 656 | bool __cxx_nonatomic_compare_equal(_Tp const& __lhs, _Tp const& __rhs) { | ||
| 657 | return memcmp(&__lhs, &__rhs, sizeof(_Tp)) == 0; | ||
| 658 | } | ||
| 659 | |||
| 632 | static_assert((is_same<underlying_type<memory_order>::type, __memory_order_underlying_t>::value), | 660 | static_assert((is_same<underlying_type<memory_order>::type, __memory_order_underlying_t>::value), |
| 633 | "unexpected underlying type for std::memory_order"); | 661 | "unexpected underlying type for std::memory_order"); |
| 634 | 662 | ||
| ... | @@ -1218,9 +1246,9 @@ _LIBCPP_INLINE_VISIBILITY | ... | @@ -1218,9 +1246,9 @@ _LIBCPP_INLINE_VISIBILITY |
| 1218 | bool __cxx_atomic_compare_exchange_strong(volatile __cxx_atomic_lock_impl<_Tp>* __a, | 1246 | bool __cxx_atomic_compare_exchange_strong(volatile __cxx_atomic_lock_impl<_Tp>* __a, |
| 1219 | _Tp* __expected, _Tp __value, memory_order, memory_order) { | 1247 | _Tp* __expected, _Tp __value, memory_order, memory_order) { |
| 1220 | __a->__lock(); | 1248 | __a->__lock(); |
| 1221 | _Tp temp; | 1249 | _Tp __temp; |
| 1222 | __cxx_atomic_assign_volatile(temp, __a->__a_value); | 1250 | __cxx_atomic_assign_volatile(__temp, __a->__a_value); |
| 1223 | bool __ret = temp == *__expected; | 1251 | bool __ret = __temp == *__expected; |
| 1224 | if(__ret) | 1252 | if(__ret) |
| 1225 | __cxx_atomic_assign_volatile(__a->__a_value, __value); | 1253 | __cxx_atomic_assign_volatile(__a->__a_value, __value); |
| 1226 | else | 1254 | else |
| ... | @@ -1247,9 +1275,9 @@ _LIBCPP_INLINE_VISIBILITY | ... | @@ -1247,9 +1275,9 @@ _LIBCPP_INLINE_VISIBILITY |
| 1247 | bool __cxx_atomic_compare_exchange_weak(volatile __cxx_atomic_lock_impl<_Tp>* __a, | 1275 | bool __cxx_atomic_compare_exchange_weak(volatile __cxx_atomic_lock_impl<_Tp>* __a, |
| 1248 | _Tp* __expected, _Tp __value, memory_order, memory_order) { | 1276 | _Tp* __expected, _Tp __value, memory_order, memory_order) { |
| 1249 | __a->__lock(); | 1277 | __a->__lock(); |
| 1250 | _Tp temp; | 1278 | _Tp __temp; |
| 1251 | __cxx_atomic_assign_volatile(temp, __a->__a_value); | 1279 | __cxx_atomic_assign_volatile(__temp, __a->__a_value); |
| 1252 | bool __ret = temp == *__expected; | 1280 | bool __ret = __temp == *__expected; |
| 1253 | if(__ret) | 1281 | if(__ret) |
| 1254 | __cxx_atomic_assign_volatile(__a->__a_value, __value); | 1282 | __cxx_atomic_assign_volatile(__a->__a_value, __value); |
| 1255 | else | 1283 | else |
| ... | @@ -1452,6 +1480,93 @@ struct __cxx_atomic_impl : public _Base { | ... | @@ -1452,6 +1480,93 @@ struct __cxx_atomic_impl : public _Base { |
| 1452 | : _Base(value) {} | 1480 | : _Base(value) {} |
| 1453 | }; | 1481 | }; |
| 1454 | 1482 | ||
| 1483 | #ifdef __linux__ | ||
| 1484 | using __cxx_contention_t = int32_t; | ||
| 1485 | #else | ||
| 1486 | using __cxx_contention_t = int64_t; | ||
| 1487 | #endif //__linux__ | ||
| 1488 | |||
| 1489 | #if _LIBCPP_STD_VER >= 11 | ||
| 1490 | |||
| 1491 | using __cxx_atomic_contention_t = __cxx_atomic_impl<__cxx_contention_t>; | ||
| 1492 | |||
| 1493 | #ifndef _LIBCPP_HAS_NO_PLATFORM_WAIT | ||
| 1494 | |||
| 1495 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(void const volatile*); | ||
| 1496 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(void const volatile*); | ||
| 1497 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t __libcpp_atomic_monitor(void const volatile*); | ||
| 1498 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __libcpp_atomic_wait(void const volatile*, __cxx_contention_t); | ||
| 1499 | |||
| 1500 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(__cxx_atomic_contention_t const volatile*); | ||
| 1501 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(__cxx_atomic_contention_t const volatile*); | ||
| 1502 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t __libcpp_atomic_monitor(__cxx_atomic_contention_t const volatile*); | ||
| 1503 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __libcpp_atomic_wait(__cxx_atomic_contention_t const volatile*, __cxx_contention_t); | ||
| 1504 | |||
| 1505 | template <class _Atp, class _Fn> | ||
| 1506 | struct __libcpp_atomic_wait_backoff_impl { | ||
| 1507 | _Atp* __a; | ||
| 1508 | _Fn __test_fn; | ||
| 1509 | _LIBCPP_AVAILABILITY_SYNC | ||
| 1510 | _LIBCPP_INLINE_VISIBILITY bool operator()(chrono::nanoseconds __elapsed) const | ||
| 1511 | { | ||
| 1512 | if(__elapsed > chrono::microseconds(64)) | ||
| 1513 | { | ||
| 1514 | auto const __monitor = __libcpp_atomic_monitor(__a); | ||
| 1515 | if(__test_fn()) | ||
| 1516 | return true; | ||
| 1517 | __libcpp_atomic_wait(__a, __monitor); | ||
| 1518 | } | ||
| 1519 | else if(__elapsed > chrono::microseconds(4)) | ||
| 1520 | __libcpp_thread_yield(); | ||
| 1521 | else | ||
| 1522 | ; // poll | ||
| 1523 | return false; | ||
| 1524 | } | ||
| 1525 | }; | ||
| 1526 | |||
| 1527 | template <class _Atp, class _Fn> | ||
| 1528 | _LIBCPP_AVAILABILITY_SYNC | ||
| 1529 | _LIBCPP_INLINE_VISIBILITY bool __cxx_atomic_wait(_Atp* __a, _Fn && __test_fn) | ||
| 1530 | { | ||
| 1531 | __libcpp_atomic_wait_backoff_impl<_Atp, typename decay<_Fn>::type> __backoff_fn = {__a, __test_fn}; | ||
| 1532 | return __libcpp_thread_poll_with_backoff(__test_fn, __backoff_fn); | ||
| 1533 | } | ||
| 1534 | |||
| 1535 | #else // _LIBCPP_HAS_NO_PLATFORM_WAIT | ||
| 1536 | |||
| 1537 | template <class _Tp> | ||
| 1538 | _LIBCPP_INLINE_VISIBILITY void __cxx_atomic_notify_all(__cxx_atomic_impl<_Tp> const volatile*) { } | ||
| 1539 | template <class _Tp> | ||
| 1540 | _LIBCPP_INLINE_VISIBILITY void __cxx_atomic_notify_one(__cxx_atomic_impl<_Tp> const volatile*) { } | ||
| 1541 | template <class _Atp, class _Fn> | ||
| 1542 | _LIBCPP_INLINE_VISIBILITY bool __cxx_atomic_wait(_Atp*, _Fn && __test_fn) | ||
| 1543 | { | ||
| 1544 | return __libcpp_thread_poll_with_backoff(__test_fn, __libcpp_timed_backoff_policy()); | ||
| 1545 | } | ||
| 1546 | |||
| 1547 | #endif // _LIBCPP_HAS_NO_PLATFORM_WAIT | ||
| 1548 | |||
| 1549 | template <class _Atp, class _Tp> | ||
| 1550 | struct __cxx_atomic_wait_test_fn_impl { | ||
| 1551 | _Atp* __a; | ||
| 1552 | _Tp __val; | ||
| 1553 | memory_order __order; | ||
| 1554 | _LIBCPP_INLINE_VISIBILITY bool operator()() const | ||
| 1555 | { | ||
| 1556 | return !__cxx_nonatomic_compare_equal(__cxx_atomic_load(__a, __order), __val); | ||
| 1557 | } | ||
| 1558 | }; | ||
| 1559 | |||
| 1560 | template <class _Atp, class _Tp> | ||
| 1561 | _LIBCPP_AVAILABILITY_SYNC | ||
| 1562 | _LIBCPP_INLINE_VISIBILITY bool __cxx_atomic_wait(_Atp* __a, _Tp const __val, memory_order __order) | ||
| 1563 | { | ||
| 1564 | __cxx_atomic_wait_test_fn_impl<_Atp, _Tp> __test_fn = {__a, __val, __order}; | ||
| 1565 | return __cxx_atomic_wait(__a, __test_fn); | ||
| 1566 | } | ||
| 1567 | |||
| 1568 | #endif //_LIBCPP_STD_VER >= 11 | ||
| 1569 | |||
| 1455 | // general atomic<T> | 1570 | // general atomic<T> |
| 1456 | 1571 | ||
| 1457 | template <class _Tp, bool = is_integral<_Tp>::value && !is_same<_Tp, bool>::value> | 1572 | template <class _Tp, bool = is_integral<_Tp>::value && !is_same<_Tp, bool>::value> |
| ... | @@ -1532,6 +1647,19 @@ struct __atomic_base // false | ... | @@ -1532,6 +1647,19 @@ struct __atomic_base // false |
| 1532 | memory_order __m = memory_order_seq_cst) _NOEXCEPT | 1647 | memory_order __m = memory_order_seq_cst) _NOEXCEPT |
| 1533 | {return __cxx_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);} | 1648 | {return __cxx_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);} |
| 1534 | 1649 | ||
| 1650 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void wait(_Tp __v, memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT | ||
| 1651 | {__cxx_atomic_wait(&__a_, __v, __m);} | ||
| 1652 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void wait(_Tp __v, memory_order __m = memory_order_seq_cst) const _NOEXCEPT | ||
| 1653 | {__cxx_atomic_wait(&__a_, __v, __m);} | ||
| 1654 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void notify_one() volatile _NOEXCEPT | ||
| 1655 | {__cxx_atomic_notify_one(&__a_);} | ||
| 1656 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void notify_one() _NOEXCEPT | ||
| 1657 | {__cxx_atomic_notify_one(&__a_);} | ||
| 1658 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void notify_all() volatile _NOEXCEPT | ||
| 1659 | {__cxx_atomic_notify_all(&__a_);} | ||
| 1660 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void notify_all() _NOEXCEPT | ||
| 1661 | {__cxx_atomic_notify_all(&__a_);} | ||
| 1662 | |||
| 1535 | _LIBCPP_INLINE_VISIBILITY | 1663 | _LIBCPP_INLINE_VISIBILITY |
| 1536 | __atomic_base() _NOEXCEPT _LIBCPP_DEFAULT | 1664 | __atomic_base() _NOEXCEPT _LIBCPP_DEFAULT |
| 1537 | 1665 | ||
| ... | @@ -1544,8 +1672,11 @@ struct __atomic_base // false | ... | @@ -1544,8 +1672,11 @@ struct __atomic_base // false |
| 1544 | __atomic_base& operator=(const __atomic_base&) volatile = delete; | 1672 | __atomic_base& operator=(const __atomic_base&) volatile = delete; |
| 1545 | #else | 1673 | #else |
| 1546 | private: | 1674 | private: |
| 1675 | _LIBCPP_INLINE_VISIBILITY | ||
| 1547 | __atomic_base(const __atomic_base&); | 1676 | __atomic_base(const __atomic_base&); |
| 1677 | _LIBCPP_INLINE_VISIBILITY | ||
| 1548 | __atomic_base& operator=(const __atomic_base&); | 1678 | __atomic_base& operator=(const __atomic_base&); |
| 1679 | _LIBCPP_INLINE_VISIBILITY | ||
| 1549 | __atomic_base& operator=(const __atomic_base&) volatile; | 1680 | __atomic_base& operator=(const __atomic_base&) volatile; |
| 1550 | #endif | 1681 | #endif |
| 1551 | }; | 1682 | }; |
| ... | @@ -1643,6 +1774,7 @@ struct atomic | ... | @@ -1643,6 +1774,7 @@ struct atomic |
| 1643 | : public __atomic_base<_Tp> | 1774 | : public __atomic_base<_Tp> |
| 1644 | { | 1775 | { |
| 1645 | typedef __atomic_base<_Tp> __base; | 1776 | typedef __atomic_base<_Tp> __base; |
| 1777 | typedef _Tp value_type; | ||
| 1646 | _LIBCPP_INLINE_VISIBILITY | 1778 | _LIBCPP_INLINE_VISIBILITY |
| 1647 | atomic() _NOEXCEPT _LIBCPP_DEFAULT | 1779 | atomic() _NOEXCEPT _LIBCPP_DEFAULT |
| 1648 | _LIBCPP_INLINE_VISIBILITY | 1780 | _LIBCPP_INLINE_VISIBILITY |
| ... | @@ -1663,6 +1795,7 @@ struct atomic<_Tp*> | ... | @@ -1663,6 +1795,7 @@ struct atomic<_Tp*> |
| 1663 | : public __atomic_base<_Tp*> | 1795 | : public __atomic_base<_Tp*> |
| 1664 | { | 1796 | { |
| 1665 | typedef __atomic_base<_Tp*> __base; | 1797 | typedef __atomic_base<_Tp*> __base; |
| 1798 | typedef _Tp* value_type; | ||
| 1666 | _LIBCPP_INLINE_VISIBILITY | 1799 | _LIBCPP_INLINE_VISIBILITY |
| 1667 | atomic() _NOEXCEPT _LIBCPP_DEFAULT | 1800 | atomic() _NOEXCEPT _LIBCPP_DEFAULT |
| 1668 | _LIBCPP_INLINE_VISIBILITY | 1801 | _LIBCPP_INLINE_VISIBILITY |
| ... | @@ -1947,6 +2080,76 @@ atomic_compare_exchange_strong_explicit(atomic<_Tp>* __o, _Tp* __e, | ... | @@ -1947,6 +2080,76 @@ atomic_compare_exchange_strong_explicit(atomic<_Tp>* __o, _Tp* __e, |
| 1947 | return __o->compare_exchange_strong(*__e, __d, __s, __f); | 2080 | return __o->compare_exchange_strong(*__e, __d, __s, __f); |
| 1948 | } | 2081 | } |
| 1949 | 2082 | ||
| 2083 | // atomic_wait | ||
| 2084 | |||
| 2085 | template <class _Tp> | ||
| 2086 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 2087 | void atomic_wait(const volatile atomic<_Tp>* __o, | ||
| 2088 | typename atomic<_Tp>::value_type __v) _NOEXCEPT | ||
| 2089 | { | ||
| 2090 | return __o->wait(__v); | ||
| 2091 | } | ||
| 2092 | |||
| 2093 | template <class _Tp> | ||
| 2094 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 2095 | void atomic_wait(const atomic<_Tp>* __o, | ||
| 2096 | typename atomic<_Tp>::value_type __v) _NOEXCEPT | ||
| 2097 | { | ||
| 2098 | return __o->wait(__v); | ||
| 2099 | } | ||
| 2100 | |||
| 2101 | // atomic_wait_explicit | ||
| 2102 | |||
| 2103 | template <class _Tp> | ||
| 2104 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 2105 | void atomic_wait_explicit(const volatile atomic<_Tp>* __o, | ||
| 2106 | typename atomic<_Tp>::value_type __v, | ||
| 2107 | memory_order __m) _NOEXCEPT | ||
| 2108 | _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m) | ||
| 2109 | { | ||
| 2110 | return __o->wait(__v, __m); | ||
| 2111 | } | ||
| 2112 | |||
| 2113 | template <class _Tp> | ||
| 2114 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 2115 | void atomic_wait_explicit(const atomic<_Tp>* __o, | ||
| 2116 | typename atomic<_Tp>::value_type __v, | ||
| 2117 | memory_order __m) _NOEXCEPT | ||
| 2118 | _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m) | ||
| 2119 | { | ||
| 2120 | return __o->wait(__v, __m); | ||
| 2121 | } | ||
| 2122 | |||
| 2123 | // atomic_notify_one | ||
| 2124 | |||
| 2125 | template <class _Tp> | ||
| 2126 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 2127 | void atomic_notify_one(volatile atomic<_Tp>* __o) _NOEXCEPT | ||
| 2128 | { | ||
| 2129 | __o->notify_one(); | ||
| 2130 | } | ||
| 2131 | template <class _Tp> | ||
| 2132 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 2133 | void atomic_notify_one(atomic<_Tp>* __o) _NOEXCEPT | ||
| 2134 | { | ||
| 2135 | __o->notify_one(); | ||
| 2136 | } | ||
| 2137 | |||
| 2138 | // atomic_notify_one | ||
| 2139 | |||
| 2140 | template <class _Tp> | ||
| 2141 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 2142 | void atomic_notify_all(volatile atomic<_Tp>* __o) _NOEXCEPT | ||
| 2143 | { | ||
| 2144 | __o->notify_all(); | ||
| 2145 | } | ||
| 2146 | template <class _Tp> | ||
| 2147 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 2148 | void atomic_notify_all(atomic<_Tp>* __o) _NOEXCEPT | ||
| 2149 | { | ||
| 2150 | __o->notify_all(); | ||
| 2151 | } | ||
| 2152 | |||
| 1950 | // atomic_fetch_add | 2153 | // atomic_fetch_add |
| 1951 | 2154 | ||
| 1952 | template <class _Tp> | 2155 | template <class _Tp> |
| ... | @@ -2279,6 +2482,13 @@ typedef struct atomic_flag | ... | @@ -2279,6 +2482,13 @@ typedef struct atomic_flag |
| 2279 | { | 2482 | { |
| 2280 | __cxx_atomic_impl<_LIBCPP_ATOMIC_FLAG_TYPE> __a_; | 2483 | __cxx_atomic_impl<_LIBCPP_ATOMIC_FLAG_TYPE> __a_; |
| 2281 | 2484 | ||
| 2485 | _LIBCPP_INLINE_VISIBILITY | ||
| 2486 | bool test(memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT | ||
| 2487 | {return _LIBCPP_ATOMIC_FLAG_TYPE(true) == __cxx_atomic_load(&__a_, __m);} | ||
| 2488 | _LIBCPP_INLINE_VISIBILITY | ||
| 2489 | bool test(memory_order __m = memory_order_seq_cst) const _NOEXCEPT | ||
| 2490 | {return _LIBCPP_ATOMIC_FLAG_TYPE(true) == __cxx_atomic_load(&__a_, __m);} | ||
| 2491 | |||
| 2282 | _LIBCPP_INLINE_VISIBILITY | 2492 | _LIBCPP_INLINE_VISIBILITY |
| 2283 | bool test_and_set(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT | 2493 | bool test_and_set(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT |
| 2284 | {return __cxx_atomic_exchange(&__a_, _LIBCPP_ATOMIC_FLAG_TYPE(true), __m);} | 2494 | {return __cxx_atomic_exchange(&__a_, _LIBCPP_ATOMIC_FLAG_TYPE(true), __m);} |
| ... | @@ -2292,6 +2502,25 @@ typedef struct atomic_flag | ... | @@ -2292,6 +2502,25 @@ typedef struct atomic_flag |
| 2292 | void clear(memory_order __m = memory_order_seq_cst) _NOEXCEPT | 2502 | void clear(memory_order __m = memory_order_seq_cst) _NOEXCEPT |
| 2293 | {__cxx_atomic_store(&__a_, _LIBCPP_ATOMIC_FLAG_TYPE(false), __m);} | 2503 | {__cxx_atomic_store(&__a_, _LIBCPP_ATOMIC_FLAG_TYPE(false), __m);} |
| 2294 | 2504 | ||
| 2505 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 2506 | void wait(bool __v, memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT | ||
| 2507 | {__cxx_atomic_wait(&__a_, _LIBCPP_ATOMIC_FLAG_TYPE(__v), __m);} | ||
| 2508 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 2509 | void wait(bool __v, memory_order __m = memory_order_seq_cst) const _NOEXCEPT | ||
| 2510 | {__cxx_atomic_wait(&__a_, _LIBCPP_ATOMIC_FLAG_TYPE(__v), __m);} | ||
| 2511 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 2512 | void notify_one() volatile _NOEXCEPT | ||
| 2513 | {__cxx_atomic_notify_one(&__a_);} | ||
| 2514 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 2515 | void notify_one() _NOEXCEPT | ||
| 2516 | {__cxx_atomic_notify_one(&__a_);} | ||
| 2517 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 2518 | void notify_all() volatile _NOEXCEPT | ||
| 2519 | {__cxx_atomic_notify_all(&__a_);} | ||
| 2520 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 2521 | void notify_all() _NOEXCEPT | ||
| 2522 | {__cxx_atomic_notify_all(&__a_);} | ||
| 2523 | |||
| 2295 | _LIBCPP_INLINE_VISIBILITY | 2524 | _LIBCPP_INLINE_VISIBILITY |
| 2296 | atomic_flag() _NOEXCEPT _LIBCPP_DEFAULT | 2525 | atomic_flag() _NOEXCEPT _LIBCPP_DEFAULT |
| 2297 | 2526 | ||
| ... | @@ -2304,12 +2533,44 @@ typedef struct atomic_flag | ... | @@ -2304,12 +2533,44 @@ typedef struct atomic_flag |
| 2304 | atomic_flag& operator=(const atomic_flag&) volatile = delete; | 2533 | atomic_flag& operator=(const atomic_flag&) volatile = delete; |
| 2305 | #else | 2534 | #else |
| 2306 | private: | 2535 | private: |
| 2536 | _LIBCPP_INLINE_VISIBILITY | ||
| 2307 | atomic_flag(const atomic_flag&); | 2537 | atomic_flag(const atomic_flag&); |
| 2538 | _LIBCPP_INLINE_VISIBILITY | ||
| 2308 | atomic_flag& operator=(const atomic_flag&); | 2539 | atomic_flag& operator=(const atomic_flag&); |
| 2540 | _LIBCPP_INLINE_VISIBILITY | ||
| 2309 | atomic_flag& operator=(const atomic_flag&) volatile; | 2541 | atomic_flag& operator=(const atomic_flag&) volatile; |
| 2310 | #endif | 2542 | #endif |
| 2311 | } atomic_flag; | 2543 | } atomic_flag; |
| 2312 | 2544 | ||
| 2545 | |||
| 2546 | inline _LIBCPP_INLINE_VISIBILITY | ||
| 2547 | bool | ||
| 2548 | atomic_flag_test(const volatile atomic_flag* __o) _NOEXCEPT | ||
| 2549 | { | ||
| 2550 | return __o->test(); | ||
| 2551 | } | ||
| 2552 | |||
| 2553 | inline _LIBCPP_INLINE_VISIBILITY | ||
| 2554 | bool | ||
| 2555 | atomic_flag_test(const atomic_flag* __o) _NOEXCEPT | ||
| 2556 | { | ||
| 2557 | return __o->test(); | ||
| 2558 | } | ||
| 2559 | |||
| 2560 | inline _LIBCPP_INLINE_VISIBILITY | ||
| 2561 | bool | ||
| 2562 | atomic_flag_test_explicit(const volatile atomic_flag* __o, memory_order __m) _NOEXCEPT | ||
| 2563 | { | ||
| 2564 | return __o->test(__m); | ||
| 2565 | } | ||
| 2566 | |||
| 2567 | inline _LIBCPP_INLINE_VISIBILITY | ||
| 2568 | bool | ||
| 2569 | atomic_flag_test_explicit(const atomic_flag* __o, memory_order __m) _NOEXCEPT | ||
| 2570 | { | ||
| 2571 | return __o->test(__m); | ||
| 2572 | } | ||
| 2573 | |||
| 2313 | inline _LIBCPP_INLINE_VISIBILITY | 2574 | inline _LIBCPP_INLINE_VISIBILITY |
| 2314 | bool | 2575 | bool |
| 2315 | atomic_flag_test_and_set(volatile atomic_flag* __o) _NOEXCEPT | 2576 | atomic_flag_test_and_set(volatile atomic_flag* __o) _NOEXCEPT |
| ... | @@ -2366,6 +2627,64 @@ atomic_flag_clear_explicit(atomic_flag* __o, memory_order __m) _NOEXCEPT | ... | @@ -2366,6 +2627,64 @@ atomic_flag_clear_explicit(atomic_flag* __o, memory_order __m) _NOEXCEPT |
| 2366 | __o->clear(__m); | 2627 | __o->clear(__m); |
| 2367 | } | 2628 | } |
| 2368 | 2629 | ||
| 2630 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_SYNC | ||
| 2631 | void | ||
| 2632 | atomic_flag_wait(const volatile atomic_flag* __o, bool __v) _NOEXCEPT | ||
| 2633 | { | ||
| 2634 | __o->wait(__v); | ||
| 2635 | } | ||
| 2636 | |||
| 2637 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_SYNC | ||
| 2638 | void | ||
| 2639 | atomic_flag_wait(const atomic_flag* __o, bool __v) _NOEXCEPT | ||
| 2640 | { | ||
| 2641 | __o->wait(__v); | ||
| 2642 | } | ||
| 2643 | |||
| 2644 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_SYNC | ||
| 2645 | void | ||
| 2646 | atomic_flag_wait_explicit(const volatile atomic_flag* __o, | ||
| 2647 | bool __v, memory_order __m) _NOEXCEPT | ||
| 2648 | { | ||
| 2649 | __o->wait(__v, __m); | ||
| 2650 | } | ||
| 2651 | |||
| 2652 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_SYNC | ||
| 2653 | void | ||
| 2654 | atomic_flag_wait_explicit(const atomic_flag* __o, | ||
| 2655 | bool __v, memory_order __m) _NOEXCEPT | ||
| 2656 | { | ||
| 2657 | __o->wait(__v, __m); | ||
| 2658 | } | ||
| 2659 | |||
| 2660 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_SYNC | ||
| 2661 | void | ||
| 2662 | atomic_flag_notify_one(volatile atomic_flag* __o) _NOEXCEPT | ||
| 2663 | { | ||
| 2664 | __o->notify_one(); | ||
| 2665 | } | ||
| 2666 | |||
| 2667 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_SYNC | ||
| 2668 | void | ||
| 2669 | atomic_flag_notify_one(atomic_flag* __o) _NOEXCEPT | ||
| 2670 | { | ||
| 2671 | __o->notify_one(); | ||
| 2672 | } | ||
| 2673 | |||
| 2674 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_SYNC | ||
| 2675 | void | ||
| 2676 | atomic_flag_notify_all(volatile atomic_flag* __o) _NOEXCEPT | ||
| 2677 | { | ||
| 2678 | __o->notify_all(); | ||
| 2679 | } | ||
| 2680 | |||
| 2681 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_SYNC | ||
| 2682 | void | ||
| 2683 | atomic_flag_notify_all(atomic_flag* __o) _NOEXCEPT | ||
| 2684 | { | ||
| 2685 | __o->notify_all(); | ||
| 2686 | } | ||
| 2687 | |||
| 2369 | // fences | 2688 | // fences |
| 2370 | 2689 | ||
| 2371 | inline _LIBCPP_INLINE_VISIBILITY | 2690 | inline _LIBCPP_INLINE_VISIBILITY |
| ... | @@ -2434,6 +2753,33 @@ typedef atomic<ptrdiff_t> atomic_ptrdiff_t; | ... | @@ -2434,6 +2753,33 @@ typedef atomic<ptrdiff_t> atomic_ptrdiff_t; |
| 2434 | typedef atomic<intmax_t> atomic_intmax_t; | 2753 | typedef atomic<intmax_t> atomic_intmax_t; |
| 2435 | typedef atomic<uintmax_t> atomic_uintmax_t; | 2754 | typedef atomic<uintmax_t> atomic_uintmax_t; |
| 2436 | 2755 | ||
| 2756 | // atomic_*_lock_free : prefer the contention type most highly, then the largest lock-free type | ||
| 2757 | |||
| 2758 | #ifdef __cpp_lib_atomic_is_always_lock_free | ||
| 2759 | # define _LIBCPP_CONTENTION_LOCK_FREE __atomic_always_lock_free(sizeof(__cxx_contention_t), 0) | ||
| 2760 | #else | ||
| 2761 | # define _LIBCPP_CONTENTION_LOCK_FREE false | ||
| 2762 | #endif | ||
| 2763 | |||
| 2764 | #if ATOMIC_LLONG_LOCK_FREE == 2 | ||
| 2765 | typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, long long>::type __libcpp_signed_lock_free; | ||
| 2766 | typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned long long>::type __libcpp_unsigned_lock_free; | ||
| 2767 | #elif ATOMIC_INT_LOCK_FREE == 2 | ||
| 2768 | typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, int>::type __libcpp_signed_lock_free; | ||
| 2769 | typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned int>::type __libcpp_unsigned_lock_free; | ||
| 2770 | #elif ATOMIC_SHORT_LOCK_FREE == 2 | ||
| 2771 | typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, short>::type __libcpp_signed_lock_free; | ||
| 2772 | typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned short>::type __libcpp_unsigned_lock_free; | ||
| 2773 | #elif ATOMIC_CHAR_LOCK_FREE == 2 | ||
| 2774 | typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, char>::type __libcpp_signed_lock_free; | ||
| 2775 | typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned char>::type __libcpp_unsigned_lock_free; | ||
| 2776 | #else | ||
| 2777 | // No signed/unsigned lock-free types | ||
| 2778 | #endif | ||
| 2779 | |||
| 2780 | typedef atomic<__libcpp_signed_lock_free> atomic_signed_lock_free; | ||
| 2781 | typedef atomic<__libcpp_unsigned_lock_free> atomic_unsigned_lock_free; | ||
| 2782 | |||
| 2437 | #define ATOMIC_FLAG_INIT {false} | 2783 | #define ATOMIC_FLAG_INIT {false} |
| 2438 | #define ATOMIC_VAR_INIT(__v) {__v} | 2784 | #define ATOMIC_VAR_INIT(__v) {__v} |
| 2439 | 2785 |
lib/libcxx/include/barrier created+322| ... | @@ -0,0 +1,322 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===--------------------------- barrier ----------------------------------===// | ||
| 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_BARRIER | ||
| 11 | #define _LIBCPP_BARRIER | ||
| 12 | |||
| 13 | /* | ||
| 14 | barrier synopsis | ||
| 15 | |||
| 16 | namespace std | ||
| 17 | { | ||
| 18 | |||
| 19 | template<class CompletionFunction = see below> | ||
| 20 | class barrier | ||
| 21 | { | ||
| 22 | public: | ||
| 23 | using arrival_token = see below; | ||
| 24 | |||
| 25 | constexpr explicit barrier(ptrdiff_t phase_count, | ||
| 26 | CompletionFunction f = CompletionFunction()); | ||
| 27 | ~barrier(); | ||
| 28 | |||
| 29 | barrier(const barrier&) = delete; | ||
| 30 | barrier& operator=(const barrier&) = delete; | ||
| 31 | |||
| 32 | [[nodiscard]] arrival_token arrive(ptrdiff_t update = 1); | ||
| 33 | void wait(arrival_token&& arrival) const; | ||
| 34 | |||
| 35 | void arrive_and_wait(); | ||
| 36 | void arrive_and_drop(); | ||
| 37 | |||
| 38 | private: | ||
| 39 | CompletionFunction completion; // exposition only | ||
| 40 | }; | ||
| 41 | |||
| 42 | } | ||
| 43 | |||
| 44 | */ | ||
| 45 | |||
| 46 | #include <__config> | ||
| 47 | #include <atomic> | ||
| 48 | #ifndef _LIBCPP_HAS_NO_TREE_BARRIER | ||
| 49 | # include <memory> | ||
| 50 | #endif | ||
| 51 | |||
| 52 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 53 | #pragma GCC system_header | ||
| 54 | #endif | ||
| 55 | |||
| 56 | #ifdef _LIBCPP_HAS_NO_THREADS | ||
| 57 | # error <barrier> is not supported on this single threaded system | ||
| 58 | #endif | ||
| 59 | |||
| 60 | #if _LIBCPP_STD_VER >= 14 | ||
| 61 | |||
| 62 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 63 | |||
| 64 | struct __empty_completion | ||
| 65 | { | ||
| 66 | inline _LIBCPP_INLINE_VISIBILITY | ||
| 67 | void operator()() noexcept | ||
| 68 | { | ||
| 69 | } | ||
| 70 | }; | ||
| 71 | |||
| 72 | #ifndef _LIBCPP_HAS_NO_TREE_BARRIER | ||
| 73 | |||
| 74 | /* | ||
| 75 | |||
| 76 | The default implementation of __barrier_base is a classic tree barrier. | ||
| 77 | |||
| 78 | It looks different from literature pseudocode for two main reasons: | ||
| 79 | 1. Threads that call into std::barrier functions do not provide indices, | ||
| 80 | so a numbering step is added before the actual barrier algorithm, | ||
| 81 | appearing as an N+1 round to the N rounds of the tree barrier. | ||
| 82 | 2. A great deal of attention has been paid to avoid cache line thrashing | ||
| 83 | by flattening the tree structure into cache-line sized arrays, that | ||
| 84 | are indexed in an efficient way. | ||
| 85 | |||
| 86 | */ | ||
| 87 | |||
| 88 | using __barrier_phase_t = uint8_t; | ||
| 89 | |||
| 90 | class __barrier_algorithm_base; | ||
| 91 | |||
| 92 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI | ||
| 93 | __barrier_algorithm_base* __construct_barrier_algorithm_base(ptrdiff_t& __expected); | ||
| 94 | |||
| 95 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI | ||
| 96 | bool __arrive_barrier_algorithm_base(__barrier_algorithm_base* __barrier, | ||
| 97 | __barrier_phase_t __old_phase); | ||
| 98 | |||
| 99 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI | ||
| 100 | void __destroy_barrier_algorithm_base(__barrier_algorithm_base* __barrier); | ||
| 101 | |||
| 102 | template<class _CompletionF> | ||
| 103 | class __barrier_base { | ||
| 104 | |||
| 105 | ptrdiff_t __expected; | ||
| 106 | unique_ptr<__barrier_algorithm_base, | ||
| 107 | void (*)(__barrier_algorithm_base*)> __base; | ||
| 108 | __atomic_base<ptrdiff_t> __expected_adjustment; | ||
| 109 | _CompletionF __completion; | ||
| 110 | __atomic_base<__barrier_phase_t> __phase; | ||
| 111 | |||
| 112 | public: | ||
| 113 | using arrival_token = __barrier_phase_t; | ||
| 114 | |||
| 115 | static constexpr ptrdiff_t max() noexcept { | ||
| 116 | return numeric_limits<ptrdiff_t>::max(); | ||
| 117 | } | ||
| 118 | |||
| 119 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 120 | __barrier_base(ptrdiff_t __expected, _CompletionF __completion = _CompletionF()) | ||
| 121 | : __expected(__expected), __base(__construct_barrier_algorithm_base(this->__expected), | ||
| 122 | &__destroy_barrier_algorithm_base), | ||
| 123 | __expected_adjustment(0), __completion(move(__completion)), __phase(0) | ||
| 124 | { | ||
| 125 | } | ||
| 126 | [[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 127 | arrival_token arrive(ptrdiff_t update) | ||
| 128 | { | ||
| 129 | auto const __old_phase = __phase.load(memory_order_relaxed); | ||
| 130 | for(; update; --update) | ||
| 131 | if(__arrive_barrier_algorithm_base(__base.get(), __old_phase)) { | ||
| 132 | __completion(); | ||
| 133 | __expected += __expected_adjustment.load(memory_order_relaxed); | ||
| 134 | __expected_adjustment.store(0, memory_order_relaxed); | ||
| 135 | __phase.store(__old_phase + 2, memory_order_release); | ||
| 136 | __phase.notify_all(); | ||
| 137 | } | ||
| 138 | return __old_phase; | ||
| 139 | } | ||
| 140 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 141 | void wait(arrival_token&& __old_phase) const | ||
| 142 | { | ||
| 143 | auto const __test_fn = [=]() -> bool { | ||
| 144 | return __phase.load(memory_order_acquire) != __old_phase; | ||
| 145 | }; | ||
| 146 | __libcpp_thread_poll_with_backoff(__test_fn, __libcpp_timed_backoff_policy()); | ||
| 147 | } | ||
| 148 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 149 | void arrive_and_drop() | ||
| 150 | { | ||
| 151 | __expected_adjustment.fetch_sub(1, memory_order_relaxed); | ||
| 152 | (void)arrive(1); | ||
| 153 | } | ||
| 154 | }; | ||
| 155 | |||
| 156 | #else | ||
| 157 | |||
| 158 | /* | ||
| 159 | |||
| 160 | The alternative implementation of __barrier_base is a central barrier. | ||
| 161 | |||
| 162 | Two versions of this algorithm are provided: | ||
| 163 | 1. A fairly straightforward implementation of the litterature for the | ||
| 164 | general case where the completion function is not empty. | ||
| 165 | 2. An optimized implementation that exploits 2's complement arithmetic | ||
| 166 | and well-defined overflow in atomic arithmetic, to handle the phase | ||
| 167 | roll-over for free. | ||
| 168 | |||
| 169 | */ | ||
| 170 | |||
| 171 | template<class _CompletionF> | ||
| 172 | class __barrier_base { | ||
| 173 | |||
| 174 | __atomic_base<ptrdiff_t> __expected; | ||
| 175 | __atomic_base<ptrdiff_t> __arrived; | ||
| 176 | _CompletionF __completion; | ||
| 177 | __atomic_base<bool> __phase; | ||
| 178 | public: | ||
| 179 | using arrival_token = bool; | ||
| 180 | |||
| 181 | static constexpr ptrdiff_t max() noexcept { | ||
| 182 | return numeric_limits<ptrdiff_t>::max(); | ||
| 183 | } | ||
| 184 | |||
| 185 | _LIBCPP_INLINE_VISIBILITY | ||
| 186 | __barrier_base(ptrdiff_t __expected, _CompletionF __completion = _CompletionF()) | ||
| 187 | : __expected(__expected), __arrived(__expected), __completion(move(__completion)), __phase(false) | ||
| 188 | { | ||
| 189 | } | ||
| 190 | [[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 191 | arrival_token arrive(ptrdiff_t update) | ||
| 192 | { | ||
| 193 | auto const __old_phase = __phase.load(memory_order_relaxed); | ||
| 194 | auto const __result = __arrived.fetch_sub(update, memory_order_acq_rel) - update; | ||
| 195 | auto const new_expected = __expected.load(memory_order_relaxed); | ||
| 196 | if(0 == __result) { | ||
| 197 | __completion(); | ||
| 198 | __arrived.store(new_expected, memory_order_relaxed); | ||
| 199 | __phase.store(!__old_phase, memory_order_release); | ||
| 200 | __phase.notify_all(); | ||
| 201 | } | ||
| 202 | return __old_phase; | ||
| 203 | } | ||
| 204 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 205 | void wait(arrival_token&& __old_phase) const | ||
| 206 | { | ||
| 207 | __phase.wait(__old_phase, memory_order_acquire); | ||
| 208 | } | ||
| 209 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 210 | void arrive_and_drop() | ||
| 211 | { | ||
| 212 | __expected.fetch_sub(1, memory_order_relaxed); | ||
| 213 | (void)arrive(1); | ||
| 214 | } | ||
| 215 | }; | ||
| 216 | |||
| 217 | template<> | ||
| 218 | class __barrier_base<__empty_completion> { | ||
| 219 | |||
| 220 | static constexpr uint64_t __expected_unit = 1ull; | ||
| 221 | static constexpr uint64_t __arrived_unit = 1ull << 32; | ||
| 222 | static constexpr uint64_t __expected_mask = __arrived_unit - 1; | ||
| 223 | static constexpr uint64_t __phase_bit = 1ull << 63; | ||
| 224 | static constexpr uint64_t __arrived_mask = (__phase_bit - 1) & ~__expected_mask; | ||
| 225 | |||
| 226 | __atomic_base<uint64_t> __phase_arrived_expected; | ||
| 227 | |||
| 228 | static _LIBCPP_INLINE_VISIBILITY | ||
| 229 | constexpr uint64_t __init(ptrdiff_t __count) _NOEXCEPT | ||
| 230 | { | ||
| 231 | return ((uint64_t(1u << 31) - __count) << 32) | ||
| 232 | | (uint64_t(1u << 31) - __count); | ||
| 233 | } | ||
| 234 | |||
| 235 | public: | ||
| 236 | using arrival_token = uint64_t; | ||
| 237 | |||
| 238 | static constexpr ptrdiff_t max() noexcept { | ||
| 239 | return ptrdiff_t(1u << 31) - 1; | ||
| 240 | } | ||
| 241 | |||
| 242 | _LIBCPP_INLINE_VISIBILITY | ||
| 243 | explicit inline __barrier_base(ptrdiff_t __count, __empty_completion = __empty_completion()) | ||
| 244 | : __phase_arrived_expected(__init(__count)) | ||
| 245 | { | ||
| 246 | } | ||
| 247 | [[nodiscard]] inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 248 | arrival_token arrive(ptrdiff_t update) | ||
| 249 | { | ||
| 250 | auto const __inc = __arrived_unit * update; | ||
| 251 | auto const __old = __phase_arrived_expected.fetch_add(__inc, memory_order_acq_rel); | ||
| 252 | if((__old ^ (__old + __inc)) & __phase_bit) { | ||
| 253 | __phase_arrived_expected.fetch_add((__old & __expected_mask) << 32, memory_order_relaxed); | ||
| 254 | __phase_arrived_expected.notify_all(); | ||
| 255 | } | ||
| 256 | return __old & __phase_bit; | ||
| 257 | } | ||
| 258 | inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 259 | void wait(arrival_token&& __phase) const | ||
| 260 | { | ||
| 261 | auto const __test_fn = [=]() -> bool { | ||
| 262 | uint64_t const __current = __phase_arrived_expected.load(memory_order_acquire); | ||
| 263 | return ((__current & __phase_bit) != __phase); | ||
| 264 | }; | ||
| 265 | __libcpp_thread_poll_with_backoff(__test_fn, __libcpp_timed_backoff_policy()); | ||
| 266 | } | ||
| 267 | inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 268 | void arrive_and_drop() | ||
| 269 | { | ||
| 270 | __phase_arrived_expected.fetch_add(__expected_unit, memory_order_relaxed); | ||
| 271 | (void)arrive(1); | ||
| 272 | } | ||
| 273 | }; | ||
| 274 | |||
| 275 | #endif //_LIBCPP_HAS_NO_TREE_BARRIER | ||
| 276 | |||
| 277 | template<class _CompletionF = __empty_completion> | ||
| 278 | class barrier { | ||
| 279 | |||
| 280 | __barrier_base<_CompletionF> __b; | ||
| 281 | public: | ||
| 282 | using arrival_token = typename __barrier_base<_CompletionF>::arrival_token; | ||
| 283 | |||
| 284 | static constexpr ptrdiff_t max() noexcept { | ||
| 285 | return __barrier_base<_CompletionF>::max(); | ||
| 286 | } | ||
| 287 | |||
| 288 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 289 | barrier(ptrdiff_t __count, _CompletionF __completion = _CompletionF()) | ||
| 290 | : __b(__count, std::move(__completion)) { | ||
| 291 | } | ||
| 292 | |||
| 293 | barrier(barrier const&) = delete; | ||
| 294 | barrier& operator=(barrier const&) = delete; | ||
| 295 | |||
| 296 | [[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 297 | arrival_token arrive(ptrdiff_t update = 1) | ||
| 298 | { | ||
| 299 | return __b.arrive(update); | ||
| 300 | } | ||
| 301 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 302 | void wait(arrival_token&& __phase) const | ||
| 303 | { | ||
| 304 | __b.wait(std::move(__phase)); | ||
| 305 | } | ||
| 306 | 	_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 307 | void arrive_and_wait() | ||
| 308 | { | ||
| 309 | wait(arrive()); | ||
| 310 | 	} | ||
| 311 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 312 | void arrive_and_drop() | ||
| 313 | { | ||
| 314 | __b.arrive_and_drop(); | ||
| 315 | } | ||
| 316 | }; | ||
| 317 | |||
| 318 | _LIBCPP_END_NAMESPACE_STD | ||
| 319 | |||
| 320 | #endif // _LIBCPP_STD_VER >= 14 | ||
| 321 | |||
| 322 | #endif //_LIBCPP_BARRIER | ||
lib/libcxx/include/bit+5-4| ... | @@ -15,6 +15,7 @@ | ... | @@ -15,6 +15,7 @@ |
| 15 | 15 | ||
| 16 | namespace std { | 16 | namespace std { |
| 17 | 17 | ||
| 18 | // [bit.pow.two], integral powers of 2 | ||
| 18 | template <class T> | 19 | template <class T> |
| 19 | constexpr bool ispow2(T x) noexcept; // C++20 | 20 | constexpr bool ispow2(T x) noexcept; // C++20 |
| 20 | template <class T> | 21 | template <class T> |
| ... | @@ -24,13 +25,13 @@ namespace std { | ... | @@ -24,13 +25,13 @@ namespace std { |
| 24 | template <class T> | 25 | template <class T> |
| 25 | constexpr T log2p1(T x) noexcept; // C++20 | 26 | constexpr T log2p1(T x) noexcept; // C++20 |
| 26 | 27 | ||
| 27 | // 23.20.2, rotating | 28 | // [bit.rotate], rotating |
| 28 | template<class T> | 29 | template<class T> |
| 29 | constexpr T rotl(T x, unsigned int s) noexcept; // C++20 | 30 | constexpr T rotl(T x, unsigned int s) noexcept; // C++20 |
| 30 | template<class T> | 31 | template<class T> |
| 31 | constexpr T rotr(T x, unsigned int s) noexcept; // C++20 | 32 | constexpr T rotr(T x, unsigned int s) noexcept; // C++20 |
| 32 | 33 | ||
| 33 | // 23.20.3, counting | 34 | // [bit.count], counting |
| 34 | template<class T> | 35 | template<class T> |
| 35 | constexpr int countl_zero(T x) noexcept; // C++20 | 36 | constexpr int countl_zero(T x) noexcept; // C++20 |
| 36 | template<class T> | 37 | template<class T> |
| ... | @@ -42,7 +43,7 @@ namespace std { | ... | @@ -42,7 +43,7 @@ namespace std { |
| 42 | template<class T> | 43 | template<class T> |
| 43 | constexpr int popcount(T x) noexcept; // C++20 | 44 | constexpr int popcount(T x) noexcept; // C++20 |
| 44 | 45 | ||
| 45 | // 20.15.9, endian | 46 | // [bit.endian], endian |
| 46 | enum class endian { | 47 | enum class endian { |
| 47 | little = see below, // C++20 | 48 | little = see below, // C++20 |
| 48 | big = see below, // C++20 | 49 | big = see below, // C++20 |
| ... | @@ -350,7 +351,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | ... | @@ -350,7 +351,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
| 350 | bool __ispow2(_Tp __t) _NOEXCEPT | 351 | bool __ispow2(_Tp __t) _NOEXCEPT |
| 351 | { | 352 | { |
| 352 | static_assert(__bitop_unsigned_integer<_Tp>::value, "__ispow2 requires unsigned"); | 353 | static_assert(__bitop_unsigned_integer<_Tp>::value, "__ispow2 requires unsigned"); |
| 353 | 	return __t != 0 && (((__t & (__t - 1)) == 0)); | 354 | return __t != 0 && (((__t & (__t - 1)) == 0)); |
| 354 | } | 355 | } |
| 355 | 356 | ||
| 356 | 357 |
lib/libcxx/include/charconv+11-2| ... | @@ -73,6 +73,7 @@ namespace std { | ... | @@ -73,6 +73,7 @@ namespace std { |
| 73 | 73 | ||
| 74 | */ | 74 | */ |
| 75 | 75 | ||
| 76 | #include <__config> | ||
| 76 | #include <__errc> | 77 | #include <__errc> |
| 77 | #include <type_traits> | 78 | #include <type_traits> |
| 78 | #include <limits> | 79 | #include <limits> |
| ... | @@ -92,8 +93,8 @@ _LIBCPP_PUSH_MACROS | ... | @@ -92,8 +93,8 @@ _LIBCPP_PUSH_MACROS |
| 92 | _LIBCPP_BEGIN_NAMESPACE_STD | 93 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 93 | 94 | ||
| 94 | namespace __itoa { | 95 | namespace __itoa { |
| 95 | _LIBCPP_FUNC_VIS char* __u64toa(uint64_t __value, char* __buffer); | 96 | _LIBCPP_AVAILABILITY_TO_CHARS _LIBCPP_FUNC_VIS char* __u64toa(uint64_t __value, char* __buffer) _NOEXCEPT; |
| 96 | _LIBCPP_FUNC_VIS char* __u32toa(uint32_t __value, char* __buffer); | 97 | _LIBCPP_AVAILABILITY_TO_CHARS _LIBCPP_FUNC_VIS char* __u32toa(uint32_t __value, char* __buffer) _NOEXCEPT; |
| 97 | } | 98 | } |
| 98 | 99 | ||
| 99 | #ifndef _LIBCPP_CXX03_LANG | 100 | #ifndef _LIBCPP_CXX03_LANG |
| ... | @@ -167,6 +168,7 @@ struct _LIBCPP_HIDDEN __traits_base | ... | @@ -167,6 +168,7 @@ struct _LIBCPP_HIDDEN __traits_base |
| 167 | } | 168 | } |
| 168 | #endif | 169 | #endif |
| 169 | 170 | ||
| 171 | _LIBCPP_AVAILABILITY_TO_CHARS | ||
| 170 | static _LIBCPP_INLINE_VISIBILITY char* __convert(_Tp __v, char* __p) | 172 | static _LIBCPP_INLINE_VISIBILITY char* __convert(_Tp __v, char* __p) |
| 171 | { | 173 | { |
| 172 | return __u64toa(__v, __p); | 174 | return __u64toa(__v, __p); |
| ... | @@ -189,6 +191,7 @@ struct _LIBCPP_HIDDEN | ... | @@ -189,6 +191,7 @@ struct _LIBCPP_HIDDEN |
| 189 | } | 191 | } |
| 190 | #endif | 192 | #endif |
| 191 | 193 | ||
| 194 | _LIBCPP_AVAILABILITY_TO_CHARS | ||
| 192 | static _LIBCPP_INLINE_VISIBILITY char* __convert(_Tp __v, char* __p) | 195 | static _LIBCPP_INLINE_VISIBILITY char* __convert(_Tp __v, char* __p) |
| 193 | { | 196 | { |
| 194 | return __u32toa(__v, __p); | 197 | return __u32toa(__v, __p); |
| ... | @@ -292,6 +295,7 @@ __to_unsigned(_Tp __x) | ... | @@ -292,6 +295,7 @@ __to_unsigned(_Tp __x) |
| 292 | } | 295 | } |
| 293 | 296 | ||
| 294 | template <typename _Tp> | 297 | template <typename _Tp> |
| 298 | _LIBCPP_AVAILABILITY_TO_CHARS | ||
| 295 | inline _LIBCPP_INLINE_VISIBILITY to_chars_result | 299 | inline _LIBCPP_INLINE_VISIBILITY to_chars_result |
| 296 | __to_chars_itoa(char* __first, char* __last, _Tp __value, true_type) | 300 | __to_chars_itoa(char* __first, char* __last, _Tp __value, true_type) |
| 297 | { | 301 | { |
| ... | @@ -306,6 +310,7 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, true_type) | ... | @@ -306,6 +310,7 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, true_type) |
| 306 | } | 310 | } |
| 307 | 311 | ||
| 308 | template <typename _Tp> | 312 | template <typename _Tp> |
| 313 | _LIBCPP_AVAILABILITY_TO_CHARS | ||
| 309 | inline _LIBCPP_INLINE_VISIBILITY to_chars_result | 314 | inline _LIBCPP_INLINE_VISIBILITY to_chars_result |
| 310 | __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type) | 315 | __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type) |
| 311 | { | 316 | { |
| ... | @@ -337,6 +342,7 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type) | ... | @@ -337,6 +342,7 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type) |
| 337 | } | 342 | } |
| 338 | 343 | ||
| 339 | template <typename _Tp> | 344 | template <typename _Tp> |
| 345 | _LIBCPP_AVAILABILITY_TO_CHARS | ||
| 340 | inline _LIBCPP_INLINE_VISIBILITY to_chars_result | 346 | inline _LIBCPP_INLINE_VISIBILITY to_chars_result |
| 341 | __to_chars_integral(char* __first, char* __last, _Tp __value, int __base, | 347 | __to_chars_integral(char* __first, char* __last, _Tp __value, int __base, |
| 342 | true_type) | 348 | true_type) |
| ... | @@ -352,6 +358,7 @@ __to_chars_integral(char* __first, char* __last, _Tp __value, int __base, | ... | @@ -352,6 +358,7 @@ __to_chars_integral(char* __first, char* __last, _Tp __value, int __base, |
| 352 | } | 358 | } |
| 353 | 359 | ||
| 354 | template <typename _Tp> | 360 | template <typename _Tp> |
| 361 | _LIBCPP_AVAILABILITY_TO_CHARS | ||
| 355 | inline _LIBCPP_INLINE_VISIBILITY to_chars_result | 362 | inline _LIBCPP_INLINE_VISIBILITY to_chars_result |
| 356 | __to_chars_integral(char* __first, char* __last, _Tp __value, int __base, | 363 | __to_chars_integral(char* __first, char* __last, _Tp __value, int __base, |
| 357 | false_type) | 364 | false_type) |
| ... | @@ -380,6 +387,7 @@ __to_chars_integral(char* __first, char* __last, _Tp __value, int __base, | ... | @@ -380,6 +387,7 @@ __to_chars_integral(char* __first, char* __last, _Tp __value, int __base, |
| 380 | } | 387 | } |
| 381 | 388 | ||
| 382 | template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0> | 389 | template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0> |
| 390 | _LIBCPP_AVAILABILITY_TO_CHARS | ||
| 383 | inline _LIBCPP_INLINE_VISIBILITY to_chars_result | 391 | inline _LIBCPP_INLINE_VISIBILITY to_chars_result |
| 384 | to_chars(char* __first, char* __last, _Tp __value) | 392 | to_chars(char* __first, char* __last, _Tp __value) |
| 385 | { | 393 | { |
| ... | @@ -387,6 +395,7 @@ to_chars(char* __first, char* __last, _Tp __value) | ... | @@ -387,6 +395,7 @@ to_chars(char* __first, char* __last, _Tp __value) |
| 387 | } | 395 | } |
| 388 | 396 | ||
| 389 | template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0> | 397 | template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0> |
| 398 | _LIBCPP_AVAILABILITY_TO_CHARS | ||
| 390 | inline _LIBCPP_INLINE_VISIBILITY to_chars_result | 399 | inline _LIBCPP_INLINE_VISIBILITY to_chars_result |
| 391 | to_chars(char* __first, char* __last, _Tp __value, int __base) | 400 | to_chars(char* __first, char* __last, _Tp __value, int __base) |
| 392 | { | 401 | { |
lib/libcxx/include/chrono+1-1| ... | @@ -2454,7 +2454,7 @@ chrono::day year_month_day_last::day() const noexcept | ... | @@ -2454,7 +2454,7 @@ chrono::day year_month_day_last::day() const noexcept |
| 2454 | chrono::day(31), chrono::day(31), chrono::day(30), | 2454 | chrono::day(31), chrono::day(31), chrono::day(30), |
| 2455 | chrono::day(31), chrono::day(30), chrono::day(31) | 2455 | chrono::day(31), chrono::day(30), chrono::day(31) |
| 2456 | }; | 2456 | }; |
| 2457 | return month() != February || !__y.is_leap() ? | 2457 | return (month() != February || !__y.is_leap()) && month().ok() ? |
| 2458 | __d[static_cast<unsigned>(month()) - 1] : chrono::day{29}; | 2458 | __d[static_cast<unsigned>(month()) - 1] : chrono::day{29}; |
| 2459 | } | 2459 | } |
| 2460 | 2460 |
lib/libcxx/include/cmath+4| ... | @@ -296,6 +296,10 @@ floating_point trunc (arithmetic x); | ... | @@ -296,6 +296,10 @@ floating_point trunc (arithmetic x); |
| 296 | float truncf(float x); | 296 | float truncf(float x); |
| 297 | long double truncl(long double x); | 297 | long double truncl(long double x); |
| 298 | 298 | ||
| 299 | constexpr float lerp(float a, float b, float t) noexcept; // C++20 | ||
| 300 | constexpr double lerp(double a, double b, double t) noexcept; // C++20 | ||
| 301 | constexpr long double lerp(long double a, long double b, long double t) noexcept; // C++20 | ||
| 302 | |||
| 299 | } // std | 303 | } // std |
| 300 | 304 | ||
| 301 | */ | 305 | */ |
lib/libcxx/include/codecvt+36-36| ... | @@ -102,11 +102,11 @@ protected: | ... | @@ -102,11 +102,11 @@ protected: |
| 102 | virtual result | 102 | virtual result |
| 103 | do_unshift(state_type& __st, | 103 | do_unshift(state_type& __st, |
| 104 | extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; | 104 | extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; |
| 105 | virtual int do_encoding() const throw(); | 105 | virtual int do_encoding() const _NOEXCEPT; |
| 106 | virtual bool do_always_noconv() const throw(); | 106 | virtual bool do_always_noconv() const _NOEXCEPT; |
| 107 | virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, | 107 | virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, |
| 108 | size_t __mx) const; | 108 | size_t __mx) const; |
| 109 | virtual int do_max_length() const throw(); | 109 | virtual int do_max_length() const _NOEXCEPT; |
| 110 | }; | 110 | }; |
| 111 | 111 | ||
| 112 | template <> | 112 | template <> |
| ... | @@ -137,11 +137,11 @@ protected: | ... | @@ -137,11 +137,11 @@ protected: |
| 137 | virtual result | 137 | virtual result |
| 138 | do_unshift(state_type& __st, | 138 | do_unshift(state_type& __st, |
| 139 | extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; | 139 | extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; |
| 140 | virtual int do_encoding() const throw(); | 140 | virtual int do_encoding() const _NOEXCEPT; |
| 141 | virtual bool do_always_noconv() const throw(); | 141 | virtual bool do_always_noconv() const _NOEXCEPT; |
| 142 | virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, | 142 | virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, |
| 143 | size_t __mx) const; | 143 | size_t __mx) const; |
| 144 | virtual int do_max_length() const throw(); | 144 | virtual int do_max_length() const _NOEXCEPT; |
| 145 | }; | 145 | }; |
| 146 | 146 | ||
| 147 | template <> | 147 | template <> |
| ... | @@ -172,11 +172,11 @@ protected: | ... | @@ -172,11 +172,11 @@ protected: |
| 172 | virtual result | 172 | virtual result |
| 173 | do_unshift(state_type& __st, | 173 | do_unshift(state_type& __st, |
| 174 | extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; | 174 | extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; |
| 175 | virtual int do_encoding() const throw(); | 175 | virtual int do_encoding() const _NOEXCEPT; |
| 176 | virtual bool do_always_noconv() const throw(); | 176 | virtual bool do_always_noconv() const _NOEXCEPT; |
| 177 | virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, | 177 | virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, |
| 178 | size_t __mx) const; | 178 | size_t __mx) const; |
| 179 | virtual int do_max_length() const throw(); | 179 | virtual int do_max_length() const _NOEXCEPT; |
| 180 | }; | 180 | }; |
| 181 | 181 | ||
| 182 | template <class _Elem, unsigned long _Maxcode = 0x10ffff, | 182 | template <class _Elem, unsigned long _Maxcode = 0x10ffff, |
| ... | @@ -225,11 +225,11 @@ protected: | ... | @@ -225,11 +225,11 @@ protected: |
| 225 | virtual result | 225 | virtual result |
| 226 | do_unshift(state_type& __st, | 226 | do_unshift(state_type& __st, |
| 227 | extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; | 227 | extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; |
| 228 | virtual int do_encoding() const throw(); | 228 | virtual int do_encoding() const _NOEXCEPT; |
| 229 | virtual bool do_always_noconv() const throw(); | 229 | virtual bool do_always_noconv() const _NOEXCEPT; |
| 230 | virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, | 230 | virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, |
| 231 | size_t __mx) const; | 231 | size_t __mx) const; |
| 232 | virtual int do_max_length() const throw(); | 232 | virtual int do_max_length() const _NOEXCEPT; |
| 233 | }; | 233 | }; |
| 234 | 234 | ||
| 235 | template <> | 235 | template <> |
| ... | @@ -260,11 +260,11 @@ protected: | ... | @@ -260,11 +260,11 @@ protected: |
| 260 | virtual result | 260 | virtual result |
| 261 | do_unshift(state_type& __st, | 261 | do_unshift(state_type& __st, |
| 262 | extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; | 262 | extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; |
| 263 | virtual int do_encoding() const throw(); | 263 | virtual int do_encoding() const _NOEXCEPT; |
| 264 | virtual bool do_always_noconv() const throw(); | 264 | virtual bool do_always_noconv() const _NOEXCEPT; |
| 265 | virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, | 265 | virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, |
| 266 | size_t __mx) const; | 266 | size_t __mx) const; |
| 267 | virtual int do_max_length() const throw(); | 267 | virtual int do_max_length() const _NOEXCEPT; |
| 268 | }; | 268 | }; |
| 269 | 269 | ||
| 270 | template <> | 270 | template <> |
| ... | @@ -295,11 +295,11 @@ protected: | ... | @@ -295,11 +295,11 @@ protected: |
| 295 | virtual result | 295 | virtual result |
| 296 | do_unshift(state_type& __st, | 296 | do_unshift(state_type& __st, |
| 297 | extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; | 297 | extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; |
| 298 | virtual int do_encoding() const throw(); | 298 | virtual int do_encoding() const _NOEXCEPT; |
| 299 | virtual bool do_always_noconv() const throw(); | 299 | virtual bool do_always_noconv() const _NOEXCEPT; |
| 300 | virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, | 300 | virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, |
| 301 | size_t __mx) const; | 301 | size_t __mx) const; |
| 302 | virtual int do_max_length() const throw(); | 302 | virtual int do_max_length() const _NOEXCEPT; |
| 303 | }; | 303 | }; |
| 304 | 304 | ||
| 305 | template <> | 305 | template <> |
| ... | @@ -330,11 +330,11 @@ protected: | ... | @@ -330,11 +330,11 @@ protected: |
| 330 | virtual result | 330 | virtual result |
| 331 | do_unshift(state_type& __st, | 331 | do_unshift(state_type& __st, |
| 332 | extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; | 332 | extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; |
| 333 | virtual int do_encoding() const throw(); | 333 | virtual int do_encoding() const _NOEXCEPT; |
| 334 | virtual bool do_always_noconv() const throw(); | 334 | virtual bool do_always_noconv() const _NOEXCEPT; |
| 335 | virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, | 335 | virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, |
| 336 | size_t __mx) const; | 336 | size_t __mx) const; |
| 337 | virtual int do_max_length() const throw(); | 337 | virtual int do_max_length() const _NOEXCEPT; |
| 338 | }; | 338 | }; |
| 339 | 339 | ||
| 340 | template <> | 340 | template <> |
| ... | @@ -365,11 +365,11 @@ protected: | ... | @@ -365,11 +365,11 @@ protected: |
| 365 | virtual result | 365 | virtual result |
| 366 | do_unshift(state_type& __st, | 366 | do_unshift(state_type& __st, |
| 367 | extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; | 367 | extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; |
| 368 | virtual int do_encoding() const throw(); | 368 | virtual int do_encoding() const _NOEXCEPT; |
| 369 | virtual bool do_always_noconv() const throw(); | 369 | virtual bool do_always_noconv() const _NOEXCEPT; |
| 370 | virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, | 370 | virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, |
| 371 | size_t __mx) const; | 371 | size_t __mx) const; |
| 372 | virtual int do_max_length() const throw(); | 372 | virtual int do_max_length() const _NOEXCEPT; |
| 373 | }; | 373 | }; |
| 374 | 374 | ||
| 375 | template <> | 375 | template <> |
| ... | @@ -400,11 +400,11 @@ protected: | ... | @@ -400,11 +400,11 @@ protected: |
| 400 | virtual result | 400 | virtual result |
| 401 | do_unshift(state_type& __st, | 401 | do_unshift(state_type& __st, |
| 402 | extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; | 402 | extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; |
| 403 | virtual int do_encoding() const throw(); | 403 | virtual int do_encoding() const _NOEXCEPT; |
| 404 | virtual bool do_always_noconv() const throw(); | 404 | virtual bool do_always_noconv() const _NOEXCEPT; |
| 405 | virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, | 405 | virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, |
| 406 | size_t __mx) const; | 406 | size_t __mx) const; |
| 407 | virtual int do_max_length() const throw(); | 407 | virtual int do_max_length() const _NOEXCEPT; |
| 408 | }; | 408 | }; |
| 409 | 409 | ||
| 410 | template <class _Elem, unsigned long _Maxcode = 0x10ffff, | 410 | template <class _Elem, unsigned long _Maxcode = 0x10ffff, |
| ... | @@ -453,11 +453,11 @@ protected: | ... | @@ -453,11 +453,11 @@ protected: |
| 453 | virtual result | 453 | virtual result |
| 454 | do_unshift(state_type& __st, | 454 | do_unshift(state_type& __st, |
| 455 | extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; | 455 | extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; |
| 456 | virtual int do_encoding() const throw(); | 456 | virtual int do_encoding() const _NOEXCEPT; |
| 457 | virtual bool do_always_noconv() const throw(); | 457 | virtual bool do_always_noconv() const _NOEXCEPT; |
| 458 | virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, | 458 | virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, |
| 459 | size_t __mx) const; | 459 | size_t __mx) const; |
| 460 | virtual int do_max_length() const throw(); | 460 | virtual int do_max_length() const _NOEXCEPT; |
| 461 | }; | 461 | }; |
| 462 | 462 | ||
| 463 | template <> | 463 | template <> |
| ... | @@ -488,11 +488,11 @@ protected: | ... | @@ -488,11 +488,11 @@ protected: |
| 488 | virtual result | 488 | virtual result |
| 489 | do_unshift(state_type& __st, | 489 | do_unshift(state_type& __st, |
| 490 | extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; | 490 | extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; |
| 491 | virtual int do_encoding() const throw(); | 491 | virtual int do_encoding() const _NOEXCEPT; |
| 492 | virtual bool do_always_noconv() const throw(); | 492 | virtual bool do_always_noconv() const _NOEXCEPT; |
| 493 | virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, | 493 | virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, |
| 494 | size_t __mx) const; | 494 | size_t __mx) const; |
| 495 | virtual int do_max_length() const throw(); | 495 | virtual int do_max_length() const _NOEXCEPT; |
| 496 | }; | 496 | }; |
| 497 | 497 | ||
| 498 | template <> | 498 | template <> |
| ... | @@ -523,11 +523,11 @@ protected: | ... | @@ -523,11 +523,11 @@ protected: |
| 523 | virtual result | 523 | virtual result |
| 524 | do_unshift(state_type& __st, | 524 | do_unshift(state_type& __st, |
| 525 | extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; | 525 | extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; |
| 526 | virtual int do_encoding() const throw(); | 526 | virtual int do_encoding() const _NOEXCEPT; |
| 527 | virtual bool do_always_noconv() const throw(); | 527 | virtual bool do_always_noconv() const _NOEXCEPT; |
| 528 | virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, | 528 | virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, |
| 529 | size_t __mx) const; | 529 | size_t __mx) const; |
| 530 | virtual int do_max_length() const throw(); | 530 | virtual int do_max_length() const _NOEXCEPT; |
| 531 | }; | 531 | }; |
| 532 | 532 | ||
| 533 | template <class _Elem, unsigned long _Maxcode = 0x10ffff, | 533 | template <class _Elem, unsigned long _Maxcode = 0x10ffff, |
lib/libcxx/include/compare+84| ... | @@ -43,6 +43,84 @@ namespace std { | ... | @@ -43,6 +43,84 @@ namespace std { |
| 43 | template<class T> constexpr partial_ordering partial_order(const T& a, const T& b); | 43 | template<class T> constexpr partial_ordering partial_order(const T& a, const T& b); |
| 44 | template<class T> constexpr strong_equality strong_equal(const T& a, const T& b); | 44 | template<class T> constexpr strong_equality strong_equal(const T& a, const T& b); |
| 45 | template<class T> constexpr weak_equality weak_equal(const T& a, const T& b); | 45 | template<class T> constexpr weak_equality weak_equal(const T& a, const T& b); |
| 46 | |||
| 47 | // [cmp.partialord], Class partial_ordering | ||
| 48 | class partial_ordering { | ||
| 49 | public: | ||
| 50 | // valid values | ||
| 51 | static const partial_ordering less; | ||
| 52 | static const partial_ordering equivalent; | ||
| 53 | static const partial_ordering greater; | ||
| 54 | static const partial_ordering unordered; | ||
| 55 | |||
| 56 | // comparisons | ||
| 57 | friend constexpr bool operator==(partial_ordering v, unspecified) noexcept; | ||
| 58 | friend constexpr bool operator==(partial_ordering v, partial_ordering w) noexcept = default; | ||
| 59 | friend constexpr bool operator< (partial_ordering v, unspecified) noexcept; | ||
| 60 | friend constexpr bool operator> (partial_ordering v, unspecified) noexcept; | ||
| 61 | friend constexpr bool operator<=(partial_ordering v, unspecified) noexcept; | ||
| 62 | friend constexpr bool operator>=(partial_ordering v, unspecified) noexcept; | ||
| 63 | friend constexpr bool operator< (unspecified, partial_ordering v) noexcept; | ||
| 64 | friend constexpr bool operator> (unspecified, partial_ordering v) noexcept; | ||
| 65 | friend constexpr bool operator<=(unspecified, partial_ordering v) noexcept; | ||
| 66 | friend constexpr bool operator>=(unspecified, partial_ordering v) noexcept; | ||
| 67 | friend constexpr partial_ordering operator<=>(partial_ordering v, unspecified) noexcept; | ||
| 68 | friend constexpr partial_ordering operator<=>(unspecified, partial_ordering v) noexcept; | ||
| 69 | }; | ||
| 70 | |||
| 71 | // [cmp.weakord], Class weak_ordering | ||
| 72 | class weak_ordering { | ||
| 73 | public: | ||
| 74 | // valid values | ||
| 75 | static const weak_ordering less; | ||
| 76 | static const weak_ordering equivalent; | ||
| 77 | static const weak_ordering greater; | ||
| 78 | |||
| 79 | // conversions | ||
| 80 | constexpr operator partial_ordering() const noexcept; | ||
| 81 | |||
| 82 | // comparisons | ||
| 83 | friend constexpr bool operator==(weak_ordering v, unspecified) noexcept; | ||
| 84 | friend constexpr bool operator==(weak_ordering v, weak_ordering w) noexcept = default; | ||
| 85 | friend constexpr bool operator< (weak_ordering v, unspecified) noexcept; | ||
| 86 | friend constexpr bool operator> (weak_ordering v, unspecified) noexcept; | ||
| 87 | friend constexpr bool operator<=(weak_ordering v, unspecified) noexcept; | ||
| 88 | friend constexpr bool operator>=(weak_ordering v, unspecified) noexcept; | ||
| 89 | friend constexpr bool operator< (unspecified, weak_ordering v) noexcept; | ||
| 90 | friend constexpr bool operator> (unspecified, weak_ordering v) noexcept; | ||
| 91 | friend constexpr bool operator<=(unspecified, weak_ordering v) noexcept; | ||
| 92 | friend constexpr bool operator>=(unspecified, weak_ordering v) noexcept; | ||
| 93 | friend constexpr weak_ordering operator<=>(weak_ordering v, unspecified) noexcept; | ||
| 94 | friend constexpr weak_ordering operator<=>(unspecified, weak_ordering v) noexcept; | ||
| 95 | }; | ||
| 96 | |||
| 97 | // [cmp.strongord], Class strong_ordering | ||
| 98 | class strong_ordering { | ||
| 99 | public: | ||
| 100 | // valid values | ||
| 101 | static const strong_ordering less; | ||
| 102 | static const strong_ordering equal; | ||
| 103 | static const strong_ordering equivalent; | ||
| 104 | static const strong_ordering greater; | ||
| 105 | |||
| 106 | // conversions | ||
| 107 | constexpr operator partial_ordering() const noexcept; | ||
| 108 | constexpr operator weak_ordering() const noexcept; | ||
| 109 | |||
| 110 | // comparisons | ||
| 111 | friend constexpr bool operator==(strong_ordering v, unspecified) noexcept; | ||
| 112 | friend constexpr bool operator==(strong_ordering v, strong_ordering w) noexcept = default; | ||
| 113 | friend constexpr bool operator< (strong_ordering v, unspecified) noexcept; | ||
| 114 | friend constexpr bool operator> (strong_ordering v, unspecified) noexcept; | ||
| 115 | friend constexpr bool operator<=(strong_ordering v, unspecified) noexcept; | ||
| 116 | friend constexpr bool operator>=(strong_ordering v, unspecified) noexcept; | ||
| 117 | friend constexpr bool operator< (unspecified, strong_ordering v) noexcept; | ||
| 118 | friend constexpr bool operator> (unspecified, strong_ordering v) noexcept; | ||
| 119 | friend constexpr bool operator<=(unspecified, strong_ordering v) noexcept; | ||
| 120 | friend constexpr bool operator>=(unspecified, strong_ordering v) noexcept; | ||
| 121 | friend constexpr strong_ordering operator<=>(strong_ordering v, unspecified) noexcept; | ||
| 122 | friend constexpr strong_ordering operator<=>(unspecified, strong_ordering v) noexcept; | ||
| 123 | }; | ||
| 46 | } | 124 | } |
| 47 | */ | 125 | */ |
| 48 | 126 | ||
| ... | @@ -248,6 +326,8 @@ public: | ... | @@ -248,6 +326,8 @@ public: |
| 248 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, partial_ordering __v) noexcept; | 326 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, partial_ordering __v) noexcept; |
| 249 | 327 | ||
| 250 | #ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR | 328 | #ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR |
| 329 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(partial_ordering, partial_ordering) noexcept = default; | ||
| 330 | |||
| 251 | _LIBCPP_INLINE_VISIBILITY friend constexpr partial_ordering operator<=>(partial_ordering __v, _CmpUnspecifiedParam) noexcept; | 331 | _LIBCPP_INLINE_VISIBILITY friend constexpr partial_ordering operator<=>(partial_ordering __v, _CmpUnspecifiedParam) noexcept; |
| 252 | _LIBCPP_INLINE_VISIBILITY friend constexpr partial_ordering operator<=>(_CmpUnspecifiedParam, partial_ordering __v) noexcept; | 332 | _LIBCPP_INLINE_VISIBILITY friend constexpr partial_ordering operator<=>(_CmpUnspecifiedParam, partial_ordering __v) noexcept; |
| 253 | #endif | 333 | #endif |
| ... | @@ -364,6 +444,8 @@ public: | ... | @@ -364,6 +444,8 @@ public: |
| 364 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, weak_ordering __v) noexcept; | 444 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, weak_ordering __v) noexcept; |
| 365 | 445 | ||
| 366 | #ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR | 446 | #ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR |
| 447 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(weak_ordering, weak_ordering) noexcept = default; | ||
| 448 | |||
| 367 | _LIBCPP_INLINE_VISIBILITY friend constexpr weak_ordering operator<=>(weak_ordering __v, _CmpUnspecifiedParam) noexcept; | 449 | _LIBCPP_INLINE_VISIBILITY friend constexpr weak_ordering operator<=>(weak_ordering __v, _CmpUnspecifiedParam) noexcept; |
| 368 | _LIBCPP_INLINE_VISIBILITY friend constexpr weak_ordering operator<=>(_CmpUnspecifiedParam, weak_ordering __v) noexcept; | 450 | _LIBCPP_INLINE_VISIBILITY friend constexpr weak_ordering operator<=>(_CmpUnspecifiedParam, weak_ordering __v) noexcept; |
| 369 | #endif | 451 | #endif |
| ... | @@ -490,6 +572,8 @@ public: | ... | @@ -490,6 +572,8 @@ public: |
| 490 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, strong_ordering __v) noexcept; | 572 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, strong_ordering __v) noexcept; |
| 491 | 573 | ||
| 492 | #ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR | 574 | #ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR |
| 575 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(strong_ordering, strong_ordering) noexcept = default; | ||
| 576 | |||
| 493 | _LIBCPP_INLINE_VISIBILITY friend constexpr strong_ordering operator<=>(strong_ordering __v, _CmpUnspecifiedParam) noexcept; | 577 | _LIBCPP_INLINE_VISIBILITY friend constexpr strong_ordering operator<=>(strong_ordering __v, _CmpUnspecifiedParam) noexcept; |
| 494 | _LIBCPP_INLINE_VISIBILITY friend constexpr strong_ordering operator<=>(_CmpUnspecifiedParam, strong_ordering __v) noexcept; | 578 | _LIBCPP_INLINE_VISIBILITY friend constexpr strong_ordering operator<=>(_CmpUnspecifiedParam, strong_ordering __v) noexcept; |
| 495 | #endif | 579 | #endif |
lib/libcxx/include/complex+7-6| ... | @@ -243,6 +243,7 @@ template<class T, class charT, class traits> | ... | @@ -243,6 +243,7 @@ template<class T, class charT, class traits> |
| 243 | #include <type_traits> | 243 | #include <type_traits> |
| 244 | #include <stdexcept> | 244 | #include <stdexcept> |
| 245 | #include <cmath> | 245 | #include <cmath> |
| 246 | #include <iosfwd> | ||
| 246 | #include <sstream> | 247 | #include <sstream> |
| 247 | #include <version> | 248 | #include <version> |
| 248 | 249 | ||
| ... | @@ -1406,10 +1407,10 @@ operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x) | ... | @@ -1406,10 +1407,10 @@ operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x) |
| 1406 | __x = complex<_Tp>(__r, __i); | 1407 | __x = complex<_Tp>(__r, __i); |
| 1407 | } | 1408 | } |
| 1408 | else | 1409 | else |
| 1409 | __is.setstate(ios_base::failbit); | 1410 | __is.setstate(__is.failbit); |
| 1410 | } | 1411 | } |
| 1411 | else | 1412 | else |
| 1412 | __is.setstate(ios_base::failbit); | 1413 | __is.setstate(__is.failbit); |
| 1413 | } | 1414 | } |
| 1414 | else if (__c == _CharT(')')) | 1415 | else if (__c == _CharT(')')) |
| 1415 | { | 1416 | { |
| ... | @@ -1417,10 +1418,10 @@ operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x) | ... | @@ -1417,10 +1418,10 @@ operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x) |
| 1417 | __x = complex<_Tp>(__r, _Tp(0)); | 1418 | __x = complex<_Tp>(__r, _Tp(0)); |
| 1418 | } | 1419 | } |
| 1419 | else | 1420 | else |
| 1420 | __is.setstate(ios_base::failbit); | 1421 | __is.setstate(__is.failbit); |
| 1421 | } | 1422 | } |
| 1422 | else | 1423 | else |
| 1423 | __is.setstate(ios_base::failbit); | 1424 | __is.setstate(__is.failbit); |
| 1424 | } | 1425 | } |
| 1425 | else | 1426 | else |
| 1426 | { | 1427 | { |
| ... | @@ -1429,11 +1430,11 @@ operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x) | ... | @@ -1429,11 +1430,11 @@ operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x) |
| 1429 | if (!__is.fail()) | 1430 | if (!__is.fail()) |
| 1430 | __x = complex<_Tp>(__r, _Tp(0)); | 1431 | __x = complex<_Tp>(__r, _Tp(0)); |
| 1431 | else | 1432 | else |
| 1432 | __is.setstate(ios_base::failbit); | 1433 | __is.setstate(__is.failbit); |
| 1433 | } | 1434 | } |
| 1434 | } | 1435 | } |
| 1435 | else | 1436 | else |
| 1436 | __is.setstate(ios_base::failbit); | 1437 | __is.setstate(__is.failbit); |
| 1437 | return __is; | 1438 | return __is; |
| 1438 | } | 1439 | } |
| 1439 | 1440 |
lib/libcxx/include/concepts created+166| ... | @@ -0,0 +1,166 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===-------------------------- concepts ----------------------------------===// | ||
| 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_CONCEPTS | ||
| 11 | #define _LIBCPP_CONCEPTS | ||
| 12 | |||
| 13 | /* | ||
| 14 | concepts synopsis | ||
| 15 | namespace std { | ||
| 16 | // [concepts.lang], language-related concepts | ||
| 17 | // [concept.same], concept same_as | ||
| 18 | template<class T, class U> | ||
| 19 | concept same_as = see below; | ||
| 20 | |||
| 21 | // [concept.derived], concept derived_from | ||
| 22 | template<class Derived, class Base> | ||
| 23 | concept derived_from = see below; | ||
| 24 | |||
| 25 | // [concept.convertible], concept convertible_to | ||
| 26 | template<class From, class To> | ||
| 27 | concept convertible_to = see below; | ||
| 28 | |||
| 29 | // [concept.commonref], concept common_reference_with | ||
| 30 | template<class T, class U> | ||
| 31 | concept common_reference_with = see below; | ||
| 32 | |||
| 33 | // [concept.common], concept common_with | ||
| 34 | template<class T, class U> | ||
| 35 | concept common_with = see below; | ||
| 36 | |||
| 37 | // [concepts.arithmetic], arithmetic concepts | ||
| 38 | template<class T> | ||
| 39 | concept integral = see below; | ||
| 40 | template<class T> | ||
| 41 | concept signed_integral = see below; | ||
| 42 | template<class T> | ||
| 43 | concept unsigned_integral = see below; | ||
| 44 | template<class T> | ||
| 45 | concept floating_point = see below; | ||
| 46 | |||
| 47 | // [concept.assignable], concept assignable_from | ||
| 48 | template<class LHS, class RHS> | ||
| 49 | concept assignable_from = see below; | ||
| 50 | |||
| 51 | // [concept.swappable], concept swappable | ||
| 52 | namespace ranges { | ||
| 53 | inline namespace unspecified { | ||
| 54 | inline constexpr unspecified swap = unspecified; | ||
| 55 | } | ||
| 56 | } | ||
| 57 | template<class T> | ||
| 58 | concept swappable = see below; | ||
| 59 | template<class T, class U> | ||
| 60 | concept swappable_with = see below; | ||
| 61 | |||
| 62 | // [concept.destructible], concept destructible | ||
| 63 | template<class T> | ||
| 64 | concept destructible = see below; | ||
| 65 | |||
| 66 | // [concept.constructible], concept constructible_from | ||
| 67 | template<class T, class... Args> | ||
| 68 | concept constructible_from = see below; | ||
| 69 | |||
| 70 | // [concept.defaultconstructible], concept default_constructible | ||
| 71 | template<class T> | ||
| 72 | concept default_constructible = see below; | ||
| 73 | |||
| 74 | // [concept.moveconstructible], concept move_constructible | ||
| 75 | template<class T> | ||
| 76 | concept move_constructible = see below; | ||
| 77 | |||
| 78 | // [concept.copyconstructible], concept copy_constructible | ||
| 79 | template<class T> | ||
| 80 | concept copy_constructible = see below; | ||
| 81 | |||
| 82 | // [concepts.compare], comparison concepts | ||
| 83 | // [concept.boolean], concept boolean | ||
| 84 | template<class B> | ||
| 85 | concept boolean = see below; | ||
| 86 | |||
| 87 | // [concept.equalitycomparable], concept equality_comparable | ||
| 88 | template<class T> | ||
| 89 | concept equality_comparable = see below; | ||
| 90 | template<class T, class U> | ||
| 91 | concept equality_comparable_with = see below; | ||
| 92 | |||
| 93 | // [concept.totallyordered], concept totally_ordered | ||
| 94 | template<class T> | ||
| 95 | concept totally_ordered = see below; | ||
| 96 | template<class T, class U> | ||
| 97 | concept totally_ordered_with = see below; | ||
| 98 | |||
| 99 | // [concepts.object], object concepts | ||
| 100 | template<class T> | ||
| 101 | concept movable = see below; | ||
| 102 | template<class T> | ||
| 103 | concept copyable = see below; | ||
| 104 | template<class T> | ||
| 105 | concept semiregular = see below; | ||
| 106 | template<class T> | ||
| 107 | concept regular = see below; | ||
| 108 | |||
| 109 | // [concepts.callable], callable concepts | ||
| 110 | // [concept.invocable], concept invocable | ||
| 111 | template<class F, class... Args> | ||
| 112 | concept invocable = see below; | ||
| 113 | |||
| 114 | // [concept.regularinvocable], concept regular_invocable | ||
| 115 | template<class F, class... Args> | ||
| 116 | concept regular_invocable = see below; | ||
| 117 | |||
| 118 | // [concept.predicate], concept predicate | ||
| 119 | template<class F, class... Args> | ||
| 120 | concept predicate = see below; | ||
| 121 | |||
| 122 | // [concept.relation], concept relation | ||
| 123 | template<class R, class T, class U> | ||
| 124 | concept relation = see below; | ||
| 125 | |||
| 126 | // [concept.equiv], concept equivalence_relation | ||
| 127 | template<class R, class T, class U> | ||
| 128 | concept equivalence_relation = see below; | ||
| 129 | |||
| 130 | // [concept.strictweakorder], concept strict_weak_order | ||
| 131 | template<class R, class T, class U> | ||
| 132 | concept strict_weak_order = see below; | ||
| 133 | } | ||
| 134 | |||
| 135 | */ | ||
| 136 | |||
| 137 | #include <__config> | ||
| 138 | #include <type_traits> | ||
| 139 | #include <version> | ||
| 140 | |||
| 141 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 142 | #pragma GCC system_header | ||
| 143 | #endif | ||
| 144 | |||
| 145 | _LIBCPP_PUSH_MACROS | ||
| 146 | #include <__undef_macros> | ||
| 147 | |||
| 148 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 149 | |||
| 150 | #if _LIBCPP_STD_VER > 17 && defined(__cpp_concepts) && __cpp_concepts >= 201811L | ||
| 151 | |||
| 152 | // [concept.same] | ||
| 153 | |||
| 154 | template<class _Tp, class _Up> | ||
| 155 | concept __same_as_impl = _VSTD::_IsSame<_Tp, _Up>::value; | ||
| 156 | |||
| 157 | template<class _Tp, class _Up> | ||
| 158 | concept same_as = __same_as_impl<_Tp, _Up> && __same_as_impl<_Up, _Tp>; | ||
| 159 | |||
| 160 | #endif //_LIBCPP_STD_VER > 17 && defined(__cpp_concepts) && __cpp_concepts >= 201811L | ||
| 161 | |||
| 162 | _LIBCPP_END_NAMESPACE_STD | ||
| 163 | |||
| 164 | _LIBCPP_POP_MACROS | ||
| 165 | |||
| 166 | #endif // _LIBCPP_CONCEPTS | ||
lib/libcxx/include/cstddef+56-8| ... | @@ -25,7 +25,7 @@ Types: | ... | @@ -25,7 +25,7 @@ Types: |
| 25 | 25 | ||
| 26 | ptrdiff_t | 26 | ptrdiff_t |
| 27 | size_t | 27 | size_t |
| 28 | max_align_t | 28 | max_align_t // C++11 |
| 29 | nullptr_t | 29 | nullptr_t |
| 30 | byte // C++17 | 30 | byte // C++17 |
| 31 | 31 | ||
| ... | @@ -49,12 +49,34 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -49,12 +49,34 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 49 | using ::ptrdiff_t; | 49 | using ::ptrdiff_t; |
| 50 | using ::size_t; | 50 | using ::size_t; |
| 51 | 51 | ||
| 52 | #if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T) || \ | 52 | #if !defined(_LIBCPP_CXX03_LANG) |
| 53 | defined(__DEFINED_max_align_t) || defined(__NetBSD__) | ||
| 54 | // Re-use the compiler's <stddef.h> max_align_t where possible. | ||
| 55 | using ::max_align_t; | 53 | using ::max_align_t; |
| 56 | #else | 54 | #endif |
| 57 | typedef long double max_align_t; | 55 | |
| 56 | template <class _Tp> struct __libcpp_is_integral { enum { value = 0 }; }; | ||
| 57 | template <> struct __libcpp_is_integral<bool> { enum { value = 1 }; }; | ||
| 58 | template <> struct __libcpp_is_integral<char> { enum { value = 1 }; }; | ||
| 59 | template <> struct __libcpp_is_integral<signed char> { enum { value = 1 }; }; | ||
| 60 | template <> struct __libcpp_is_integral<unsigned char> { enum { value = 1 }; }; | ||
| 61 | template <> struct __libcpp_is_integral<wchar_t> { enum { value = 1 }; }; | ||
| 62 | #ifndef _LIBCPP_NO_HAS_CHAR8_T | ||
| 63 | template <> struct __libcpp_is_integral<char8_t> { enum { value = 1 }; }; | ||
| 64 | #endif | ||
| 65 | #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS | ||
| 66 | template <> struct __libcpp_is_integral<char16_t> { enum { value = 1 }; }; | ||
| 67 | template <> struct __libcpp_is_integral<char32_t> { enum { value = 1 }; }; | ||
| 68 | #endif // _LIBCPP_HAS_NO_UNICODE_CHARS | ||
| 69 | template <> struct __libcpp_is_integral<short> { enum { value = 1 }; }; | ||
| 70 | template <> struct __libcpp_is_integral<unsigned short> { enum { value = 1 }; }; | ||
| 71 | template <> struct __libcpp_is_integral<int> { enum { value = 1 }; }; | ||
| 72 | template <> struct __libcpp_is_integral<unsigned int> { enum { value = 1 }; }; | ||
| 73 | template <> struct __libcpp_is_integral<long> { enum { value = 1 }; }; | ||
| 74 | template <> struct __libcpp_is_integral<unsigned long> { enum { value = 1 }; }; | ||
| 75 | template <> struct __libcpp_is_integral<long long> { enum { value = 1 }; }; | ||
| 76 | template <> struct __libcpp_is_integral<unsigned long long> { enum { value = 1 }; }; | ||
| 77 | #ifndef _LIBCPP_HAS_NO_INT128 | ||
| 78 | template <> struct __libcpp_is_integral<__int128_t> { enum { value = 1 }; }; | ||
| 79 | template <> struct __libcpp_is_integral<__uint128_t> { enum { value = 1 }; }; | ||
| 58 | #endif | 80 | #endif |
| 59 | 81 | ||
| 60 | _LIBCPP_END_NAMESPACE_STD | 82 | _LIBCPP_END_NAMESPACE_STD |
| ... | @@ -64,6 +86,11 @@ namespace std // purposefully not versioned | ... | @@ -64,6 +86,11 @@ namespace std // purposefully not versioned |
| 64 | { | 86 | { |
| 65 | enum class byte : unsigned char {}; | 87 | enum class byte : unsigned char {}; |
| 66 | 88 | ||
| 89 | |||
| 90 | template <bool> struct __enable_if_integral_imp {}; | ||
| 91 | template <> struct __enable_if_integral_imp<true> { using type = byte; }; | ||
| 92 | template <class _Tp> using _EnableByteOverload = typename __enable_if_integral_imp<__libcpp_is_integral<_Tp>::value>::type; | ||
| 93 | |||
| 67 | constexpr byte operator| (byte __lhs, byte __rhs) noexcept | 94 | constexpr byte operator| (byte __lhs, byte __rhs) noexcept |
| 68 | { | 95 | { |
| 69 | return static_cast<byte>( | 96 | return static_cast<byte>( |
| ... | @@ -104,10 +131,31 @@ constexpr byte operator~ (byte __b) noexcept | ... | @@ -104,10 +131,31 @@ constexpr byte operator~ (byte __b) noexcept |
| 104 | ~static_cast<unsigned int>(__b) | 131 | ~static_cast<unsigned int>(__b) |
| 105 | )); | 132 | )); |
| 106 | } | 133 | } |
| 107 | 134 | template <class _Integer> | |
| 135 | constexpr _EnableByteOverload<_Integer> & | ||
| 136 | operator<<=(byte& __lhs, _Integer __shift) noexcept | ||
| 137 | { return __lhs = __lhs << __shift; } | ||
| 138 | |||
| 139 | template <class _Integer> | ||
| 140 | constexpr _EnableByteOverload<_Integer> | ||
| 141 | operator<< (byte __lhs, _Integer __shift) noexcept | ||
| 142 | { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) << __shift)); } | ||
| 143 | |||
| 144 | template <class _Integer> | ||
| 145 | constexpr _EnableByteOverload<_Integer> & | ||
| 146 | operator>>=(byte& __lhs, _Integer __shift) noexcept | ||
| 147 | { return __lhs = __lhs >> __shift; } | ||
| 148 | |||
| 149 | template <class _Integer> | ||
| 150 | constexpr _EnableByteOverload<_Integer> | ||
| 151 | operator>> (byte __lhs, _Integer __shift) noexcept | ||
| 152 | { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) >> __shift)); } | ||
| 153 | |||
| 154 | template <class _Integer, class = _EnableByteOverload<_Integer> > | ||
| 155 | constexpr _Integer | ||
| 156 | to_integer(byte __b) noexcept { return static_cast<_Integer>(__b); } | ||
| 108 | } | 157 | } |
| 109 | 158 | ||
| 110 | #include <type_traits> // rest of byte | ||
| 111 | #endif | 159 | #endif |
| 112 | 160 | ||
| 113 | #endif // _LIBCPP_CSTDDEF | 161 | #endif // _LIBCPP_CSTDDEF |
lib/libcxx/include/cstdio+4| ... | @@ -131,9 +131,13 @@ using ::putc; | ... | @@ -131,9 +131,13 @@ using ::putc; |
| 131 | using ::ungetc; | 131 | using ::ungetc; |
| 132 | using ::fread; | 132 | using ::fread; |
| 133 | using ::fwrite; | 133 | using ::fwrite; |
| 134 | #ifndef _LIBCPP_HAS_NO_FGETPOS_FSETPOS | ||
| 134 | using ::fgetpos; | 135 | using ::fgetpos; |
| 136 | #endif | ||
| 135 | using ::fseek; | 137 | using ::fseek; |
| 138 | #ifndef _LIBCPP_HAS_NO_FGETPOS_FSETPOS | ||
| 136 | using ::fsetpos; | 139 | using ::fsetpos; |
| 140 | #endif | ||
| 137 | using ::ftell; | 141 | using ::ftell; |
| 138 | using ::rewind; | 142 | using ::rewind; |
| 139 | using ::clearerr; | 143 | using ::clearerr; |
lib/libcxx/include/deque+16-8| ... | @@ -150,9 +150,11 @@ template <class T, class Allocator> | ... | @@ -150,9 +150,11 @@ template <class T, class Allocator> |
| 150 | noexcept(noexcept(x.swap(y))); | 150 | noexcept(noexcept(x.swap(y))); |
| 151 | 151 | ||
| 152 | template <class T, class Allocator, class U> | 152 | template <class T, class Allocator, class U> |
| 153 | void erase(deque<T, Allocator>& c, const U& value); // C++20 | 153 | typename deque<T, Allocator>::size_type |
| 154 | erase(deque<T, Allocator>& c, const U& value); // C++20 | ||
| 154 | template <class T, class Allocator, class Predicate> | 155 | template <class T, class Allocator, class Predicate> |
| 155 | void erase_if(deque<T, Allocator>& c, Predicate pred); // C++20 | 156 | typename deque<T, Allocator>::size_type |
| 157 | erase_if(deque<T, Allocator>& c, Predicate pred); // C++20 | ||
| 156 | 158 | ||
| 157 | } // std | 159 | } // std |
| 158 | 160 | ||
| ... | @@ -3021,14 +3023,20 @@ swap(deque<_Tp, _Allocator>& __x, deque<_Tp, _Allocator>& __y) | ... | @@ -3021,14 +3023,20 @@ swap(deque<_Tp, _Allocator>& __x, deque<_Tp, _Allocator>& __y) |
| 3021 | 3023 | ||
| 3022 | #if _LIBCPP_STD_VER > 17 | 3024 | #if _LIBCPP_STD_VER > 17 |
| 3023 | template <class _Tp, class _Allocator, class _Up> | 3025 | template <class _Tp, class _Allocator, class _Up> |
| 3024 | inline _LIBCPP_INLINE_VISIBILITY | 3026 | inline _LIBCPP_INLINE_VISIBILITY typename deque<_Tp, _Allocator>::size_type |
| 3025 | void erase(deque<_Tp, _Allocator>& __c, const _Up& __v) | 3027 | erase(deque<_Tp, _Allocator>& __c, const _Up& __v) { |
| 3026 | { __c.erase(_VSTD::remove(__c.begin(), __c.end(), __v), __c.end()); } | 3028 | auto __old_size = __c.size(); |
| 3029 | __c.erase(_VSTD::remove(__c.begin(), __c.end(), __v), __c.end()); | ||
| 3030 | return __old_size - __c.size(); | ||
| 3031 | } | ||
| 3027 | 3032 | ||
| 3028 | template <class _Tp, class _Allocator, class _Predicate> | 3033 | template <class _Tp, class _Allocator, class _Predicate> |
| 3029 | inline _LIBCPP_INLINE_VISIBILITY | 3034 | inline _LIBCPP_INLINE_VISIBILITY typename deque<_Tp, _Allocator>::size_type |
| 3030 | void erase_if(deque<_Tp, _Allocator>& __c, _Predicate __pred) | 3035 | erase_if(deque<_Tp, _Allocator>& __c, _Predicate __pred) { |
| 3031 | { __c.erase(_VSTD::remove_if(__c.begin(), __c.end(), __pred), __c.end()); } | 3036 | auto __old_size = __c.size(); |
| 3037 | __c.erase(_VSTD::remove_if(__c.begin(), __c.end(), __pred), __c.end()); | ||
| 3038 | return __old_size - __c.size(); | ||
| 3039 | } | ||
| 3032 | #endif | 3040 | #endif |
| 3033 | 3041 | ||
| 3034 | 3042 |
lib/libcxx/include/exception+2| ... | @@ -98,6 +98,8 @@ class _LIBCPP_EXCEPTION_ABI exception | ... | @@ -98,6 +98,8 @@ class _LIBCPP_EXCEPTION_ABI exception |
| 98 | { | 98 | { |
| 99 | public: | 99 | public: |
| 100 | _LIBCPP_INLINE_VISIBILITY exception() _NOEXCEPT {} | 100 | _LIBCPP_INLINE_VISIBILITY exception() _NOEXCEPT {} |
| 101 | _LIBCPP_INLINE_VISIBILITY exception(const exception&) _NOEXCEPT = default; | ||
| 102 | |||
| 101 | virtual ~exception() _NOEXCEPT; | 103 | virtual ~exception() _NOEXCEPT; |
| 102 | virtual const char* what() const _NOEXCEPT; | 104 | virtual const char* what() const _NOEXCEPT; |
| 103 | }; | 105 | }; |
lib/libcxx/include/filesystem+1| ... | @@ -1346,6 +1346,7 @@ public: | ... | @@ -1346,6 +1346,7 @@ public: |
| 1346 | _LIBCPP_INLINE_VISIBILITY | 1346 | _LIBCPP_INLINE_VISIBILITY |
| 1347 | const path& path2() const noexcept { return __storage_->__p2_; } | 1347 | const path& path2() const noexcept { return __storage_->__p2_; } |
| 1348 | 1348 | ||
| 1349 | filesystem_error(const filesystem_error&) = default; | ||
| 1349 | ~filesystem_error() override; // key function | 1350 | ~filesystem_error() override; // key function |
| 1350 | 1351 | ||
| 1351 | _LIBCPP_INLINE_VISIBILITY | 1352 | _LIBCPP_INLINE_VISIBILITY |
lib/libcxx/include/forward_list+12-6| ... | @@ -169,9 +169,11 @@ template <class T, class Allocator> | ... | @@ -169,9 +169,11 @@ template <class T, class Allocator> |
| 169 | noexcept(noexcept(x.swap(y))); | 169 | noexcept(noexcept(x.swap(y))); |
| 170 | 170 | ||
| 171 | template <class T, class Allocator, class U> | 171 | template <class T, class Allocator, class U> |
| 172 | void erase(forward_list<T, Allocator>& c, const U& value); // C++20 | 172 | typename forward_list<T, Allocator>::size_type |
| 173 | erase(forward_list<T, Allocator>& c, const U& value); // C++20 | ||
| 173 | template <class T, class Allocator, class Predicate> | 174 | template <class T, class Allocator, class Predicate> |
| 174 | void erase_if(forward_list<T, Allocator>& c, Predicate pred); // C++20 | 175 | typename forward_list<T, Allocator>::size_type |
| 176 | erase_if(forward_list<T, Allocator>& c, Predicate pred); // C++20 | ||
| 175 | 177 | ||
| 176 | } // std | 178 | } // std |
| 177 | 179 | ||
| ... | @@ -1765,13 +1767,17 @@ swap(forward_list<_Tp, _Alloc>& __x, forward_list<_Tp, _Alloc>& __y) | ... | @@ -1765,13 +1767,17 @@ swap(forward_list<_Tp, _Alloc>& __x, forward_list<_Tp, _Alloc>& __y) |
| 1765 | #if _LIBCPP_STD_VER > 17 | 1767 | #if _LIBCPP_STD_VER > 17 |
| 1766 | template <class _Tp, class _Allocator, class _Predicate> | 1768 | template <class _Tp, class _Allocator, class _Predicate> |
| 1767 | inline _LIBCPP_INLINE_VISIBILITY | 1769 | inline _LIBCPP_INLINE_VISIBILITY |
| 1768 | void erase_if(forward_list<_Tp, _Allocator>& __c, _Predicate __pred) | 1770 | typename forward_list<_Tp, _Allocator>::size_type |
| 1769 | { __c.remove_if(__pred); } | 1771 | erase_if(forward_list<_Tp, _Allocator>& __c, _Predicate __pred) { |
| 1772 | return __c.remove_if(__pred); | ||
| 1773 | } | ||
| 1770 | 1774 | ||
| 1771 | template <class _Tp, class _Allocator, class _Up> | 1775 | template <class _Tp, class _Allocator, class _Up> |
| 1772 | inline _LIBCPP_INLINE_VISIBILITY | 1776 | inline _LIBCPP_INLINE_VISIBILITY |
| 1773 | void erase(forward_list<_Tp, _Allocator>& __c, const _Up& __v) | 1777 | typename forward_list<_Tp, _Allocator>::size_type |
| 1774 | { _VSTD::erase_if(__c, [&](auto& __elem) { return __elem == __v; }); } | 1778 | erase(forward_list<_Tp, _Allocator>& __c, const _Up& __v) { |
| 1779 | return _VSTD::erase_if(__c, [&](auto& __elem) { return __elem == __v; }); | ||
| 1780 | } | ||
| 1775 | #endif | 1781 | #endif |
| 1776 | 1782 | ||
| 1777 | _LIBCPP_END_NAMESPACE_STD | 1783 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/functional+112-25| ... | @@ -508,6 +508,10 @@ POLICY: For non-variadic implementations, the number of arguments is limited | ... | @@ -508,6 +508,10 @@ POLICY: For non-variadic implementations, the number of arguments is limited |
| 508 | 508 | ||
| 509 | #include <__functional_base> | 509 | #include <__functional_base> |
| 510 | 510 | ||
| 511 | #if defined(_LIBCPP_HAS_BLOCKS_RUNTIME) && !defined(_LIBCPP_HAS_OBJC_ARC) | ||
| 512 | #include <Block.h> | ||
| 513 | #endif | ||
| 514 | |||
| 511 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 515 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 512 | #pragma GCC system_header | 516 | #pragma GCC system_header |
| 513 | #endif | 517 | #endif |
| ... | @@ -1434,7 +1438,14 @@ void __throw_bad_function_call() | ... | @@ -1434,7 +1438,14 @@ void __throw_bad_function_call() |
| 1434 | #endif | 1438 | #endif |
| 1435 | } | 1439 | } |
| 1436 | 1440 | ||
| 1437 | template<class _Fp> class _LIBCPP_TEMPLATE_VIS function; // undefined | 1441 | #if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS) && __has_attribute(deprecated) |
| 1442 | # define _LIBCPP_DEPRECATED_CXX03_FUNCTION \ | ||
| 1443 | __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type"))) | ||
| 1444 | #else | ||
| 1445 | # define _LIBCPP_DEPRECATED_CXX03_FUNCTION /* nothing */ | ||
| 1446 | #endif | ||
| 1447 | |||
| 1448 | template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined | ||
| 1438 | 1449 | ||
| 1439 | namespace __function | 1450 | namespace __function |
| 1440 | { | 1451 | { |
| ... | @@ -1477,6 +1488,12 @@ template <class _Fp> | ... | @@ -1477,6 +1488,12 @@ template <class _Fp> |
| 1477 | _LIBCPP_INLINE_VISIBILITY | 1488 | _LIBCPP_INLINE_VISIBILITY |
| 1478 | bool __not_null(function<_Fp> const& __f) { return !!__f; } | 1489 | bool __not_null(function<_Fp> const& __f) { return !!__f; } |
| 1479 | 1490 | ||
| 1491 | #ifdef _LIBCPP_HAS_EXTENSION_BLOCKS | ||
| 1492 | template <class _Rp, class ..._Args> | ||
| 1493 | _LIBCPP_INLINE_VISIBILITY | ||
| 1494 | bool __not_null(_Rp (^__p)(_Args...)) { return __p; } | ||
| 1495 | #endif | ||
| 1496 | |||
| 1480 | } // namespace __function | 1497 | } // namespace __function |
| 1481 | 1498 | ||
| 1482 | #ifndef _LIBCPP_CXX03_LANG | 1499 | #ifndef _LIBCPP_CXX03_LANG |
| ... | @@ -1611,7 +1628,7 @@ public: | ... | @@ -1611,7 +1628,7 @@ public: |
| 1611 | 1628 | ||
| 1612 | // __base provides an abstract interface for copyable functors. | 1629 | // __base provides an abstract interface for copyable functors. |
| 1613 | 1630 | ||
| 1614 | template<class _Fp> class __base; | 1631 | template<class _Fp> class _LIBCPP_TEMPLATE_VIS __base; |
| 1615 | 1632 | ||
| 1616 | template<class _Rp, class ..._ArgTypes> | 1633 | template<class _Rp, class ..._ArgTypes> |
| 1617 | class __base<_Rp(_ArgTypes...)> | 1634 | class __base<_Rp(_ArgTypes...)> |
| ... | @@ -2238,6 +2255,72 @@ template <class _Rp, class... _ArgTypes> class __policy_func<_Rp(_ArgTypes...)> | ... | @@ -2238,6 +2255,72 @@ template <class _Rp, class... _ArgTypes> class __policy_func<_Rp(_ArgTypes...)> |
| 2238 | #endif // _LIBCPP_NO_RTTI | 2255 | #endif // _LIBCPP_NO_RTTI |
| 2239 | }; | 2256 | }; |
| 2240 | 2257 | ||
| 2258 | #if defined(_LIBCPP_HAS_BLOCKS_RUNTIME) && !defined(_LIBCPP_HAS_OBJC_ARC) | ||
| 2259 | |||
| 2260 | template<class _Rp1, class ..._ArgTypes1, class _Alloc, class _Rp, class ..._ArgTypes> | ||
| 2261 | class __func<_Rp1(^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)> | ||
| 2262 | : public __base<_Rp(_ArgTypes...)> | ||
| 2263 | { | ||
| 2264 | typedef _Rp1(^__block_type)(_ArgTypes1...); | ||
| 2265 | __block_type __f_; | ||
| 2266 | |||
| 2267 | public: | ||
| 2268 | _LIBCPP_INLINE_VISIBILITY | ||
| 2269 | explicit __func(__block_type const& __f) | ||
| 2270 | : __f_(__f ? Block_copy(__f) : (__block_type)0) | ||
| 2271 | { } | ||
| 2272 | |||
| 2273 | // [TODO] add && to save on a retain | ||
| 2274 | |||
| 2275 | _LIBCPP_INLINE_VISIBILITY | ||
| 2276 | explicit __func(__block_type __f, const _Alloc& /* unused */) | ||
| 2277 | : __f_(__f ? Block_copy(__f) : (__block_type)0) | ||
| 2278 | { } | ||
| 2279 | |||
| 2280 | virtual __base<_Rp(_ArgTypes...)>* __clone() const { | ||
| 2281 | _LIBCPP_ASSERT(false, | ||
| 2282 | "Block pointers are just pointers, so they should always fit into " | ||
| 2283 | "std::function's small buffer optimization. This function should " | ||
| 2284 | "never be invoked."); | ||
| 2285 | return nullptr; | ||
| 2286 | } | ||
| 2287 | |||
| 2288 | virtual void __clone(__base<_Rp(_ArgTypes...)>* __p) const { | ||
| 2289 | ::new (__p) __func(__f_); | ||
| 2290 | } | ||
| 2291 | |||
| 2292 | virtual void destroy() _NOEXCEPT { | ||
| 2293 | if (__f_) | ||
| 2294 | Block_release(__f_); | ||
| 2295 | __f_ = 0; | ||
| 2296 | } | ||
| 2297 | |||
| 2298 | virtual void destroy_deallocate() _NOEXCEPT { | ||
| 2299 | _LIBCPP_ASSERT(false, | ||
| 2300 | "Block pointers are just pointers, so they should always fit into " | ||
| 2301 | "std::function's small buffer optimization. This function should " | ||
| 2302 | "never be invoked."); | ||
| 2303 | } | ||
| 2304 | |||
| 2305 | virtual _Rp operator()(_ArgTypes&& ... __arg) { | ||
| 2306 | return __invoke(__f_, _VSTD::forward<_ArgTypes>(__arg)...); | ||
| 2307 | } | ||
| 2308 | |||
| 2309 | #ifndef _LIBCPP_NO_RTTI | ||
| 2310 | virtual const void* target(type_info const& __ti) const _NOEXCEPT { | ||
| 2311 | if (__ti == typeid(__func::__block_type)) | ||
| 2312 | return &__f_; | ||
| 2313 | return (const void*)nullptr; | ||
| 2314 | } | ||
| 2315 | |||
| 2316 | virtual const std::type_info& target_type() const _NOEXCEPT { | ||
| 2317 | return typeid(__func::__block_type); | ||
| 2318 | } | ||
| 2319 | #endif // _LIBCPP_NO_RTTI | ||
| 2320 | }; | ||
| 2321 | |||
| 2322 | #endif // _LIBCPP_HAS_EXTENSION_BLOCKS && !_LIBCPP_HAS_OBJC_ARC | ||
| 2323 | |||
| 2241 | } // __function | 2324 | } // __function |
| 2242 | 2325 | ||
| 2243 | template<class _Rp, class ..._ArgTypes> | 2326 | template<class _Rp, class ..._ArgTypes> |
| ... | @@ -2255,14 +2338,14 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)> | ... | @@ -2255,14 +2338,14 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)> |
| 2255 | 2338 | ||
| 2256 | template <class _Fp, bool = _And< | 2339 | template <class _Fp, bool = _And< |
| 2257 | _IsNotSame<__uncvref_t<_Fp>, function>, | 2340 | _IsNotSame<__uncvref_t<_Fp>, function>, |
| 2258 | __invokable<_Fp&, _ArgTypes...> | 2341 | __invokable<_Fp, _ArgTypes...> |
| 2259 | >::value> | 2342 | >::value> |
| 2260 | struct __callable; | 2343 | struct __callable; |
| 2261 | template <class _Fp> | 2344 | template <class _Fp> |
| 2262 | struct __callable<_Fp, true> | 2345 | struct __callable<_Fp, true> |
| 2263 | { | 2346 | { |
| 2264 | static const bool value = is_same<void, _Rp>::value || | 2347 | static const bool value = is_same<void, _Rp>::value || |
| 2265 | is_convertible<typename __invoke_of<_Fp&, _ArgTypes...>::type, | 2348 | is_convertible<typename __invoke_of<_Fp, _ArgTypes...>::type, |
| 2266 | _Rp>::value; | 2349 | _Rp>::value; |
| 2267 | }; | 2350 | }; |
| 2268 | template <class _Fp> | 2351 | template <class _Fp> |
| ... | @@ -2272,7 +2355,7 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)> | ... | @@ -2272,7 +2355,7 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)> |
| 2272 | }; | 2355 | }; |
| 2273 | 2356 | ||
| 2274 | template <class _Fp> | 2357 | template <class _Fp> |
| 2275 | using _EnableIfCallable = typename enable_if<__callable<_Fp>::value>::type; | 2358 | using _EnableIfLValueCallable = typename enable_if<__callable<_Fp&>::value>::type; |
| 2276 | public: | 2359 | public: |
| 2277 | typedef _Rp result_type; | 2360 | typedef _Rp result_type; |
| 2278 | 2361 | ||
| ... | @@ -2283,7 +2366,7 @@ public: | ... | @@ -2283,7 +2366,7 @@ public: |
| 2283 | function(nullptr_t) _NOEXCEPT {} | 2366 | function(nullptr_t) _NOEXCEPT {} |
| 2284 | function(const function&); | 2367 | function(const function&); |
| 2285 | function(function&&) _NOEXCEPT; | 2368 | function(function&&) _NOEXCEPT; |
| 2286 | template<class _Fp, class = _EnableIfCallable<_Fp>> | 2369 | template<class _Fp, class = _EnableIfLValueCallable<_Fp>> |
| 2287 | function(_Fp); | 2370 | function(_Fp); |
| 2288 | 2371 | ||
| 2289 | #if _LIBCPP_STD_VER <= 14 | 2372 | #if _LIBCPP_STD_VER <= 14 |
| ... | @@ -2297,14 +2380,14 @@ public: | ... | @@ -2297,14 +2380,14 @@ public: |
| 2297 | function(allocator_arg_t, const _Alloc&, const function&); | 2380 | function(allocator_arg_t, const _Alloc&, const function&); |
| 2298 | template<class _Alloc> | 2381 | template<class _Alloc> |
| 2299 | function(allocator_arg_t, const _Alloc&, function&&); | 2382 | function(allocator_arg_t, const _Alloc&, function&&); |
| 2300 | template<class _Fp, class _Alloc, class = _EnableIfCallable<_Fp>> | 2383 | template<class _Fp, class _Alloc, class = _EnableIfLValueCallable<_Fp>> |
| 2301 | function(allocator_arg_t, const _Alloc& __a, _Fp __f); | 2384 | function(allocator_arg_t, const _Alloc& __a, _Fp __f); |
| 2302 | #endif | 2385 | #endif |
| 2303 | 2386 | ||
| 2304 | function& operator=(const function&); | 2387 | function& operator=(const function&); |
| 2305 | function& operator=(function&&) _NOEXCEPT; | 2388 | function& operator=(function&&) _NOEXCEPT; |
| 2306 | function& operator=(nullptr_t) _NOEXCEPT; | 2389 | function& operator=(nullptr_t) _NOEXCEPT; |
| 2307 | template<class _Fp, class = _EnableIfCallable<_Fp>> | 2390 | template<class _Fp, class = _EnableIfLValueCallable<typename decay<_Fp>::type>> |
| 2308 | function& operator=(_Fp&&); | 2391 | function& operator=(_Fp&&); |
| 2309 | 2392 | ||
| 2310 | ~function(); | 2393 | ~function(); |
| ... | @@ -2967,14 +3050,14 @@ __search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, | ... | @@ -2967,14 +3050,14 @@ __search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, |
| 2967 | forward_iterator_tag, forward_iterator_tag) | 3050 | forward_iterator_tag, forward_iterator_tag) |
| 2968 | { | 3051 | { |
| 2969 | if (__first2 == __last2) | 3052 | if (__first2 == __last2) |
| 2970 | return make_pair(__first1, __first1); // Everything matches an empty sequence | 3053 | return _VSTD::make_pair(__first1, __first1); // Everything matches an empty sequence |
| 2971 | while (true) | 3054 | while (true) |
| 2972 | { | 3055 | { |
| 2973 | // Find first element in sequence 1 that matchs *__first2, with a mininum of loop checks | 3056 | // Find first element in sequence 1 that matchs *__first2, with a mininum of loop checks |
| 2974 | while (true) | 3057 | while (true) |
| 2975 | { | 3058 | { |
| 2976 | if (__first1 == __last1) // return __last1 if no element matches *__first2 | 3059 | if (__first1 == __last1) // return __last1 if no element matches *__first2 |
| 2977 | return make_pair(__last1, __last1); | 3060 | return _VSTD::make_pair(__last1, __last1); |
| 2978 | if (__pred(*__first1, *__first2)) | 3061 | if (__pred(*__first1, *__first2)) |
| 2979 | break; | 3062 | break; |
| 2980 | ++__first1; | 3063 | ++__first1; |
| ... | @@ -2985,9 +3068,9 @@ __search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, | ... | @@ -2985,9 +3068,9 @@ __search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, |
| 2985 | while (true) | 3068 | while (true) |
| 2986 | { | 3069 | { |
| 2987 | if (++__m2 == __last2) // If pattern exhausted, __first1 is the answer (works for 1 element pattern) | 3070 | if (++__m2 == __last2) // If pattern exhausted, __first1 is the answer (works for 1 element pattern) |
| 2988 | return make_pair(__first1, __m1); | 3071 | return _VSTD::make_pair(__first1, __m1); |
| 2989 | if (++__m1 == __last1) // Otherwise if source exhaused, pattern not found | 3072 | if (++__m1 == __last1) // Otherwise if source exhaused, pattern not found |
| 2990 | return make_pair(__last1, __last1); | 3073 | return _VSTD::make_pair(__last1, __last1); |
| 2991 | if (!__pred(*__m1, *__m2)) // if there is a mismatch, restart with a new __first1 | 3074 | if (!__pred(*__m1, *__m2)) // if there is a mismatch, restart with a new __first1 |
| 2992 | { | 3075 | { |
| 2993 | ++__first1; | 3076 | ++__first1; |
| ... | @@ -3009,10 +3092,10 @@ __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, | ... | @@ -3009,10 +3092,10 @@ __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, |
| 3009 | // Take advantage of knowing source and pattern lengths. Stop short when source is smaller than pattern | 3092 | // Take advantage of knowing source and pattern lengths. Stop short when source is smaller than pattern |
| 3010 | const _D2 __len2 = __last2 - __first2; | 3093 | const _D2 __len2 = __last2 - __first2; |
| 3011 | if (__len2 == 0) | 3094 | if (__len2 == 0) |
| 3012 | return make_pair(__first1, __first1); | 3095 | return _VSTD::make_pair(__first1, __first1); |
| 3013 | const _D1 __len1 = __last1 - __first1; | 3096 | const _D1 __len1 = __last1 - __first1; |
| 3014 | if (__len1 < __len2) | 3097 | if (__len1 < __len2) |
| 3015 | return make_pair(__last1, __last1); | 3098 | return _VSTD::make_pair(__last1, __last1); |
| 3016 | const _RandomAccessIterator1 __s = __last1 - (__len2 - 1); // Start of pattern match can't go beyond here | 3099 | const _RandomAccessIterator1 __s = __last1 - (__len2 - 1); // Start of pattern match can't go beyond here |
| 3017 | 3100 | ||
| 3018 | while (true) | 3101 | while (true) |
| ... | @@ -3020,7 +3103,7 @@ __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, | ... | @@ -3020,7 +3103,7 @@ __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, |
| 3020 | while (true) | 3103 | while (true) |
| 3021 | { | 3104 | { |
| 3022 | if (__first1 == __s) | 3105 | if (__first1 == __s) |
| 3023 | return make_pair(__last1, __last1); | 3106 | return _VSTD::make_pair(__last1, __last1); |
| 3024 | if (__pred(*__first1, *__first2)) | 3107 | if (__pred(*__first1, *__first2)) |
| 3025 | break; | 3108 | break; |
| 3026 | ++__first1; | 3109 | ++__first1; |
| ... | @@ -3031,7 +3114,7 @@ __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, | ... | @@ -3031,7 +3114,7 @@ __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, |
| 3031 | while (true) | 3114 | while (true) |
| 3032 | { | 3115 | { |
| 3033 | if (++__m2 == __last2) | 3116 | if (++__m2 == __last2) |
| 3034 | return make_pair(__first1, __first1 + __len2); | 3117 | return _VSTD::make_pair(__first1, __first1 + __len2); |
| 3035 | ++__m1; // no need to check range on __m1 because __s guarantees we have enough source | 3118 | ++__m1; // no need to check range on __m1 because __s guarantees we have enough source |
| 3036 | if (!__pred(*__m1, *__m2)) | 3119 | if (!__pred(*__m1, *__m2)) |
| 3037 | { | 3120 | { |
| ... | @@ -3080,15 +3163,19 @@ using unwrap_ref_decay_t = typename unwrap_ref_decay<_Tp>::type; | ... | @@ -3080,15 +3163,19 @@ using unwrap_ref_decay_t = typename unwrap_ref_decay<_Tp>::type; |
| 3080 | #endif // > C++17 | 3163 | #endif // > C++17 |
| 3081 | 3164 | ||
| 3082 | template <class _Container, class _Predicate> | 3165 | template <class _Container, class _Predicate> |
| 3083 | inline void __libcpp_erase_if_container( _Container& __c, _Predicate __pred) | 3166 | inline typename _Container::size_type |
| 3084 | { | 3167 | __libcpp_erase_if_container(_Container& __c, _Predicate __pred) { |
| 3085 | 	for (typename _Container::iterator __iter = __c.begin(), __last = __c.end(); __iter != __last;) | 3168 | typename _Container::size_type __old_size = __c.size(); |
| 3086 | 	{ | 3169 | |
| 3087 | 		if (__pred(*__iter)) | 3170 | const typename _Container::iterator __last = __c.end(); |
| 3088 | 			__iter = __c.erase(__iter); | 3171 | for (typename _Container::iterator __iter = __c.begin(); __iter != __last;) { |
| 3089 | 		else | 3172 | if (__pred(*__iter)) |
| 3090 | 			++__iter; | 3173 | __iter = __c.erase(__iter); |
| 3091 | 	} | 3174 | else |
| 3175 | ++__iter; | ||
| 3176 | } | ||
| 3177 | |||
| 3178 | return __old_size - __c.size(); | ||
| 3092 | } | 3179 | } |
| 3093 | 3180 | ||
| 3094 | _LIBCPP_END_NAMESPACE_STD | 3181 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/future+1| ... | @@ -506,6 +506,7 @@ public: | ... | @@ -506,6 +506,7 @@ public: |
| 506 | _LIBCPP_INLINE_VISIBILITY | 506 | _LIBCPP_INLINE_VISIBILITY |
| 507 | const error_code& code() const _NOEXCEPT {return __ec_;} | 507 | const error_code& code() const _NOEXCEPT {return __ec_;} |
| 508 | 508 | ||
| 509 | future_error(const future_error&) _NOEXCEPT = default; | ||
| 509 | virtual ~future_error() _NOEXCEPT; | 510 | virtual ~future_error() _NOEXCEPT; |
| 510 | }; | 511 | }; |
| 511 | 512 |
lib/libcxx/include/ios+26-25| ... | @@ -431,7 +431,8 @@ class _LIBCPP_EXCEPTION_ABI ios_base::failure | ... | @@ -431,7 +431,8 @@ class _LIBCPP_EXCEPTION_ABI ios_base::failure |
| 431 | public: | 431 | public: |
| 432 | explicit failure(const string& __msg, const error_code& __ec = io_errc::stream); | 432 | explicit failure(const string& __msg, const error_code& __ec = io_errc::stream); |
| 433 | explicit failure(const char* __msg, const error_code& __ec = io_errc::stream); | 433 | explicit failure(const char* __msg, const error_code& __ec = io_errc::stream); |
| 434 | virtual ~failure() throw(); | 434 | failure(const failure&) _NOEXCEPT = default; |
| 435 | virtual ~failure() _NOEXCEPT; | ||
| 435 | }; | 436 | }; |
| 436 | 437 | ||
| 437 | _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY | 438 | _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY |
| ... | @@ -842,7 +843,7 @@ basic_ios<_CharT, _Traits>::set_rdbuf(basic_streambuf<char_type, traits_type>* _ | ... | @@ -842,7 +843,7 @@ basic_ios<_CharT, _Traits>::set_rdbuf(basic_streambuf<char_type, traits_type>* _ |
| 842 | ios_base::set_rdbuf(__sb); | 843 | ios_base::set_rdbuf(__sb); |
| 843 | } | 844 | } |
| 844 | 845 | ||
| 845 | inline _LIBCPP_INLINE_VISIBILITY | 846 | inline |
| 846 | ios_base& | 847 | ios_base& |
| 847 | boolalpha(ios_base& __str) | 848 | boolalpha(ios_base& __str) |
| 848 | { | 849 | { |
| ... | @@ -850,7 +851,7 @@ boolalpha(ios_base& __str) | ... | @@ -850,7 +851,7 @@ boolalpha(ios_base& __str) |
| 850 | return __str; | 851 | return __str; |
| 851 | } | 852 | } |
| 852 | 853 | ||
| 853 | inline _LIBCPP_INLINE_VISIBILITY | 854 | inline |
| 854 | ios_base& | 855 | ios_base& |
| 855 | noboolalpha(ios_base& __str) | 856 | noboolalpha(ios_base& __str) |
| 856 | { | 857 | { |
| ... | @@ -858,7 +859,7 @@ noboolalpha(ios_base& __str) | ... | @@ -858,7 +859,7 @@ noboolalpha(ios_base& __str) |
| 858 | return __str; | 859 | return __str; |
| 859 | } | 860 | } |
| 860 | 861 | ||
| 861 | inline _LIBCPP_INLINE_VISIBILITY | 862 | inline |
| 862 | ios_base& | 863 | ios_base& |
| 863 | showbase(ios_base& __str) | 864 | showbase(ios_base& __str) |
| 864 | { | 865 | { |
| ... | @@ -866,7 +867,7 @@ showbase(ios_base& __str) | ... | @@ -866,7 +867,7 @@ showbase(ios_base& __str) |
| 866 | return __str; | 867 | return __str; |
| 867 | } | 868 | } |
| 868 | 869 | ||
| 869 | inline _LIBCPP_INLINE_VISIBILITY | 870 | inline |
| 870 | ios_base& | 871 | ios_base& |
| 871 | noshowbase(ios_base& __str) | 872 | noshowbase(ios_base& __str) |
| 872 | { | 873 | { |
| ... | @@ -874,7 +875,7 @@ noshowbase(ios_base& __str) | ... | @@ -874,7 +875,7 @@ noshowbase(ios_base& __str) |
| 874 | return __str; | 875 | return __str; |
| 875 | } | 876 | } |
| 876 | 877 | ||
| 877 | inline _LIBCPP_INLINE_VISIBILITY | 878 | inline |
| 878 | ios_base& | 879 | ios_base& |
| 879 | showpoint(ios_base& __str) | 880 | showpoint(ios_base& __str) |
| 880 | { | 881 | { |
| ... | @@ -882,7 +883,7 @@ showpoint(ios_base& __str) | ... | @@ -882,7 +883,7 @@ showpoint(ios_base& __str) |
| 882 | return __str; | 883 | return __str; |
| 883 | } | 884 | } |
| 884 | 885 | ||
| 885 | inline _LIBCPP_INLINE_VISIBILITY | 886 | inline |
| 886 | ios_base& | 887 | ios_base& |
| 887 | noshowpoint(ios_base& __str) | 888 | noshowpoint(ios_base& __str) |
| 888 | { | 889 | { |
| ... | @@ -890,7 +891,7 @@ noshowpoint(ios_base& __str) | ... | @@ -890,7 +891,7 @@ noshowpoint(ios_base& __str) |
| 890 | return __str; | 891 | return __str; |
| 891 | } | 892 | } |
| 892 | 893 | ||
| 893 | inline _LIBCPP_INLINE_VISIBILITY | 894 | inline |
| 894 | ios_base& | 895 | ios_base& |
| 895 | showpos(ios_base& __str) | 896 | showpos(ios_base& __str) |
| 896 | { | 897 | { |
| ... | @@ -898,7 +899,7 @@ showpos(ios_base& __str) | ... | @@ -898,7 +899,7 @@ showpos(ios_base& __str) |
| 898 | return __str; | 899 | return __str; |
| 899 | } | 900 | } |
| 900 | 901 | ||
| 901 | inline _LIBCPP_INLINE_VISIBILITY | 902 | inline |
| 902 | ios_base& | 903 | ios_base& |
| 903 | noshowpos(ios_base& __str) | 904 | noshowpos(ios_base& __str) |
| 904 | { | 905 | { |
| ... | @@ -906,7 +907,7 @@ noshowpos(ios_base& __str) | ... | @@ -906,7 +907,7 @@ noshowpos(ios_base& __str) |
| 906 | return __str; | 907 | return __str; |
| 907 | } | 908 | } |
| 908 | 909 | ||
| 909 | inline _LIBCPP_INLINE_VISIBILITY | 910 | inline |
| 910 | ios_base& | 911 | ios_base& |
| 911 | skipws(ios_base& __str) | 912 | skipws(ios_base& __str) |
| 912 | { | 913 | { |
| ... | @@ -914,7 +915,7 @@ skipws(ios_base& __str) | ... | @@ -914,7 +915,7 @@ skipws(ios_base& __str) |
| 914 | return __str; | 915 | return __str; |
| 915 | } | 916 | } |
| 916 | 917 | ||
| 917 | inline _LIBCPP_INLINE_VISIBILITY | 918 | inline |
| 918 | ios_base& | 919 | ios_base& |
| 919 | noskipws(ios_base& __str) | 920 | noskipws(ios_base& __str) |
| 920 | { | 921 | { |
| ... | @@ -922,7 +923,7 @@ noskipws(ios_base& __str) | ... | @@ -922,7 +923,7 @@ noskipws(ios_base& __str) |
| 922 | return __str; | 923 | return __str; |
| 923 | } | 924 | } |
| 924 | 925 | ||
| 925 | inline _LIBCPP_INLINE_VISIBILITY | 926 | inline |
| 926 | ios_base& | 927 | ios_base& |
| 927 | uppercase(ios_base& __str) | 928 | uppercase(ios_base& __str) |
| 928 | { | 929 | { |
| ... | @@ -930,7 +931,7 @@ uppercase(ios_base& __str) | ... | @@ -930,7 +931,7 @@ uppercase(ios_base& __str) |
| 930 | return __str; | 931 | return __str; |
| 931 | } | 932 | } |
| 932 | 933 | ||
| 933 | inline _LIBCPP_INLINE_VISIBILITY | 934 | inline |
| 934 | ios_base& | 935 | ios_base& |
| 935 | nouppercase(ios_base& __str) | 936 | nouppercase(ios_base& __str) |
| 936 | { | 937 | { |
| ... | @@ -938,7 +939,7 @@ nouppercase(ios_base& __str) | ... | @@ -938,7 +939,7 @@ nouppercase(ios_base& __str) |
| 938 | return __str; | 939 | return __str; |
| 939 | } | 940 | } |
| 940 | 941 | ||
| 941 | inline _LIBCPP_INLINE_VISIBILITY | 942 | inline |
| 942 | ios_base& | 943 | ios_base& |
| 943 | unitbuf(ios_base& __str) | 944 | unitbuf(ios_base& __str) |
| 944 | { | 945 | { |
| ... | @@ -946,7 +947,7 @@ unitbuf(ios_base& __str) | ... | @@ -946,7 +947,7 @@ unitbuf(ios_base& __str) |
| 946 | return __str; | 947 | return __str; |
| 947 | } | 948 | } |
| 948 | 949 | ||
| 949 | inline _LIBCPP_INLINE_VISIBILITY | 950 | inline |
| 950 | ios_base& | 951 | ios_base& |
| 951 | nounitbuf(ios_base& __str) | 952 | nounitbuf(ios_base& __str) |
| 952 | { | 953 | { |
| ... | @@ -954,7 +955,7 @@ nounitbuf(ios_base& __str) | ... | @@ -954,7 +955,7 @@ nounitbuf(ios_base& __str) |
| 954 | return __str; | 955 | return __str; |
| 955 | } | 956 | } |
| 956 | 957 | ||
| 957 | inline _LIBCPP_INLINE_VISIBILITY | 958 | inline |
| 958 | ios_base& | 959 | ios_base& |
| 959 | internal(ios_base& __str) | 960 | internal(ios_base& __str) |
| 960 | { | 961 | { |
| ... | @@ -962,7 +963,7 @@ internal(ios_base& __str) | ... | @@ -962,7 +963,7 @@ internal(ios_base& __str) |
| 962 | return __str; | 963 | return __str; |
| 963 | } | 964 | } |
| 964 | 965 | ||
| 965 | inline _LIBCPP_INLINE_VISIBILITY | 966 | inline |
| 966 | ios_base& | 967 | ios_base& |
| 967 | left(ios_base& __str) | 968 | left(ios_base& __str) |
| 968 | { | 969 | { |
| ... | @@ -970,7 +971,7 @@ left(ios_base& __str) | ... | @@ -970,7 +971,7 @@ left(ios_base& __str) |
| 970 | return __str; | 971 | return __str; |
| 971 | } | 972 | } |
| 972 | 973 | ||
| 973 | inline _LIBCPP_INLINE_VISIBILITY | 974 | inline |
| 974 | ios_base& | 975 | ios_base& |
| 975 | right(ios_base& __str) | 976 | right(ios_base& __str) |
| 976 | { | 977 | { |
| ... | @@ -978,7 +979,7 @@ right(ios_base& __str) | ... | @@ -978,7 +979,7 @@ right(ios_base& __str) |
| 978 | return __str; | 979 | return __str; |
| 979 | } | 980 | } |
| 980 | 981 | ||
| 981 | inline _LIBCPP_INLINE_VISIBILITY | 982 | inline |
| 982 | ios_base& | 983 | ios_base& |
| 983 | dec(ios_base& __str) | 984 | dec(ios_base& __str) |
| 984 | { | 985 | { |
| ... | @@ -986,7 +987,7 @@ dec(ios_base& __str) | ... | @@ -986,7 +987,7 @@ dec(ios_base& __str) |
| 986 | return __str; | 987 | return __str; |
| 987 | } | 988 | } |
| 988 | 989 | ||
| 989 | inline _LIBCPP_INLINE_VISIBILITY | 990 | inline |
| 990 | ios_base& | 991 | ios_base& |
| 991 | hex(ios_base& __str) | 992 | hex(ios_base& __str) |
| 992 | { | 993 | { |
| ... | @@ -994,7 +995,7 @@ hex(ios_base& __str) | ... | @@ -994,7 +995,7 @@ hex(ios_base& __str) |
| 994 | return __str; | 995 | return __str; |
| 995 | } | 996 | } |
| 996 | 997 | ||
| 997 | inline _LIBCPP_INLINE_VISIBILITY | 998 | inline |
| 998 | ios_base& | 999 | ios_base& |
| 999 | oct(ios_base& __str) | 1000 | oct(ios_base& __str) |
| 1000 | { | 1001 | { |
| ... | @@ -1002,7 +1003,7 @@ oct(ios_base& __str) | ... | @@ -1002,7 +1003,7 @@ oct(ios_base& __str) |
| 1002 | return __str; | 1003 | return __str; |
| 1003 | } | 1004 | } |
| 1004 | 1005 | ||
| 1005 | inline _LIBCPP_INLINE_VISIBILITY | 1006 | inline |
| 1006 | ios_base& | 1007 | ios_base& |
| 1007 | fixed(ios_base& __str) | 1008 | fixed(ios_base& __str) |
| 1008 | { | 1009 | { |
| ... | @@ -1010,7 +1011,7 @@ fixed(ios_base& __str) | ... | @@ -1010,7 +1011,7 @@ fixed(ios_base& __str) |
| 1010 | return __str; | 1011 | return __str; |
| 1011 | } | 1012 | } |
| 1012 | 1013 | ||
| 1013 | inline _LIBCPP_INLINE_VISIBILITY | 1014 | inline |
| 1014 | ios_base& | 1015 | ios_base& |
| 1015 | scientific(ios_base& __str) | 1016 | scientific(ios_base& __str) |
| 1016 | { | 1017 | { |
| ... | @@ -1018,7 +1019,7 @@ scientific(ios_base& __str) | ... | @@ -1018,7 +1019,7 @@ scientific(ios_base& __str) |
| 1018 | return __str; | 1019 | return __str; |
| 1019 | } | 1020 | } |
| 1020 | 1021 | ||
| 1021 | inline _LIBCPP_INLINE_VISIBILITY | 1022 | inline |
| 1022 | ios_base& | 1023 | ios_base& |
| 1023 | hexfloat(ios_base& __str) | 1024 | hexfloat(ios_base& __str) |
| 1024 | { | 1025 | { |
| ... | @@ -1026,7 +1027,7 @@ hexfloat(ios_base& __str) | ... | @@ -1026,7 +1027,7 @@ hexfloat(ios_base& __str) |
| 1026 | return __str; | 1027 | return __str; |
| 1027 | } | 1028 | } |
| 1028 | 1029 | ||
| 1029 | inline _LIBCPP_INLINE_VISIBILITY | 1030 | inline |
| 1030 | ios_base& | 1031 | ios_base& |
| 1031 | defaultfloat(ios_base& __str) | 1032 | defaultfloat(ios_base& __str) |
| 1032 | { | 1033 | { |
lib/libcxx/include/iterator+10-11| ... | @@ -54,10 +54,8 @@ struct bidirectional_iterator_tag : public forward_iterator_tag {}; | ... | @@ -54,10 +54,8 @@ struct bidirectional_iterator_tag : public forward_iterator_tag {}; |
| 54 | struct random_access_iterator_tag : public bidirectional_iterator_tag {}; | 54 | struct random_access_iterator_tag : public bidirectional_iterator_tag {}; |
| 55 | 55 | ||
| 56 | // 27.4.3, iterator operations | 56 | // 27.4.3, iterator operations |
| 57 | // extension: second argument not conforming to C++03 | 57 | template <class InputIterator, class Distance> // constexpr in C++17 |
| 58 | template <class InputIterator> // constexpr in C++17 | 58 | constexpr void advance(InputIterator& i, Distance n); |
| 59 | constexpr void advance(InputIterator& i, | ||
| 60 | typename iterator_traits<InputIterator>::difference_type n); | ||
| 61 | 59 | ||
| 62 | template <class InputIterator> // constexpr in C++17 | 60 | template <class InputIterator> // constexpr in C++17 |
| 63 | constexpr typename iterator_traits<InputIterator>::difference_type | 61 | constexpr typename iterator_traits<InputIterator>::difference_type |
| ... | @@ -663,13 +661,14 @@ void __advance(_RandIter& __i, | ... | @@ -663,13 +661,14 @@ void __advance(_RandIter& __i, |
| 663 | __i += __n; | 661 | __i += __n; |
| 664 | } | 662 | } |
| 665 | 663 | ||
| 666 | template <class _InputIter> | 664 | template <class _InputIter, class _Distance> |
| 667 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | 665 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 668 | void advance(_InputIter& __i, | 666 | void advance(_InputIter& __i, _Distance __orig_n) |
| 669 | typename iterator_traits<_InputIter>::difference_type __n) | ||
| 670 | { | 667 | { |
| 671 | _LIBCPP_ASSERT(__n >= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value, | 668 | _LIBCPP_ASSERT(__orig_n >= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value, |
| 672 | "Attempt to advance(it, -n) on a non-bidi iterator"); | 669 | "Attempt to advance(it, n) with negative n on a non-bidirectional iterator"); |
| 670 | typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize; | ||
| 671 | _IntegralSize __n = __orig_n; | ||
| 673 | __advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category()); | 672 | __advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category()); |
| 674 | } | 673 | } |
| 675 | 674 | ||
| ... | @@ -711,7 +710,7 @@ next(_InputIter __x, | ... | @@ -711,7 +710,7 @@ next(_InputIter __x, |
| 711 | typename iterator_traits<_InputIter>::difference_type __n = 1) | 710 | typename iterator_traits<_InputIter>::difference_type __n = 1) |
| 712 | { | 711 | { |
| 713 | _LIBCPP_ASSERT(__n >= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value, | 712 | _LIBCPP_ASSERT(__n >= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value, |
| 714 | "Attempt to next(it, -n) on a non-bidi iterator"); | 713 | "Attempt to next(it, n) with negative n on a non-bidirectional iterator"); |
| 715 | 714 | ||
| 716 | _VSTD::advance(__x, __n); | 715 | _VSTD::advance(__x, __n); |
| 717 | return __x; | 716 | return __x; |
| ... | @@ -728,7 +727,7 @@ prev(_InputIter __x, | ... | @@ -728,7 +727,7 @@ prev(_InputIter __x, |
| 728 | typename iterator_traits<_InputIter>::difference_type __n = 1) | 727 | typename iterator_traits<_InputIter>::difference_type __n = 1) |
| 729 | { | 728 | { |
| 730 | _LIBCPP_ASSERT(__n <= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value, | 729 | _LIBCPP_ASSERT(__n <= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value, |
| 731 | "Attempt to prev(it, +n) on a non-bidi iterator"); | 730 | "Attempt to prev(it, n) with a positive n on a non-bidirectional iterator"); |
| 732 | _VSTD::advance(__x, -__n); | 731 | _VSTD::advance(__x, -__n); |
| 733 | return __x; | 732 | return __x; |
| 734 | } | 733 | } |
lib/libcxx/include/latch created+104| ... | @@ -0,0 +1,104 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===--------------------------- latch -----------------------------------===// | ||
| 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_LATCH | ||
| 11 | #define _LIBCPP_LATCH | ||
| 12 | |||
| 13 | /* | ||
| 14 | latch synopsis | ||
| 15 | |||
| 16 | namespace std | ||
| 17 | { | ||
| 18 | |||
| 19 | class latch | ||
| 20 | { | ||
| 21 | public: | ||
| 22 | constexpr explicit latch(ptrdiff_t __expected); | ||
| 23 | ~latch(); | ||
| 24 | |||
| 25 | latch(const latch&) = delete; | ||
| 26 | latch& operator=(const latch&) = delete; | ||
| 27 | |||
| 28 | void count_down(ptrdiff_t __update = 1); | ||
| 29 | bool try_wait() const noexcept; | ||
| 30 | void wait() const; | ||
| 31 | void arrive_and_wait(ptrdiff_t __update = 1); | ||
| 32 | |||
| 33 | private: | ||
| 34 | ptrdiff_t __counter; // exposition only | ||
| 35 | }; | ||
| 36 | |||
| 37 | } | ||
| 38 | |||
| 39 | */ | ||
| 40 | |||
| 41 | #include <__config> | ||
| 42 | #include <atomic> | ||
| 43 | |||
| 44 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 45 | #pragma GCC system_header | ||
| 46 | #endif | ||
| 47 | |||
| 48 | #ifdef _LIBCPP_HAS_NO_THREADS | ||
| 49 | # error <latch> is not supported on this single threaded system | ||
| 50 | #endif | ||
| 51 | |||
| 52 | #if _LIBCPP_STD_VER >= 14 | ||
| 53 | |||
| 54 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 55 | |||
| 56 | class latch | ||
| 57 | { | ||
| 58 | __atomic_base<ptrdiff_t> __a; | ||
| 59 | |||
| 60 | public: | ||
| 61 | static constexpr ptrdiff_t max() noexcept { | ||
| 62 | return numeric_limits<ptrdiff_t>::max(); | ||
| 63 | } | ||
| 64 | |||
| 65 | inline _LIBCPP_INLINE_VISIBILITY | ||
| 66 | constexpr explicit latch(ptrdiff_t __expected) : __a(__expected) { } | ||
| 67 | |||
| 68 | ~latch() = default; | ||
| 69 | latch(const latch&) = delete; | ||
| 70 | latch& operator=(const latch&) = delete; | ||
| 71 | |||
| 72 | inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 73 | void count_down(ptrdiff_t __update = 1) | ||
| 74 | { | ||
| 75 | auto const __old = __a.fetch_sub(__update, memory_order_release); | ||
| 76 | if(__old == __update) | ||
| 77 | __a.notify_all(); | ||
| 78 | } | ||
| 79 | inline _LIBCPP_INLINE_VISIBILITY | ||
| 80 | bool try_wait() const noexcept | ||
| 81 | { | ||
| 82 | return 0 == __a.load(memory_order_acquire); | ||
| 83 | } | ||
| 84 | inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 85 | void wait() const | ||
| 86 | { | ||
| 87 | auto const __test_fn = [=]() -> bool { | ||
| 88 | return try_wait(); | ||
| 89 | }; | ||
| 90 | __cxx_atomic_wait(&__a.__a_, __test_fn); | ||
| 91 | } | ||
| 92 | inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 93 | void arrive_and_wait(ptrdiff_t __update = 1) | ||
| 94 | { | ||
| 95 | count_down(__update); | ||
| 96 | wait(); | ||
| 97 | } | ||
| 98 | }; | ||
| 99 | |||
| 100 | _LIBCPP_END_NAMESPACE_STD | ||
| 101 | |||
| 102 | #endif // _LIBCPP_STD_VER >= 14 | ||
| 103 | |||
| 104 | #endif //_LIBCPP_LATCH | ||
lib/libcxx/include/list+12-8| ... | @@ -170,9 +170,11 @@ template <class T, class Alloc> | ... | @@ -170,9 +170,11 @@ template <class T, class Alloc> |
| 170 | noexcept(noexcept(x.swap(y))); | 170 | noexcept(noexcept(x.swap(y))); |
| 171 | 171 | ||
| 172 | template <class T, class Allocator, class U> | 172 | template <class T, class Allocator, class U> |
| 173 | void erase(list<T, Allocator>& c, const U& value); // C++20 | 173 | typename list<T, Allocator>::size_type |
| 174 | erase(list<T, Allocator>& c, const U& value); // C++20 | ||
| 174 | template <class T, class Allocator, class Predicate> | 175 | template <class T, class Allocator, class Predicate> |
| 175 | void erase_if(list<T, Allocator>& c, Predicate pred); // C++20 | 176 | typename list<T, Allocator>::size_type |
| 177 | erase_if(list<T, Allocator>& c, Predicate pred); // C++20 | ||
| 176 | 178 | ||
| 177 | } // std | 179 | } // std |
| 178 | 180 | ||
| ... | @@ -2471,14 +2473,16 @@ swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y) | ... | @@ -2471,14 +2473,16 @@ swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y) |
| 2471 | 2473 | ||
| 2472 | #if _LIBCPP_STD_VER > 17 | 2474 | #if _LIBCPP_STD_VER > 17 |
| 2473 | template <class _Tp, class _Allocator, class _Predicate> | 2475 | template <class _Tp, class _Allocator, class _Predicate> |
| 2474 | inline _LIBCPP_INLINE_VISIBILITY | 2476 | inline _LIBCPP_INLINE_VISIBILITY typename list<_Tp, _Allocator>::size_type |
| 2475 | void erase_if(list<_Tp, _Allocator>& __c, _Predicate __pred) | 2477 | erase_if(list<_Tp, _Allocator>& __c, _Predicate __pred) { |
| 2476 | { __c.remove_if(__pred); } | 2478 | return __c.remove_if(__pred); |
| 2479 | } | ||
| 2477 | 2480 | ||
| 2478 | template <class _Tp, class _Allocator, class _Up> | 2481 | template <class _Tp, class _Allocator, class _Up> |
| 2479 | inline _LIBCPP_INLINE_VISIBILITY | 2482 | inline _LIBCPP_INLINE_VISIBILITY typename list<_Tp, _Allocator>::size_type |
| 2480 | void erase(list<_Tp, _Allocator>& __c, const _Up& __v) | 2483 | erase(list<_Tp, _Allocator>& __c, const _Up& __v) { |
| 2481 | { _VSTD::erase_if(__c, [&](auto& __elem) { return __elem == __v; }); } | 2484 | return _VSTD::erase_if(__c, [&](auto& __elem) { return __elem == __v; }); |
| 2485 | } | ||
| 2482 | #endif | 2486 | #endif |
| 2483 | 2487 | ||
| 2484 | _LIBCPP_END_NAMESPACE_STD | 2488 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/map+17-8| ... | @@ -254,7 +254,8 @@ swap(map<Key, T, Compare, Allocator>& x, map<Key, T, Compare, Allocator>& y) | ... | @@ -254,7 +254,8 @@ swap(map<Key, T, Compare, Allocator>& x, map<Key, T, Compare, Allocator>& y) |
| 254 | noexcept(noexcept(x.swap(y))); | 254 | noexcept(noexcept(x.swap(y))); |
| 255 | 255 | ||
| 256 | template <class Key, class T, class Compare, class Allocator, class Predicate> | 256 | template <class Key, class T, class Compare, class Allocator, class Predicate> |
| 257 | void erase_if(map<Key, T, Compare, Allocator>& c, Predicate pred); // C++20 | 257 | typename map<Key, T, Compare, Allocator>::size_type |
| 258 | erase_if(map<Key, T, Compare, Allocator>& c, Predicate pred); // C++20 | ||
| 258 | 259 | ||
| 259 | 260 | ||
| 260 | template <class Key, class T, class Compare = less<Key>, | 261 | template <class Key, class T, class Compare = less<Key>, |
| ... | @@ -469,7 +470,8 @@ swap(multimap<Key, T, Compare, Allocator>& x, | ... | @@ -469,7 +470,8 @@ swap(multimap<Key, T, Compare, Allocator>& x, |
| 469 | noexcept(noexcept(x.swap(y))); | 470 | noexcept(noexcept(x.swap(y))); |
| 470 | 471 | ||
| 471 | template <class Key, class T, class Compare, class Allocator, class Predicate> | 472 | template <class Key, class T, class Compare, class Allocator, class Predicate> |
| 472 | void erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20 | 473 | typename multimap<Key, T, Compare, Allocator>::size_type |
| 474 | erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20 | ||
| 473 | 475 | ||
| 474 | } // std | 476 | } // std |
| 475 | 477 | ||
| ... | @@ -1653,10 +1655,13 @@ swap(map<_Key, _Tp, _Compare, _Allocator>& __x, | ... | @@ -1653,10 +1655,13 @@ swap(map<_Key, _Tp, _Compare, _Allocator>& __x, |
| 1653 | } | 1655 | } |
| 1654 | 1656 | ||
| 1655 | #if _LIBCPP_STD_VER > 17 | 1657 | #if _LIBCPP_STD_VER > 17 |
| 1656 | template <class _Key, class _Tp, class _Compare, class _Allocator, class _Predicate> | 1658 | template <class _Key, class _Tp, class _Compare, class _Allocator, |
| 1659 | class _Predicate> | ||
| 1657 | inline _LIBCPP_INLINE_VISIBILITY | 1660 | inline _LIBCPP_INLINE_VISIBILITY |
| 1658 | void erase_if(map<_Key, _Tp, _Compare, _Allocator>& __c, _Predicate __pred) | 1661 | typename map<_Key, _Tp, _Compare, _Allocator>::size_type |
| 1659 | { __libcpp_erase_if_container(__c, __pred); } | 1662 | erase_if(map<_Key, _Tp, _Compare, _Allocator>& __c, _Predicate __pred) { |
| 1663 | return __libcpp_erase_if_container(__c, __pred); | ||
| 1664 | } | ||
| 1660 | #endif | 1665 | #endif |
| 1661 | 1666 | ||
| 1662 | 1667 | ||
| ... | @@ -2235,10 +2240,14 @@ swap(multimap<_Key, _Tp, _Compare, _Allocator>& __x, | ... | @@ -2235,10 +2240,14 @@ swap(multimap<_Key, _Tp, _Compare, _Allocator>& __x, |
| 2235 | } | 2240 | } |
| 2236 | 2241 | ||
| 2237 | #if _LIBCPP_STD_VER > 17 | 2242 | #if _LIBCPP_STD_VER > 17 |
| 2238 | template <class _Key, class _Tp, class _Compare, class _Allocator, class _Predicate> | 2243 | template <class _Key, class _Tp, class _Compare, class _Allocator, |
| 2244 | class _Predicate> | ||
| 2239 | inline _LIBCPP_INLINE_VISIBILITY | 2245 | inline _LIBCPP_INLINE_VISIBILITY |
| 2240 | void erase_if(multimap<_Key, _Tp, _Compare, _Allocator>& __c, _Predicate __pred) | 2246 | typename multimap<_Key, _Tp, _Compare, _Allocator>::size_type |
| 2241 | { __libcpp_erase_if_container(__c, __pred); } | 2247 | erase_if(multimap<_Key, _Tp, _Compare, _Allocator>& __c, |
| 2248 | _Predicate __pred) { | ||
| 2249 | return __libcpp_erase_if_container(__c, __pred); | ||
| 2250 | } | ||
| 2242 | #endif | 2251 | #endif |
| 2243 | 2252 | ||
| 2244 | _LIBCPP_END_NAMESPACE_STD | 2253 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/math.h+5-56| ... | @@ -297,9 +297,6 @@ long double truncl(long double x); | ... | @@ -297,9 +297,6 @@ long double truncl(long double x); |
| 297 | #pragma GCC system_header | 297 | #pragma GCC system_header |
| 298 | #endif | 298 | #endif |
| 299 | 299 | ||
| 300 | #define _LIBCPP_STDLIB_INCLUDE_NEXT | ||
| 301 | #include <stdlib.h> | ||
| 302 | |||
| 303 | #include_next <math.h> | 300 | #include_next <math.h> |
| 304 | 301 | ||
| 305 | #ifdef __cplusplus | 302 | #ifdef __cplusplus |
| ... | @@ -308,6 +305,7 @@ long double truncl(long double x); | ... | @@ -308,6 +305,7 @@ long double truncl(long double x); |
| 308 | // back to C++ linkage before including these C++ headers. | 305 | // back to C++ linkage before including these C++ headers. |
| 309 | extern "C++" { | 306 | extern "C++" { |
| 310 | 307 | ||
| 308 | #include <stdlib.h> | ||
| 311 | #include <type_traits> | 309 | #include <type_traits> |
| 312 | #include <limits> | 310 | #include <limits> |
| 313 | 311 | ||
| ... | @@ -760,61 +758,12 @@ isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT | ... | @@ -760,61 +758,12 @@ isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT |
| 760 | #endif // isunordered | 758 | #endif // isunordered |
| 761 | 759 | ||
| 762 | // abs | 760 | // abs |
| 763 | 761 | // | |
| 764 | #undef abs | 762 | // handled in stdlib.h |
| 765 | #undef labs | ||
| 766 | #ifndef _LIBCPP_HAS_NO_LONG_LONG | ||
| 767 | #undef llabs | ||
| 768 | #endif | ||
| 769 | |||
| 770 | // MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined | ||
| 771 | #if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX) | ||
| 772 | inline _LIBCPP_INLINE_VISIBILITY long abs(long __x) _NOEXCEPT { | ||
| 773 | return ::labs(__x); | ||
| 774 | } | ||
| 775 | #ifndef _LIBCPP_HAS_NO_LONG_LONG | ||
| 776 | inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT { | ||
| 777 | return ::llabs(__x); | ||
| 778 | } | ||
| 779 | #endif // _LIBCPP_HAS_NO_LONG_LONG | ||
| 780 | #endif // !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX) | ||
| 781 | |||
| 782 | |||
| 783 | #if !(defined(_AIX) || defined(__sun__)) | ||
| 784 | inline _LIBCPP_INLINE_VISIBILITY float abs(float __lcpp_x) _NOEXCEPT { | ||
| 785 | return ::fabsf(__lcpp_x); | ||
| 786 | } | ||
| 787 | |||
| 788 | inline _LIBCPP_INLINE_VISIBILITY double abs(double __lcpp_x) _NOEXCEPT { | ||
| 789 | return ::fabs(__lcpp_x); | ||
| 790 | } | ||
| 791 | |||
| 792 | inline _LIBCPP_INLINE_VISIBILITY long double | ||
| 793 | abs(long double __lcpp_x) _NOEXCEPT { | ||
| 794 | return ::fabsl(__lcpp_x); | ||
| 795 | } | ||
| 796 | #endif // !(defined(_AIX) || defined(__sun__)) | ||
| 797 | 763 | ||
| 798 | // div | 764 | // div |
| 799 | 765 | // | |
| 800 | #undef div | 766 | // handled in stdlib.h |
| 801 | #undef ldiv | ||
| 802 | #ifndef _LIBCPP_HAS_NO_LONG_LONG | ||
| 803 | #undef lldiv | ||
| 804 | #endif | ||
| 805 | |||
| 806 | // MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined | ||
| 807 | #if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX) | ||
| 808 | inline _LIBCPP_INLINE_VISIBILITY ldiv_t div(long __x, long __y) _NOEXCEPT { | ||
| 809 | return ::ldiv(__x, __y); | ||
| 810 | } | ||
| 811 | #ifndef _LIBCPP_HAS_NO_LONG_LONG | ||
| 812 | inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x, | ||
| 813 | long long __y) _NOEXCEPT { | ||
| 814 | return ::lldiv(__x, __y); | ||
| 815 | } | ||
| 816 | #endif // _LIBCPP_HAS_NO_LONG_LONG | ||
| 817 | #endif // _LIBCPP_MSVCRT / __sun__ / _AIX | ||
| 818 | 767 | ||
| 819 | // acos | 768 | // acos |
| 820 | 769 |
lib/libcxx/include/memory+290-382| ... | @@ -80,7 +80,7 @@ struct allocator_traits | ... | @@ -80,7 +80,7 @@ struct allocator_traits |
| 80 | typedef Alloc::is_always_equal | 80 | typedef Alloc::is_always_equal |
| 81 | | is_empty is_always_equal; | 81 | | is_empty is_always_equal; |
| 82 | 82 | ||
| 83 | template <class T> using rebind_alloc = Alloc::rebind<U>::other | Alloc<T, Args...>; | 83 | template <class T> using rebind_alloc = Alloc::rebind<T>::other | Alloc<T, Args...>; |
| 84 | template <class T> using rebind_traits = allocator_traits<rebind_alloc<T>>; | 84 | template <class T> using rebind_traits = allocator_traits<rebind_alloc<T>>; |
| 85 | 85 | ||
| 86 | static pointer allocate(allocator_type& a, size_type n); // [[nodiscard]] in C++20 | 86 | static pointer allocate(allocator_type& a, size_type n); // [[nodiscard]] in C++20 |
| ... | @@ -101,7 +101,7 @@ struct allocator_traits | ... | @@ -101,7 +101,7 @@ struct allocator_traits |
| 101 | }; | 101 | }; |
| 102 | 102 | ||
| 103 | template <> | 103 | template <> |
| 104 | class allocator<void> | 104 | class allocator<void> // deprecated in C++17, removed in C++20 |
| 105 | { | 105 | { |
| 106 | public: | 106 | public: |
| 107 | typedef void* pointer; | 107 | typedef void* pointer; |
| ... | @@ -115,30 +115,37 @@ template <class T> | ... | @@ -115,30 +115,37 @@ template <class T> |
| 115 | class allocator | 115 | class allocator |
| 116 | { | 116 | { |
| 117 | public: | 117 | public: |
| 118 | typedef size_t size_type; | 118 | typedef size_t size_type; // deprecated in C++17, removed in C++20 |
| 119 | typedef ptrdiff_t difference_type; | 119 | typedef ptrdiff_t difference_type; // deprecated in C++17, removed in C++20 |
| 120 | typedef T* pointer; | 120 | typedef T* pointer; // deprecated in C++17, removed in C++20 |
| 121 | typedef const T* const_pointer; | 121 | typedef const T* const_pointer; // deprecated in C++17, removed in C++20 |
| 122 | typedef typename add_lvalue_reference<T>::type reference; | 122 | typedef typename add_lvalue_reference<T>::type |
| 123 | typedef typename add_lvalue_reference<const T>::type const_reference; | 123 | reference; // deprecated in C++17, removed in C++20 |
| 124 | typedef T value_type; | 124 | typedef typename add_lvalue_reference<const T>::type |
| 125 | const_reference; // deprecated in C++17, removed in C++20 | ||
| 125 | 126 | ||
| 126 | template <class U> struct rebind {typedef allocator<U> other;}; | 127 | typedef T value_type; |
| 128 | |||
| 129 | template <class U> struct rebind {typedef allocator<U> other;}; // deprecated in C++17, removed in C++20 | ||
| 130 | |||
| 131 | typedef true_type propagate_on_container_move_assignment; | ||
| 132 | typedef true_type is_always_equal; | ||
| 127 | 133 | ||
| 128 | constexpr allocator() noexcept; // constexpr in C++20 | 134 | constexpr allocator() noexcept; // constexpr in C++20 |
| 129 | constexpr allocator(const allocator&) noexcept; // constexpr in C++20 | 135 | constexpr allocator(const allocator&) noexcept; // constexpr in C++20 |
| 130 | template <class U> | 136 | template <class U> |
| 131 | constexpr allocator(const allocator<U>&) noexcept; // constexpr in C++20 | 137 | constexpr allocator(const allocator<U>&) noexcept; // constexpr in C++20 |
| 132 | ~allocator(); | 138 | ~allocator(); |
| 133 | pointer address(reference x) const noexcept; | 139 | pointer address(reference x) const noexcept; // deprecated in C++17, removed in C++20 |
| 134 | const_pointer address(const_reference x) const noexcept; | 140 | const_pointer address(const_reference x) const noexcept; // deprecated in C++17, removed in C++20 |
| 135 | pointer allocate(size_type, allocator<void>::const_pointer hint = 0); | 141 | T* allocate(size_t n, const void* hint); // deprecated in C++17, removed in C++20 |
| 136 | void deallocate(pointer p, size_type n) noexcept; | 142 | T* allocate(size_t n); |
| 137 | size_type max_size() const noexcept; | 143 | void deallocate(T* p, size_t n) noexcept; |
| 144 | size_type max_size() const noexcept; // deprecated in C++17, removed in C++20 | ||
| 138 | template<class U, class... Args> | 145 | template<class U, class... Args> |
| 139 | void construct(U* p, Args&&... args); | 146 | void construct(U* p, Args&&... args); // deprecated in C++17, removed in C++20 |
| 140 | template <class U> | 147 | template <class U> |
| 141 | void destroy(U* p); | 148 | void destroy(U* p); // deprecated in C++17, removed in C++20 |
| 142 | }; | 149 | }; |
| 143 | 150 | ||
| 144 | template <class T, class U> | 151 | template <class T, class U> |
| ... | @@ -443,6 +450,11 @@ public: | ... | @@ -443,6 +450,11 @@ public: |
| 443 | template<class U> bool owner_before(weak_ptr<U> const& b) const noexcept; | 450 | template<class U> bool owner_before(weak_ptr<U> const& b) const noexcept; |
| 444 | }; | 451 | }; |
| 445 | 452 | ||
| 453 | template<class T> | ||
| 454 | shared_ptr(weak_ptr<T>) -> shared_ptr<T>; | ||
| 455 | template<class T, class D> | ||
| 456 | shared_ptr(unique_ptr<T, D>) -> shared_ptr<T>; | ||
| 457 | |||
| 446 | // shared_ptr comparisons: | 458 | // shared_ptr comparisons: |
| 447 | template<class T, class U> | 459 | template<class T, class U> |
| 448 | bool operator==(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; | 460 | bool operator==(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; |
| ... | @@ -541,6 +553,9 @@ public: | ... | @@ -541,6 +553,9 @@ public: |
| 541 | template<class U> bool owner_before(weak_ptr<U> const& b) const noexcept; | 553 | template<class U> bool owner_before(weak_ptr<U> const& b) const noexcept; |
| 542 | }; | 554 | }; |
| 543 | 555 | ||
| 556 | template<class T> | ||
| 557 | weak_ptr(shared_ptr<T>) -> weak_ptr<T>; | ||
| 558 | |||
| 544 | // weak_ptr specialized algorithms: | 559 | // weak_ptr specialized algorithms: |
| 545 | template<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b) noexcept; | 560 | template<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b) noexcept; |
| 546 | 561 | ||
| ... | @@ -705,8 +720,9 @@ _ValueType __libcpp_acquire_load(_ValueType const* __value) { | ... | @@ -705,8 +720,9 @@ _ValueType __libcpp_acquire_load(_ValueType const* __value) { |
| 705 | 720 | ||
| 706 | template <class _Tp> class allocator; | 721 | template <class _Tp> class allocator; |
| 707 | 722 | ||
| 723 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS) | ||
| 708 | template <> | 724 | template <> |
| 709 | class _LIBCPP_TEMPLATE_VIS allocator<void> | 725 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 allocator<void> |
| 710 | { | 726 | { |
| 711 | public: | 727 | public: |
| 712 | typedef void* pointer; | 728 | typedef void* pointer; |
| ... | @@ -717,7 +733,7 @@ public: | ... | @@ -717,7 +733,7 @@ public: |
| 717 | }; | 733 | }; |
| 718 | 734 | ||
| 719 | template <> | 735 | template <> |
| 720 | class _LIBCPP_TEMPLATE_VIS allocator<const void> | 736 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 allocator<const void> |
| 721 | { | 737 | { |
| 722 | public: | 738 | public: |
| 723 | typedef const void* pointer; | 739 | typedef const void* pointer; |
| ... | @@ -726,6 +742,7 @@ public: | ... | @@ -726,6 +742,7 @@ public: |
| 726 | 742 | ||
| 727 | template <class _Up> struct rebind {typedef allocator<_Up> other;}; | 743 | template <class _Up> struct rebind {typedef allocator<_Up> other;}; |
| 728 | }; | 744 | }; |
| 745 | #endif | ||
| 729 | 746 | ||
| 730 | // pointer_traits | 747 | // pointer_traits |
| 731 | 748 | ||
| ... | @@ -838,7 +855,9 @@ struct __has_rebind | ... | @@ -838,7 +855,9 @@ struct __has_rebind |
| 838 | private: | 855 | private: |
| 839 | struct __two {char __lx; char __lxx;}; | 856 | struct __two {char __lx; char __lxx;}; |
| 840 | template <class _Xp> static __two __test(...); | 857 | template <class _Xp> static __two __test(...); |
| 858 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 841 | template <class _Xp> static char __test(typename _Xp::template rebind<_Up>* = 0); | 859 | template <class _Xp> static char __test(typename _Xp::template rebind<_Up>* = 0); |
| 860 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 842 | public: | 861 | public: |
| 843 | static const bool value = sizeof(__test<_Tp>(0)) == 1; | 862 | static const bool value = sizeof(__test<_Tp>(0)) == 1; |
| 844 | }; | 863 | }; |
| ... | @@ -1266,7 +1285,9 @@ struct __has_rebind_other | ... | @@ -1266,7 +1285,9 @@ struct __has_rebind_other |
| 1266 | private: | 1285 | private: |
| 1267 | struct __two {char __lx; char __lxx;}; | 1286 | struct __two {char __lx; char __lxx;}; |
| 1268 | template <class _Xp> static __two __test(...); | 1287 | template <class _Xp> static __two __test(...); |
| 1288 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 1269 | template <class _Xp> static char __test(typename _Xp::template rebind<_Up>::other* = 0); | 1289 | template <class _Xp> static char __test(typename _Xp::template rebind<_Up>::other* = 0); |
| 1290 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 1270 | public: | 1291 | public: |
| 1271 | static const bool value = sizeof(__test<_Tp>(0)) == 1; | 1292 | static const bool value = sizeof(__test<_Tp>(0)) == 1; |
| 1272 | }; | 1293 | }; |
| ... | @@ -1280,15 +1301,17 @@ struct __has_rebind_other<_Tp, _Up, false> | ... | @@ -1280,15 +1301,17 @@ struct __has_rebind_other<_Tp, _Up, false> |
| 1280 | template <class _Tp, class _Up, bool = __has_rebind_other<_Tp, _Up>::value> | 1301 | template <class _Tp, class _Up, bool = __has_rebind_other<_Tp, _Up>::value> |
| 1281 | struct __allocator_traits_rebind | 1302 | struct __allocator_traits_rebind |
| 1282 | { | 1303 | { |
| 1304 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 1283 | typedef _LIBCPP_NODEBUG_TYPE typename _Tp::template rebind<_Up>::other type; | 1305 | typedef _LIBCPP_NODEBUG_TYPE typename _Tp::template rebind<_Up>::other type; |
| 1306 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 1284 | }; | 1307 | }; |
| 1285 | 1308 | ||
| 1286 | #ifndef _LIBCPP_HAS_NO_VARIADICS | ||
| 1287 | |||
| 1288 | template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up> | 1309 | template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up> |
| 1289 | struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, true> | 1310 | struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, true> |
| 1290 | { | 1311 | { |
| 1312 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 1291 | typedef _LIBCPP_NODEBUG_TYPE typename _Alloc<_Tp, _Args...>::template rebind<_Up>::other type; | 1313 | typedef _LIBCPP_NODEBUG_TYPE typename _Alloc<_Tp, _Args...>::template rebind<_Up>::other type; |
| 1314 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 1292 | }; | 1315 | }; |
| 1293 | 1316 | ||
| 1294 | template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up> | 1317 | template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up> |
| ... | @@ -1297,68 +1320,14 @@ struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, false> | ... | @@ -1297,68 +1320,14 @@ struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, false> |
| 1297 | typedef _LIBCPP_NODEBUG_TYPE _Alloc<_Up, _Args...> type; | 1320 | typedef _LIBCPP_NODEBUG_TYPE _Alloc<_Up, _Args...> type; |
| 1298 | }; | 1321 | }; |
| 1299 | 1322 | ||
| 1300 | #else // _LIBCPP_HAS_NO_VARIADICS | ||
| 1301 | |||
| 1302 | template <template <class> class _Alloc, class _Tp, class _Up> | ||
| 1303 | struct __allocator_traits_rebind<_Alloc<_Tp>, _Up, true> | ||
| 1304 | { | ||
| 1305 | typedef typename _Alloc<_Tp>::template rebind<_Up>::other type; | ||
| 1306 | }; | ||
| 1307 | |||
| 1308 | template <template <class> class _Alloc, class _Tp, class _Up> | ||
| 1309 | struct __allocator_traits_rebind<_Alloc<_Tp>, _Up, false> | ||
| 1310 | { | ||
| 1311 | typedef _Alloc<_Up> type; | ||
| 1312 | }; | ||
| 1313 | |||
| 1314 | template <template <class, class> class _Alloc, class _Tp, class _A0, class _Up> | ||
| 1315 | struct __allocator_traits_rebind<_Alloc<_Tp, _A0>, _Up, true> | ||
| 1316 | { | ||
| 1317 | typedef typename _Alloc<_Tp, _A0>::template rebind<_Up>::other type; | ||
| 1318 | }; | ||
| 1319 | |||
| 1320 | template <template <class, class> class _Alloc, class _Tp, class _A0, class _Up> | ||
| 1321 | struct __allocator_traits_rebind<_Alloc<_Tp, _A0>, _Up, false> | ||
| 1322 | { | ||
| 1323 | typedef _Alloc<_Up, _A0> type; | ||
| 1324 | }; | ||
| 1325 | |||
| 1326 | template <template <class, class, class> class _Alloc, class _Tp, class _A0, | ||
| 1327 | class _A1, class _Up> | ||
| 1328 | struct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1>, _Up, true> | ||
| 1329 | { | ||
| 1330 | typedef typename _Alloc<_Tp, _A0, _A1>::template rebind<_Up>::other type; | ||
| 1331 | }; | ||
| 1332 | |||
| 1333 | template <template <class, class, class> class _Alloc, class _Tp, class _A0, | ||
| 1334 | class _A1, class _Up> | ||
| 1335 | struct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1>, _Up, false> | ||
| 1336 | { | ||
| 1337 | typedef _Alloc<_Up, _A0, _A1> type; | ||
| 1338 | }; | ||
| 1339 | |||
| 1340 | template <template <class, class, class, class> class _Alloc, class _Tp, class _A0, | ||
| 1341 | class _A1, class _A2, class _Up> | ||
| 1342 | struct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1, _A2>, _Up, true> | ||
| 1343 | { | ||
| 1344 | typedef typename _Alloc<_Tp, _A0, _A1, _A2>::template rebind<_Up>::other type; | ||
| 1345 | }; | ||
| 1346 | |||
| 1347 | template <template <class, class, class, class> class _Alloc, class _Tp, class _A0, | ||
| 1348 | class _A1, class _A2, class _Up> | ||
| 1349 | struct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1, _A2>, _Up, false> | ||
| 1350 | { | ||
| 1351 | typedef _Alloc<_Up, _A0, _A1, _A2> type; | ||
| 1352 | }; | ||
| 1353 | |||
| 1354 | #endif // _LIBCPP_HAS_NO_VARIADICS | ||
| 1355 | |||
| 1356 | #ifndef _LIBCPP_CXX03_LANG | 1323 | #ifndef _LIBCPP_CXX03_LANG |
| 1357 | 1324 | ||
| 1325 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 1358 | template <class _Alloc, class _SizeType, class _ConstVoidPtr> | 1326 | template <class _Alloc, class _SizeType, class _ConstVoidPtr> |
| 1359 | auto | 1327 | auto |
| 1360 | __has_allocate_hint_test(_Alloc&& __a, _SizeType&& __sz, _ConstVoidPtr&& __p) | 1328 | __has_allocate_hint_test(_Alloc&& __a, _SizeType&& __sz, _ConstVoidPtr&& __p) |
| 1361 | -> decltype((void)__a.allocate(__sz, __p), true_type()); | 1329 | -> decltype((void)__a.allocate(__sz, __p), true_type()); |
| 1330 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 1362 | 1331 | ||
| 1363 | template <class _Alloc, class _SizeType, class _ConstVoidPtr> | 1332 | template <class _Alloc, class _SizeType, class _ConstVoidPtr> |
| 1364 | auto | 1333 | auto |
| ... | @@ -1367,12 +1336,9 @@ __has_allocate_hint_test(const _Alloc& __a, _SizeType&& __sz, _ConstVoidPtr&& __ | ... | @@ -1367,12 +1336,9 @@ __has_allocate_hint_test(const _Alloc& __a, _SizeType&& __sz, _ConstVoidPtr&& __ |
| 1367 | 1336 | ||
| 1368 | template <class _Alloc, class _SizeType, class _ConstVoidPtr> | 1337 | template <class _Alloc, class _SizeType, class _ConstVoidPtr> |
| 1369 | struct __has_allocate_hint | 1338 | struct __has_allocate_hint |
| 1370 | : integral_constant<bool, | 1339 | : decltype(_VSTD::__has_allocate_hint_test(declval<_Alloc>(), |
| 1371 | is_same< | 1340 | declval<_SizeType>(), |
| 1372 | decltype(_VSTD::__has_allocate_hint_test(declval<_Alloc>(), | 1341 | declval<_ConstVoidPtr>())) |
| 1373 | declval<_SizeType>(), | ||
| 1374 | declval<_ConstVoidPtr>())), | ||
| 1375 | true_type>::value> | ||
| 1376 | { | 1342 | { |
| 1377 | }; | 1343 | }; |
| 1378 | 1344 | ||
| ... | @@ -1386,33 +1352,26 @@ struct __has_allocate_hint | ... | @@ -1386,33 +1352,26 @@ struct __has_allocate_hint |
| 1386 | 1352 | ||
| 1387 | #endif // _LIBCPP_CXX03_LANG | 1353 | #endif // _LIBCPP_CXX03_LANG |
| 1388 | 1354 | ||
| 1389 | #if !defined(_LIBCPP_CXX03_LANG) | 1355 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 1356 | template <class _Alloc, class ..._Args, | ||
| 1357 | class = decltype(_VSTD::declval<_Alloc>().construct(_VSTD::declval<_Args>()...))> | ||
| 1358 | static true_type __test_has_construct(int); | ||
| 1359 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 1390 | 1360 | ||
| 1391 | template <class _Alloc, class _Tp, class ..._Args> | 1361 | template <class _Alloc, class...> |
| 1392 | decltype(_VSTD::declval<_Alloc>().construct(_VSTD::declval<_Tp*>(), | 1362 | static false_type __test_has_construct(...); |
| 1393 | _VSTD::declval<_Args>()...), | 1363 | |
| 1394 | true_type()) | 1364 | template <class _Alloc, class ..._Args> |
| 1395 | __has_construct_test(_Alloc&& __a, _Tp* __p, _Args&& ...__args); | 1365 | struct __has_construct : decltype(__test_has_construct<_Alloc, _Args...>(0)) {}; |
| 1396 | 1366 | ||
| 1397 | template <class _Alloc, class _Pointer, class ..._Args> | 1367 | #if !defined(_LIBCPP_CXX03_LANG) |
| 1398 | false_type | ||
| 1399 | __has_construct_test(const _Alloc& __a, _Pointer&& __p, _Args&& ...__args); | ||
| 1400 | |||
| 1401 | template <class _Alloc, class _Pointer, class ..._Args> | ||
| 1402 | struct __has_construct | ||
| 1403 | : integral_constant<bool, | ||
| 1404 | is_same< | ||
| 1405 | decltype(_VSTD::__has_construct_test(declval<_Alloc>(), | ||
| 1406 | declval<_Pointer>(), | ||
| 1407 | declval<_Args>()...)), | ||
| 1408 | true_type>::value> | ||
| 1409 | { | ||
| 1410 | }; | ||
| 1411 | 1368 | ||
| 1369 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 1412 | template <class _Alloc, class _Pointer> | 1370 | template <class _Alloc, class _Pointer> |
| 1413 | auto | 1371 | auto |
| 1414 | __has_destroy_test(_Alloc&& __a, _Pointer&& __p) | 1372 | __has_destroy_test(_Alloc&& __a, _Pointer&& __p) |
| 1415 | -> decltype(__a.destroy(__p), true_type()); | 1373 | -> decltype(__a.destroy(__p), true_type()); |
| 1374 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 1416 | 1375 | ||
| 1417 | template <class _Alloc, class _Pointer> | 1376 | template <class _Alloc, class _Pointer> |
| 1418 | auto | 1377 | auto |
| ... | @@ -1421,18 +1380,17 @@ __has_destroy_test(const _Alloc& __a, _Pointer&& __p) | ... | @@ -1421,18 +1380,17 @@ __has_destroy_test(const _Alloc& __a, _Pointer&& __p) |
| 1421 | 1380 | ||
| 1422 | template <class _Alloc, class _Pointer> | 1381 | template <class _Alloc, class _Pointer> |
| 1423 | struct __has_destroy | 1382 | struct __has_destroy |
| 1424 | : integral_constant<bool, | 1383 | : decltype(_VSTD::__has_destroy_test(declval<_Alloc>(), |
| 1425 | is_same< | 1384 | declval<_Pointer>())) |
| 1426 | decltype(_VSTD::__has_destroy_test(declval<_Alloc>(), | ||
| 1427 | declval<_Pointer>())), | ||
| 1428 | true_type>::value> | ||
| 1429 | { | 1385 | { |
| 1430 | }; | 1386 | }; |
| 1431 | 1387 | ||
| 1388 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 1432 | template <class _Alloc> | 1389 | template <class _Alloc> |
| 1433 | auto | 1390 | auto |
| 1434 | __has_max_size_test(_Alloc&& __a) | 1391 | __has_max_size_test(_Alloc&& __a) |
| 1435 | -> decltype(__a.max_size(), true_type()); | 1392 | -> decltype(__a.max_size(), true_type()); |
| 1393 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 1436 | 1394 | ||
| 1437 | template <class _Alloc> | 1395 | template <class _Alloc> |
| 1438 | auto | 1396 | auto |
| ... | @@ -1441,10 +1399,7 @@ __has_max_size_test(const volatile _Alloc& __a) | ... | @@ -1441,10 +1399,7 @@ __has_max_size_test(const volatile _Alloc& __a) |
| 1441 | 1399 | ||
| 1442 | template <class _Alloc> | 1400 | template <class _Alloc> |
| 1443 | struct __has_max_size | 1401 | struct __has_max_size |
| 1444 | : integral_constant<bool, | 1402 | : decltype(_VSTD::__has_max_size_test(declval<_Alloc&>())) |
| 1445 | is_same< | ||
| 1446 | decltype(_VSTD::__has_max_size_test(declval<_Alloc&>())), | ||
| 1447 | true_type>::value> | ||
| 1448 | { | 1403 | { |
| 1449 | }; | 1404 | }; |
| 1450 | 1405 | ||
| ... | @@ -1460,23 +1415,12 @@ __has_select_on_container_copy_construction_test(const volatile _Alloc& __a) | ... | @@ -1460,23 +1415,12 @@ __has_select_on_container_copy_construction_test(const volatile _Alloc& __a) |
| 1460 | 1415 | ||
| 1461 | template <class _Alloc> | 1416 | template <class _Alloc> |
| 1462 | struct __has_select_on_container_copy_construction | 1417 | struct __has_select_on_container_copy_construction |
| 1463 | : integral_constant<bool, | 1418 | : decltype(_VSTD::__has_select_on_container_copy_construction_test(declval<_Alloc&>())) |
| 1464 | is_same< | ||
| 1465 | decltype(_VSTD::__has_select_on_container_copy_construction_test(declval<_Alloc&>())), | ||
| 1466 | true_type>::value> | ||
| 1467 | { | 1419 | { |
| 1468 | }; | 1420 | }; |
| 1469 | 1421 | ||
| 1470 | #else // _LIBCPP_CXX03_LANG | 1422 | #else // _LIBCPP_CXX03_LANG |
| 1471 | 1423 | ||
| 1472 | template <class _Alloc, class _Pointer, class _Tp, class = void> | ||
| 1473 | struct __has_construct : std::false_type {}; | ||
| 1474 | |||
| 1475 | template <class _Alloc, class _Pointer, class _Tp> | ||
| 1476 | struct __has_construct<_Alloc, _Pointer, _Tp, typename __void_t< | ||
| 1477 | decltype(_VSTD::declval<_Alloc>().construct(_VSTD::declval<_Pointer>(), _VSTD::declval<_Tp>())) | ||
| 1478 | >::type> : std::true_type {}; | ||
| 1479 | |||
| 1480 | template <class _Alloc, class _Pointer, class = void> | 1424 | template <class _Alloc, class _Pointer, class = void> |
| 1481 | struct __has_destroy : false_type {}; | 1425 | struct __has_destroy : false_type {}; |
| 1482 | 1426 | ||
| ... | @@ -1588,41 +1532,11 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits | ... | @@ -1588,41 +1532,11 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits |
| 1588 | static void deallocate(allocator_type& __a, pointer __p, size_type __n) _NOEXCEPT | 1532 | static void deallocate(allocator_type& __a, pointer __p, size_type __n) _NOEXCEPT |
| 1589 | {__a.deallocate(__p, __n);} | 1533 | {__a.deallocate(__p, __n);} |
| 1590 | 1534 | ||
| 1591 | #ifndef _LIBCPP_HAS_NO_VARIADICS | ||
| 1592 | template <class _Tp, class... _Args> | 1535 | template <class _Tp, class... _Args> |
| 1593 | _LIBCPP_INLINE_VISIBILITY | 1536 | _LIBCPP_INLINE_VISIBILITY |
| 1594 | static void construct(allocator_type& __a, _Tp* __p, _Args&&... __args) | 1537 | static void construct(allocator_type& __a, _Tp* __p, _Args&&... __args) |
| 1595 | {__construct(__has_construct<allocator_type, _Tp*, _Args...>(), | 1538 | {__construct(__has_construct<allocator_type, _Tp*, _Args...>(), |
| 1596 | __a, __p, _VSTD::forward<_Args>(__args)...);} | 1539 | __a, __p, _VSTD::forward<_Args>(__args)...);} |
| 1597 | #else // _LIBCPP_HAS_NO_VARIADICS | ||
| 1598 | template <class _Tp> | ||
| 1599 | _LIBCPP_INLINE_VISIBILITY | ||
| 1600 | static void construct(allocator_type&, _Tp* __p) | ||
| 1601 | { | ||
| 1602 | ::new ((void*)__p) _Tp(); | ||
| 1603 | } | ||
| 1604 | template <class _Tp, class _A0> | ||
| 1605 | _LIBCPP_INLINE_VISIBILITY | ||
| 1606 | static void construct(allocator_type& __a, _Tp* __p, const _A0& __a0) | ||
| 1607 | { | ||
| 1608 | __construct(__has_construct<allocator_type, _Tp*, const _A0&>(), | ||
| 1609 | __a, __p, __a0); | ||
| 1610 | } | ||
| 1611 | template <class _Tp, class _A0, class _A1> | ||
| 1612 | _LIBCPP_INLINE_VISIBILITY | ||
| 1613 | static void construct(allocator_type&, _Tp* __p, const _A0& __a0, | ||
| 1614 | const _A1& __a1) | ||
| 1615 | { | ||
| 1616 | ::new ((void*)__p) _Tp(__a0, __a1); | ||
| 1617 | } | ||
| 1618 | template <class _Tp, class _A0, class _A1, class _A2> | ||
| 1619 | _LIBCPP_INLINE_VISIBILITY | ||
| 1620 | static void construct(allocator_type&, _Tp* __p, const _A0& __a0, | ||
| 1621 | const _A1& __a1, const _A2& __a2) | ||
| 1622 | { | ||
| 1623 | ::new ((void*)__p) _Tp(__a0, __a1, __a2); | ||
| 1624 | } | ||
| 1625 | #endif // _LIBCPP_HAS_NO_VARIADICS | ||
| 1626 | 1540 | ||
| 1627 | template <class _Tp> | 1541 | template <class _Tp> |
| 1628 | _LIBCPP_INLINE_VISIBILITY | 1542 | _LIBCPP_INLINE_VISIBILITY |
| ... | @@ -1695,7 +1609,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits | ... | @@ -1695,7 +1609,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits |
| 1695 | static | 1609 | static |
| 1696 | typename enable_if | 1610 | typename enable_if |
| 1697 | < | 1611 | < |
| 1698 | is_trivially_move_constructible<_DestTp>::value && | 1612 | is_trivially_copy_constructible<_DestTp>::value && |
| 1699 | is_same<_RawSourceTp, _RawDestTp>::value && | 1613 | is_same<_RawSourceTp, _RawDestTp>::value && |
| 1700 | (__is_default_allocator<allocator_type>::value || | 1614 | (__is_default_allocator<allocator_type>::value || |
| 1701 | !__has_construct<allocator_type, _DestTp*, _SourceTp&>::value), | 1615 | !__has_construct<allocator_type, _DestTp*, _SourceTp&>::value), |
| ... | @@ -1755,42 +1669,40 @@ private: | ... | @@ -1755,42 +1669,40 @@ private: |
| 1755 | _LIBCPP_INLINE_VISIBILITY | 1669 | _LIBCPP_INLINE_VISIBILITY |
| 1756 | static pointer __allocate(allocator_type& __a, size_type __n, | 1670 | static pointer __allocate(allocator_type& __a, size_type __n, |
| 1757 | const_void_pointer __hint, true_type) | 1671 | const_void_pointer __hint, true_type) |
| 1758 | {return __a.allocate(__n, __hint);} | 1672 | { |
| 1673 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 1674 | return __a.allocate(__n, __hint); | ||
| 1675 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 1676 | } | ||
| 1759 | _LIBCPP_INLINE_VISIBILITY | 1677 | _LIBCPP_INLINE_VISIBILITY |
| 1760 | static pointer __allocate(allocator_type& __a, size_type __n, | 1678 | static pointer __allocate(allocator_type& __a, size_type __n, |
| 1761 | const_void_pointer, false_type) | 1679 | const_void_pointer, false_type) |
| 1762 | {return __a.allocate(__n);} | 1680 | {return __a.allocate(__n);} |
| 1763 | 1681 | ||
| 1764 | #ifndef _LIBCPP_HAS_NO_VARIADICS | ||
| 1765 | template <class _Tp, class... _Args> | 1682 | template <class _Tp, class... _Args> |
| 1766 | _LIBCPP_INLINE_VISIBILITY | 1683 | _LIBCPP_INLINE_VISIBILITY |
| 1767 | static void __construct(true_type, allocator_type& __a, _Tp* __p, _Args&&... __args) | 1684 | static void __construct(true_type, allocator_type& __a, _Tp* __p, _Args&&... __args) |
| 1768 | {__a.construct(__p, _VSTD::forward<_Args>(__args)...);} | 1685 | { |
| 1686 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 1687 | __a.construct(__p, _VSTD::forward<_Args>(__args)...); | ||
| 1688 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 1689 | } | ||
| 1690 | |||
| 1769 | template <class _Tp, class... _Args> | 1691 | template <class _Tp, class... _Args> |
| 1770 | _LIBCPP_INLINE_VISIBILITY | 1692 | _LIBCPP_INLINE_VISIBILITY |
| 1771 | static void __construct(false_type, allocator_type&, _Tp* __p, _Args&&... __args) | 1693 | static void __construct(false_type, allocator_type&, _Tp* __p, _Args&&... __args) |
| 1772 | { | 1694 | { |
| 1773 | ::new ((void*)__p) _Tp(_VSTD::forward<_Args>(__args)...); | 1695 | ::new ((void*)__p) _Tp(_VSTD::forward<_Args>(__args)...); |
| 1774 | } | 1696 | } |
| 1775 | #else // _LIBCPP_HAS_NO_VARIADICS | ||
| 1776 | template <class _Tp, class _A0> | ||
| 1777 | _LIBCPP_INLINE_VISIBILITY | ||
| 1778 | static void __construct(true_type, allocator_type& __a, _Tp* __p, | ||
| 1779 | const _A0& __a0) | ||
| 1780 | {__a.construct(__p, __a0);} | ||
| 1781 | template <class _Tp, class _A0> | ||
| 1782 | _LIBCPP_INLINE_VISIBILITY | ||
| 1783 | static void __construct(false_type, allocator_type&, _Tp* __p, | ||
| 1784 | const _A0& __a0) | ||
| 1785 | { | ||
| 1786 | ::new ((void*)__p) _Tp(__a0); | ||
| 1787 | } | ||
| 1788 | #endif // _LIBCPP_HAS_NO_VARIADICS | ||
| 1789 | 1697 | ||
| 1790 | template <class _Tp> | 1698 | template <class _Tp> |
| 1791 | _LIBCPP_INLINE_VISIBILITY | 1699 | _LIBCPP_INLINE_VISIBILITY |
| 1792 | static void __destroy(true_type, allocator_type& __a, _Tp* __p) | 1700 | static void __destroy(true_type, allocator_type& __a, _Tp* __p) |
| 1793 | {__a.destroy(__p);} | 1701 | { |
| 1702 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 1703 | __a.destroy(__p); | ||
| 1704 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 1705 | } | ||
| 1794 | template <class _Tp> | 1706 | template <class _Tp> |
| 1795 | _LIBCPP_INLINE_VISIBILITY | 1707 | _LIBCPP_INLINE_VISIBILITY |
| 1796 | static void __destroy(false_type, allocator_type&, _Tp* __p) | 1708 | static void __destroy(false_type, allocator_type&, _Tp* __p) |
| ... | @@ -1800,7 +1712,12 @@ private: | ... | @@ -1800,7 +1712,12 @@ private: |
| 1800 | 1712 | ||
| 1801 | _LIBCPP_INLINE_VISIBILITY | 1713 | _LIBCPP_INLINE_VISIBILITY |
| 1802 | static size_type __max_size(true_type, const allocator_type& __a) _NOEXCEPT | 1714 | static size_type __max_size(true_type, const allocator_type& __a) _NOEXCEPT |
| 1803 | {return __a.max_size();} | 1715 | { |
| 1716 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 1717 | return __a.max_size(); | ||
| 1718 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 1719 | } | ||
| 1720 | |||
| 1804 | _LIBCPP_INLINE_VISIBILITY | 1721 | _LIBCPP_INLINE_VISIBILITY |
| 1805 | static size_type __max_size(false_type, const allocator_type&) _NOEXCEPT | 1722 | static size_type __max_size(false_type, const allocator_type&) _NOEXCEPT |
| 1806 | {return numeric_limits<size_type>::max() / sizeof(value_type);} | 1723 | {return numeric_limits<size_type>::max() / sizeof(value_type);} |
| ... | @@ -1831,19 +1748,22 @@ template <class _Tp> | ... | @@ -1831,19 +1748,22 @@ template <class _Tp> |
| 1831 | class _LIBCPP_TEMPLATE_VIS allocator | 1748 | class _LIBCPP_TEMPLATE_VIS allocator |
| 1832 | { | 1749 | { |
| 1833 | public: | 1750 | public: |
| 1834 | typedef size_t size_type; | 1751 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS) |
| 1835 | typedef ptrdiff_t difference_type; | 1752 | _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t size_type; |
| 1836 | typedef _Tp* pointer; | 1753 | _LIBCPP_DEPRECATED_IN_CXX17 typedef ptrdiff_t difference_type; |
| 1837 | typedef const _Tp* const_pointer; | 1754 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp* pointer; |
| 1838 | typedef _Tp& reference; | 1755 | _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* const_pointer; |
| 1839 | typedef const _Tp& const_reference; | 1756 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp& reference; |
| 1840 | typedef _Tp value_type; | 1757 | _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& const_reference; |
| 1758 | |||
| 1759 | template <class _Up> struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {typedef allocator<_Up> other;}; | ||
| 1760 | #endif | ||
| 1761 | |||
| 1762 | typedef _Tp value_type; | ||
| 1841 | 1763 | ||
| 1842 | typedef true_type propagate_on_container_move_assignment; | 1764 | typedef true_type propagate_on_container_move_assignment; |
| 1843 | typedef true_type is_always_equal; | 1765 | typedef true_type is_always_equal; |
| 1844 | 1766 | ||
| 1845 | template <class _Up> struct rebind {typedef allocator<_Up> other;}; | ||
| 1846 | |||
| 1847 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | 1767 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 1848 | allocator() _NOEXCEPT {} | 1768 | allocator() _NOEXCEPT {} |
| 1849 | 1769 | ||
| ... | @@ -1851,103 +1771,67 @@ public: | ... | @@ -1851,103 +1771,67 @@ public: |
| 1851 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | 1771 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 1852 | allocator(const allocator<_Up>&) _NOEXCEPT {} | 1772 | allocator(const allocator<_Up>&) _NOEXCEPT {} |
| 1853 | 1773 | ||
| 1854 | _LIBCPP_INLINE_VISIBILITY pointer address(reference __x) const _NOEXCEPT | 1774 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS) |
| 1775 | _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY | ||
| 1776 | pointer address(reference __x) const _NOEXCEPT | ||
| 1855 | {return _VSTD::addressof(__x);} | 1777 | {return _VSTD::addressof(__x);} |
| 1856 | _LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT | 1778 | _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY |
| 1779 | const_pointer address(const_reference __x) const _NOEXCEPT | ||
| 1857 | {return _VSTD::addressof(__x);} | 1780 | {return _VSTD::addressof(__x);} |
| 1858 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | 1781 | #endif |
| 1859 | pointer allocate(size_type __n, allocator<void>::const_pointer = 0) | 1782 | |
| 1783 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _Tp* allocate(size_t __n) | ||
| 1860 | { | 1784 | { |
| 1861 | if (__n > max_size()) | 1785 | // TODO(mpark): Replace with `allocator_traits<allocator>::max_size(*this)`. |
| 1786 | if (__n > (size_t(~0) / sizeof(_Tp))) | ||
| 1862 | __throw_length_error("allocator<T>::allocate(size_t n)" | 1787 | __throw_length_error("allocator<T>::allocate(size_t n)" |
| 1863 | " 'n' exceeds maximum supported size"); | 1788 | " 'n' exceeds maximum supported size"); |
| 1864 | return static_cast<pointer>(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp))); | 1789 | return static_cast<_Tp*>(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp))); |
| 1865 | } | 1790 | } |
| 1866 | _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type __n) _NOEXCEPT | 1791 | |
| 1792 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS) | ||
| 1793 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_IN_CXX17 | ||
| 1794 | _Tp* allocate(size_t __n, const void*) { return allocate(__n); } | ||
| 1795 | #endif | ||
| 1796 | |||
| 1797 | _LIBCPP_INLINE_VISIBILITY void deallocate(_Tp* __p, size_t __n) _NOEXCEPT | ||
| 1867 | {_VSTD::__libcpp_deallocate((void*)__p, __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));} | 1798 | {_VSTD::__libcpp_deallocate((void*)__p, __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));} |
| 1868 | _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT | 1799 | |
| 1800 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS) | ||
| 1801 | _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT | ||
| 1869 | {return size_type(~0) / sizeof(_Tp);} | 1802 | {return size_type(~0) / sizeof(_Tp);} |
| 1870 | #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) | 1803 | |
| 1871 | template <class _Up, class... _Args> | 1804 | template <class _Up, class... _Args> |
| 1872 | _LIBCPP_INLINE_VISIBILITY | 1805 | _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY |
| 1873 | void | 1806 | void |
| 1874 | construct(_Up* __p, _Args&&... __args) | 1807 | construct(_Up* __p, _Args&&... __args) |
| 1875 | { | 1808 | { |
| 1876 | ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...); | 1809 | ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...); |
| 1877 | } | 1810 | } |
| 1878 | #else // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) | 1811 | _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();} |
| 1879 | _LIBCPP_INLINE_VISIBILITY | 1812 | #endif |
| 1880 | void | ||
| 1881 | construct(pointer __p) | ||
| 1882 | { | ||
| 1883 | ::new((void*)__p) _Tp(); | ||
| 1884 | } | ||
| 1885 | # if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) | ||
| 1886 | |||
| 1887 | template <class _A0> | ||
| 1888 | _LIBCPP_INLINE_VISIBILITY | ||
| 1889 | void | ||
| 1890 | construct(pointer __p, _A0& __a0) | ||
| 1891 | { | ||
| 1892 | ::new((void*)__p) _Tp(__a0); | ||
| 1893 | } | ||
| 1894 | template <class _A0> | ||
| 1895 | _LIBCPP_INLINE_VISIBILITY | ||
| 1896 | void | ||
| 1897 | construct(pointer __p, const _A0& __a0) | ||
| 1898 | { | ||
| 1899 | ::new((void*)__p) _Tp(__a0); | ||
| 1900 | } | ||
| 1901 | # endif // defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) | ||
| 1902 | template <class _A0, class _A1> | ||
| 1903 | _LIBCPP_INLINE_VISIBILITY | ||
| 1904 | void | ||
| 1905 | construct(pointer __p, _A0& __a0, _A1& __a1) | ||
| 1906 | { | ||
| 1907 | ::new((void*)__p) _Tp(__a0, __a1); | ||
| 1908 | } | ||
| 1909 | template <class _A0, class _A1> | ||
| 1910 | _LIBCPP_INLINE_VISIBILITY | ||
| 1911 | void | ||
| 1912 | construct(pointer __p, const _A0& __a0, _A1& __a1) | ||
| 1913 | { | ||
| 1914 | ::new((void*)__p) _Tp(__a0, __a1); | ||
| 1915 | } | ||
| 1916 | template <class _A0, class _A1> | ||
| 1917 | _LIBCPP_INLINE_VISIBILITY | ||
| 1918 | void | ||
| 1919 | construct(pointer __p, _A0& __a0, const _A1& __a1) | ||
| 1920 | { | ||
| 1921 | ::new((void*)__p) _Tp(__a0, __a1); | ||
| 1922 | } | ||
| 1923 | template <class _A0, class _A1> | ||
| 1924 | _LIBCPP_INLINE_VISIBILITY | ||
| 1925 | void | ||
| 1926 | construct(pointer __p, const _A0& __a0, const _A1& __a1) | ||
| 1927 | { | ||
| 1928 | ::new((void*)__p) _Tp(__a0, __a1); | ||
| 1929 | } | ||
| 1930 | #endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) | ||
| 1931 | _LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();} | ||
| 1932 | }; | 1813 | }; |
| 1933 | 1814 | ||
| 1934 | template <class _Tp> | 1815 | template <class _Tp> |
| 1935 | class _LIBCPP_TEMPLATE_VIS allocator<const _Tp> | 1816 | class _LIBCPP_TEMPLATE_VIS allocator<const _Tp> |
| 1936 | { | 1817 | { |
| 1937 | public: | 1818 | public: |
| 1938 | typedef size_t size_type; | 1819 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS) |
| 1939 | typedef ptrdiff_t difference_type; | 1820 | _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t size_type; |
| 1940 | typedef const _Tp* pointer; | 1821 | _LIBCPP_DEPRECATED_IN_CXX17 typedef ptrdiff_t difference_type; |
| 1941 | typedef const _Tp* const_pointer; | 1822 | _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* pointer; |
| 1942 | typedef const _Tp& reference; | 1823 | _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* const_pointer; |
| 1943 | typedef const _Tp& const_reference; | 1824 | _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& reference; |
| 1944 | typedef const _Tp value_type; | 1825 | _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& const_reference; |
| 1826 | |||
| 1827 | template <class _Up> struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {typedef allocator<_Up> other;}; | ||
| 1828 | #endif | ||
| 1829 | |||
| 1830 | typedef const _Tp value_type; | ||
| 1945 | 1831 | ||
| 1946 | typedef true_type propagate_on_container_move_assignment; | 1832 | typedef true_type propagate_on_container_move_assignment; |
| 1947 | typedef true_type is_always_equal; | 1833 | typedef true_type is_always_equal; |
| 1948 | 1834 | ||
| 1949 | template <class _Up> struct rebind {typedef allocator<_Up> other;}; | ||
| 1950 | |||
| 1951 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | 1835 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 1952 | allocator() _NOEXCEPT {} | 1836 | allocator() _NOEXCEPT {} |
| 1953 | 1837 | ||
| ... | @@ -1955,22 +1839,36 @@ public: | ... | @@ -1955,22 +1839,36 @@ public: |
| 1955 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | 1839 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 1956 | allocator(const allocator<_Up>&) _NOEXCEPT {} | 1840 | allocator(const allocator<_Up>&) _NOEXCEPT {} |
| 1957 | 1841 | ||
| 1958 | _LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT | 1842 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS) |
| 1843 | _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY | ||
| 1844 | const_pointer address(const_reference __x) const _NOEXCEPT | ||
| 1959 | {return _VSTD::addressof(__x);} | 1845 | {return _VSTD::addressof(__x);} |
| 1960 | _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::const_pointer = 0) | 1846 | #endif |
| 1847 | |||
| 1848 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const _Tp* allocate(size_t __n) | ||
| 1961 | { | 1849 | { |
| 1962 | if (__n > max_size()) | 1850 | // TODO(mpark): Replace with `allocator_traits<allocator>::max_size(*this)`. |
| 1851 | if (__n > (size_t(~0) / sizeof(_Tp))) | ||
| 1963 | __throw_length_error("allocator<const T>::allocate(size_t n)" | 1852 | __throw_length_error("allocator<const T>::allocate(size_t n)" |
| 1964 | " 'n' exceeds maximum supported size"); | 1853 | " 'n' exceeds maximum supported size"); |
| 1965 | return static_cast<pointer>(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp))); | 1854 | return static_cast<const _Tp*>(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp))); |
| 1966 | } | 1855 | } |
| 1967 | _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type __n) _NOEXCEPT | 1856 | |
| 1857 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS) | ||
| 1858 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_IN_CXX17 | ||
| 1859 | const _Tp* allocate(size_t __n, const void*) { return allocate(__n); } | ||
| 1860 | #endif | ||
| 1861 | |||
| 1862 | _LIBCPP_INLINE_VISIBILITY void deallocate(const _Tp* __p, size_t __n) | ||
| 1968 | {_VSTD::__libcpp_deallocate((void*) const_cast<_Tp *>(__p), __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));} | 1863 | {_VSTD::__libcpp_deallocate((void*) const_cast<_Tp *>(__p), __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));} |
| 1969 | _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT | 1864 | |
| 1865 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS) | ||
| 1866 | _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT | ||
| 1970 | {return size_type(~0) / sizeof(_Tp);} | 1867 | {return size_type(~0) / sizeof(_Tp);} |
| 1868 | |||
| 1971 | #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) | 1869 | #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) |
| 1972 | template <class _Up, class... _Args> | 1870 | template <class _Up, class... _Args> |
| 1973 | _LIBCPP_INLINE_VISIBILITY | 1871 | _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY |
| 1974 | void | 1872 | void |
| 1975 | construct(_Up* __p, _Args&&... __args) | 1873 | construct(_Up* __p, _Args&&... __args) |
| 1976 | { | 1874 | { |
| ... | @@ -2029,7 +1927,8 @@ public: | ... | @@ -2029,7 +1927,8 @@ public: |
| 2029 | ::new((void*) const_cast<_Tp *>(__p)) _Tp(__a0, __a1); | 1927 | ::new((void*) const_cast<_Tp *>(__p)) _Tp(__a0, __a1); |
| 2030 | } | 1928 | } |
| 2031 | #endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) | 1929 | #endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) |
| 2032 | _LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();} | 1930 | _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();} |
| 1931 | #endif | ||
| 2033 | }; | 1932 | }; |
| 2034 | 1933 | ||
| 2035 | template <class _Tp, class _Up> | 1934 | template <class _Tp, class _Up> |
| ... | @@ -2134,39 +2033,39 @@ private: | ... | @@ -2134,39 +2033,39 @@ private: |
| 2134 | public: | 2033 | public: |
| 2135 | typedef _Tp element_type; | 2034 | typedef _Tp element_type; |
| 2136 | 2035 | ||
| 2137 | _LIBCPP_INLINE_VISIBILITY explicit auto_ptr(_Tp* __p = 0) throw() : __ptr_(__p) {} | 2036 | _LIBCPP_INLINE_VISIBILITY explicit auto_ptr(_Tp* __p = 0) _NOEXCEPT : __ptr_(__p) {} |
| 2138 | _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr& __p) throw() : __ptr_(__p.release()) {} | 2037 | _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr& __p) _NOEXCEPT : __ptr_(__p.release()) {} |
| 2139 | template<class _Up> _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr<_Up>& __p) throw() | 2038 | template<class _Up> _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr<_Up>& __p) _NOEXCEPT |
| 2140 | : __ptr_(__p.release()) {} | 2039 | : __ptr_(__p.release()) {} |
| 2141 | _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr& __p) throw() | 2040 | _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr& __p) _NOEXCEPT |
| 2142 | {reset(__p.release()); return *this;} | 2041 | {reset(__p.release()); return *this;} |
| 2143 | template<class _Up> _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr<_Up>& __p) throw() | 2042 | template<class _Up> _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr<_Up>& __p) _NOEXCEPT |
| 2144 | {reset(__p.release()); return *this;} | 2043 | {reset(__p.release()); return *this;} |
| 2145 | _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr_ref<_Tp> __p) throw() | 2044 | _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr_ref<_Tp> __p) _NOEXCEPT |
| 2146 | {reset(__p.__ptr_); return *this;} | 2045 | {reset(__p.__ptr_); return *this;} |
| 2147 | _LIBCPP_INLINE_VISIBILITY ~auto_ptr() throw() {delete __ptr_;} | 2046 | _LIBCPP_INLINE_VISIBILITY ~auto_ptr() _NOEXCEPT {delete __ptr_;} |
| 2148 | 2047 | ||
| 2149 | _LIBCPP_INLINE_VISIBILITY _Tp& operator*() const throw() | 2048 | _LIBCPP_INLINE_VISIBILITY _Tp& operator*() const _NOEXCEPT |
| 2150 | {return *__ptr_;} | 2049 | {return *__ptr_;} |
| 2151 | _LIBCPP_INLINE_VISIBILITY _Tp* operator->() const throw() {return __ptr_;} | 2050 | _LIBCPP_INLINE_VISIBILITY _Tp* operator->() const _NOEXCEPT {return __ptr_;} |
| 2152 | _LIBCPP_INLINE_VISIBILITY _Tp* get() const throw() {return __ptr_;} | 2051 | _LIBCPP_INLINE_VISIBILITY _Tp* get() const _NOEXCEPT {return __ptr_;} |
| 2153 | _LIBCPP_INLINE_VISIBILITY _Tp* release() throw() | 2052 | _LIBCPP_INLINE_VISIBILITY _Tp* release() _NOEXCEPT |
| 2154 | { | 2053 | { |
| 2155 | _Tp* __t = __ptr_; | 2054 | _Tp* __t = __ptr_; |
| 2156 | __ptr_ = 0; | 2055 | __ptr_ = 0; |
| 2157 | return __t; | 2056 | return __t; |
| 2158 | } | 2057 | } |
| 2159 | _LIBCPP_INLINE_VISIBILITY void reset(_Tp* __p = 0) throw() | 2058 | _LIBCPP_INLINE_VISIBILITY void reset(_Tp* __p = 0) _NOEXCEPT |
| 2160 | { | 2059 | { |
| 2161 | if (__ptr_ != __p) | 2060 | if (__ptr_ != __p) |
| 2162 | delete __ptr_; | 2061 | delete __ptr_; |
| 2163 | __ptr_ = __p; | 2062 | __ptr_ = __p; |
| 2164 | } | 2063 | } |
| 2165 | 2064 | ||
| 2166 | _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr_ref<_Tp> __p) throw() : __ptr_(__p.__ptr_) {} | 2065 | _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr_ref<_Tp> __p) _NOEXCEPT : __ptr_(__p.__ptr_) {} |
| 2167 | template<class _Up> _LIBCPP_INLINE_VISIBILITY operator auto_ptr_ref<_Up>() throw() | 2066 | template<class _Up> _LIBCPP_INLINE_VISIBILITY operator auto_ptr_ref<_Up>() _NOEXCEPT |
| 2168 | {auto_ptr_ref<_Up> __t; __t.__ptr_ = release(); return __t;} | 2067 | {auto_ptr_ref<_Up> __t; __t.__ptr_ = release(); return __t;} |
| 2169 | template<class _Up> _LIBCPP_INLINE_VISIBILITY operator auto_ptr<_Up>() throw() | 2068 | template<class _Up> _LIBCPP_INLINE_VISIBILITY operator auto_ptr<_Up>() _NOEXCEPT |
| 2170 | {return auto_ptr<_Up>(release());} | 2069 | {return auto_ptr<_Up>(release());} |
| 2171 | }; | 2070 | }; |
| 2172 | 2071 | ||
| ... | @@ -3393,6 +3292,8 @@ class _LIBCPP_EXCEPTION_ABI bad_weak_ptr | ... | @@ -3393,6 +3292,8 @@ class _LIBCPP_EXCEPTION_ABI bad_weak_ptr |
| 3393 | : public std::exception | 3292 | : public std::exception |
| 3394 | { | 3293 | { |
| 3395 | public: | 3294 | public: |
| 3295 | bad_weak_ptr() _NOEXCEPT = default; | ||
| 3296 | bad_weak_ptr(const bad_weak_ptr&) _NOEXCEPT = default; | ||
| 3396 | virtual ~bad_weak_ptr() _NOEXCEPT; | 3297 | virtual ~bad_weak_ptr() _NOEXCEPT; |
| 3397 | virtual const char* what() const _NOEXCEPT; | 3298 | virtual const char* what() const _NOEXCEPT; |
| 3398 | }; | 3299 | }; |
| ... | @@ -3628,15 +3529,25 @@ public: | ... | @@ -3628,15 +3529,25 @@ public: |
| 3628 | 3529 | ||
| 3629 | template<class _Tp> class _LIBCPP_TEMPLATE_VIS enable_shared_from_this; | 3530 | template<class _Tp> class _LIBCPP_TEMPLATE_VIS enable_shared_from_this; |
| 3630 | 3531 | ||
| 3532 | template<class _Tp, class _Up> | ||
| 3533 | struct __compatible_with | ||
| 3534 | #if _LIBCPP_STD_VER > 14 | ||
| 3535 | : is_convertible<remove_extent_t<_Tp>*, remove_extent_t<_Up>*> {}; | ||
| 3536 | #else | ||
| 3537 | : is_convertible<_Tp*, _Up*> {}; | ||
| 3538 | #endif // _LIBCPP_STD_VER > 14 | ||
| 3539 | |||
| 3631 | template<class _Tp> | 3540 | template<class _Tp> |
| 3632 | class _LIBCPP_TEMPLATE_VIS shared_ptr | 3541 | class _LIBCPP_TEMPLATE_VIS shared_ptr |
| 3633 | { | 3542 | { |
| 3634 | public: | 3543 | public: |
| 3635 | typedef _Tp element_type; | ||
| 3636 | |||
| 3637 | #if _LIBCPP_STD_VER > 14 | 3544 | #if _LIBCPP_STD_VER > 14 |
| 3638 | typedef weak_ptr<_Tp> weak_type; | 3545 | typedef weak_ptr<_Tp> weak_type; |
| 3546 | typedef remove_extent_t<_Tp> element_type; | ||
| 3547 | #else | ||
| 3548 | typedef _Tp element_type; | ||
| 3639 | #endif | 3549 | #endif |
| 3550 | |||
| 3640 | private: | 3551 | private: |
| 3641 | element_type* __ptr_; | 3552 | element_type* __ptr_; |
| 3642 | __shared_weak_count* __cntrl_; | 3553 | __shared_weak_count* __cntrl_; |
| ... | @@ -3649,13 +3560,13 @@ public: | ... | @@ -3649,13 +3560,13 @@ public: |
| 3649 | _LIBCPP_CONSTEXPR shared_ptr(nullptr_t) _NOEXCEPT; | 3560 | _LIBCPP_CONSTEXPR shared_ptr(nullptr_t) _NOEXCEPT; |
| 3650 | template<class _Yp> | 3561 | template<class _Yp> |
| 3651 | explicit shared_ptr(_Yp* __p, | 3562 | explicit shared_ptr(_Yp* __p, |
| 3652 | typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat()); | 3563 | typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type = __nat()); |
| 3653 | template<class _Yp, class _Dp> | 3564 | template<class _Yp, class _Dp> |
| 3654 | shared_ptr(_Yp* __p, _Dp __d, | 3565 | shared_ptr(_Yp* __p, _Dp __d, |
| 3655 | typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat()); | 3566 | typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type = __nat()); |
| 3656 | template<class _Yp, class _Dp, class _Alloc> | 3567 | template<class _Yp, class _Dp, class _Alloc> |
| 3657 | shared_ptr(_Yp* __p, _Dp __d, _Alloc __a, | 3568 | shared_ptr(_Yp* __p, _Dp __d, _Alloc __a, |
| 3658 | typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat()); | 3569 | typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type = __nat()); |
| 3659 | template <class _Dp> shared_ptr(nullptr_t __p, _Dp __d); | 3570 | template <class _Dp> shared_ptr(nullptr_t __p, _Dp __d); |
| 3660 | template <class _Dp, class _Alloc> shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a); | 3571 | template <class _Dp, class _Alloc> shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a); |
| 3661 | template<class _Yp> _LIBCPP_INLINE_VISIBILITY shared_ptr(const shared_ptr<_Yp>& __r, element_type* __p) _NOEXCEPT; | 3572 | template<class _Yp> _LIBCPP_INLINE_VISIBILITY shared_ptr(const shared_ptr<_Yp>& __r, element_type* __p) _NOEXCEPT; |
| ... | @@ -3664,13 +3575,13 @@ public: | ... | @@ -3664,13 +3575,13 @@ public: |
| 3664 | template<class _Yp> | 3575 | template<class _Yp> |
| 3665 | _LIBCPP_INLINE_VISIBILITY | 3576 | _LIBCPP_INLINE_VISIBILITY |
| 3666 | shared_ptr(const shared_ptr<_Yp>& __r, | 3577 | shared_ptr(const shared_ptr<_Yp>& __r, |
| 3667 | typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat()) | 3578 | typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type = __nat()) |
| 3668 | _NOEXCEPT; | 3579 | _NOEXCEPT; |
| 3669 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 3580 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
| 3670 | _LIBCPP_INLINE_VISIBILITY | 3581 | _LIBCPP_INLINE_VISIBILITY |
| 3671 | shared_ptr(shared_ptr&& __r) _NOEXCEPT; | 3582 | shared_ptr(shared_ptr&& __r) _NOEXCEPT; |
| 3672 | template<class _Yp> _LIBCPP_INLINE_VISIBILITY shared_ptr(shared_ptr<_Yp>&& __r, | 3583 | template<class _Yp> _LIBCPP_INLINE_VISIBILITY shared_ptr(shared_ptr<_Yp>&& __r, |
| 3673 | typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat()) | 3584 | typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type = __nat()) |
| 3674 | _NOEXCEPT; | 3585 | _NOEXCEPT; |
| 3675 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 3586 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
| 3676 | template<class _Yp> explicit shared_ptr(const weak_ptr<_Yp>& __r, | 3587 | template<class _Yp> explicit shared_ptr(const weak_ptr<_Yp>& __r, |
| ... | @@ -3686,7 +3597,6 @@ public: | ... | @@ -3686,7 +3597,6 @@ public: |
| 3686 | typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat()); | 3597 | typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat()); |
| 3687 | #endif | 3598 | #endif |
| 3688 | #endif | 3599 | #endif |
| 3689 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | ||
| 3690 | template <class _Yp, class _Dp> | 3600 | template <class _Yp, class _Dp> |
| 3691 | shared_ptr(unique_ptr<_Yp, _Dp>&&, | 3601 | shared_ptr(unique_ptr<_Yp, _Dp>&&, |
| 3692 | typename enable_if | 3602 | typename enable_if |
| ... | @@ -3705,26 +3615,6 @@ public: | ... | @@ -3705,26 +3615,6 @@ public: |
| 3705 | is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value, | 3615 | is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value, |
| 3706 | __nat | 3616 | __nat |
| 3707 | >::type = __nat()); | 3617 | >::type = __nat()); |
| 3708 | #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES | ||
| 3709 | template <class _Yp, class _Dp> | ||
| 3710 | shared_ptr(unique_ptr<_Yp, _Dp>, | ||
| 3711 | typename enable_if | ||
| 3712 | < | ||
| 3713 | !is_lvalue_reference<_Dp>::value && | ||
| 3714 | !is_array<_Yp>::value && | ||
| 3715 | is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value, | ||
| 3716 | __nat | ||
| 3717 | >::type = __nat()); | ||
| 3718 | template <class _Yp, class _Dp> | ||
| 3719 | shared_ptr(unique_ptr<_Yp, _Dp>, | ||
| 3720 | typename enable_if | ||
| 3721 | < | ||
| 3722 | is_lvalue_reference<_Dp>::value && | ||
| 3723 | !is_array<_Yp>::value && | ||
| 3724 | is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value, | ||
| 3725 | __nat | ||
| 3726 | >::type = __nat()); | ||
| 3727 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES | ||
| 3728 | 3618 | ||
| 3729 | ~shared_ptr(); | 3619 | ~shared_ptr(); |
| 3730 | 3620 | ||
| ... | @@ -3733,7 +3623,7 @@ public: | ... | @@ -3733,7 +3623,7 @@ public: |
| 3733 | template<class _Yp> | 3623 | template<class _Yp> |
| 3734 | typename enable_if | 3624 | typename enable_if |
| 3735 | < | 3625 | < |
| 3736 | is_convertible<_Yp*, element_type*>::value, | 3626 | __compatible_with<_Yp, element_type>::value, |
| 3737 | shared_ptr& | 3627 | shared_ptr& |
| 3738 | >::type | 3628 | >::type |
| 3739 | _LIBCPP_INLINE_VISIBILITY | 3629 | _LIBCPP_INLINE_VISIBILITY |
| ... | @@ -3744,8 +3634,8 @@ public: | ... | @@ -3744,8 +3634,8 @@ public: |
| 3744 | template<class _Yp> | 3634 | template<class _Yp> |
| 3745 | typename enable_if | 3635 | typename enable_if |
| 3746 | < | 3636 | < |
| 3747 | is_convertible<_Yp*, element_type*>::value, | 3637 | __compatible_with<_Yp, element_type>::value, |
| 3748 | shared_ptr<_Tp>& | 3638 | shared_ptr& |
| 3749 | >::type | 3639 | >::type |
| 3750 | _LIBCPP_INLINE_VISIBILITY | 3640 | _LIBCPP_INLINE_VISIBILITY |
| 3751 | operator=(shared_ptr<_Yp>&& __r); | 3641 | operator=(shared_ptr<_Yp>&& __r); |
| ... | @@ -3795,7 +3685,7 @@ public: | ... | @@ -3795,7 +3685,7 @@ public: |
| 3795 | template<class _Yp> | 3685 | template<class _Yp> |
| 3796 | typename enable_if | 3686 | typename enable_if |
| 3797 | < | 3687 | < |
| 3798 | is_convertible<_Yp*, element_type*>::value, | 3688 | __compatible_with<_Yp, element_type>::value, |
| 3799 | void | 3689 | void |
| 3800 | >::type | 3690 | >::type |
| 3801 | _LIBCPP_INLINE_VISIBILITY | 3691 | _LIBCPP_INLINE_VISIBILITY |
| ... | @@ -3803,7 +3693,7 @@ public: | ... | @@ -3803,7 +3693,7 @@ public: |
| 3803 | template<class _Yp, class _Dp> | 3693 | template<class _Yp, class _Dp> |
| 3804 | typename enable_if | 3694 | typename enable_if |
| 3805 | < | 3695 | < |
| 3806 | is_convertible<_Yp*, element_type*>::value, | 3696 | __compatible_with<_Yp, element_type>::value, |
| 3807 | void | 3697 | void |
| 3808 | >::type | 3698 | >::type |
| 3809 | _LIBCPP_INLINE_VISIBILITY | 3699 | _LIBCPP_INLINE_VISIBILITY |
| ... | @@ -3811,7 +3701,7 @@ public: | ... | @@ -3811,7 +3701,7 @@ public: |
| 3811 | template<class _Yp, class _Dp, class _Alloc> | 3701 | template<class _Yp, class _Dp, class _Alloc> |
| 3812 | typename enable_if | 3702 | typename enable_if |
| 3813 | < | 3703 | < |
| 3814 | is_convertible<_Yp*, element_type*>::value, | 3704 | __compatible_with<_Yp, element_type>::value, |
| 3815 | void | 3705 | void |
| 3816 | >::type | 3706 | >::type |
| 3817 | _LIBCPP_INLINE_VISIBILITY | 3707 | _LIBCPP_INLINE_VISIBILITY |
| ... | @@ -3823,7 +3713,12 @@ public: | ... | @@ -3823,7 +3713,12 @@ public: |
| 3823 | typename add_lvalue_reference<element_type>::type operator*() const _NOEXCEPT | 3713 | typename add_lvalue_reference<element_type>::type operator*() const _NOEXCEPT |
| 3824 | {return *__ptr_;} | 3714 | {return *__ptr_;} |
| 3825 | _LIBCPP_INLINE_VISIBILITY | 3715 | _LIBCPP_INLINE_VISIBILITY |
| 3826 | element_type* operator->() const _NOEXCEPT {return __ptr_;} | 3716 | element_type* operator->() const _NOEXCEPT |
| 3717 | { | ||
| 3718 | static_assert(!_VSTD::is_array<_Tp>::value, | ||
| 3719 | "std::shared_ptr<T>::operator-> is only valid when T is not an array type."); | ||
| 3720 | return __ptr_; | ||
| 3721 | } | ||
| 3827 | _LIBCPP_INLINE_VISIBILITY | 3722 | _LIBCPP_INLINE_VISIBILITY |
| 3828 | long use_count() const _NOEXCEPT {return __cntrl_ ? __cntrl_->use_count() : 0;} | 3723 | long use_count() const _NOEXCEPT {return __cntrl_ ? __cntrl_->use_count() : 0;} |
| 3829 | _LIBCPP_INLINE_VISIBILITY | 3724 | _LIBCPP_INLINE_VISIBILITY |
| ... | @@ -3843,6 +3738,17 @@ public: | ... | @@ -3843,6 +3738,17 @@ public: |
| 3843 | __owner_equivalent(const shared_ptr& __p) const | 3738 | __owner_equivalent(const shared_ptr& __p) const |
| 3844 | {return __cntrl_ == __p.__cntrl_;} | 3739 | {return __cntrl_ == __p.__cntrl_;} |
| 3845 | 3740 | ||
| 3741 | #if _LIBCPP_STD_VER > 14 | ||
| 3742 | typename add_lvalue_reference<element_type>::type | ||
| 3743 | _LIBCPP_INLINE_VISIBILITY | ||
| 3744 | operator[](ptrdiff_t __i) const | ||
| 3745 | { | ||
| 3746 | static_assert(_VSTD::is_array<_Tp>::value, | ||
| 3747 | "std::shared_ptr<T>::operator[] is only valid when T is an array type."); | ||
| 3748 | return __ptr_[__i]; | ||
| 3749 | } | ||
| 3750 | #endif | ||
| 3751 | |||
| 3846 | #ifndef _LIBCPP_NO_RTTI | 3752 | #ifndef _LIBCPP_NO_RTTI |
| 3847 | template <class _Dp> | 3753 | template <class _Dp> |
| 3848 | _LIBCPP_INLINE_VISIBILITY | 3754 | _LIBCPP_INLINE_VISIBILITY |
| ... | @@ -3854,7 +3760,7 @@ public: | ... | @@ -3854,7 +3760,7 @@ public: |
| 3854 | 3760 | ||
| 3855 | template<class _Yp, class _CntrlBlk> | 3761 | template<class _Yp, class _CntrlBlk> |
| 3856 | static shared_ptr<_Tp> | 3762 | static shared_ptr<_Tp> |
| 3857 | __create_with_control_block(_Yp* __p, _CntrlBlk* __cntrl) | 3763 | __create_with_control_block(_Yp* __p, _CntrlBlk* __cntrl) _NOEXCEPT |
| 3858 | { | 3764 | { |
| 3859 | shared_ptr<_Tp> __r; | 3765 | shared_ptr<_Tp> __r; |
| 3860 | __r.__ptr_ = __p; | 3766 | __r.__ptr_ = __p; |
| ... | @@ -3863,11 +3769,6 @@ public: | ... | @@ -3863,11 +3769,6 @@ public: |
| 3863 | return __r; | 3769 | return __r; |
| 3864 | } | 3770 | } |
| 3865 | 3771 | ||
| 3866 | template<class _Alloc, class ..._Args> | ||
| 3867 | static | ||
| 3868 | shared_ptr<_Tp> | ||
| 3869 | allocate_shared(const _Alloc& __a, _Args&& ...__args); | ||
| 3870 | |||
| 3871 | private: | 3772 | private: |
| 3872 | template <class _Yp, bool = is_function<_Yp>::value> | 3773 | template <class _Yp, bool = is_function<_Yp>::value> |
| 3873 | struct __shared_ptr_default_allocator | 3774 | struct __shared_ptr_default_allocator |
| ... | @@ -3900,10 +3801,28 @@ private: | ... | @@ -3900,10 +3801,28 @@ private: |
| 3900 | 3801 | ||
| 3901 | _LIBCPP_INLINE_VISIBILITY void __enable_weak_this(...) _NOEXCEPT {} | 3802 | _LIBCPP_INLINE_VISIBILITY void __enable_weak_this(...) _NOEXCEPT {} |
| 3902 | 3803 | ||
| 3804 | template <class, class _Yp> | ||
| 3805 | struct __shared_ptr_default_delete | ||
| 3806 | : default_delete<_Yp> {}; | ||
| 3807 | |||
| 3808 | template <class _Yp, class _Un, size_t _Sz> | ||
| 3809 | struct __shared_ptr_default_delete<_Yp[_Sz], _Un> | ||
| 3810 | : default_delete<_Yp[]> {}; | ||
| 3811 | |||
| 3812 | template <class _Yp, class _Un> | ||
| 3813 | struct __shared_ptr_default_delete<_Yp[], _Un> | ||
| 3814 | : default_delete<_Yp[]> {}; | ||
| 3815 | |||
| 3903 | template <class _Up> friend class _LIBCPP_TEMPLATE_VIS shared_ptr; | 3816 | template <class _Up> friend class _LIBCPP_TEMPLATE_VIS shared_ptr; |
| 3904 | template <class _Up> friend class _LIBCPP_TEMPLATE_VIS weak_ptr; | 3817 | template <class _Up> friend class _LIBCPP_TEMPLATE_VIS weak_ptr; |
| 3905 | }; | 3818 | }; |
| 3906 | 3819 | ||
| 3820 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | ||
| 3821 | template<class _Tp> | ||
| 3822 | shared_ptr(weak_ptr<_Tp>) -> shared_ptr<_Tp>; | ||
| 3823 | template<class _Tp, class _Dp> | ||
| 3824 | shared_ptr(unique_ptr<_Tp, _Dp>) -> shared_ptr<_Tp>; | ||
| 3825 | #endif | ||
| 3907 | 3826 | ||
| 3908 | template<class _Tp> | 3827 | template<class _Tp> |
| 3909 | inline | 3828 | inline |
| ... | @@ -3926,13 +3845,13 @@ shared_ptr<_Tp>::shared_ptr(nullptr_t) _NOEXCEPT | ... | @@ -3926,13 +3845,13 @@ shared_ptr<_Tp>::shared_ptr(nullptr_t) _NOEXCEPT |
| 3926 | template<class _Tp> | 3845 | template<class _Tp> |
| 3927 | template<class _Yp> | 3846 | template<class _Yp> |
| 3928 | shared_ptr<_Tp>::shared_ptr(_Yp* __p, | 3847 | shared_ptr<_Tp>::shared_ptr(_Yp* __p, |
| 3929 | typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type) | 3848 | typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type) |
| 3930 | : __ptr_(__p) | 3849 | : __ptr_(__p) |
| 3931 | { | 3850 | { |
| 3932 | unique_ptr<_Yp> __hold(__p); | 3851 | unique_ptr<_Yp> __hold(__p); |
| 3933 | typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT; | 3852 | typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT; |
| 3934 | typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, _AllocT > _CntrlBlk; | 3853 | typedef __shared_ptr_pointer<_Yp*, __shared_ptr_default_delete<_Tp, _Yp>, _AllocT > _CntrlBlk; |
| 3935 | __cntrl_ = new _CntrlBlk(__p, default_delete<_Yp>(), _AllocT()); | 3854 | __cntrl_ = new _CntrlBlk(__p, __shared_ptr_default_delete<_Tp, _Yp>(), _AllocT()); |
| 3936 | __hold.release(); | 3855 | __hold.release(); |
| 3937 | __enable_weak_this(__p, __p); | 3856 | __enable_weak_this(__p, __p); |
| 3938 | } | 3857 | } |
| ... | @@ -3940,7 +3859,7 @@ shared_ptr<_Tp>::shared_ptr(_Yp* __p, | ... | @@ -3940,7 +3859,7 @@ shared_ptr<_Tp>::shared_ptr(_Yp* __p, |
| 3940 | template<class _Tp> | 3859 | template<class _Tp> |
| 3941 | template<class _Yp, class _Dp> | 3860 | template<class _Yp, class _Dp> |
| 3942 | shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, | 3861 | shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, |
| 3943 | typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type) | 3862 | typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type) |
| 3944 | : __ptr_(__p) | 3863 | : __ptr_(__p) |
| 3945 | { | 3864 | { |
| 3946 | #ifndef _LIBCPP_NO_EXCEPTIONS | 3865 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| ... | @@ -3986,7 +3905,7 @@ shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d) | ... | @@ -3986,7 +3905,7 @@ shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d) |
| 3986 | template<class _Tp> | 3905 | template<class _Tp> |
| 3987 | template<class _Yp, class _Dp, class _Alloc> | 3906 | template<class _Yp, class _Dp, class _Alloc> |
| 3988 | shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a, | 3907 | shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a, |
| 3989 | typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type) | 3908 | typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type) |
| 3990 | : __ptr_(__p) | 3909 | : __ptr_(__p) |
| 3991 | { | 3910 | { |
| 3992 | #ifndef _LIBCPP_NO_EXCEPTIONS | 3911 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| ... | @@ -4064,7 +3983,7 @@ template<class _Tp> | ... | @@ -4064,7 +3983,7 @@ template<class _Tp> |
| 4064 | template<class _Yp> | 3983 | template<class _Yp> |
| 4065 | inline | 3984 | inline |
| 4066 | shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, | 3985 | shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, |
| 4067 | typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type) | 3986 | typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type) |
| 4068 | _NOEXCEPT | 3987 | _NOEXCEPT |
| 4069 | : __ptr_(__r.__ptr_), | 3988 | : __ptr_(__r.__ptr_), |
| 4070 | __cntrl_(__r.__cntrl_) | 3989 | __cntrl_(__r.__cntrl_) |
| ... | @@ -4089,7 +4008,7 @@ template<class _Tp> | ... | @@ -4089,7 +4008,7 @@ template<class _Tp> |
| 4089 | template<class _Yp> | 4008 | template<class _Yp> |
| 4090 | inline | 4009 | inline |
| 4091 | shared_ptr<_Tp>::shared_ptr(shared_ptr<_Yp>&& __r, | 4010 | shared_ptr<_Tp>::shared_ptr(shared_ptr<_Yp>&& __r, |
| 4092 | typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type) | 4011 | typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type) |
| 4093 | _NOEXCEPT | 4012 | _NOEXCEPT |
| 4094 | : __ptr_(__r.__ptr_), | 4013 | : __ptr_(__r.__ptr_), |
| 4095 | __cntrl_(__r.__cntrl_) | 4014 | __cntrl_(__r.__cntrl_) |
| ... | @@ -4120,11 +4039,7 @@ shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp> __r, | ... | @@ -4120,11 +4039,7 @@ shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp> __r, |
| 4120 | 4039 | ||
| 4121 | template<class _Tp> | 4040 | template<class _Tp> |
| 4122 | template <class _Yp, class _Dp> | 4041 | template <class _Yp, class _Dp> |
| 4123 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | ||
| 4124 | shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r, | 4042 | shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r, |
| 4125 | #else | ||
| 4126 | shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r, | ||
| 4127 | #endif | ||
| 4128 | typename enable_if | 4043 | typename enable_if |
| 4129 | < | 4044 | < |
| 4130 | !is_lvalue_reference<_Dp>::value && | 4045 | !is_lvalue_reference<_Dp>::value && |
| ... | @@ -4150,11 +4065,7 @@ shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r, | ... | @@ -4150,11 +4065,7 @@ shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r, |
| 4150 | 4065 | ||
| 4151 | template<class _Tp> | 4066 | template<class _Tp> |
| 4152 | template <class _Yp, class _Dp> | 4067 | template <class _Yp, class _Dp> |
| 4153 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | ||
| 4154 | shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r, | 4068 | shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r, |
| 4155 | #else | ||
| 4156 | shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r, | ||
| 4157 | #endif | ||
| 4158 | typename enable_if | 4069 | typename enable_if |
| 4159 | < | 4070 | < |
| 4160 | is_lvalue_reference<_Dp>::value && | 4071 | is_lvalue_reference<_Dp>::value && |
| ... | @@ -4174,32 +4085,12 @@ shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r, | ... | @@ -4174,32 +4085,12 @@ shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r, |
| 4174 | typedef __shared_ptr_pointer<_Yp*, | 4085 | typedef __shared_ptr_pointer<_Yp*, |
| 4175 | reference_wrapper<typename remove_reference<_Dp>::type>, | 4086 | reference_wrapper<typename remove_reference<_Dp>::type>, |
| 4176 | _AllocT > _CntrlBlk; | 4087 | _AllocT > _CntrlBlk; |
| 4177 | __cntrl_ = new _CntrlBlk(__r.get(), ref(__r.get_deleter()), _AllocT()); | 4088 | __cntrl_ = new _CntrlBlk(__r.get(), _VSTD::ref(__r.get_deleter()), _AllocT()); |
| 4178 | __enable_weak_this(__r.get(), __r.get()); | 4089 | __enable_weak_this(__r.get(), __r.get()); |
| 4179 | } | 4090 | } |
| 4180 | __r.release(); | 4091 | __r.release(); |
| 4181 | } | 4092 | } |
| 4182 | 4093 | ||
| 4183 | template<class _Tp> | ||
| 4184 | template<class _Alloc, class ..._Args> | ||
| 4185 | shared_ptr<_Tp> | ||
| 4186 | shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _Args&& ...__args) | ||
| 4187 | { | ||
| 4188 | static_assert( is_constructible<_Tp, _Args...>::value, "Can't construct object in allocate_shared" ); | ||
| 4189 | typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; | ||
| 4190 | typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2; | ||
| 4191 | typedef __allocator_destructor<_A2> _D2; | ||
| 4192 | _A2 __a2(__a); | ||
| 4193 | unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); | ||
| 4194 | ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get()))) | ||
| 4195 | _CntrlBlk(__a, _VSTD::forward<_Args>(__args)...); | ||
| 4196 | shared_ptr<_Tp> __r; | ||
| 4197 | __r.__ptr_ = __hold2.get()->get(); | ||
| 4198 | __r.__cntrl_ = _VSTD::addressof(*__hold2.release()); | ||
| 4199 | __r.__enable_weak_this(__r.__ptr_, __r.__ptr_); | ||
| 4200 | return __r; | ||
| 4201 | } | ||
| 4202 | |||
| 4203 | template<class _Tp> | 4094 | template<class _Tp> |
| 4204 | shared_ptr<_Tp>::~shared_ptr() | 4095 | shared_ptr<_Tp>::~shared_ptr() |
| 4205 | { | 4096 | { |
| ... | @@ -4221,7 +4112,7 @@ template<class _Yp> | ... | @@ -4221,7 +4112,7 @@ template<class _Yp> |
| 4221 | inline | 4112 | inline |
| 4222 | typename enable_if | 4113 | typename enable_if |
| 4223 | < | 4114 | < |
| 4224 | is_convertible<_Yp*, typename shared_ptr<_Tp>::element_type*>::value, | 4115 | __compatible_with<_Yp, typename shared_ptr<_Tp>::element_type>::value, |
| 4225 | shared_ptr<_Tp>& | 4116 | shared_ptr<_Tp>& |
| 4226 | >::type | 4117 | >::type |
| 4227 | shared_ptr<_Tp>::operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT | 4118 | shared_ptr<_Tp>::operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT |
| ... | @@ -4246,7 +4137,7 @@ template<class _Yp> | ... | @@ -4246,7 +4137,7 @@ template<class _Yp> |
| 4246 | inline | 4137 | inline |
| 4247 | typename enable_if | 4138 | typename enable_if |
| 4248 | < | 4139 | < |
| 4249 | is_convertible<_Yp*, typename shared_ptr<_Tp>::element_type*>::value, | 4140 | __compatible_with<_Yp, typename shared_ptr<_Tp>::element_type>::value, |
| 4250 | shared_ptr<_Tp>& | 4141 | shared_ptr<_Tp>& |
| 4251 | >::type | 4142 | >::type |
| 4252 | shared_ptr<_Tp>::operator=(shared_ptr<_Yp>&& __r) | 4143 | shared_ptr<_Tp>::operator=(shared_ptr<_Yp>&& __r) |
| ... | @@ -4347,7 +4238,7 @@ template<class _Yp> | ... | @@ -4347,7 +4238,7 @@ template<class _Yp> |
| 4347 | inline | 4238 | inline |
| 4348 | typename enable_if | 4239 | typename enable_if |
| 4349 | < | 4240 | < |
| 4350 | is_convertible<_Yp*, typename shared_ptr<_Tp>::element_type*>::value, | 4241 | __compatible_with<_Yp, typename shared_ptr<_Tp>::element_type>::value, |
| 4351 | void | 4242 | void |
| 4352 | >::type | 4243 | >::type |
| 4353 | shared_ptr<_Tp>::reset(_Yp* __p) | 4244 | shared_ptr<_Tp>::reset(_Yp* __p) |
| ... | @@ -4360,7 +4251,7 @@ template<class _Yp, class _Dp> | ... | @@ -4360,7 +4251,7 @@ template<class _Yp, class _Dp> |
| 4360 | inline | 4251 | inline |
| 4361 | typename enable_if | 4252 | typename enable_if |
| 4362 | < | 4253 | < |
| 4363 | is_convertible<_Yp*, typename shared_ptr<_Tp>::element_type*>::value, | 4254 | __compatible_with<_Yp, typename shared_ptr<_Tp>::element_type>::value, |
| 4364 | void | 4255 | void |
| 4365 | >::type | 4256 | >::type |
| 4366 | shared_ptr<_Tp>::reset(_Yp* __p, _Dp __d) | 4257 | shared_ptr<_Tp>::reset(_Yp* __p, _Dp __d) |
| ... | @@ -4373,7 +4264,7 @@ template<class _Yp, class _Dp, class _Alloc> | ... | @@ -4373,7 +4264,7 @@ template<class _Yp, class _Dp, class _Alloc> |
| 4373 | inline | 4264 | inline |
| 4374 | typename enable_if | 4265 | typename enable_if |
| 4375 | < | 4266 | < |
| 4376 | is_convertible<_Yp*, typename shared_ptr<_Tp>::element_type*>::value, | 4267 | __compatible_with<_Yp, typename shared_ptr<_Tp>::element_type>::value, |
| 4377 | void | 4268 | void |
| 4378 | >::type | 4269 | >::type |
| 4379 | shared_ptr<_Tp>::reset(_Yp* __p, _Dp __d, _Alloc __a) | 4270 | shared_ptr<_Tp>::reset(_Yp* __p, _Dp __d, _Alloc __a) |
| ... | @@ -4412,7 +4303,19 @@ typename enable_if | ... | @@ -4412,7 +4303,19 @@ typename enable_if |
| 4412 | >::type | 4303 | >::type |
| 4413 | allocate_shared(const _Alloc& __a, _Args&& ...__args) | 4304 | allocate_shared(const _Alloc& __a, _Args&& ...__args) |
| 4414 | { | 4305 | { |
| 4415 | return shared_ptr<_Tp>::allocate_shared(__a, _VSTD::forward<_Args>(__args)...); | 4306 | static_assert( is_constructible<_Tp, _Args...>::value, "Can't construct object in allocate_shared"); |
| 4307 | |||
| 4308 | typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; | ||
| 4309 | typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2; | ||
| 4310 | typedef __allocator_destructor<_A2> _D2; | ||
| 4311 | |||
| 4312 | _A2 __a2(__a); | ||
| 4313 | unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); | ||
| 4314 | ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get()))) | ||
| 4315 | _CntrlBlk(__a, _VSTD::forward<_Args>(__args)...); | ||
| 4316 | |||
| 4317 | typename shared_ptr<_Tp>::element_type *__p = __hold2.get()->get(); | ||
| 4318 | return shared_ptr<_Tp>::__create_with_control_block(__p, _VSTD::addressof(*__hold2.release())); | ||
| 4416 | } | 4319 | } |
| 4417 | 4320 | ||
| 4418 | template<class _Tp, class _Up> | 4321 | template<class _Tp, class _Up> |
| ... | @@ -4575,41 +4478,41 @@ swap(shared_ptr<_Tp>& __x, shared_ptr<_Tp>& __y) _NOEXCEPT | ... | @@ -4575,41 +4478,41 @@ swap(shared_ptr<_Tp>& __x, shared_ptr<_Tp>& __y) _NOEXCEPT |
| 4575 | 4478 | ||
| 4576 | template<class _Tp, class _Up> | 4479 | template<class _Tp, class _Up> |
| 4577 | inline _LIBCPP_INLINE_VISIBILITY | 4480 | inline _LIBCPP_INLINE_VISIBILITY |
| 4578 | typename enable_if | 4481 | shared_ptr<_Tp> |
| 4579 | < | ||
| 4580 | !is_array<_Tp>::value && !is_array<_Up>::value, | ||
| 4581 | shared_ptr<_Tp> | ||
| 4582 | >::type | ||
| 4583 | static_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT | 4482 | static_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT |
| 4584 | { | 4483 | { |
| 4585 | return shared_ptr<_Tp>(__r, static_cast<_Tp*>(__r.get())); | 4484 | return shared_ptr<_Tp>(__r, |
| 4485 | static_cast< | ||
| 4486 | typename shared_ptr<_Tp>::element_type*>(__r.get())); | ||
| 4586 | } | 4487 | } |
| 4587 | 4488 | ||
| 4588 | template<class _Tp, class _Up> | 4489 | template<class _Tp, class _Up> |
| 4589 | inline _LIBCPP_INLINE_VISIBILITY | 4490 | inline _LIBCPP_INLINE_VISIBILITY |
| 4590 | typename enable_if | 4491 | shared_ptr<_Tp> |
| 4591 | < | ||
| 4592 | !is_array<_Tp>::value && !is_array<_Up>::value, | ||
| 4593 | shared_ptr<_Tp> | ||
| 4594 | >::type | ||
| 4595 | dynamic_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT | 4492 | dynamic_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT |
| 4596 | { | 4493 | { |
| 4597 | _Tp* __p = dynamic_cast<_Tp*>(__r.get()); | 4494 | typedef typename shared_ptr<_Tp>::element_type _ET; |
| 4495 | _ET* __p = dynamic_cast<_ET*>(__r.get()); | ||
| 4598 | return __p ? shared_ptr<_Tp>(__r, __p) : shared_ptr<_Tp>(); | 4496 | return __p ? shared_ptr<_Tp>(__r, __p) : shared_ptr<_Tp>(); |
| 4599 | } | 4497 | } |
| 4600 | 4498 | ||
| 4601 | template<class _Tp, class _Up> | 4499 | template<class _Tp, class _Up> |
| 4602 | typename enable_if | 4500 | shared_ptr<_Tp> |
| 4603 | < | ||
| 4604 | is_array<_Tp>::value == is_array<_Up>::value, | ||
| 4605 | shared_ptr<_Tp> | ||
| 4606 | >::type | ||
| 4607 | const_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT | 4501 | const_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT |
| 4608 | { | 4502 | { |
| 4609 | typedef typename remove_extent<_Tp>::type _RTp; | 4503 | typedef typename shared_ptr<_Tp>::element_type _RTp; |
| 4610 | return shared_ptr<_Tp>(__r, const_cast<_RTp*>(__r.get())); | 4504 | return shared_ptr<_Tp>(__r, const_cast<_RTp*>(__r.get())); |
| 4611 | } | 4505 | } |
| 4612 | 4506 | ||
| 4507 | template<class _Tp, class _Up> | ||
| 4508 | shared_ptr<_Tp> | ||
| 4509 | reinterpret_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT | ||
| 4510 | { | ||
| 4511 | return shared_ptr<_Tp>(__r, | ||
| 4512 | reinterpret_cast< | ||
| 4513 | typename shared_ptr<_Tp>::element_type*>(__r.get())); | ||
| 4514 | } | ||
| 4515 | |||
| 4613 | #ifndef _LIBCPP_NO_RTTI | 4516 | #ifndef _LIBCPP_NO_RTTI |
| 4614 | 4517 | ||
| 4615 | template<class _Dp, class _Tp> | 4518 | template<class _Dp, class _Tp> |
| ... | @@ -4712,6 +4615,11 @@ public: | ... | @@ -4712,6 +4615,11 @@ public: |
| 4712 | template <class _Up> friend class _LIBCPP_TEMPLATE_VIS shared_ptr; | 4615 | template <class _Up> friend class _LIBCPP_TEMPLATE_VIS shared_ptr; |
| 4713 | }; | 4616 | }; |
| 4714 | 4617 | ||
| 4618 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | ||
| 4619 | template<class _Tp> | ||
| 4620 | weak_ptr(shared_ptr<_Tp>) -> weak_ptr<_Tp>; | ||
| 4621 | #endif | ||
| 4622 | |||
| 4715 | template<class _Tp> | 4623 | template<class _Tp> |
| 4716 | inline | 4624 | inline |
| 4717 | _LIBCPP_CONSTEXPR | 4625 | _LIBCPP_CONSTEXPR |
| ... | @@ -5008,7 +4916,7 @@ struct _LIBCPP_TEMPLATE_VIS hash<shared_ptr<_Tp> > | ... | @@ -5008,7 +4916,7 @@ struct _LIBCPP_TEMPLATE_VIS hash<shared_ptr<_Tp> > |
| 5008 | _LIBCPP_INLINE_VISIBILITY | 4916 | _LIBCPP_INLINE_VISIBILITY |
| 5009 | result_type operator()(const argument_type& __ptr) const _NOEXCEPT | 4917 | result_type operator()(const argument_type& __ptr) const _NOEXCEPT |
| 5010 | { | 4918 | { |
| 5011 | return hash<_Tp*>()(__ptr.get()); | 4919 | return hash<typename shared_ptr<_Tp>::element_type*>()(__ptr.get()); |
| 5012 | } | 4920 | } |
| 5013 | }; | 4921 | }; |
| 5014 | 4922 |
lib/libcxx/include/module.modulemap+23| ... | @@ -231,6 +231,11 @@ module std [system] { | ... | @@ -231,6 +231,11 @@ module std [system] { |
| 231 | header "atomic" | 231 | header "atomic" |
| 232 | export * | 232 | export * |
| 233 | } | 233 | } |
| 234 | module barrier { | ||
| 235 | requires cplusplus14 | ||
| 236 | header "barrier" | ||
| 237 | export * | ||
| 238 | } | ||
| 234 | module bit { | 239 | module bit { |
| 235 | header "bit" | 240 | header "bit" |
| 236 | export * | 241 | export * |
| ... | @@ -262,6 +267,10 @@ module std [system] { | ... | @@ -262,6 +267,10 @@ module std [system] { |
| 262 | header "complex" | 267 | header "complex" |
| 263 | export * | 268 | export * |
| 264 | } | 269 | } |
| 270 | module concepts { | ||
| 271 | header "concepts" | ||
| 272 | export * | ||
| 273 | } | ||
| 265 | module condition_variable { | 274 | module condition_variable { |
| 266 | header "condition_variable" | 275 | header "condition_variable" |
| 267 | export * | 276 | export * |
| ... | @@ -334,6 +343,11 @@ module std [system] { | ... | @@ -334,6 +343,11 @@ module std [system] { |
| 334 | header "iterator" | 343 | header "iterator" |
| 335 | export * | 344 | export * |
| 336 | } | 345 | } |
| 346 | module latch { | ||
| 347 | requires cplusplus14 | ||
| 348 | header "latch" | ||
| 349 | export * | ||
| 350 | } | ||
| 337 | module limits { | 351 | module limits { |
| 338 | header "limits" | 352 | header "limits" |
| 339 | export * | 353 | export * |
| ... | @@ -364,6 +378,10 @@ module std [system] { | ... | @@ -364,6 +378,10 @@ module std [system] { |
| 364 | header "new" | 378 | header "new" |
| 365 | export * | 379 | export * |
| 366 | } | 380 | } |
| 381 | module numbers { | ||
| 382 | header "numbers" | ||
| 383 | export * | ||
| 384 | } | ||
| 367 | module numeric { | 385 | module numeric { |
| 368 | header "numeric" | 386 | header "numeric" |
| 369 | export * | 387 | export * |
| ... | @@ -400,6 +418,11 @@ module std [system] { | ... | @@ -400,6 +418,11 @@ module std [system] { |
| 400 | header "scoped_allocator" | 418 | header "scoped_allocator" |
| 401 | export * | 419 | export * |
| 402 | } | 420 | } |
| 421 | module semaphore { | ||
| 422 | requires cplusplus14 | ||
| 423 | header "semaphore" | ||
| 424 | export * | ||
| 425 | } | ||
| 403 | module set { | 426 | module set { |
| 404 | header "set" | 427 | header "set" |
| 405 | export initializer_list | 428 | export initializer_list |
lib/libcxx/include/numbers created+141| ... | @@ -0,0 +1,141 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===---------------------------- numbers ---------------------------------===// | ||
| 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_NUMBERS | ||
| 11 | #define _LIBCPP_NUMBERS | ||
| 12 | |||
| 13 | /* | ||
| 14 | numbers synopsis | ||
| 15 | |||
| 16 | namespace std::numbers { | ||
| 17 | template<class T> inline constexpr T e_v = unspecified; | ||
| 18 | template<class T> inline constexpr T log2e_v = unspecified; | ||
| 19 | template<class T> inline constexpr T log10e_v = unspecified; | ||
| 20 | template<class T> inline constexpr T pi_v = unspecified; | ||
| 21 | template<class T> inline constexpr T inv_pi_v = unspecified; | ||
| 22 | template<class T> inline constexpr T inv_sqrtpi_v = unspecified; | ||
| 23 | template<class T> inline constexpr T ln2_v = unspecified; | ||
| 24 | template<class T> inline constexpr T ln10_v = unspecified; | ||
| 25 | template<class T> inline constexpr T sqrt2_v = unspecified; | ||
| 26 | template<class T> inline constexpr T sqrt3_v = unspecified; | ||
| 27 | template<class T> inline constexpr T inv_sqrt3_v = unspecified; | ||
| 28 | template<class T> inline constexpr T egamma_v = unspecified; | ||
| 29 | template<class T> inline constexpr T phi_v = unspecified; | ||
| 30 | |||
| 31 | template<floating_point T> inline constexpr T e_v<T> = see below; | ||
| 32 | template<floating_point T> inline constexpr T log2e_v<T> = see below; | ||
| 33 | template<floating_point T> inline constexpr T log10e_v<T> = see below; | ||
| 34 | template<floating_point T> inline constexpr T pi_v<T> = see below; | ||
| 35 | template<floating_point T> inline constexpr T inv_pi_v<T> = see below; | ||
| 36 | template<floating_point T> inline constexpr T inv_sqrtpi_v<T> = see below; | ||
| 37 | template<floating_point T> inline constexpr T ln2_v<T> = see below; | ||
| 38 | template<floating_point T> inline constexpr T ln10_v<T> = see below; | ||
| 39 | template<floating_point T> inline constexpr T sqrt2_v<T> = see below; | ||
| 40 | template<floating_point T> inline constexpr T sqrt3_v<T> = see below; | ||
| 41 | template<floating_point T> inline constexpr T inv_sqrt3_v<T> = see below; | ||
| 42 | template<floating_point T> inline constexpr T egamma_v<T> = see below; | ||
| 43 | template<floating_point T> inline constexpr T phi_v<T> = see below; | ||
| 44 | |||
| 45 | inline constexpr double e = e_v<double>; | ||
| 46 | inline constexpr double log2e = log2e_v<double>; | ||
| 47 | inline constexpr double log10e = log10e_v<double>; | ||
| 48 | inline constexpr double pi = pi_v<double>; | ||
| 49 | inline constexpr double inv_pi = inv_pi_v<double>; | ||
| 50 | inline constexpr double inv_sqrtpi = inv_sqrtpi_v<double>; | ||
| 51 | inline constexpr double ln2 = ln2_v<double>; | ||
| 52 | inline constexpr double ln10 = ln10_v<double>; | ||
| 53 | inline constexpr double sqrt2 = sqrt2_v<double>; | ||
| 54 | inline constexpr double sqrt3 = sqrt3_v<double>; | ||
| 55 | inline constexpr double inv_sqrt3 = inv_sqrt3_v<double>; | ||
| 56 | inline constexpr double egamma = egamma_v<double>; | ||
| 57 | inline constexpr double phi = phi_v<double>; | ||
| 58 | } | ||
| 59 | */ | ||
| 60 | |||
| 61 | #include <__config> | ||
| 62 | |||
| 63 | #if _LIBCPP_STD_VER > 17 && defined(__cpp_concepts) && __cpp_concepts >= 201811L | ||
| 64 | |||
| 65 | #include <type_traits> | ||
| 66 | #include <version> | ||
| 67 | |||
| 68 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 69 | #pragma GCC system_header | ||
| 70 | #endif | ||
| 71 | |||
| 72 | _LIBCPP_PUSH_MACROS | ||
| 73 | #include <__undef_macros> | ||
| 74 | |||
| 75 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 76 | |||
| 77 | namespace numbers { | ||
| 78 | |||
| 79 | template <class T> | ||
| 80 | inline constexpr bool __false = false; | ||
| 81 | |||
| 82 | template <class T> | ||
| 83 | struct __illformed | ||
| 84 | { | ||
| 85 | static_assert(__false<T>, "A program that instantiates a primary template of a mathematical constant variable template is ill-formed."); | ||
| 86 | }; | ||
| 87 | |||
| 88 | template <class T> inline constexpr T e_v = __illformed<T>{}; | ||
| 89 | template <class T> inline constexpr T log2e_v = __illformed<T>{}; | ||
| 90 | template <class T> inline constexpr T log10e_v = __illformed<T>{}; | ||
| 91 | template <class T> inline constexpr T pi_v = __illformed<T>{}; | ||
| 92 | template <class T> inline constexpr T inv_pi_v = __illformed<T>{}; | ||
| 93 | template <class T> inline constexpr T inv_sqrtpi_v = __illformed<T>{}; | ||
| 94 | template <class T> inline constexpr T ln2_v = __illformed<T>{}; | ||
| 95 | template <class T> inline constexpr T ln10_v = __illformed<T>{}; | ||
| 96 | template <class T> inline constexpr T sqrt2_v = __illformed<T>{}; | ||
| 97 | template <class T> inline constexpr T sqrt3_v = __illformed<T>{}; | ||
| 98 | template <class T> inline constexpr T inv_sqrt3_v = __illformed<T>{}; | ||
| 99 | template <class T> inline constexpr T egamma_v = __illformed<T>{}; | ||
| 100 | template <class T> inline constexpr T phi_v = __illformed<T>{}; | ||
| 101 | |||
| 102 | template <class T> | ||
| 103 | concept __floating_point = std::is_floating_point_v<T>; | ||
| 104 | |||
| 105 | template <__floating_point T> inline constexpr T e_v<T> = 2.718281828459045235360287471352662; | ||
| 106 | template <__floating_point T> inline constexpr T log2e_v<T> = 1.442695040888963407359924681001892; | ||
| 107 | template <__floating_point T> inline constexpr T log10e_v<T> = 0.434294481903251827651128918916605; | ||
| 108 | template <__floating_point T> inline constexpr T pi_v<T> = 3.141592653589793238462643383279502; | ||
| 109 | template <__floating_point T> inline constexpr T inv_pi_v<T> = 0.318309886183790671537767526745028; | ||
| 110 | template <__floating_point T> inline constexpr T inv_sqrtpi_v<T> = 0.564189583547756286948079451560772; | ||
| 111 | template <__floating_point T> inline constexpr T ln2_v<T> = 0.693147180559945309417232121458176; | ||
| 112 | template <__floating_point T> inline constexpr T ln10_v<T> = 2.302585092994045684017991454684364; | ||
| 113 | template <__floating_point T> inline constexpr T sqrt2_v<T> = 1.414213562373095048801688724209698; | ||
| 114 | template <__floating_point T> inline constexpr T sqrt3_v<T> = 1.732050807568877293527446341505872; | ||
| 115 | template <__floating_point T> inline constexpr T inv_sqrt3_v<T> = 0.577350269189625764509148780501957; | ||
| 116 | template <__floating_point T> inline constexpr T egamma_v<T> = 0.577215664901532860606512090082402; | ||
| 117 | template <__floating_point T> inline constexpr T phi_v<T> = 1.618033988749894848204586834365638; | ||
| 118 | |||
| 119 | inline constexpr double e = e_v<double>; | ||
| 120 | inline constexpr double log2e = log2e_v<double>; | ||
| 121 | inline constexpr double log10e = log10e_v<double>; | ||
| 122 | inline constexpr double pi = pi_v<double>; | ||
| 123 | inline constexpr double inv_pi = inv_pi_v<double>; | ||
| 124 | inline constexpr double inv_sqrtpi = inv_sqrtpi_v<double>; | ||
| 125 | inline constexpr double ln2 = ln2_v<double>; | ||
| 126 | inline constexpr double ln10 = ln10_v<double>; | ||
| 127 | inline constexpr double sqrt2 = sqrt2_v<double>; | ||
| 128 | inline constexpr double sqrt3 = sqrt3_v<double>; | ||
| 129 | inline constexpr double inv_sqrt3 = inv_sqrt3_v<double>; | ||
| 130 | inline constexpr double egamma = egamma_v<double>; | ||
| 131 | inline constexpr double phi = phi_v<double>; | ||
| 132 | |||
| 133 | } // namespace numbers | ||
| 134 | |||
| 135 | _LIBCPP_END_NAMESPACE_STD | ||
| 136 | |||
| 137 | _LIBCPP_POP_MACROS | ||
| 138 | |||
| 139 | #endif //_LIBCPP_STD_VER > 17 && defined(__cpp_concepts) && __cpp_concepts >= 201811L | ||
| 140 | |||
| 141 | #endif // _LIBCPP_NUMBERS | ||
lib/libcxx/include/ostream+3-3| ... | @@ -999,7 +999,7 @@ basic_ostream<_CharT, _Traits>::seekp(off_type __off, ios_base::seekdir __dir) | ... | @@ -999,7 +999,7 @@ basic_ostream<_CharT, _Traits>::seekp(off_type __off, ios_base::seekdir __dir) |
| 999 | } | 999 | } |
| 1000 | 1000 | ||
| 1001 | template <class _CharT, class _Traits> | 1001 | template <class _CharT, class _Traits> |
| 1002 | inline _LIBCPP_INLINE_VISIBILITY | 1002 | inline |
| 1003 | basic_ostream<_CharT, _Traits>& | 1003 | basic_ostream<_CharT, _Traits>& |
| 1004 | endl(basic_ostream<_CharT, _Traits>& __os) | 1004 | endl(basic_ostream<_CharT, _Traits>& __os) |
| 1005 | { | 1005 | { |
| ... | @@ -1009,7 +1009,7 @@ endl(basic_ostream<_CharT, _Traits>& __os) | ... | @@ -1009,7 +1009,7 @@ endl(basic_ostream<_CharT, _Traits>& __os) |
| 1009 | } | 1009 | } |
| 1010 | 1010 | ||
| 1011 | template <class _CharT, class _Traits> | 1011 | template <class _CharT, class _Traits> |
| 1012 | inline _LIBCPP_INLINE_VISIBILITY | 1012 | inline |
| 1013 | basic_ostream<_CharT, _Traits>& | 1013 | basic_ostream<_CharT, _Traits>& |
| 1014 | ends(basic_ostream<_CharT, _Traits>& __os) | 1014 | ends(basic_ostream<_CharT, _Traits>& __os) |
| 1015 | { | 1015 | { |
| ... | @@ -1018,7 +1018,7 @@ ends(basic_ostream<_CharT, _Traits>& __os) | ... | @@ -1018,7 +1018,7 @@ ends(basic_ostream<_CharT, _Traits>& __os) |
| 1018 | } | 1018 | } |
| 1019 | 1019 | ||
| 1020 | template <class _CharT, class _Traits> | 1020 | template <class _CharT, class _Traits> |
| 1021 | inline _LIBCPP_INLINE_VISIBILITY | 1021 | inline |
| 1022 | basic_ostream<_CharT, _Traits>& | 1022 | basic_ostream<_CharT, _Traits>& |
| 1023 | flush(basic_ostream<_CharT, _Traits>& __os) | 1023 | flush(basic_ostream<_CharT, _Traits>& __os) |
| 1024 | { | 1024 | { |
lib/libcxx/include/random+5| ... | @@ -4048,10 +4048,12 @@ binomial_distribution<_IntType>::operator()(_URNG& __g, const param_type& __pr) | ... | @@ -4048,10 +4048,12 @@ binomial_distribution<_IntType>::operator()(_URNG& __g, const param_type& __pr) |
| 4048 | result_type __rd = __ru; | 4048 | result_type __rd = __ru; |
| 4049 | while (true) | 4049 | while (true) |
| 4050 | { | 4050 | { |
| 4051 | bool __break = true; | ||
| 4051 | if (__rd >= 1) | 4052 | if (__rd >= 1) |
| 4052 | { | 4053 | { |
| 4053 | __pd *= __rd / (__pr.__odds_ratio_ * (__pr.__t_ - __rd + 1)); | 4054 | __pd *= __rd / (__pr.__odds_ratio_ * (__pr.__t_ - __rd + 1)); |
| 4054 | __u -= __pd; | 4055 | __u -= __pd; |
| 4056 | __break = false; | ||
| 4055 | if (__u < 0) | 4057 | if (__u < 0) |
| 4056 | return __rd - 1; | 4058 | return __rd - 1; |
| 4057 | } | 4059 | } |
| ... | @@ -4062,9 +4064,12 @@ binomial_distribution<_IntType>::operator()(_URNG& __g, const param_type& __pr) | ... | @@ -4062,9 +4064,12 @@ binomial_distribution<_IntType>::operator()(_URNG& __g, const param_type& __pr) |
| 4062 | { | 4064 | { |
| 4063 | __pu *= (__pr.__t_ - __ru + 1) * __pr.__odds_ratio_ / __ru; | 4065 | __pu *= (__pr.__t_ - __ru + 1) * __pr.__odds_ratio_ / __ru; |
| 4064 | __u -= __pu; | 4066 | __u -= __pu; |
| 4067 | __break = false; | ||
| 4065 | if (__u < 0) | 4068 | if (__u < 0) |
| 4066 | return __ru; | 4069 | return __ru; |
| 4067 | } | 4070 | } |
| 4071 | if (__break) | ||
| 4072 | return 0; | ||
| 4068 | } | 4073 | } |
| 4069 | } | 4074 | } |
| 4070 | 4075 |
lib/libcxx/include/regex+47-21| ... | @@ -21,7 +21,7 @@ namespace std | ... | @@ -21,7 +21,7 @@ namespace std |
| 21 | namespace regex_constants | 21 | namespace regex_constants |
| 22 | { | 22 | { |
| 23 | 23 | ||
| 24 | emum syntax_option_type | 24 | enum syntax_option_type |
| 25 | { | 25 | { |
| 26 | icase = unspecified, | 26 | icase = unspecified, |
| 27 | nosubs = unspecified, | 27 | nosubs = unspecified, |
| ... | @@ -631,7 +631,7 @@ template <class OutputIterator, class BidirectionalIterator, | ... | @@ -631,7 +631,7 @@ template <class OutputIterator, class BidirectionalIterator, |
| 631 | const basic_regex<charT, traits>& e, const charT* fmt, | 631 | const basic_regex<charT, traits>& e, const charT* fmt, |
| 632 | regex_constants::match_flag_type flags = regex_constants::match_default); | 632 | regex_constants::match_flag_type flags = regex_constants::match_default); |
| 633 | 633 | ||
| 634 | template <class traits, class charT, class ST, class SA, class FST, class FSA>> | 634 | template <class traits, class charT, class ST, class SA, class FST, class FSA> |
| 635 | basic_string<charT, ST, SA> | 635 | basic_string<charT, ST, SA> |
| 636 | regex_replace(const basic_string<charT, ST, SA>& s, | 636 | regex_replace(const basic_string<charT, ST, SA>& s, |
| 637 | const basic_regex<charT, traits>& e, | 637 | const basic_regex<charT, traits>& e, |
| ... | @@ -675,9 +675,9 @@ public: | ... | @@ -675,9 +675,9 @@ public: |
| 675 | regex_iterator(BidirectionalIterator a, BidirectionalIterator b, | 675 | regex_iterator(BidirectionalIterator a, BidirectionalIterator b, |
| 676 | const regex_type& re, | 676 | const regex_type& re, |
| 677 | regex_constants::match_flag_type m = regex_constants::match_default); | 677 | regex_constants::match_flag_type m = regex_constants::match_default); |
| 678 | regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, | 678 | regex_iterator(BidirectionalIterator a, BidirectionalIterator b, |
| 679 | const regex_type&& __re, | 679 | const regex_type&& re, |
| 680 | regex_constants::match_flag_type __m | 680 | regex_constants::match_flag_type m |
| 681 | = regex_constants::match_default) = delete; // C++14 | 681 | = regex_constants::match_default) = delete; // C++14 |
| 682 | regex_iterator(const regex_iterator&); | 682 | regex_iterator(const regex_iterator&); |
| 683 | regex_iterator& operator=(const regex_iterator&); | 683 | regex_iterator& operator=(const regex_iterator&); |
| ... | @@ -698,7 +698,7 @@ typedef regex_iterator<string::const_iterator> sregex_iterator; | ... | @@ -698,7 +698,7 @@ typedef regex_iterator<string::const_iterator> sregex_iterator; |
| 698 | typedef regex_iterator<wstring::const_iterator> wsregex_iterator; | 698 | typedef regex_iterator<wstring::const_iterator> wsregex_iterator; |
| 699 | 699 | ||
| 700 | template <class BidirectionalIterator, | 700 | template <class BidirectionalIterator, |
| 701 | class charT = typename iterator_traits< BidirectionalIterator>::value_type, | 701 | class charT = typename iterator_traits<BidirectionalIterator>::value_type, |
| 702 | class traits = regex_traits<charT>> | 702 | class traits = regex_traits<charT>> |
| 703 | class regex_token_iterator | 703 | class regex_token_iterator |
| 704 | { | 704 | { |
| ... | @@ -735,8 +735,8 @@ public: | ... | @@ -735,8 +735,8 @@ public: |
| 735 | regex_constants::match_flag_type m = regex_constants::match_default); | 735 | regex_constants::match_flag_type m = regex_constants::match_default); |
| 736 | template <size_t N> | 736 | template <size_t N> |
| 737 | regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, | 737 | regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, |
| 738 | const regex_type& re, const int (&submatches)[N], | 738 | const regex_type&& re, const int (&submatches)[N], |
| 739 | regex_constants::match_flag_type m = regex_constants::match_default) = delete // C++14; | 739 | regex_constants::match_flag_type m = regex_constants::match_default) = delete; // C++14 |
| 740 | regex_token_iterator(const regex_token_iterator&); | 740 | regex_token_iterator(const regex_token_iterator&); |
| 741 | regex_token_iterator& operator=(const regex_token_iterator&); | 741 | regex_token_iterator& operator=(const regex_token_iterator&); |
| 742 | 742 | ||
| ... | @@ -977,7 +977,8 @@ class _LIBCPP_EXCEPTION_ABI regex_error | ... | @@ -977,7 +977,8 @@ class _LIBCPP_EXCEPTION_ABI regex_error |
| 977 | regex_constants::error_type __code_; | 977 | regex_constants::error_type __code_; |
| 978 | public: | 978 | public: |
| 979 | explicit regex_error(regex_constants::error_type __ecode); | 979 | explicit regex_error(regex_constants::error_type __ecode); |
| 980 | virtual ~regex_error() throw(); | 980 | regex_error(const regex_error&) _NOEXCEPT = default; |
| 981 | virtual ~regex_error() _NOEXCEPT; | ||
| 981 | _LIBCPP_INLINE_VISIBILITY | 982 | _LIBCPP_INLINE_VISIBILITY |
| 982 | regex_constants::error_type code() const {return __code_;} | 983 | regex_constants::error_type code() const {return __code_;} |
| 983 | }; | 984 | }; |
| ... | @@ -1000,7 +1001,19 @@ public: | ... | @@ -1000,7 +1001,19 @@ public: |
| 1000 | typedef _CharT char_type; | 1001 | typedef _CharT char_type; |
| 1001 | typedef basic_string<char_type> string_type; | 1002 | typedef basic_string<char_type> string_type; |
| 1002 | typedef locale locale_type; | 1003 | typedef locale locale_type; |
| 1004 | #ifdef __BIONIC__ | ||
| 1005 | // Originally bionic's ctype_base used its own ctype masks because the | ||
| 1006 | // builtin ctype implementation wasn't in libc++ yet. Bionic's ctype mask | ||
| 1007 | // was only 8 bits wide and already saturated, so it used a wider type here | ||
| 1008 | // to make room for __regex_word (then a part of this class rather than | ||
| 1009 | // ctype_base). Bionic has since moved to the builtin ctype_base | ||
| 1010 | // implementation, but this was not updated to match. Since then Android has | ||
| 1011 | // needed to maintain a stable libc++ ABI, and this can't be changed without | ||
| 1012 | // an ABI break. | ||
| 1013 | typedef uint16_t char_class_type; | ||
| 1014 | #else | ||
| 1003 | typedef ctype_base::mask char_class_type; | 1015 | typedef ctype_base::mask char_class_type; |
| 1016 | #endif | ||
| 1004 | 1017 | ||
| 1005 | static const char_class_type __regex_word = ctype_base::__regex_word; | 1018 | static const char_class_type __regex_word = ctype_base::__regex_word; |
| 1006 | private: | 1019 | private: |
| ... | @@ -2837,6 +2850,8 @@ private: | ... | @@ -2837,6 +2850,8 @@ private: |
| 2837 | __parse_awk_escape(_ForwardIterator __first, _ForwardIterator __last, | 2850 | __parse_awk_escape(_ForwardIterator __first, _ForwardIterator __last, |
| 2838 | basic_string<_CharT>* __str = nullptr); | 2851 | basic_string<_CharT>* __str = nullptr); |
| 2839 | 2852 | ||
| 2853 | bool __test_back_ref(_CharT c); | ||
| 2854 | |||
| 2840 | _LIBCPP_INLINE_VISIBILITY | 2855 | _LIBCPP_INLINE_VISIBILITY |
| 2841 | void __push_l_anchor(); | 2856 | void __push_l_anchor(); |
| 2842 | void __push_r_anchor(); | 2857 | void __push_r_anchor(); |
| ... | @@ -3408,18 +3423,8 @@ basic_regex<_CharT, _Traits>::__parse_BACKREF(_ForwardIterator __first, | ... | @@ -3408,18 +3423,8 @@ basic_regex<_CharT, _Traits>::__parse_BACKREF(_ForwardIterator __first, |
| 3408 | if (__first != __last) | 3423 | if (__first != __last) |
| 3409 | { | 3424 | { |
| 3410 | _ForwardIterator __temp = _VSTD::next(__first); | 3425 | _ForwardIterator __temp = _VSTD::next(__first); |
| 3411 | if (__temp != __last) | 3426 | if (__temp != __last && *__first == '\\' && __test_back_ref(*__temp)) |
| 3412 | { | 3427 | __first = ++__temp; |
| 3413 | if (*__first == '\\') | ||
| 3414 | { | ||
| 3415 | int __val = __traits_.value(*__temp, 10); | ||
| 3416 | if (__val >= 1 && __val <= 9) | ||
| 3417 | { | ||
| 3418 | __push_back_ref(__val); | ||
| 3419 | __first = ++__temp; | ||
| 3420 | } | ||
| 3421 | } | ||
| 3422 | } | ||
| 3423 | } | 3428 | } |
| 3424 | return __first; | 3429 | return __first; |
| 3425 | } | 3430 | } |
| ... | @@ -3547,6 +3552,8 @@ basic_regex<_CharT, _Traits>::__parse_QUOTED_CHAR_ERE(_ForwardIterator __first, | ... | @@ -3547,6 +3552,8 @@ basic_regex<_CharT, _Traits>::__parse_QUOTED_CHAR_ERE(_ForwardIterator __first, |
| 3547 | default: | 3552 | default: |
| 3548 | if (__get_grammar(__flags_) == awk) | 3553 | if (__get_grammar(__flags_) == awk) |
| 3549 | __first = __parse_awk_escape(++__first, __last); | 3554 | __first = __parse_awk_escape(++__first, __last); |
| 3555 | else if(__test_back_ref(*__temp)) | ||
| 3556 | __first = ++__temp; | ||
| 3550 | break; | 3557 | break; |
| 3551 | } | 3558 | } |
| 3552 | } | 3559 | } |
| ... | @@ -4660,6 +4667,22 @@ basic_regex<_CharT, _Traits>::__parse_egrep(_ForwardIterator __first, | ... | @@ -4660,6 +4667,22 @@ basic_regex<_CharT, _Traits>::__parse_egrep(_ForwardIterator __first, |
| 4660 | return __first; | 4667 | return __first; |
| 4661 | } | 4668 | } |
| 4662 | 4669 | ||
| 4670 | template <class _CharT, class _Traits> | ||
| 4671 | bool | ||
| 4672 | basic_regex<_CharT, _Traits>::__test_back_ref(_CharT c) | ||
| 4673 | { | ||
| 4674 | unsigned __val = __traits_.value(c, 10); | ||
| 4675 | if (__val >= 1 && __val <= 9) | ||
| 4676 | { | ||
| 4677 | if (__val > mark_count()) | ||
| 4678 | __throw_regex_error<regex_constants::error_backref>(); | ||
| 4679 | __push_back_ref(__val); | ||
| 4680 | return true; | ||
| 4681 | } | ||
| 4682 | |||
| 4683 | return false; | ||
| 4684 | } | ||
| 4685 | |||
| 4663 | template <class _CharT, class _Traits> | 4686 | template <class _CharT, class _Traits> |
| 4664 | void | 4687 | void |
| 4665 | basic_regex<_CharT, _Traits>::__push_loop(size_t __min, size_t __max, | 4688 | basic_regex<_CharT, _Traits>::__push_loop(size_t __min, size_t __max, |
| ... | @@ -5917,6 +5940,9 @@ basic_regex<_CharT, _Traits>::__search( | ... | @@ -5917,6 +5940,9 @@ basic_regex<_CharT, _Traits>::__search( |
| 5917 | match_results<const _CharT*, _Allocator>& __m, | 5940 | match_results<const _CharT*, _Allocator>& __m, |
| 5918 | regex_constants::match_flag_type __flags) const | 5941 | regex_constants::match_flag_type __flags) const |
| 5919 | { | 5942 | { |
| 5943 | if (__flags & regex_constants::match_prev_avail) | ||
| 5944 | __flags &= ~(regex_constants::match_not_bol | regex_constants::match_not_bow); | ||
| 5945 | |||
| 5920 | __m.__init(1 + mark_count(), __first, __last, | 5946 | __m.__init(1 + mark_count(), __first, __last, |
| 5921 | __flags & regex_constants::__no_update_pos); | 5947 | __flags & regex_constants::__no_update_pos); |
| 5922 | if (__match_at_start(__first, __last, __m, __flags, | 5948 | if (__match_at_start(__first, __last, __m, __flags, |
lib/libcxx/include/semaphore created+235| ... | @@ -0,0 +1,235 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===--------------------------- semaphore --------------------------------===// | ||
| 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_SEMAPHORE | ||
| 11 | #define _LIBCPP_SEMAPHORE | ||
| 12 | |||
| 13 | /* | ||
| 14 | semaphore synopsis | ||
| 15 | |||
| 16 | namespace std { | ||
| 17 | |||
| 18 | template<ptrdiff_t least_max_value = implementation-defined> | ||
| 19 | class counting_semaphore | ||
| 20 | { | ||
| 21 | public: | ||
| 22 | static constexpr ptrdiff_t max() noexcept; | ||
| 23 | |||
| 24 | constexpr explicit counting_semaphore(ptrdiff_t desired); | ||
| 25 | ~counting_semaphore(); | ||
| 26 | |||
| 27 | counting_semaphore(const counting_semaphore&) = delete; | ||
| 28 | counting_semaphore& operator=(const counting_semaphore&) = delete; | ||
| 29 | |||
| 30 | void release(ptrdiff_t update = 1); | ||
| 31 | void acquire(); | ||
| 32 | bool try_acquire() noexcept; | ||
| 33 | template<class Rep, class Period> | ||
| 34 | bool try_acquire_for(const chrono::duration<Rep, Period>& rel_time); | ||
| 35 | template<class Clock, class Duration> | ||
| 36 | bool try_acquire_until(const chrono::time_point<Clock, Duration>& abs_time); | ||
| 37 | |||
| 38 | private: | ||
| 39 | ptrdiff_t counter; // exposition only | ||
| 40 | }; | ||
| 41 | |||
| 42 | using binary_semaphore = counting_semaphore<1>; | ||
| 43 | |||
| 44 | } | ||
| 45 | |||
| 46 | */ | ||
| 47 | |||
| 48 | #include <__config> | ||
| 49 | #include <__threading_support> | ||
| 50 | #include <atomic> | ||
| 51 | #include <cassert> | ||
| 52 | |||
| 53 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 54 | #pragma GCC system_header | ||
| 55 | #endif | ||
| 56 | |||
| 57 | #ifdef _LIBCPP_HAS_NO_THREADS | ||
| 58 | # error <semaphore> is not supported on this single threaded system | ||
| 59 | #endif | ||
| 60 | |||
| 61 | #if _LIBCPP_STD_VER >= 14 | ||
| 62 | |||
| 63 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 64 | |||
| 65 | /* | ||
| 66 | |||
| 67 | __atomic_semaphore_base is the general-case implementation, to be used for | ||
| 68 | user-requested least-max values that exceed the OS implementation support | ||
| 69 | (incl. when the OS has no support of its own) and for binary semaphores. | ||
| 70 | |||
| 71 | It is a typical Dijsktra semaphore algorithm over atomics, wait and notify | ||
| 72 | functions. It avoids contention against users' own use of those facilities. | ||
| 73 | |||
| 74 | */ | ||
| 75 | |||
| 76 | class __atomic_semaphore_base | ||
| 77 | { | ||
| 78 | __atomic_base<ptrdiff_t> __a; | ||
| 79 | |||
| 80 | public: | ||
| 81 | _LIBCPP_INLINE_VISIBILITY | ||
| 82 | __atomic_semaphore_base(ptrdiff_t __count) : __a(__count) | ||
| 83 | { | ||
| 84 | } | ||
| 85 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 86 | void release(ptrdiff_t __update = 1) | ||
| 87 | { | ||
| 88 | if(0 < __a.fetch_add(__update, memory_order_release)) | ||
| 89 | ; | ||
| 90 | else if(__update > 1) | ||
| 91 | __a.notify_all(); | ||
| 92 | else | ||
| 93 | __a.notify_one(); | ||
| 94 | } | ||
| 95 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 96 | void acquire() | ||
| 97 | { | ||
| 98 | auto const __test_fn = [=]() -> bool { | ||
| 99 | auto __old = __a.load(memory_order_relaxed); | ||
| 100 | return (__old != 0) && __a.compare_exchange_strong(__old, __old - 1, memory_order_acquire, memory_order_relaxed); | ||
| 101 | }; | ||
| 102 | __cxx_atomic_wait(&__a.__a_, __test_fn); | ||
| 103 | } | ||
| 104 | template <class Rep, class Period> | ||
| 105 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 106 | bool try_acquire_for(chrono::duration<Rep, Period> const& __rel_time) | ||
| 107 | { | ||
| 108 | auto const __test_fn = [=]() -> bool { | ||
| 109 | auto __old = __a.load(memory_order_acquire); | ||
| 110 | while(1) { | ||
| 111 | if (__old == 0) | ||
| 112 | return false; | ||
| 113 | if(__a.compare_exchange_strong(__old, __old - 1, memory_order_acquire, memory_order_relaxed)) | ||
| 114 | return true; | ||
| 115 | } | ||
| 116 | }; | ||
| 117 | return __libcpp_thread_poll_with_backoff(__test_fn, __libcpp_timed_backoff_policy(), __rel_time); | ||
| 118 | } | ||
| 119 | }; | ||
| 120 | |||
| 121 | #ifndef _LIBCPP_NO_NATIVE_SEMAPHORES | ||
| 122 | |||
| 123 | /* | ||
| 124 | |||
| 125 | __platform_semaphore_base a simple wrapper for the OS semaphore type. That | ||
| 126 | is, every call is routed to the OS in the most direct manner possible. | ||
| 127 | |||
| 128 | */ | ||
| 129 | |||
| 130 | class __platform_semaphore_base | ||
| 131 | { | ||
| 132 | __libcpp_semaphore_t __semaphore; | ||
| 133 | |||
| 134 | public: | ||
| 135 | _LIBCPP_INLINE_VISIBILITY | ||
| 136 | __platform_semaphore_base(ptrdiff_t __count) : | ||
| 137 | __semaphore() | ||
| 138 | { | ||
| 139 | __libcpp_semaphore_init(&__semaphore, __count); | ||
| 140 | } | ||
| 141 | _LIBCPP_INLINE_VISIBILITY | ||
| 142 | ~__platform_semaphore_base() { | ||
| 143 | __libcpp_semaphore_destroy(&__semaphore); | ||
| 144 | } | ||
| 145 | _LIBCPP_INLINE_VISIBILITY | ||
| 146 | void release(ptrdiff_t __update) | ||
| 147 | { | ||
| 148 | for(; __update; --__update) | ||
| 149 | __libcpp_semaphore_post(&__semaphore); | ||
| 150 | } | ||
| 151 | _LIBCPP_INLINE_VISIBILITY | ||
| 152 | void acquire() | ||
| 153 | { | ||
| 154 | __libcpp_semaphore_wait(&__semaphore); | ||
| 155 | } | ||
| 156 | _LIBCPP_INLINE_VISIBILITY | ||
| 157 | bool try_acquire_for(chrono::nanoseconds __rel_time) | ||
| 158 | { | ||
| 159 | return __libcpp_semaphore_wait_timed(&__semaphore, __rel_time); | ||
| 160 | } | ||
| 161 | }; | ||
| 162 | |||
| 163 | template<ptrdiff_t __least_max_value> | ||
| 164 | using __semaphore_base = | ||
| 165 | typename conditional<(__least_max_value > 1 && __least_max_value <= _LIBCPP_SEMAPHORE_MAX), | ||
| 166 | __platform_semaphore_base, | ||
| 167 | __atomic_semaphore_base>::type; | ||
| 168 | |||
| 169 | #else | ||
| 170 | |||
| 171 | template<ptrdiff_t __least_max_value> | ||
| 172 | using __semaphore_base = | ||
| 173 | __atomic_semaphore_base; | ||
| 174 | |||
| 175 | #define _LIBCPP_SEMAPHORE_MAX (numeric_limits<ptrdiff_t>::max()) | ||
| 176 | |||
| 177 | #endif //_LIBCPP_NO_NATIVE_SEMAPHORES | ||
| 178 | |||
| 179 | template<ptrdiff_t __least_max_value = _LIBCPP_SEMAPHORE_MAX> | ||
| 180 | class counting_semaphore | ||
| 181 | { | ||
| 182 | __semaphore_base<__least_max_value> __semaphore; | ||
| 183 | |||
| 184 | public: | ||
| 185 | static constexpr ptrdiff_t max() noexcept { | ||
| 186 | return __least_max_value; | ||
| 187 | } | ||
| 188 | |||
| 189 | _LIBCPP_INLINE_VISIBILITY | ||
| 190 | counting_semaphore(ptrdiff_t __count = 0) : __semaphore(__count) { } | ||
| 191 | ~counting_semaphore() = default; | ||
| 192 | |||
| 193 | counting_semaphore(const counting_semaphore&) = delete; | ||
| 194 | counting_semaphore& operator=(const counting_semaphore&) = delete; | ||
| 195 | |||
| 196 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 197 | void release(ptrdiff_t __update = 1) | ||
| 198 | { | ||
| 199 | __semaphore.release(__update); | ||
| 200 | } | ||
| 201 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 202 | void acquire() | ||
| 203 | { | ||
| 204 | __semaphore.acquire(); | ||
| 205 | } | ||
| 206 | template<class Rep, class Period> | ||
| 207 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 208 | bool try_acquire_for(chrono::duration<Rep, Period> const& __rel_time) | ||
| 209 | { | ||
| 210 | return __semaphore.try_acquire_for(chrono::duration_cast<chrono::nanoseconds>(__rel_time)); | ||
| 211 | } | ||
| 212 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 213 | bool try_acquire() | ||
| 214 | { | ||
| 215 | return try_acquire_for(chrono::nanoseconds::zero()); | ||
| 216 | } | ||
| 217 | template <class Clock, class Duration> | ||
| 218 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | ||
| 219 | bool try_acquire_until(chrono::time_point<Clock, Duration> const& __abs_time) | ||
| 220 | { | ||
| 221 | auto const current = Clock::now(); | ||
| 222 | if(current >= __abs_time) | ||
| 223 | return try_acquire(); | ||
| 224 | else | ||
| 225 | return try_acquire_for(__abs_time - current); | ||
| 226 | } | ||
| 227 | }; | ||
| 228 | |||
| 229 | using binary_semaphore = counting_semaphore<1>; | ||
| 230 | |||
| 231 | _LIBCPP_END_NAMESPACE_STD | ||
| 232 | |||
| 233 | #endif // _LIBCPP_STD_VER >= 14 | ||
| 234 | |||
| 235 | #endif //_LIBCPP_SEMAPHORE | ||
lib/libcxx/include/set+12-6| ... | @@ -216,7 +216,8 @@ swap(set<Key, Compare, Allocator>& x, set<Key, Compare, Allocator>& y) | ... | @@ -216,7 +216,8 @@ swap(set<Key, Compare, Allocator>& x, set<Key, Compare, Allocator>& y) |
| 216 | noexcept(noexcept(x.swap(y))); | 216 | noexcept(noexcept(x.swap(y))); |
| 217 | 217 | ||
| 218 | template <class Key, class Compare, class Allocator, class Predicate> | 218 | template <class Key, class Compare, class Allocator, class Predicate> |
| 219 | void erase_if(set<Key, Compare, Allocator>& c, Predicate pred); // C++20 | 219 | typename set<Key, Compare, Allocator>::size_type |
| 220 | erase_if(set<Key, Compare, Allocator>& c, Predicate pred); // C++20 | ||
| 220 | 221 | ||
| 221 | template <class Key, class Compare = less<Key>, | 222 | template <class Key, class Compare = less<Key>, |
| 222 | class Allocator = allocator<Key>> | 223 | class Allocator = allocator<Key>> |
| ... | @@ -417,7 +418,8 @@ swap(multiset<Key, Compare, Allocator>& x, multiset<Key, Compare, Allocator>& y) | ... | @@ -417,7 +418,8 @@ swap(multiset<Key, Compare, Allocator>& x, multiset<Key, Compare, Allocator>& y) |
| 417 | noexcept(noexcept(x.swap(y))); | 418 | noexcept(noexcept(x.swap(y))); |
| 418 | 419 | ||
| 419 | template <class Key, class Compare, class Allocator, class Predicate> | 420 | template <class Key, class Compare, class Allocator, class Predicate> |
| 420 | void erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20 | 421 | typename multiset<Key, Compare, Allocator>::size_type |
| 422 | erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20 | ||
| 421 | 423 | ||
| 422 | } // std | 424 | } // std |
| 423 | 425 | ||
| ... | @@ -960,8 +962,10 @@ swap(set<_Key, _Compare, _Allocator>& __x, | ... | @@ -960,8 +962,10 @@ swap(set<_Key, _Compare, _Allocator>& __x, |
| 960 | #if _LIBCPP_STD_VER > 17 | 962 | #if _LIBCPP_STD_VER > 17 |
| 961 | template <class _Key, class _Compare, class _Allocator, class _Predicate> | 963 | template <class _Key, class _Compare, class _Allocator, class _Predicate> |
| 962 | inline _LIBCPP_INLINE_VISIBILITY | 964 | inline _LIBCPP_INLINE_VISIBILITY |
| 963 | void erase_if(set<_Key, _Compare, _Allocator>& __c, _Predicate __pred) | 965 | typename set<_Key, _Compare, _Allocator>::size_type |
| 964 | { __libcpp_erase_if_container(__c, __pred); } | 966 | erase_if(set<_Key, _Compare, _Allocator>& __c, _Predicate __pred) { |
| 967 | return __libcpp_erase_if_container(__c, __pred); | ||
| 968 | } | ||
| 965 | #endif | 969 | #endif |
| 966 | 970 | ||
| 967 | template <class _Key, class _Compare = less<_Key>, | 971 | template <class _Key, class _Compare = less<_Key>, |
| ... | @@ -1484,8 +1488,10 @@ swap(multiset<_Key, _Compare, _Allocator>& __x, | ... | @@ -1484,8 +1488,10 @@ swap(multiset<_Key, _Compare, _Allocator>& __x, |
| 1484 | #if _LIBCPP_STD_VER > 17 | 1488 | #if _LIBCPP_STD_VER > 17 |
| 1485 | template <class _Key, class _Compare, class _Allocator, class _Predicate> | 1489 | template <class _Key, class _Compare, class _Allocator, class _Predicate> |
| 1486 | inline _LIBCPP_INLINE_VISIBILITY | 1490 | inline _LIBCPP_INLINE_VISIBILITY |
| 1487 | void erase_if(multiset<_Key, _Compare, _Allocator>& __c, _Predicate __pred) | 1491 | typename multiset<_Key, _Compare, _Allocator>::size_type |
| 1488 | { __libcpp_erase_if_container(__c, __pred); } | 1492 | erase_if(multiset<_Key, _Compare, _Allocator>& __c, _Predicate __pred) { |
| 1493 | return __libcpp_erase_if_container(__c, __pred); | ||
| 1494 | } | ||
| 1489 | #endif | 1495 | #endif |
| 1490 | 1496 | ||
| 1491 | _LIBCPP_END_NAMESPACE_STD | 1497 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/span+64-106| ... | @@ -46,15 +46,13 @@ public: | ... | @@ -46,15 +46,13 @@ public: |
| 46 | using reference = element_type&; | 46 | using reference = element_type&; |
| 47 | using const_reference = const element_type&; | 47 | using const_reference = const element_type&; |
| 48 | using iterator = implementation-defined; | 48 | using iterator = implementation-defined; |
| 49 | using const_iterator = implementation-defined; | ||
| 50 | using reverse_iterator = std::reverse_iterator<iterator>; | 49 | using reverse_iterator = std::reverse_iterator<iterator>; |
| 51 | using const_reverse_iterator = std::reverse_iterator<const_iterator>; | ||
| 52 | static constexpr size_type extent = Extent; | 50 | static constexpr size_type extent = Extent; |
| 53 | 51 | ||
| 54 | // [span.cons], span constructors, copy, assignment, and destructor | 52 | // [span.cons], span constructors, copy, assignment, and destructor |
| 55 | constexpr span() noexcept; | 53 | constexpr span() noexcept; |
| 56 | constexpr span(pointer ptr, size_type count); | 54 | constexpr explicit(Extent != dynamic_extent) span(pointer ptr, size_type count); |
| 57 | constexpr span(pointer firstElem, pointer lastElem); | 55 | constexpr explicit(Extent != dynamic_extent) span(pointer firstElem, pointer lastElem); |
| 58 | template <size_t N> | 56 | template <size_t N> |
| 59 | constexpr span(element_type (&arr)[N]) noexcept; | 57 | constexpr span(element_type (&arr)[N]) noexcept; |
| 60 | template <size_t N> | 58 | template <size_t N> |
| ... | @@ -62,12 +60,12 @@ public: | ... | @@ -62,12 +60,12 @@ public: |
| 62 | template <size_t N> | 60 | template <size_t N> |
| 63 | constexpr span(const array<value_type, N>& arr) noexcept; | 61 | constexpr span(const array<value_type, N>& arr) noexcept; |
| 64 | template <class Container> | 62 | template <class Container> |
| 65 | constexpr span(Container& cont); | 63 | constexpr explicit(Extent != dynamic_extent) span(Container& cont); |
| 66 | template <class Container> | 64 | template <class Container> |
| 67 | constexpr span(const Container& cont); | 65 | constexpr explicit(Extent != dynamic_extent) span(const Container& cont); |
| 68 | constexpr span(const span& other) noexcept = default; | 66 | constexpr span(const span& other) noexcept = default; |
| 69 | template <class OtherElementType, size_t OtherExtent> | 67 | template <class OtherElementType, size_t OtherExtent> |
| 70 | constexpr span(const span<OtherElementType, OtherExtent>& s) noexcept; | 68 | constexpr explicit(Extent != dynamic_extent) span(const span<OtherElementType, OtherExtent>& s) noexcept; |
| 71 | ~span() noexcept = default; | 69 | ~span() noexcept = default; |
| 72 | constexpr span& operator=(const span& other) noexcept = default; | 70 | constexpr span& operator=(const span& other) noexcept = default; |
| 73 | 71 | ||
| ... | @@ -97,12 +95,8 @@ public: | ... | @@ -97,12 +95,8 @@ public: |
| 97 | // [span.iterators], span iterator support | 95 | // [span.iterators], span iterator support |
| 98 | constexpr iterator begin() const noexcept; | 96 | constexpr iterator begin() const noexcept; |
| 99 | constexpr iterator end() const noexcept; | 97 | constexpr iterator end() const noexcept; |
| 100 | constexpr const_iterator cbegin() const noexcept; | ||
| 101 | constexpr const_iterator cend() const noexcept; | ||
| 102 | constexpr reverse_iterator rbegin() const noexcept; | 98 | constexpr reverse_iterator rbegin() const noexcept; |
| 103 | constexpr reverse_iterator rend() const noexcept; | 99 | constexpr reverse_iterator rend() const noexcept; |
| 104 | constexpr const_reverse_iterator crbegin() const noexcept; | ||
| 105 | constexpr const_reverse_iterator crend() const noexcept; | ||
| 106 | 100 | ||
| 107 | private: | 101 | private: |
| 108 | pointer data_; // exposition only | 102 | pointer data_; // exposition only |
| ... | @@ -129,11 +123,10 @@ template<class Container> | ... | @@ -129,11 +123,10 @@ template<class Container> |
| 129 | */ | 123 | */ |
| 130 | 124 | ||
| 131 | #include <__config> | 125 | #include <__config> |
| 132 | #include <cstddef> // for ptrdiff_t | ||
| 133 | #include <iterator> // for iterators | ||
| 134 | #include <array> // for array | 126 | #include <array> // for array |
| 135 | #include <type_traits> // for remove_cv, etc | ||
| 136 | #include <cstddef> // for byte | 127 | #include <cstddef> // for byte |
| 128 | #include <iterator> // for iterators | ||
| 129 | #include <type_traits> // for remove_cv, etc | ||
| 137 | 130 | ||
| 138 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 131 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 139 | #pragma GCC system_header | 132 | #pragma GCC system_header |
| ... | @@ -143,7 +136,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -143,7 +136,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 143 | 136 | ||
| 144 | #if _LIBCPP_STD_VER > 17 | 137 | #if _LIBCPP_STD_VER > 17 |
| 145 | 138 | ||
| 146 | inline constexpr size_t dynamic_extent = numeric_limits<size_t>::max(); | 139 | inline constexpr size_t dynamic_extent = (numeric_limits<size_t>::max)(); |
| 147 | template <typename _Tp, size_t _Extent = dynamic_extent> class span; | 140 | template <typename _Tp, size_t _Extent = dynamic_extent> class span; |
| 148 | 141 | ||
| 149 | 142 | ||
| ... | @@ -202,27 +195,49 @@ public: | ... | @@ -202,27 +195,49 @@ public: |
| 202 | using reference = _Tp &; | 195 | using reference = _Tp &; |
| 203 | using const_reference = const _Tp &; | 196 | using const_reference = const _Tp &; |
| 204 | using iterator = __wrap_iter<pointer>; | 197 | using iterator = __wrap_iter<pointer>; |
| 205 | using const_iterator = __wrap_iter<const_pointer>; | ||
| 206 | using reverse_iterator = _VSTD::reverse_iterator<iterator>; | 198 | using reverse_iterator = _VSTD::reverse_iterator<iterator>; |
| 207 | using const_reverse_iterator = _VSTD::reverse_iterator<const_iterator>; | ||
| 208 | 199 | ||
| 209 | static constexpr size_type extent = _Extent; | 200 | static constexpr size_type extent = _Extent; |
| 210 | 201 | ||
| 211 | // [span.cons], span constructors, copy, assignment, and destructor | 202 | // [span.cons], span constructors, copy, assignment, and destructor |
| 212 | _LIBCPP_INLINE_VISIBILITY constexpr span() noexcept : __data{nullptr} | 203 | template <size_t _Sz = _Extent, enable_if_t<_Sz == 0, nullptr_t> = nullptr> |
| 213 | { static_assert(_Extent == 0, "Can't default construct a statically sized span with size > 0"); } | 204 | _LIBCPP_INLINE_VISIBILITY constexpr span() noexcept : __data{nullptr} {} |
| 214 | 205 | ||
| 215 | constexpr span (const span&) noexcept = default; | 206 | constexpr span (const span&) noexcept = default; |
| 216 | constexpr span& operator=(const span&) noexcept = default; | 207 | constexpr span& operator=(const span&) noexcept = default; |
| 217 | 208 | ||
| 218 | _LIBCPP_INLINE_VISIBILITY constexpr span(pointer __ptr, size_type __count) : __data{__ptr} | 209 | _LIBCPP_INLINE_VISIBILITY constexpr explicit span(pointer __ptr, size_type __count) : __data{__ptr} |
| 219 | { (void)__count; _LIBCPP_ASSERT(_Extent == __count, "size mismatch in span's constructor (ptr, len)"); } | 210 | { (void)__count; _LIBCPP_ASSERT(_Extent == __count, "size mismatch in span's constructor (ptr, len)"); } |
| 220 | _LIBCPP_INLINE_VISIBILITY constexpr span(pointer __f, pointer __l) : __data{__f} | 211 | _LIBCPP_INLINE_VISIBILITY constexpr explicit span(pointer __f, pointer __l) : __data{__f} |
| 221 | { (void)__l; _LIBCPP_ASSERT(_Extent == distance(__f, __l), "size mismatch in span's constructor (ptr, ptr)"); } | 212 | { (void)__l; _LIBCPP_ASSERT(_Extent == distance(__f, __l), "size mismatch in span's constructor (ptr, ptr)"); } |
| 222 | 213 | ||
| 223 | _LIBCPP_INLINE_VISIBILITY constexpr span(element_type (&__arr)[_Extent]) noexcept : __data{__arr} {} | 214 | _LIBCPP_INLINE_VISIBILITY constexpr span(element_type (&__arr)[_Extent]) noexcept : __data{__arr} {} |
| 224 | _LIBCPP_INLINE_VISIBILITY constexpr span( array<value_type, _Extent>& __arr) noexcept : __data{__arr.data()} {} | 215 | |
| 225 | _LIBCPP_INLINE_VISIBILITY constexpr span(const array<value_type, _Extent>& __arr) noexcept : __data{__arr.data()} {} | 216 | template <class _OtherElementType, |
| 217 | enable_if_t<is_convertible_v<_OtherElementType(*)[], element_type (*)[]>, nullptr_t> = nullptr> | ||
| 218 | _LIBCPP_INLINE_VISIBILITY | ||
| 219 | constexpr span(array<_OtherElementType, _Extent>& __arr) noexcept : __data{__arr.data()} {} | ||
| 220 | |||
| 221 | template <class _OtherElementType, | ||
| 222 | enable_if_t<is_convertible_v<const _OtherElementType(*)[], element_type (*)[]>, nullptr_t> = nullptr> | ||
| 223 | _LIBCPP_INLINE_VISIBILITY | ||
| 224 | constexpr span(const array<_OtherElementType, _Extent>& __arr) noexcept : __data{__arr.data()} {} | ||
| 225 | |||
| 226 | template <class _Container> | ||
| 227 | _LIBCPP_INLINE_VISIBILITY | ||
| 228 | constexpr explicit span( _Container& __c, | ||
| 229 | enable_if_t<__is_span_compatible_container<_Container, _Tp>::value, nullptr_t> = nullptr) | ||
| 230 | : __data{_VSTD::data(__c)} { | ||
| 231 | _LIBCPP_ASSERT(_Extent == _VSTD::size(__c), "size mismatch in span's constructor (range)"); | ||
| 232 | } | ||
| 233 | |||
| 234 | template <class _Container> | ||
| 235 | _LIBCPP_INLINE_VISIBILITY | ||
| 236 | constexpr explicit span(const _Container& __c, | ||
| 237 | enable_if_t<__is_span_compatible_container<const _Container, _Tp>::value, nullptr_t> = nullptr) | ||
| 238 | : __data{_VSTD::data(__c)} { | ||
| 239 | _LIBCPP_ASSERT(_Extent == _VSTD::size(__c), "size mismatch in span's constructor (range)"); | ||
| 240 | } | ||
| 226 | 241 | ||
| 227 | template <class _OtherElementType> | 242 | template <class _OtherElementType> |
| 228 | _LIBCPP_INLINE_VISIBILITY | 243 | _LIBCPP_INLINE_VISIBILITY |
| ... | @@ -234,7 +249,7 @@ public: | ... | @@ -234,7 +249,7 @@ public: |
| 234 | 249 | ||
| 235 | template <class _OtherElementType> | 250 | template <class _OtherElementType> |
| 236 | _LIBCPP_INLINE_VISIBILITY | 251 | _LIBCPP_INLINE_VISIBILITY |
| 237 | constexpr span(const span<_OtherElementType, dynamic_extent>& __other, | 252 | constexpr explicit span(const span<_OtherElementType, dynamic_extent>& __other, |
| 238 | enable_if_t< | 253 | enable_if_t< |
| 239 | is_convertible_v<_OtherElementType(*)[], element_type (*)[]>, | 254 | is_convertible_v<_OtherElementType(*)[], element_type (*)[]>, |
| 240 | nullptr_t> = nullptr) noexcept | 255 | nullptr_t> = nullptr) noexcept |
| ... | @@ -248,7 +263,7 @@ public: | ... | @@ -248,7 +263,7 @@ public: |
| 248 | constexpr span<element_type, _Count> first() const noexcept | 263 | constexpr span<element_type, _Count> first() const noexcept |
| 249 | { | 264 | { |
| 250 | static_assert(_Count <= _Extent, "Count out of range in span::first()"); | 265 | static_assert(_Count <= _Extent, "Count out of range in span::first()"); |
| 251 | return {data(), _Count}; | 266 | return span<element_type, _Count>{data(), _Count}; |
| 252 | } | 267 | } |
| 253 | 268 | ||
| 254 | template <size_t _Count> | 269 | template <size_t _Count> |
| ... | @@ -256,7 +271,7 @@ public: | ... | @@ -256,7 +271,7 @@ public: |
| 256 | constexpr span<element_type, _Count> last() const noexcept | 271 | constexpr span<element_type, _Count> last() const noexcept |
| 257 | { | 272 | { |
| 258 | static_assert(_Count <= _Extent, "Count out of range in span::last()"); | 273 | static_assert(_Count <= _Extent, "Count out of range in span::last()"); |
| 259 | return {data() + size() - _Count, _Count}; | 274 | return span<element_type, _Count>{data() + size() - _Count, _Count}; |
| 260 | } | 275 | } |
| 261 | 276 | ||
| 262 | _LIBCPP_INLINE_VISIBILITY | 277 | _LIBCPP_INLINE_VISIBILITY |
| ... | @@ -279,7 +294,10 @@ public: | ... | @@ -279,7 +294,10 @@ public: |
| 279 | -> span<element_type, _Count != dynamic_extent ? _Count : _Extent - _Offset> | 294 | -> span<element_type, _Count != dynamic_extent ? _Count : _Extent - _Offset> |
| 280 | { | 295 | { |
| 281 | static_assert(_Offset <= _Extent, "Offset out of range in span::subspan()"); | 296 | static_assert(_Offset <= _Extent, "Offset out of range in span::subspan()"); |
| 282 | return {data() + _Offset, _Count == dynamic_extent ? size() - _Offset : _Count}; | 297 | static_assert(_Count == dynamic_extent || _Count <= _Extent - _Offset, "Offset + count out of range in span::subspan()"); |
| 298 | |||
| 299 | using _ReturnType = span<element_type, _Count != dynamic_extent ? _Count : _Extent - _Offset>; | ||
| 300 | return _ReturnType{data() + _Offset, _Count == dynamic_extent ? size() - _Offset : _Count}; | ||
| 283 | } | 301 | } |
| 284 | 302 | ||
| 285 | 303 | ||
| ... | @@ -291,7 +309,7 @@ public: | ... | @@ -291,7 +309,7 @@ public: |
| 291 | _LIBCPP_ASSERT(__count <= size() || __count == dynamic_extent, "Count out of range in span::subspan(offset, count)"); | 309 | _LIBCPP_ASSERT(__count <= size() || __count == dynamic_extent, "Count out of range in span::subspan(offset, count)"); |
| 292 | if (__count == dynamic_extent) | 310 | if (__count == dynamic_extent) |
| 293 | return {data() + __offset, size() - __offset}; | 311 | return {data() + __offset, size() - __offset}; |
| 294 | _LIBCPP_ASSERT(__offset <= size() - __count, "count + offset out of range in span::subspan(offset, count)"); | 312 | _LIBCPP_ASSERT(__count <= size() - __offset, "Offset + count out of range in span::subspan(offset, count)"); |
| 295 | return {data() + __offset, __count}; | 313 | return {data() + __offset, __count}; |
| 296 | } | 314 | } |
| 297 | 315 | ||
| ... | @@ -301,19 +319,19 @@ public: | ... | @@ -301,19 +319,19 @@ public: |
| 301 | 319 | ||
| 302 | _LIBCPP_INLINE_VISIBILITY constexpr reference operator[](size_type __idx) const noexcept | 320 | _LIBCPP_INLINE_VISIBILITY constexpr reference operator[](size_type __idx) const noexcept |
| 303 | { | 321 | { |
| 304 | _LIBCPP_ASSERT(__idx >= 0 && __idx < size(), "span<T,N>[] index out of bounds"); | 322 | _LIBCPP_ASSERT(__idx < size(), "span<T,N>[] index out of bounds"); |
| 305 | return __data[__idx]; | 323 | return __data[__idx]; |
| 306 | } | 324 | } |
| 307 | 325 | ||
| 308 | _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept | 326 | _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept |
| 309 | { | 327 | { |
| 310 | static_assert(_Extent > 0, "span<T,N>[].front() on empty span"); | 328 | _LIBCPP_ASSERT(!empty(), "span<T, N>::front() on empty span"); |
| 311 | return __data[0]; | 329 | return __data[0]; |
| 312 | } | 330 | } |
| 313 | 331 | ||
| 314 | _LIBCPP_INLINE_VISIBILITY constexpr reference back() const noexcept | 332 | _LIBCPP_INLINE_VISIBILITY constexpr reference back() const noexcept |
| 315 | { | 333 | { |
| 316 | static_assert(_Extent > 0, "span<T,N>[].back() on empty span"); | 334 | _LIBCPP_ASSERT(!empty(), "span<T, N>::back() on empty span"); |
| 317 | return __data[size()-1]; | 335 | return __data[size()-1]; |
| 318 | } | 336 | } |
| 319 | 337 | ||
| ... | @@ -322,25 +340,14 @@ public: | ... | @@ -322,25 +340,14 @@ public: |
| 322 | // [span.iter], span iterator support | 340 | // [span.iter], span iterator support |
| 323 | _LIBCPP_INLINE_VISIBILITY constexpr iterator begin() const noexcept { return iterator(data()); } | 341 | _LIBCPP_INLINE_VISIBILITY constexpr iterator begin() const noexcept { return iterator(data()); } |
| 324 | _LIBCPP_INLINE_VISIBILITY constexpr iterator end() const noexcept { return iterator(data() + size()); } | 342 | _LIBCPP_INLINE_VISIBILITY constexpr iterator end() const noexcept { return iterator(data() + size()); } |
| 325 | _LIBCPP_INLINE_VISIBILITY constexpr const_iterator cbegin() const noexcept { return const_iterator(data()); } | ||
| 326 | _LIBCPP_INLINE_VISIBILITY constexpr const_iterator cend() const noexcept { return const_iterator(data() + size()); } | ||
| 327 | _LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator(end()); } | 343 | _LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator(end()); } |
| 328 | _LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator rend() const noexcept { return reverse_iterator(begin()); } | 344 | _LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator rend() const noexcept { return reverse_iterator(begin()); } |
| 329 | _LIBCPP_INLINE_VISIBILITY constexpr const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(cend()); } | ||
| 330 | _LIBCPP_INLINE_VISIBILITY constexpr const_reverse_iterator crend() const noexcept { return const_reverse_iterator(cbegin()); } | ||
| 331 | |||
| 332 | _LIBCPP_INLINE_VISIBILITY constexpr void swap(span &__other) noexcept | ||
| 333 | { | ||
| 334 | pointer __p = __data; | ||
| 335 | __data = __other.__data; | ||
| 336 | __other.__data = __p; | ||
| 337 | } | ||
| 338 | 345 | ||
| 339 | _LIBCPP_INLINE_VISIBILITY span<const byte, _Extent * sizeof(element_type)> __as_bytes() const noexcept | 346 | _LIBCPP_INLINE_VISIBILITY span<const byte, _Extent * sizeof(element_type)> __as_bytes() const noexcept |
| 340 | { return {reinterpret_cast<const byte *>(data()), size_bytes()}; } | 347 | { return span<const byte, _Extent * sizeof(element_type)>{reinterpret_cast<const byte *>(data()), size_bytes()}; } |
| 341 | 348 | ||
| 342 | _LIBCPP_INLINE_VISIBILITY span<byte, _Extent * sizeof(element_type)> __as_writable_bytes() const noexcept | 349 | _LIBCPP_INLINE_VISIBILITY span<byte, _Extent * sizeof(element_type)> __as_writable_bytes() const noexcept |
| 343 | { return {reinterpret_cast<byte *>(data()), size_bytes()}; } | 350 | { return span<byte, _Extent * sizeof(element_type)>{reinterpret_cast<byte *>(data()), size_bytes()}; } |
| 344 | 351 | ||
| 345 | private: | 352 | private: |
| 346 | pointer __data; | 353 | pointer __data; |
| ... | @@ -363,9 +370,7 @@ public: | ... | @@ -363,9 +370,7 @@ public: |
| 363 | using reference = _Tp &; | 370 | using reference = _Tp &; |
| 364 | using const_reference = const _Tp &; | 371 | using const_reference = const _Tp &; |
| 365 | using iterator = __wrap_iter<pointer>; | 372 | using iterator = __wrap_iter<pointer>; |
| 366 | using const_iterator = __wrap_iter<const_pointer>; | ||
| 367 | using reverse_iterator = _VSTD::reverse_iterator<iterator>; | 373 | using reverse_iterator = _VSTD::reverse_iterator<iterator>; |
| 368 | using const_reverse_iterator = _VSTD::reverse_iterator<const_iterator>; | ||
| 369 | 374 | ||
| 370 | static constexpr size_type extent = dynamic_extent; | 375 | static constexpr size_type extent = dynamic_extent; |
| 371 | 376 | ||
| ... | @@ -382,13 +387,15 @@ public: | ... | @@ -382,13 +387,15 @@ public: |
| 382 | _LIBCPP_INLINE_VISIBILITY | 387 | _LIBCPP_INLINE_VISIBILITY |
| 383 | constexpr span(element_type (&__arr)[_Sz]) noexcept : __data{__arr}, __size{_Sz} {} | 388 | constexpr span(element_type (&__arr)[_Sz]) noexcept : __data{__arr}, __size{_Sz} {} |
| 384 | 389 | ||
| 385 | template <size_t _Sz> | 390 | template <class _OtherElementType, size_t _Sz, |
| 391 | enable_if_t<is_convertible_v<_OtherElementType(*)[], element_type (*)[]>, nullptr_t> = nullptr> | ||
| 386 | _LIBCPP_INLINE_VISIBILITY | 392 | _LIBCPP_INLINE_VISIBILITY |
| 387 | constexpr span(array<value_type, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} {} | 393 | constexpr span(array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} {} |
| 388 | 394 | ||
| 389 | template <size_t _Sz> | 395 | template <class _OtherElementType, size_t _Sz, |
| 396 | enable_if_t<is_convertible_v<const _OtherElementType(*)[], element_type (*)[]>, nullptr_t> = nullptr> | ||
| 390 | _LIBCPP_INLINE_VISIBILITY | 397 | _LIBCPP_INLINE_VISIBILITY |
| 391 | constexpr span(const array<value_type, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} {} | 398 | constexpr span(const array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} {} |
| 392 | 399 | ||
| 393 | template <class _Container> | 400 | template <class _Container> |
| 394 | _LIBCPP_INLINE_VISIBILITY | 401 | _LIBCPP_INLINE_VISIBILITY |
| ... | @@ -418,7 +425,7 @@ public: | ... | @@ -418,7 +425,7 @@ public: |
| 418 | constexpr span<element_type, _Count> first() const noexcept | 425 | constexpr span<element_type, _Count> first() const noexcept |
| 419 | { | 426 | { |
| 420 | _LIBCPP_ASSERT(_Count <= size(), "Count out of range in span::first()"); | 427 | _LIBCPP_ASSERT(_Count <= size(), "Count out of range in span::first()"); |
| 421 | return {data(), _Count}; | 428 | return span<element_type, _Count>{data(), _Count}; |
| 422 | } | 429 | } |
| 423 | 430 | ||
| 424 | template <size_t _Count> | 431 | template <size_t _Count> |
| ... | @@ -426,7 +433,7 @@ public: | ... | @@ -426,7 +433,7 @@ public: |
| 426 | constexpr span<element_type, _Count> last() const noexcept | 433 | constexpr span<element_type, _Count> last() const noexcept |
| 427 | { | 434 | { |
| 428 | _LIBCPP_ASSERT(_Count <= size(), "Count out of range in span::last()"); | 435 | _LIBCPP_ASSERT(_Count <= size(), "Count out of range in span::last()"); |
| 429 | return {data() + size() - _Count, _Count}; | 436 | return span<element_type, _Count>{data() + size() - _Count, _Count}; |
| 430 | } | 437 | } |
| 431 | 438 | ||
| 432 | _LIBCPP_INLINE_VISIBILITY | 439 | _LIBCPP_INLINE_VISIBILITY |
| ... | @@ -445,11 +452,11 @@ public: | ... | @@ -445,11 +452,11 @@ public: |
| 445 | 452 | ||
| 446 | template <size_t _Offset, size_t _Count = dynamic_extent> | 453 | template <size_t _Offset, size_t _Count = dynamic_extent> |
| 447 | _LIBCPP_INLINE_VISIBILITY | 454 | _LIBCPP_INLINE_VISIBILITY |
| 448 | constexpr span<_Tp, dynamic_extent> subspan() const noexcept | 455 | constexpr span<element_type, _Count> subspan() const noexcept |
| 449 | { | 456 | { |
| 450 | _LIBCPP_ASSERT(_Offset <= size(), "Offset out of range in span::subspan()"); | 457 | _LIBCPP_ASSERT(_Offset <= size(), "Offset out of range in span::subspan()"); |
| 451 | _LIBCPP_ASSERT(_Count == dynamic_extent || _Offset + _Count <= size(), "Count out of range in span::subspan()"); | 458 | _LIBCPP_ASSERT(_Count == dynamic_extent || _Count <= size() - _Offset, "Offset + count out of range in span::subspan()"); |
| 452 | return {data() + _Offset, _Count == dynamic_extent ? size() - _Offset : _Count}; | 459 | return span<element_type, _Count>{data() + _Offset, _Count == dynamic_extent ? size() - _Offset : _Count}; |
| 453 | } | 460 | } |
| 454 | 461 | ||
| 455 | constexpr span<element_type, dynamic_extent> | 462 | constexpr span<element_type, dynamic_extent> |
| ... | @@ -460,7 +467,7 @@ public: | ... | @@ -460,7 +467,7 @@ public: |
| 460 | _LIBCPP_ASSERT(__count <= size() || __count == dynamic_extent, "count out of range in span::subspan(offset, count)"); | 467 | _LIBCPP_ASSERT(__count <= size() || __count == dynamic_extent, "count out of range in span::subspan(offset, count)"); |
| 461 | if (__count == dynamic_extent) | 468 | if (__count == dynamic_extent) |
| 462 | return {data() + __offset, size() - __offset}; | 469 | return {data() + __offset, size() - __offset}; |
| 463 | _LIBCPP_ASSERT(__offset <= size() - __count, "Offset + count out of range in span::subspan(offset, count)"); | 470 | _LIBCPP_ASSERT(__count <= size() - __offset, "Offset + count out of range in span::subspan(offset, count)"); |
| 464 | return {data() + __offset, __count}; | 471 | return {data() + __offset, __count}; |
| 465 | } | 472 | } |
| 466 | 473 | ||
| ... | @@ -470,7 +477,7 @@ public: | ... | @@ -470,7 +477,7 @@ public: |
| 470 | 477 | ||
| 471 | _LIBCPP_INLINE_VISIBILITY constexpr reference operator[](size_type __idx) const noexcept | 478 | _LIBCPP_INLINE_VISIBILITY constexpr reference operator[](size_type __idx) const noexcept |
| 472 | { | 479 | { |
| 473 | _LIBCPP_ASSERT(__idx >= 0 && __idx < size(), "span<T>[] index out of bounds"); | 480 | _LIBCPP_ASSERT(__idx < size(), "span<T>[] index out of bounds"); |
| 474 | return __data[__idx]; | 481 | return __data[__idx]; |
| 475 | } | 482 | } |
| 476 | 483 | ||
| ... | @@ -492,23 +499,8 @@ public: | ... | @@ -492,23 +499,8 @@ public: |
| 492 | // [span.iter], span iterator support | 499 | // [span.iter], span iterator support |
| 493 | _LIBCPP_INLINE_VISIBILITY constexpr iterator begin() const noexcept { return iterator(data()); } | 500 | _LIBCPP_INLINE_VISIBILITY constexpr iterator begin() const noexcept { return iterator(data()); } |
| 494 | _LIBCPP_INLINE_VISIBILITY constexpr iterator end() const noexcept { return iterator(data() + size()); } | 501 | _LIBCPP_INLINE_VISIBILITY constexpr iterator end() const noexcept { return iterator(data() + size()); } |
| 495 | _LIBCPP_INLINE_VISIBILITY constexpr const_iterator cbegin() const noexcept { return const_iterator(data()); } | ||
| 496 | _LIBCPP_INLINE_VISIBILITY constexpr const_iterator cend() const noexcept { return const_iterator(data() + size()); } | ||
| 497 | _LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator(end()); } | 502 | _LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator(end()); } |
| 498 | _LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator rend() const noexcept { return reverse_iterator(begin()); } | 503 | _LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator rend() const noexcept { return reverse_iterator(begin()); } |
| 499 | _LIBCPP_INLINE_VISIBILITY constexpr const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(cend()); } | ||
| 500 | _LIBCPP_INLINE_VISIBILITY constexpr const_reverse_iterator crend() const noexcept { return const_reverse_iterator(cbegin()); } | ||
| 501 | |||
| 502 | _LIBCPP_INLINE_VISIBILITY constexpr void swap(span &__other) noexcept | ||
| 503 | { | ||
| 504 | pointer __p = __data; | ||
| 505 | __data = __other.__data; | ||
| 506 | __other.__data = __p; | ||
| 507 | |||
| 508 | size_type __sz = __size; | ||
| 509 | __size = __other.__size; | ||
| 510 | __other.__size = __sz; | ||
| 511 | } | ||
| 512 | 504 | ||
| 513 | _LIBCPP_INLINE_VISIBILITY span<const byte, dynamic_extent> __as_bytes() const noexcept | 505 | _LIBCPP_INLINE_VISIBILITY span<const byte, dynamic_extent> __as_bytes() const noexcept |
| 514 | { return {reinterpret_cast<const byte *>(data()), size_bytes()}; } | 506 | { return {reinterpret_cast<const byte *>(data()), size_bytes()}; } |
| ... | @@ -521,34 +513,6 @@ private: | ... | @@ -521,34 +513,6 @@ private: |
| 521 | size_type __size; | 513 | size_type __size; |
| 522 | }; | 514 | }; |
| 523 | 515 | ||
| 524 | // tuple interface | ||
| 525 | template <class _Tp, size_t _Size> | ||
| 526 | struct _LIBCPP_TEMPLATE_VIS tuple_size<span<_Tp, _Size>> | ||
| 527 | : public integral_constant<size_t, _Size> {}; | ||
| 528 | |||
| 529 | template <class _Tp> | ||
| 530 | struct _LIBCPP_TEMPLATE_VIS tuple_size<span<_Tp, dynamic_extent>>; // declared but not defined | ||
| 531 | |||
| 532 | |||
| 533 | template <size_t _Ip, class _Tp, size_t _Size> | ||
| 534 | struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, span<_Tp, _Size>> | ||
| 535 | { | ||
| 536 | static_assert( dynamic_extent != _Size, "std::tuple_element<> not supported for std::span<T, dynamic_extent>"); | ||
| 537 | static_assert(_Ip < _Size, "Index out of bounds in std::tuple_element<> (std::span)"); | ||
| 538 | typedef _Tp type; | ||
| 539 | }; | ||
| 540 | |||
| 541 | template <size_t _Ip, class _Tp, size_t _Size> | ||
| 542 | _LIBCPP_INLINE_VISIBILITY constexpr | ||
| 543 | _Tp& | ||
| 544 | get(span<_Tp, _Size> __s) noexcept | ||
| 545 | { | ||
| 546 | static_assert( dynamic_extent != _Size, "std::get<> not supported for std::span<T, dynamic_extent>"); | ||
| 547 | static_assert(_Ip < _Size, "Index out of bounds in std::get<> (std::span)"); | ||
| 548 | return __s[_Ip]; | ||
| 549 | } | ||
| 550 | |||
| 551 | |||
| 552 | // as_bytes & as_writable_bytes | 516 | // as_bytes & as_writable_bytes |
| 553 | template <class _Tp, size_t _Extent> | 517 | template <class _Tp, size_t _Extent> |
| 554 | _LIBCPP_INLINE_VISIBILITY | 518 | _LIBCPP_INLINE_VISIBILITY |
| ... | @@ -562,12 +526,6 @@ auto as_writable_bytes(span<_Tp, _Extent> __s) noexcept | ... | @@ -562,12 +526,6 @@ auto as_writable_bytes(span<_Tp, _Extent> __s) noexcept |
| 562 | -> enable_if_t<!is_const_v<_Tp>, decltype(__s.__as_writable_bytes())> | 526 | -> enable_if_t<!is_const_v<_Tp>, decltype(__s.__as_writable_bytes())> |
| 563 | { return __s.__as_writable_bytes(); } | 527 | { return __s.__as_writable_bytes(); } |
| 564 | 528 | ||
| 565 | template <class _Tp, size_t _Extent> | ||
| 566 | _LIBCPP_INLINE_VISIBILITY | ||
| 567 | constexpr void swap(span<_Tp, _Extent> &__lhs, span<_Tp, _Extent> &__rhs) noexcept | ||
| 568 | { __lhs.swap(__rhs); } | ||
| 569 | |||
| 570 | |||
| 571 | // Deduction guides | 529 | // Deduction guides |
| 572 | template<class _Tp, size_t _Sz> | 530 | template<class _Tp, size_t _Sz> |
| 573 | span(_Tp (&)[_Sz]) -> span<_Tp, _Sz>; | 531 | span(_Tp (&)[_Sz]) -> span<_Tp, _Sz>; |
lib/libcxx/include/stddef.h+1-7| ... | @@ -31,7 +31,7 @@ Types: | ... | @@ -31,7 +31,7 @@ Types: |
| 31 | 31 | ||
| 32 | ptrdiff_t | 32 | ptrdiff_t |
| 33 | size_t | 33 | size_t |
| 34 | max_align_t | 34 | max_align_t // C++11 |
| 35 | nullptr_t | 35 | nullptr_t |
| 36 | 36 | ||
| 37 | */ | 37 | */ |
| ... | @@ -51,12 +51,6 @@ extern "C++" { | ... | @@ -51,12 +51,6 @@ extern "C++" { |
| 51 | using std::nullptr_t; | 51 | using std::nullptr_t; |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | // Re-use the compiler's <stddef.h> max_align_t where possible. | ||
| 55 | #if !defined(__CLANG_MAX_ALIGN_T_DEFINED) && !defined(_GCC_MAX_ALIGN_T) && \ | ||
| 56 | !defined(__DEFINED_max_align_t) && !defined(__NetBSD__) | ||
| 57 | typedef long double max_align_t; | ||
| 58 | #endif | ||
| 59 | |||
| 60 | #endif | 54 | #endif |
| 61 | 55 | ||
| 62 | #endif // _LIBCPP_STDDEF_H | 56 | #endif // _LIBCPP_STDDEF_H |
lib/libcxx/include/stdexcept+7| ... | @@ -129,6 +129,7 @@ public: | ... | @@ -129,6 +129,7 @@ public: |
| 129 | _LIBCPP_INLINE_VISIBILITY explicit domain_error(const char* __s) : logic_error(__s) {} | 129 | _LIBCPP_INLINE_VISIBILITY explicit domain_error(const char* __s) : logic_error(__s) {} |
| 130 | 130 | ||
| 131 | #ifndef _LIBCPP_ABI_VCRUNTIME | 131 | #ifndef _LIBCPP_ABI_VCRUNTIME |
| 132 | domain_error(const domain_error&) _NOEXCEPT = default; | ||
| 132 | virtual ~domain_error() _NOEXCEPT; | 133 | virtual ~domain_error() _NOEXCEPT; |
| 133 | #endif | 134 | #endif |
| 134 | }; | 135 | }; |
| ... | @@ -141,6 +142,7 @@ public: | ... | @@ -141,6 +142,7 @@ public: |
| 141 | _LIBCPP_INLINE_VISIBILITY explicit invalid_argument(const char* __s) : logic_error(__s) {} | 142 | _LIBCPP_INLINE_VISIBILITY explicit invalid_argument(const char* __s) : logic_error(__s) {} |
| 142 | 143 | ||
| 143 | #ifndef _LIBCPP_ABI_VCRUNTIME | 144 | #ifndef _LIBCPP_ABI_VCRUNTIME |
| 145 | invalid_argument(const invalid_argument&) _NOEXCEPT = default; | ||
| 144 | virtual ~invalid_argument() _NOEXCEPT; | 146 | virtual ~invalid_argument() _NOEXCEPT; |
| 145 | #endif | 147 | #endif |
| 146 | }; | 148 | }; |
| ... | @@ -152,6 +154,7 @@ public: | ... | @@ -152,6 +154,7 @@ public: |
| 152 | _LIBCPP_INLINE_VISIBILITY explicit length_error(const string& __s) : logic_error(__s) {} | 154 | _LIBCPP_INLINE_VISIBILITY explicit length_error(const string& __s) : logic_error(__s) {} |
| 153 | _LIBCPP_INLINE_VISIBILITY explicit length_error(const char* __s) : logic_error(__s) {} | 155 | _LIBCPP_INLINE_VISIBILITY explicit length_error(const char* __s) : logic_error(__s) {} |
| 154 | #ifndef _LIBCPP_ABI_VCRUNTIME | 156 | #ifndef _LIBCPP_ABI_VCRUNTIME |
| 157 | length_error(const length_error&) _NOEXCEPT = default; | ||
| 155 | virtual ~length_error() _NOEXCEPT; | 158 | virtual ~length_error() _NOEXCEPT; |
| 156 | #endif | 159 | #endif |
| 157 | }; | 160 | }; |
| ... | @@ -164,6 +167,7 @@ public: | ... | @@ -164,6 +167,7 @@ public: |
| 164 | _LIBCPP_INLINE_VISIBILITY explicit out_of_range(const char* __s) : logic_error(__s) {} | 167 | _LIBCPP_INLINE_VISIBILITY explicit out_of_range(const char* __s) : logic_error(__s) {} |
| 165 | 168 | ||
| 166 | #ifndef _LIBCPP_ABI_VCRUNTIME | 169 | #ifndef _LIBCPP_ABI_VCRUNTIME |
| 170 | out_of_range(const out_of_range&) _NOEXCEPT = default; | ||
| 167 | virtual ~out_of_range() _NOEXCEPT; | 171 | virtual ~out_of_range() _NOEXCEPT; |
| 168 | #endif | 172 | #endif |
| 169 | }; | 173 | }; |
| ... | @@ -176,6 +180,7 @@ public: | ... | @@ -176,6 +180,7 @@ public: |
| 176 | _LIBCPP_INLINE_VISIBILITY explicit range_error(const char* __s) : runtime_error(__s) {} | 180 | _LIBCPP_INLINE_VISIBILITY explicit range_error(const char* __s) : runtime_error(__s) {} |
| 177 | 181 | ||
| 178 | #ifndef _LIBCPP_ABI_VCRUNTIME | 182 | #ifndef _LIBCPP_ABI_VCRUNTIME |
| 183 | range_error(const range_error&) _NOEXCEPT = default; | ||
| 179 | virtual ~range_error() _NOEXCEPT; | 184 | virtual ~range_error() _NOEXCEPT; |
| 180 | #endif | 185 | #endif |
| 181 | }; | 186 | }; |
| ... | @@ -188,6 +193,7 @@ public: | ... | @@ -188,6 +193,7 @@ public: |
| 188 | _LIBCPP_INLINE_VISIBILITY explicit overflow_error(const char* __s) : runtime_error(__s) {} | 193 | _LIBCPP_INLINE_VISIBILITY explicit overflow_error(const char* __s) : runtime_error(__s) {} |
| 189 | 194 | ||
| 190 | #ifndef _LIBCPP_ABI_VCRUNTIME | 195 | #ifndef _LIBCPP_ABI_VCRUNTIME |
| 196 | overflow_error(const overflow_error&) _NOEXCEPT = default; | ||
| 191 | virtual ~overflow_error() _NOEXCEPT; | 197 | virtual ~overflow_error() _NOEXCEPT; |
| 192 | #endif | 198 | #endif |
| 193 | }; | 199 | }; |
| ... | @@ -200,6 +206,7 @@ public: | ... | @@ -200,6 +206,7 @@ public: |
| 200 | _LIBCPP_INLINE_VISIBILITY explicit underflow_error(const char* __s) : runtime_error(__s) {} | 206 | _LIBCPP_INLINE_VISIBILITY explicit underflow_error(const char* __s) : runtime_error(__s) {} |
| 201 | 207 | ||
| 202 | #ifndef _LIBCPP_ABI_VCRUNTIME | 208 | #ifndef _LIBCPP_ABI_VCRUNTIME |
| 209 | underflow_error(const underflow_error&) _NOEXCEPT = default; | ||
| 203 | virtual ~underflow_error() _NOEXCEPT; | 210 | virtual ~underflow_error() _NOEXCEPT; |
| 204 | #endif | 211 | #endif |
| 205 | }; | 212 | }; |
lib/libcxx/include/stdlib.h+58-6| ... | @@ -7,16 +7,12 @@ | ... | @@ -7,16 +7,12 @@ |
| 7 | // | 7 | // |
| 8 | //===----------------------------------------------------------------------===// | 8 | //===----------------------------------------------------------------------===// |
| 9 | 9 | ||
| 10 | #if defined(__need_malloc_and_calloc) || defined(_LIBCPP_STDLIB_INCLUDE_NEXT) | 10 | #if defined(__need_malloc_and_calloc) |
| 11 | 11 | ||
| 12 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 12 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 13 | #pragma GCC system_header | 13 | #pragma GCC system_header |
| 14 | #endif | 14 | #endif |
| 15 | 15 | ||
| 16 | #if defined(_LIBCPP_STDLIB_INCLUDE_NEXT) | ||
| 17 | #undef _LIBCPP_STDLIB_INCLUDE_NEXT | ||
| 18 | #endif | ||
| 19 | |||
| 20 | #include_next <stdlib.h> | 16 | #include_next <stdlib.h> |
| 21 | 17 | ||
| 22 | #elif !defined(_LIBCPP_STDLIB_H) | 18 | #elif !defined(_LIBCPP_STDLIB_H) |
| ... | @@ -97,7 +93,63 @@ void *aligned_alloc(size_t alignment, size_t size); // C11 | ... | @@ -97,7 +93,63 @@ void *aligned_alloc(size_t alignment, size_t size); // C11 |
| 97 | #include_next <stdlib.h> | 93 | #include_next <stdlib.h> |
| 98 | 94 | ||
| 99 | #ifdef __cplusplus | 95 | #ifdef __cplusplus |
| 100 | #include <math.h> | 96 | extern "C++" { |
| 97 | // abs | ||
| 98 | |||
| 99 | #undef abs | ||
| 100 | #undef labs | ||
| 101 | #ifndef _LIBCPP_HAS_NO_LONG_LONG | ||
| 102 | #undef llabs | ||
| 103 | #endif | ||
| 104 | |||
| 105 | // MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined | ||
| 106 | #if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX) | ||
| 107 | inline _LIBCPP_INLINE_VISIBILITY long abs(long __x) _NOEXCEPT { | ||
| 108 | return __builtin_labs(__x); | ||
| 109 | } | ||
| 110 | #ifndef _LIBCPP_HAS_NO_LONG_LONG | ||
| 111 | inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT { | ||
| 112 | return __builtin_llabs(__x); | ||
| 113 | } | ||
| 114 | #endif // _LIBCPP_HAS_NO_LONG_LONG | ||
| 115 | #endif // !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX) | ||
| 116 | |||
| 117 | #if !(defined(_AIX) || defined(__sun__)) | ||
| 118 | inline _LIBCPP_INLINE_VISIBILITY float abs(float __lcpp_x) _NOEXCEPT { | ||
| 119 | return __builtin_fabsf(__lcpp_x); // Use builtins to prevent needing math.h | ||
| 120 | } | ||
| 121 | |||
| 122 | inline _LIBCPP_INLINE_VISIBILITY double abs(double __lcpp_x) _NOEXCEPT { | ||
| 123 | return __builtin_fabs(__lcpp_x); | ||
| 124 | } | ||
| 125 | |||
| 126 | inline _LIBCPP_INLINE_VISIBILITY long double | ||
| 127 | abs(long double __lcpp_x) _NOEXCEPT { | ||
| 128 | return __builtin_fabsl(__lcpp_x); | ||
| 129 | } | ||
| 130 | #endif // !(defined(_AIX) || defined(__sun__)) | ||
| 131 | |||
| 132 | // div | ||
| 133 | |||
| 134 | #undef div | ||
| 135 | #undef ldiv | ||
| 136 | #ifndef _LIBCPP_HAS_NO_LONG_LONG | ||
| 137 | #undef lldiv | ||
| 138 | #endif | ||
| 139 | |||
| 140 | // MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined | ||
| 141 | #if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX) | ||
| 142 | inline _LIBCPP_INLINE_VISIBILITY ldiv_t div(long __x, long __y) _NOEXCEPT { | ||
| 143 | return ::ldiv(__x, __y); | ||
| 144 | } | ||
| 145 | #ifndef _LIBCPP_HAS_NO_LONG_LONG | ||
| 146 | inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x, | ||
| 147 | long long __y) _NOEXCEPT { | ||
| 148 | return ::lldiv(__x, __y); | ||
| 149 | } | ||
| 150 | #endif // _LIBCPP_HAS_NO_LONG_LONG | ||
| 151 | #endif // _LIBCPP_MSVCRT / __sun__ / _AIX | ||
| 152 | } // extern "C++" | ||
| 101 | #endif // __cplusplus | 153 | #endif // __cplusplus |
| 102 | 154 | ||
| 103 | #endif // _LIBCPP_STDLIB_H | 155 | #endif // _LIBCPP_STDLIB_H |
lib/libcxx/include/string+313-185| ... | @@ -437,9 +437,11 @@ basic_istream<charT, traits>& | ... | @@ -437,9 +437,11 @@ basic_istream<charT, traits>& |
| 437 | getline(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str); | 437 | getline(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str); |
| 438 | 438 | ||
| 439 | template<class charT, class traits, class Allocator, class U> | 439 | template<class charT, class traits, class Allocator, class U> |
| 440 | void erase(basic_string<charT, traits, Allocator>& c, const U& value); // C++20 | 440 | typename basic_string<charT, traits, Allocator>::size_type |
| 441 | erase(basic_string<charT, traits, Allocator>& c, const U& value); // C++20 | ||
| 441 | template<class charT, class traits, class Allocator, class Predicate> | 442 | template<class charT, class traits, class Allocator, class Predicate> |
| 442 | void erase_if(basic_string<charT, traits, Allocator>& c, Predicate pred); // C++20 | 443 | typename basic_string<charT, traits, Allocator>::size_type |
| 444 | erase_if(basic_string<charT, traits, Allocator>& c, Predicate pred); // C++20 | ||
| 443 | 445 | ||
| 444 | typedef basic_string<char> string; | 446 | typedef basic_string<char> string; |
| 445 | typedef basic_string<wchar_t> wstring; | 447 | typedef basic_string<wchar_t> wstring; |
| ... | @@ -643,9 +645,10 @@ struct __libcpp_string_gets_noexcept_iterator | ... | @@ -643,9 +645,10 @@ struct __libcpp_string_gets_noexcept_iterator |
| 643 | : public _LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value || __libcpp_string_gets_noexcept_iterator_impl<_Iter>::value) {}; | 645 | : public _LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value || __libcpp_string_gets_noexcept_iterator_impl<_Iter>::value) {}; |
| 644 | 646 | ||
| 645 | template <class _CharT, class _Traits, class _Tp> | 647 | template <class _CharT, class _Traits, class _Tp> |
| 646 | struct __can_be_converted_to_string_view : public _LIBCPP_BOOL_CONSTANT( | 648 | struct __can_be_converted_to_string_view : public _BoolConstant< |
| 647 | ( is_convertible<const _Tp&, basic_string_view<_CharT, _Traits> >::value && | 649 | is_convertible<const _Tp&, basic_string_view<_CharT, _Traits> >::value && |
| 648 | !is_convertible<const _Tp&, const _CharT*>::value)) {}; | 650 | !is_convertible<const _Tp&, const _CharT*>::value |
| 651 | > {}; | ||
| 649 | 652 | ||
| 650 | #ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | 653 | #ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT |
| 651 | 654 | ||
| ... | @@ -688,13 +691,8 @@ public: | ... | @@ -688,13 +691,8 @@ public: |
| 688 | static_assert(( is_same<typename allocator_type::value_type, value_type>::value), | 691 | static_assert(( is_same<typename allocator_type::value_type, value_type>::value), |
| 689 | "Allocator::value_type must be same type as value_type"); | 692 | "Allocator::value_type must be same type as value_type"); |
| 690 | 693 | ||
| 691 | #if defined(_LIBCPP_RAW_ITERATORS) | ||
| 692 | typedef pointer iterator; | ||
| 693 | typedef const_pointer const_iterator; | ||
| 694 | #else // defined(_LIBCPP_RAW_ITERATORS) | ||
| 695 | typedef __wrap_iter<pointer> iterator; | 694 | typedef __wrap_iter<pointer> iterator; |
| 696 | typedef __wrap_iter<const_pointer> const_iterator; | 695 | typedef __wrap_iter<const_pointer> const_iterator; |
| 697 | #endif // defined(_LIBCPP_RAW_ITERATORS) | ||
| 698 | typedef _VSTD::reverse_iterator<iterator> reverse_iterator; | 696 | typedef _VSTD::reverse_iterator<iterator> reverse_iterator; |
| 699 | typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; | 697 | typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; |
| 700 | 698 | ||
| ... | @@ -784,6 +782,7 @@ private: | ... | @@ -784,6 +782,7 @@ private: |
| 784 | __compressed_pair<__rep, allocator_type> __r_; | 782 | __compressed_pair<__rep, allocator_type> __r_; |
| 785 | 783 | ||
| 786 | public: | 784 | public: |
| 785 | _LIBCPP_FUNC_VIS | ||
| 787 | static const size_type npos = -1; | 786 | static const size_type npos = -1; |
| 788 | 787 | ||
| 789 | _LIBCPP_INLINE_VISIBILITY basic_string() | 788 | _LIBCPP_INLINE_VISIBILITY basic_string() |
| ... | @@ -812,7 +811,7 @@ public: | ... | @@ -812,7 +811,7 @@ public: |
| 812 | basic_string(basic_string&& __str, const allocator_type& __a); | 811 | basic_string(basic_string&& __str, const allocator_type& __a); |
| 813 | #endif // _LIBCPP_CXX03_LANG | 812 | #endif // _LIBCPP_CXX03_LANG |
| 814 | 813 | ||
| 815 | template <class = typename enable_if<__is_allocator<_Allocator>::value, nullptr_t>::type> | 814 | template <class = _EnableIf<__is_allocator<_Allocator>::value, nullptr_t> > |
| 816 | _LIBCPP_INLINE_VISIBILITY | 815 | _LIBCPP_INLINE_VISIBILITY |
| 817 | basic_string(const _CharT* __s) : __r_(__default_init_tag(), __default_init_tag()) { | 816 | basic_string(const _CharT* __s) : __r_(__default_init_tag(), __default_init_tag()) { |
| 818 | _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected nullptr"); | 817 | _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected nullptr"); |
| ... | @@ -822,7 +821,7 @@ public: | ... | @@ -822,7 +821,7 @@ public: |
| 822 | # endif | 821 | # endif |
| 823 | } | 822 | } |
| 824 | 823 | ||
| 825 | template <class = typename enable_if<__is_allocator<_Allocator>::value, nullptr_t>::type> | 824 | template <class = _EnableIf<__is_allocator<_Allocator>::value, nullptr_t> > |
| 826 | _LIBCPP_INLINE_VISIBILITY | 825 | _LIBCPP_INLINE_VISIBILITY |
| 827 | basic_string(const _CharT* __s, const _Allocator& __a); | 826 | basic_string(const _CharT* __s, const _Allocator& __a); |
| 828 | 827 | ||
| ... | @@ -833,7 +832,7 @@ public: | ... | @@ -833,7 +832,7 @@ public: |
| 833 | _LIBCPP_INLINE_VISIBILITY | 832 | _LIBCPP_INLINE_VISIBILITY |
| 834 | basic_string(size_type __n, _CharT __c); | 833 | basic_string(size_type __n, _CharT __c); |
| 835 | 834 | ||
| 836 | template <class = typename enable_if<__is_allocator<_Allocator>::value, nullptr_t>::type> | 835 | template <class = _EnableIf<__is_allocator<_Allocator>::value, nullptr_t> > |
| 837 | _LIBCPP_INLINE_VISIBILITY | 836 | _LIBCPP_INLINE_VISIBILITY |
| 838 | basic_string(size_type __n, _CharT __c, const _Allocator& __a); | 837 | basic_string(size_type __n, _CharT __c, const _Allocator& __a); |
| 839 | 838 | ||
| ... | @@ -843,23 +842,24 @@ public: | ... | @@ -843,23 +842,24 @@ public: |
| 843 | basic_string(const basic_string& __str, size_type __pos, | 842 | basic_string(const basic_string& __str, size_type __pos, |
| 844 | const _Allocator& __a = _Allocator()); | 843 | const _Allocator& __a = _Allocator()); |
| 845 | 844 | ||
| 846 | template<class _Tp, class = typename enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, void>::type> | 845 | template<class _Tp, class = _EnableIf<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value> > |
| 847 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 846 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 848 | basic_string(const _Tp& __t, size_type __pos, size_type __n, | 847 | basic_string(const _Tp& __t, size_type __pos, size_type __n, |
| 849 | const allocator_type& __a = allocator_type()); | 848 | const allocator_type& __a = allocator_type()); |
| 850 | 849 | ||
| 851 | template<class _Tp, class = typename enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, void>::type> | 850 | template<class _Tp, class = _EnableIf<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && |
| 851 | !__is_same_uncvref<_Tp, basic_string>::value> > | ||
| 852 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 852 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 853 | explicit basic_string(const _Tp& __t); | 853 | explicit basic_string(const _Tp& __t); |
| 854 | 854 | ||
| 855 | template<class _Tp, class = typename enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, void>::type> | 855 | template<class _Tp, class = _EnableIf<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value> > |
| 856 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 856 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 857 | explicit basic_string(const _Tp& __t, const allocator_type& __a); | 857 | explicit basic_string(const _Tp& __t, const allocator_type& __a); |
| 858 | 858 | ||
| 859 | template<class _InputIterator, class = typename enable_if<__is_cpp17_input_iterator<_InputIterator>::value>::type> | 859 | template<class _InputIterator, class = _EnableIf<__is_cpp17_input_iterator<_InputIterator>::value> > |
| 860 | _LIBCPP_INLINE_VISIBILITY | 860 | _LIBCPP_INLINE_VISIBILITY |
| 861 | basic_string(_InputIterator __first, _InputIterator __last); | 861 | basic_string(_InputIterator __first, _InputIterator __last); |
| 862 | template<class _InputIterator, class = typename enable_if<__is_cpp17_input_iterator<_InputIterator>::value>::type> | 862 | template<class _InputIterator, class = _EnableIf<__is_cpp17_input_iterator<_InputIterator>::value> > |
| 863 | _LIBCPP_INLINE_VISIBILITY | 863 | _LIBCPP_INLINE_VISIBILITY |
| 864 | basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a); | 864 | basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a); |
| 865 | #ifndef _LIBCPP_CXX03_LANG | 865 | #ifndef _LIBCPP_CXX03_LANG |
| ... | @@ -876,7 +876,7 @@ public: | ... | @@ -876,7 +876,7 @@ public: |
| 876 | 876 | ||
| 877 | basic_string& operator=(const basic_string& __str); | 877 | basic_string& operator=(const basic_string& __str); |
| 878 | 878 | ||
| 879 | template <class _Tp, class = typename enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, void>::type> | 879 | template <class _Tp, class = _EnableIf<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value> > |
| 880 | basic_string& operator=(const _Tp& __t) | 880 | basic_string& operator=(const _Tp& __t) |
| 881 | {__self_view __sv = __t; return assign(__sv);} | 881 | {__self_view __sv = __t; return assign(__sv);} |
| 882 | 882 | ||
| ... | @@ -976,11 +976,12 @@ public: | ... | @@ -976,11 +976,12 @@ public: |
| 976 | 976 | ||
| 977 | template <class _Tp> | 977 | template <class _Tp> |
| 978 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 978 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 979 | typename enable_if | 979 | _EnableIf |
| 980 | < | 980 | < |
| 981 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 981 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value |
| 982 | && !__is_same_uncvref<_Tp, basic_string >::value, | ||
| 982 | basic_string& | 983 | basic_string& |
| 983 | >::type | 984 | > |
| 984 | operator+=(const _Tp& __t) {__self_view __sv = __t; return append(__sv);} | 985 | operator+=(const _Tp& __t) {__self_view __sv = __t; return append(__sv);} |
| 985 | _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(const value_type* __s) {return append(__s);} | 986 | _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(const value_type* __s) {return append(__s);} |
| 986 | _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(value_type __c) {push_back(__c); return *this;} | 987 | _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(value_type __c) {push_back(__c); return *this;} |
| ... | @@ -993,21 +994,22 @@ public: | ... | @@ -993,21 +994,22 @@ public: |
| 993 | 994 | ||
| 994 | template <class _Tp> | 995 | template <class _Tp> |
| 995 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 996 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 996 | typename enable_if | 997 | _EnableIf< |
| 997 | < | 998 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value |
| 998 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 999 | && !__is_same_uncvref<_Tp, basic_string>::value, |
| 999 | basic_string& | 1000 | basic_string& |
| 1000 | >::type | 1001 | > |
| 1001 | append(const _Tp& __t) { __self_view __sv = __t; return append(__sv.data(), __sv.size()); } | 1002 | append(const _Tp& __t) { __self_view __sv = __t; return append(__sv.data(), __sv.size()); } |
| 1002 | basic_string& append(const basic_string& __str, size_type __pos, size_type __n=npos); | 1003 | basic_string& append(const basic_string& __str, size_type __pos, size_type __n=npos); |
| 1003 | 1004 | ||
| 1004 | template <class _Tp> | 1005 | template <class _Tp> |
| 1005 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 1006 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1006 | typename enable_if | 1007 | _EnableIf |
| 1007 | < | 1008 | < |
| 1008 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 1009 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value |
| 1010 | && !__is_same_uncvref<_Tp, basic_string>::value, | ||
| 1009 | basic_string& | 1011 | basic_string& |
| 1010 | >::type | 1012 | > |
| 1011 | append(const _Tp& __t, size_type __pos, size_type __n=npos); | 1013 | append(const _Tp& __t, size_type __pos, size_type __n=npos); |
| 1012 | basic_string& append(const value_type* __s, size_type __n); | 1014 | basic_string& append(const value_type* __s, size_type __n); |
| 1013 | basic_string& append(const value_type* __s); | 1015 | basic_string& append(const value_type* __s); |
| ... | @@ -1021,12 +1023,12 @@ public: | ... | @@ -1021,12 +1023,12 @@ public: |
| 1021 | basic_string& __append_forward_unsafe(_ForwardIterator, _ForwardIterator); | 1023 | basic_string& __append_forward_unsafe(_ForwardIterator, _ForwardIterator); |
| 1022 | template<class _InputIterator> | 1024 | template<class _InputIterator> |
| 1023 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 1025 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1024 | typename enable_if | 1026 | _EnableIf |
| 1025 | < | 1027 | < |
| 1026 | __is_exactly_cpp17_input_iterator<_InputIterator>::value | 1028 | __is_exactly_cpp17_input_iterator<_InputIterator>::value |
| 1027 | || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, | 1029 | || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, |
| 1028 | basic_string& | 1030 | basic_string& |
| 1029 | >::type | 1031 | > |
| 1030 | _LIBCPP_INLINE_VISIBILITY | 1032 | _LIBCPP_INLINE_VISIBILITY |
| 1031 | append(_InputIterator __first, _InputIterator __last) { | 1033 | append(_InputIterator __first, _InputIterator __last) { |
| 1032 | const basic_string __temp (__first, __last, __alloc()); | 1034 | const basic_string __temp (__first, __last, __alloc()); |
| ... | @@ -1035,12 +1037,12 @@ public: | ... | @@ -1035,12 +1037,12 @@ public: |
| 1035 | } | 1037 | } |
| 1036 | template<class _ForwardIterator> | 1038 | template<class _ForwardIterator> |
| 1037 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 1039 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1038 | typename enable_if | 1040 | _EnableIf |
| 1039 | < | 1041 | < |
| 1040 | __is_cpp17_forward_iterator<_ForwardIterator>::value | 1042 | __is_cpp17_forward_iterator<_ForwardIterator>::value |
| 1041 | && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, | 1043 | && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, |
| 1042 | basic_string& | 1044 | basic_string& |
| 1043 | >::type | 1045 | > |
| 1044 | _LIBCPP_INLINE_VISIBILITY | 1046 | _LIBCPP_INLINE_VISIBILITY |
| 1045 | append(_ForwardIterator __first, _ForwardIterator __last) { | 1047 | append(_ForwardIterator __first, _ForwardIterator __last) { |
| 1046 | return __append_forward_unsafe(__first, __last); | 1048 | return __append_forward_unsafe(__first, __last); |
| ... | @@ -1061,11 +1063,11 @@ public: | ... | @@ -1061,11 +1063,11 @@ public: |
| 1061 | 1063 | ||
| 1062 | template <class _Tp> | 1064 | template <class _Tp> |
| 1063 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 1065 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1064 | typename enable_if | 1066 | _EnableIf |
| 1065 | < | 1067 | < |
| 1066 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 1068 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 1067 | basic_string& | 1069 | basic_string& |
| 1068 | >::type | 1070 | > |
| 1069 | assign(const _Tp & __t) { __self_view __sv = __t; return assign(__sv.data(), __sv.size()); } | 1071 | assign(const _Tp & __t) { __self_view __sv = __t; return assign(__sv.data(), __sv.size()); } |
| 1070 | _LIBCPP_INLINE_VISIBILITY | 1072 | _LIBCPP_INLINE_VISIBILITY |
| 1071 | basic_string& assign(const basic_string& __str) { return *this = __str; } | 1073 | basic_string& assign(const basic_string& __str) { return *this = __str; } |
| ... | @@ -1078,32 +1080,33 @@ public: | ... | @@ -1078,32 +1080,33 @@ public: |
| 1078 | basic_string& assign(const basic_string& __str, size_type __pos, size_type __n=npos); | 1080 | basic_string& assign(const basic_string& __str, size_type __pos, size_type __n=npos); |
| 1079 | template <class _Tp> | 1081 | template <class _Tp> |
| 1080 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 1082 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1081 | typename enable_if | 1083 | _EnableIf |
| 1082 | < | 1084 | < |
| 1083 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 1085 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value |
| 1086 | && !__is_same_uncvref<_Tp, basic_string>::value, | ||
| 1084 | basic_string& | 1087 | basic_string& |
| 1085 | >::type | 1088 | > |
| 1086 | assign(const _Tp & __t, size_type __pos, size_type __n=npos); | 1089 | assign(const _Tp & __t, size_type __pos, size_type __n=npos); |
| 1087 | basic_string& assign(const value_type* __s, size_type __n); | 1090 | basic_string& assign(const value_type* __s, size_type __n); |
| 1088 | basic_string& assign(const value_type* __s); | 1091 | basic_string& assign(const value_type* __s); |
| 1089 | basic_string& assign(size_type __n, value_type __c); | 1092 | basic_string& assign(size_type __n, value_type __c); |
| 1090 | template<class _InputIterator> | 1093 | template<class _InputIterator> |
| 1091 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 1094 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1092 | typename enable_if | 1095 | _EnableIf |
| 1093 | < | 1096 | < |
| 1094 | __is_exactly_cpp17_input_iterator<_InputIterator>::value | 1097 | __is_exactly_cpp17_input_iterator<_InputIterator>::value |
| 1095 | || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, | 1098 | || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, |
| 1096 | basic_string& | 1099 | basic_string& |
| 1097 | >::type | 1100 | > |
| 1098 | assign(_InputIterator __first, _InputIterator __last); | 1101 | assign(_InputIterator __first, _InputIterator __last); |
| 1099 | template<class _ForwardIterator> | 1102 | template<class _ForwardIterator> |
| 1100 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 1103 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1101 | typename enable_if | 1104 | _EnableIf |
| 1102 | < | 1105 | < |
| 1103 | __is_cpp17_forward_iterator<_ForwardIterator>::value | 1106 | __is_cpp17_forward_iterator<_ForwardIterator>::value |
| 1104 | && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, | 1107 | && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, |
| 1105 | basic_string& | 1108 | basic_string& |
| 1106 | >::type | 1109 | > |
| 1107 | assign(_ForwardIterator __first, _ForwardIterator __last); | 1110 | assign(_ForwardIterator __first, _ForwardIterator __last); |
| 1108 | #ifndef _LIBCPP_CXX03_LANG | 1111 | #ifndef _LIBCPP_CXX03_LANG |
| 1109 | _LIBCPP_INLINE_VISIBILITY | 1112 | _LIBCPP_INLINE_VISIBILITY |
| ... | @@ -1115,21 +1118,21 @@ public: | ... | @@ -1115,21 +1118,21 @@ public: |
| 1115 | 1118 | ||
| 1116 | template <class _Tp> | 1119 | template <class _Tp> |
| 1117 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 1120 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1118 | typename enable_if | 1121 | _EnableIf |
| 1119 | < | 1122 | < |
| 1120 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 1123 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 1121 | basic_string& | 1124 | basic_string& |
| 1122 | >::type | 1125 | > |
| 1123 | insert(size_type __pos1, const _Tp& __t) | 1126 | insert(size_type __pos1, const _Tp& __t) |
| 1124 | { __self_view __sv = __t; return insert(__pos1, __sv.data(), __sv.size()); } | 1127 | { __self_view __sv = __t; return insert(__pos1, __sv.data(), __sv.size()); } |
| 1125 | 1128 | ||
| 1126 | template <class _Tp> | 1129 | template <class _Tp> |
| 1127 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 1130 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1128 | typename enable_if | 1131 | _EnableIf |
| 1129 | < | 1132 | < |
| 1130 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 1133 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value, |
| 1131 | basic_string& | 1134 | basic_string& |
| 1132 | >::type | 1135 | > |
| 1133 | insert(size_type __pos1, const _Tp& __t, size_type __pos2, size_type __n=npos); | 1136 | insert(size_type __pos1, const _Tp& __t, size_type __pos2, size_type __n=npos); |
| 1134 | basic_string& insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n=npos); | 1137 | basic_string& insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n=npos); |
| 1135 | basic_string& insert(size_type __pos, const value_type* __s, size_type __n); | 1138 | basic_string& insert(size_type __pos, const value_type* __s, size_type __n); |
| ... | @@ -1140,21 +1143,21 @@ public: | ... | @@ -1140,21 +1143,21 @@ public: |
| 1140 | iterator insert(const_iterator __pos, size_type __n, value_type __c); | 1143 | iterator insert(const_iterator __pos, size_type __n, value_type __c); |
| 1141 | template<class _InputIterator> | 1144 | template<class _InputIterator> |
| 1142 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 1145 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1143 | typename enable_if | 1146 | _EnableIf |
| 1144 | < | 1147 | < |
| 1145 | __is_exactly_cpp17_input_iterator<_InputIterator>::value | 1148 | __is_exactly_cpp17_input_iterator<_InputIterator>::value |
| 1146 | || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, | 1149 | || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, |
| 1147 | iterator | 1150 | iterator |
| 1148 | >::type | 1151 | > |
| 1149 | insert(const_iterator __pos, _InputIterator __first, _InputIterator __last); | 1152 | insert(const_iterator __pos, _InputIterator __first, _InputIterator __last); |
| 1150 | template<class _ForwardIterator> | 1153 | template<class _ForwardIterator> |
| 1151 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 1154 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1152 | typename enable_if | 1155 | _EnableIf |
| 1153 | < | 1156 | < |
| 1154 | __is_cpp17_forward_iterator<_ForwardIterator>::value | 1157 | __is_cpp17_forward_iterator<_ForwardIterator>::value |
| 1155 | && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, | 1158 | && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, |
| 1156 | iterator | 1159 | iterator |
| 1157 | >::type | 1160 | > |
| 1158 | insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last); | 1161 | insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last); |
| 1159 | #ifndef _LIBCPP_CXX03_LANG | 1162 | #ifndef _LIBCPP_CXX03_LANG |
| 1160 | _LIBCPP_INLINE_VISIBILITY | 1163 | _LIBCPP_INLINE_VISIBILITY |
| ... | @@ -1173,20 +1176,20 @@ public: | ... | @@ -1173,20 +1176,20 @@ public: |
| 1173 | 1176 | ||
| 1174 | template <class _Tp> | 1177 | template <class _Tp> |
| 1175 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 1178 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1176 | typename enable_if | 1179 | _EnableIf |
| 1177 | < | 1180 | < |
| 1178 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 1181 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 1179 | basic_string& | 1182 | basic_string& |
| 1180 | >::type | 1183 | > |
| 1181 | replace(size_type __pos1, size_type __n1, const _Tp& __t) { __self_view __sv = __t; return replace(__pos1, __n1, __sv.data(), __sv.size()); } | 1184 | replace(size_type __pos1, size_type __n1, const _Tp& __t) { __self_view __sv = __t; return replace(__pos1, __n1, __sv.data(), __sv.size()); } |
| 1182 | basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos); | 1185 | basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos); |
| 1183 | template <class _Tp> | 1186 | template <class _Tp> |
| 1184 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 1187 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1185 | typename enable_if | 1188 | _EnableIf |
| 1186 | < | 1189 | < |
| 1187 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 1190 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value, |
| 1188 | basic_string& | 1191 | basic_string& |
| 1189 | >::type | 1192 | > |
| 1190 | replace(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2=npos); | 1193 | replace(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2=npos); |
| 1191 | basic_string& replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2); | 1194 | basic_string& replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2); |
| 1192 | basic_string& replace(size_type __pos, size_type __n1, const value_type* __s); | 1195 | basic_string& replace(size_type __pos, size_type __n1, const value_type* __s); |
| ... | @@ -1196,11 +1199,11 @@ public: | ... | @@ -1196,11 +1199,11 @@ public: |
| 1196 | 1199 | ||
| 1197 | template <class _Tp> | 1200 | template <class _Tp> |
| 1198 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 1201 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1199 | typename enable_if | 1202 | _EnableIf |
| 1200 | < | 1203 | < |
| 1201 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 1204 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 1202 | basic_string& | 1205 | basic_string& |
| 1203 | >::type | 1206 | > |
| 1204 | replace(const_iterator __i1, const_iterator __i2, const _Tp& __t) { __self_view __sv = __t; return replace(__i1 - begin(), __i2 - __i1, __sv); } | 1207 | replace(const_iterator __i1, const_iterator __i2, const _Tp& __t) { __self_view __sv = __t; return replace(__i1 - begin(), __i2 - __i1, __sv); } |
| 1205 | 1208 | ||
| 1206 | _LIBCPP_INLINE_VISIBILITY | 1209 | _LIBCPP_INLINE_VISIBILITY |
| ... | @@ -1211,11 +1214,11 @@ public: | ... | @@ -1211,11 +1214,11 @@ public: |
| 1211 | basic_string& replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c); | 1214 | basic_string& replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c); |
| 1212 | template<class _InputIterator> | 1215 | template<class _InputIterator> |
| 1213 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 1216 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1214 | typename enable_if | 1217 | _EnableIf |
| 1215 | < | 1218 | < |
| 1216 | __is_cpp17_input_iterator<_InputIterator>::value, | 1219 | __is_cpp17_input_iterator<_InputIterator>::value, |
| 1217 | basic_string& | 1220 | basic_string& |
| 1218 | >::type | 1221 | > |
| 1219 | replace(const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2); | 1222 | replace(const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2); |
| 1220 | #ifndef _LIBCPP_CXX03_LANG | 1223 | #ifndef _LIBCPP_CXX03_LANG |
| 1221 | _LIBCPP_INLINE_VISIBILITY | 1224 | _LIBCPP_INLINE_VISIBILITY |
| ... | @@ -1253,11 +1256,11 @@ public: | ... | @@ -1253,11 +1256,11 @@ public: |
| 1253 | 1256 | ||
| 1254 | template <class _Tp> | 1257 | template <class _Tp> |
| 1255 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 1258 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1256 | typename enable_if | 1259 | _EnableIf |
| 1257 | < | 1260 | < |
| 1258 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 1261 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 1259 | size_type | 1262 | size_type |
| 1260 | >::type | 1263 | > |
| 1261 | find(const _Tp& __t, size_type __pos = 0) const; | 1264 | find(const _Tp& __t, size_type __pos = 0) const; |
| 1262 | size_type find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; | 1265 | size_type find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; |
| 1263 | _LIBCPP_INLINE_VISIBILITY | 1266 | _LIBCPP_INLINE_VISIBILITY |
| ... | @@ -1269,11 +1272,11 @@ public: | ... | @@ -1269,11 +1272,11 @@ public: |
| 1269 | 1272 | ||
| 1270 | template <class _Tp> | 1273 | template <class _Tp> |
| 1271 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 1274 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1272 | typename enable_if | 1275 | _EnableIf |
| 1273 | < | 1276 | < |
| 1274 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 1277 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 1275 | size_type | 1278 | size_type |
| 1276 | >::type | 1279 | > |
| 1277 | rfind(const _Tp& __t, size_type __pos = npos) const; | 1280 | rfind(const _Tp& __t, size_type __pos = npos) const; |
| 1278 | size_type rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; | 1281 | size_type rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; |
| 1279 | _LIBCPP_INLINE_VISIBILITY | 1282 | _LIBCPP_INLINE_VISIBILITY |
| ... | @@ -1285,11 +1288,11 @@ public: | ... | @@ -1285,11 +1288,11 @@ public: |
| 1285 | 1288 | ||
| 1286 | template <class _Tp> | 1289 | template <class _Tp> |
| 1287 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 1290 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1288 | typename enable_if | 1291 | _EnableIf |
| 1289 | < | 1292 | < |
| 1290 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 1293 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 1291 | size_type | 1294 | size_type |
| 1292 | >::type | 1295 | > |
| 1293 | find_first_of(const _Tp& __t, size_type __pos = 0) const; | 1296 | find_first_of(const _Tp& __t, size_type __pos = 0) const; |
| 1294 | size_type find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; | 1297 | size_type find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; |
| 1295 | _LIBCPP_INLINE_VISIBILITY | 1298 | _LIBCPP_INLINE_VISIBILITY |
| ... | @@ -1302,11 +1305,11 @@ public: | ... | @@ -1302,11 +1305,11 @@ public: |
| 1302 | 1305 | ||
| 1303 | template <class _Tp> | 1306 | template <class _Tp> |
| 1304 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 1307 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1305 | typename enable_if | 1308 | _EnableIf |
| 1306 | < | 1309 | < |
| 1307 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 1310 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 1308 | size_type | 1311 | size_type |
| 1309 | >::type | 1312 | > |
| 1310 | find_last_of(const _Tp& __t, size_type __pos = npos) const; | 1313 | find_last_of(const _Tp& __t, size_type __pos = npos) const; |
| 1311 | size_type find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; | 1314 | size_type find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; |
| 1312 | _LIBCPP_INLINE_VISIBILITY | 1315 | _LIBCPP_INLINE_VISIBILITY |
| ... | @@ -1319,11 +1322,11 @@ public: | ... | @@ -1319,11 +1322,11 @@ public: |
| 1319 | 1322 | ||
| 1320 | template <class _Tp> | 1323 | template <class _Tp> |
| 1321 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 1324 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1322 | typename enable_if | 1325 | _EnableIf |
| 1323 | < | 1326 | < |
| 1324 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 1327 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 1325 | size_type | 1328 | size_type |
| 1326 | >::type | 1329 | > |
| 1327 | find_first_not_of(const _Tp &__t, size_type __pos = 0) const; | 1330 | find_first_not_of(const _Tp &__t, size_type __pos = 0) const; |
| 1328 | size_type find_first_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; | 1331 | size_type find_first_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; |
| 1329 | _LIBCPP_INLINE_VISIBILITY | 1332 | _LIBCPP_INLINE_VISIBILITY |
| ... | @@ -1336,11 +1339,11 @@ public: | ... | @@ -1336,11 +1339,11 @@ public: |
| 1336 | 1339 | ||
| 1337 | template <class _Tp> | 1340 | template <class _Tp> |
| 1338 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 1341 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1339 | typename enable_if | 1342 | _EnableIf |
| 1340 | < | 1343 | < |
| 1341 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 1344 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 1342 | size_type | 1345 | size_type |
| 1343 | >::type | 1346 | > |
| 1344 | find_last_not_of(const _Tp& __t, size_type __pos = npos) const; | 1347 | find_last_not_of(const _Tp& __t, size_type __pos = npos) const; |
| 1345 | size_type find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; | 1348 | size_type find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; |
| 1346 | _LIBCPP_INLINE_VISIBILITY | 1349 | _LIBCPP_INLINE_VISIBILITY |
| ... | @@ -1353,20 +1356,20 @@ public: | ... | @@ -1353,20 +1356,20 @@ public: |
| 1353 | 1356 | ||
| 1354 | template <class _Tp> | 1357 | template <class _Tp> |
| 1355 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 1358 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1356 | typename enable_if | 1359 | _EnableIf |
| 1357 | < | 1360 | < |
| 1358 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 1361 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 1359 | int | 1362 | int |
| 1360 | >::type | 1363 | > |
| 1361 | compare(const _Tp &__t) const; | 1364 | compare(const _Tp &__t) const; |
| 1362 | 1365 | ||
| 1363 | template <class _Tp> | 1366 | template <class _Tp> |
| 1364 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 1367 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1365 | typename enable_if | 1368 | _EnableIf |
| 1366 | < | 1369 | < |
| 1367 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 1370 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 1368 | int | 1371 | int |
| 1369 | >::type | 1372 | > |
| 1370 | compare(size_type __pos1, size_type __n1, const _Tp& __t) const; | 1373 | compare(size_type __pos1, size_type __n1, const _Tp& __t) const; |
| 1371 | 1374 | ||
| 1372 | _LIBCPP_INLINE_VISIBILITY | 1375 | _LIBCPP_INLINE_VISIBILITY |
| ... | @@ -1375,11 +1378,11 @@ public: | ... | @@ -1375,11 +1378,11 @@ public: |
| 1375 | 1378 | ||
| 1376 | template <class _Tp> | 1379 | template <class _Tp> |
| 1377 | inline _LIBCPP_INLINE_VISIBILITY | 1380 | inline _LIBCPP_INLINE_VISIBILITY |
| 1378 | typename enable_if | 1381 | _EnableIf |
| 1379 | < | 1382 | < |
| 1380 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 1383 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value, |
| 1381 | int | 1384 | int |
| 1382 | >::type | 1385 | > |
| 1383 | compare(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2=npos) const; | 1386 | compare(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2=npos) const; |
| 1384 | int compare(const value_type* __s) const _NOEXCEPT; | 1387 | int compare(const value_type* __s) const _NOEXCEPT; |
| 1385 | int compare(size_type __pos1, size_type __n1, const value_type* __s) const; | 1388 | int compare(size_type __pos1, size_type __n1, const value_type* __s) const; |
| ... | @@ -1543,22 +1546,30 @@ private: | ... | @@ -1543,22 +1546,30 @@ private: |
| 1543 | inline | 1546 | inline |
| 1544 | void __init(size_type __n, value_type __c); | 1547 | void __init(size_type __n, value_type __c); |
| 1545 | 1548 | ||
| 1549 | // Slow path for the (inlined) copy constructor for 'long' strings. | ||
| 1550 | // Always externally instantiated and not inlined. | ||
| 1551 | // Requires that __s is zero terminated. | ||
| 1552 | // The main reason for this function to exist is because for unstable, we | ||
| 1553 | // want to allow inlining of the copy constructor. However, we don't want | ||
| 1554 | // to call the __init() functions as those are marked as inline which may | ||
| 1555 | // result in over-aggressive inlining by the compiler, where our aim is | ||
| 1556 | // to only inline the fast path code directly in the ctor. | ||
| 1557 | void __init_copy_ctor_external(const value_type* __s, size_type __sz); | ||
| 1558 | |||
| 1546 | template <class _InputIterator> | 1559 | template <class _InputIterator> |
| 1547 | inline | 1560 | inline |
| 1548 | typename enable_if | 1561 | _EnableIf |
| 1549 | < | 1562 | < |
| 1550 | __is_exactly_cpp17_input_iterator<_InputIterator>::value, | 1563 | __is_exactly_cpp17_input_iterator<_InputIterator>::value |
| 1551 | void | 1564 | > |
| 1552 | >::type | ||
| 1553 | __init(_InputIterator __first, _InputIterator __last); | 1565 | __init(_InputIterator __first, _InputIterator __last); |
| 1554 | 1566 | ||
| 1555 | template <class _ForwardIterator> | 1567 | template <class _ForwardIterator> |
| 1556 | inline | 1568 | inline |
| 1557 | typename enable_if | 1569 | _EnableIf |
| 1558 | < | 1570 | < |
| 1559 | __is_cpp17_forward_iterator<_ForwardIterator>::value, | 1571 | __is_cpp17_forward_iterator<_ForwardIterator>::value |
| 1560 | void | 1572 | > |
| 1561 | >::type | ||
| 1562 | __init(_ForwardIterator __first, _ForwardIterator __last); | 1573 | __init(_ForwardIterator __first, _ForwardIterator __last); |
| 1563 | 1574 | ||
| 1564 | void __grow_by(size_type __old_cap, size_type __delta_cap, size_type __old_sz, | 1575 | void __grow_by(size_type __old_cap, size_type __delta_cap, size_type __old_sz, |
| ... | @@ -1567,9 +1578,19 @@ private: | ... | @@ -1567,9 +1578,19 @@ private: |
| 1567 | size_type __n_copy, size_type __n_del, | 1578 | size_type __n_copy, size_type __n_del, |
| 1568 | size_type __n_add, const value_type* __p_new_stuff); | 1579 | size_type __n_add, const value_type* __p_new_stuff); |
| 1569 | 1580 | ||
| 1581 | // __assign_no_alias is invoked for assignment operations where we | ||
| 1582 | // have proof that the input does not alias the current instance. | ||
| 1583 | // For example, operator=(basic_string) performs a 'self' check. | ||
| 1584 | template <bool __is_short> | ||
| 1585 | basic_string& __assign_no_alias(const value_type* __s, size_type __n); | ||
| 1586 | |||
| 1570 | _LIBCPP_INLINE_VISIBILITY | 1587 | _LIBCPP_INLINE_VISIBILITY |
| 1571 | void __erase_to_end(size_type __pos); | 1588 | void __erase_to_end(size_type __pos); |
| 1572 | 1589 | ||
| 1590 | // __erase_external_with_move is invoked for erase() invocations where | ||
| 1591 | // `n ~= npos`, likely requiring memory moves on the string data. | ||
| 1592 | void __erase_external_with_move(size_type __pos, size_type __n); | ||
| 1593 | |||
| 1573 | _LIBCPP_INLINE_VISIBILITY | 1594 | _LIBCPP_INLINE_VISIBILITY |
| 1574 | void __copy_assign_alloc(const basic_string& __str) | 1595 | void __copy_assign_alloc(const basic_string& __str) |
| 1575 | {__copy_assign_alloc(__str, integral_constant<bool, | 1596 | {__copy_assign_alloc(__str, integral_constant<bool, |
| ... | @@ -1638,6 +1659,19 @@ private: | ... | @@ -1638,6 +1659,19 @@ private: |
| 1638 | _NOEXCEPT | 1659 | _NOEXCEPT |
| 1639 | {} | 1660 | {} |
| 1640 | 1661 | ||
| 1662 | basic_string& __assign_external(const value_type* __s); | ||
| 1663 | basic_string& __assign_external(const value_type* __s, size_type __n); | ||
| 1664 | |||
| 1665 | // Assigns the value in __s, guaranteed to be __n < __min_cap in length. | ||
| 1666 | inline basic_string& __assign_short(const value_type* __s, size_type __n) { | ||
| 1667 | pointer __p = __is_long() | ||
| 1668 | ? (__set_long_size(__n), __get_long_pointer()) | ||
| 1669 | : (__set_short_size(__n), __get_short_pointer()); | ||
| 1670 | traits_type::move(_VSTD::__to_address(__p), __s, __n); | ||
| 1671 | traits_type::assign(__p[__n], value_type()); | ||
| 1672 | return *this; | ||
| 1673 | } | ||
| 1674 | |||
| 1641 | _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators(); | 1675 | _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators(); |
| 1642 | _LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(size_type); | 1676 | _LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(size_type); |
| 1643 | 1677 | ||
| ... | @@ -1648,12 +1682,23 @@ private: | ... | @@ -1648,12 +1682,23 @@ private: |
| 1648 | friend basic_string operator+<>(const basic_string&, value_type); | 1682 | friend basic_string operator+<>(const basic_string&, value_type); |
| 1649 | }; | 1683 | }; |
| 1650 | 1684 | ||
| 1685 | // These declarations must appear before any functions are implicitly used | ||
| 1686 | // so that they have the correct visibility specifier. | ||
| 1687 | #ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION | ||
| 1688 | _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, char) | ||
| 1689 | _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, wchar_t) | ||
| 1690 | #else | ||
| 1691 | _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, char) | ||
| 1692 | _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, wchar_t) | ||
| 1693 | #endif | ||
| 1694 | |||
| 1695 | |||
| 1651 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | 1696 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES |
| 1652 | template<class _InputIterator, | 1697 | template<class _InputIterator, |
| 1653 | class _CharT = typename iterator_traits<_InputIterator>::value_type, | 1698 | class _CharT = typename iterator_traits<_InputIterator>::value_type, |
| 1654 | class _Allocator = allocator<_CharT>, | 1699 | class _Allocator = allocator<_CharT>, |
| 1655 | class = typename enable_if<__is_cpp17_input_iterator<_InputIterator>::value, void>::type, | 1700 | class = _EnableIf<__is_cpp17_input_iterator<_InputIterator>::value>, |
| 1656 | class = typename enable_if<__is_allocator<_Allocator>::value, void>::type | 1701 | class = _EnableIf<__is_allocator<_Allocator>::value> |
| 1657 | > | 1702 | > |
| 1658 | basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator()) | 1703 | basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator()) |
| 1659 | -> basic_string<_CharT, char_traits<_CharT>, _Allocator>; | 1704 | -> basic_string<_CharT, char_traits<_CharT>, _Allocator>; |
| ... | @@ -1661,7 +1706,7 @@ basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator()) | ... | @@ -1661,7 +1706,7 @@ basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator()) |
| 1661 | template<class _CharT, | 1706 | template<class _CharT, |
| 1662 | class _Traits, | 1707 | class _Traits, |
| 1663 | class _Allocator = allocator<_CharT>, | 1708 | class _Allocator = allocator<_CharT>, |
| 1664 | class = typename enable_if<__is_allocator<_Allocator>::value, void>::type | 1709 | class = _EnableIf<__is_allocator<_Allocator>::value> |
| 1665 | > | 1710 | > |
| 1666 | explicit basic_string(basic_string_view<_CharT, _Traits>, const _Allocator& = _Allocator()) | 1711 | explicit basic_string(basic_string_view<_CharT, _Traits>, const _Allocator& = _Allocator()) |
| 1667 | -> basic_string<_CharT, _Traits, _Allocator>; | 1712 | -> basic_string<_CharT, _Traits, _Allocator>; |
| ... | @@ -1669,14 +1714,13 @@ explicit basic_string(basic_string_view<_CharT, _Traits>, const _Allocator& = _A | ... | @@ -1669,14 +1714,13 @@ explicit basic_string(basic_string_view<_CharT, _Traits>, const _Allocator& = _A |
| 1669 | template<class _CharT, | 1714 | template<class _CharT, |
| 1670 | class _Traits, | 1715 | class _Traits, |
| 1671 | class _Allocator = allocator<_CharT>, | 1716 | class _Allocator = allocator<_CharT>, |
| 1672 | class = typename enable_if<__is_allocator<_Allocator>::value, void>::type, | 1717 | class = _EnableIf<__is_allocator<_Allocator>::value>, |
| 1673 | class _Sz = typename allocator_traits<_Allocator>::size_type | 1718 | class _Sz = typename allocator_traits<_Allocator>::size_type |
| 1674 | > | 1719 | > |
| 1675 | basic_string(basic_string_view<_CharT, _Traits>, _Sz, _Sz, const _Allocator& = _Allocator()) | 1720 | basic_string(basic_string_view<_CharT, _Traits>, _Sz, _Sz, const _Allocator& = _Allocator()) |
| 1676 | -> basic_string<_CharT, _Traits, _Allocator>; | 1721 | -> basic_string<_CharT, _Traits, _Allocator>; |
| 1677 | #endif | 1722 | #endif |
| 1678 | 1723 | ||
| 1679 | |||
| 1680 | template <class _CharT, class _Traits, class _Allocator> | 1724 | template <class _CharT, class _Traits, class _Allocator> |
| 1681 | inline | 1725 | inline |
| 1682 | void | 1726 | void |
| ... | @@ -1837,7 +1881,9 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st | ... | @@ -1837,7 +1881,9 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st |
| 1837 | if (!__str.__is_long()) | 1881 | if (!__str.__is_long()) |
| 1838 | __r_.first().__r = __str.__r_.first().__r; | 1882 | __r_.first().__r = __str.__r_.first().__r; |
| 1839 | else | 1883 | else |
| 1840 | __init(_VSTD::__to_address(__str.__get_long_pointer()), __str.__get_long_size()); | 1884 | __init_copy_ctor_external(_VSTD::__to_address(__str.__get_long_pointer()), |
| 1885 | __str.__get_long_size()); | ||
| 1886 | |||
| 1841 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 1887 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 1842 | __get_db()->__insert_c(this); | 1888 | __get_db()->__insert_c(this); |
| 1843 | #endif | 1889 | #endif |
| ... | @@ -1851,12 +1897,32 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string( | ... | @@ -1851,12 +1897,32 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string( |
| 1851 | if (!__str.__is_long()) | 1897 | if (!__str.__is_long()) |
| 1852 | __r_.first().__r = __str.__r_.first().__r; | 1898 | __r_.first().__r = __str.__r_.first().__r; |
| 1853 | else | 1899 | else |
| 1854 | __init(_VSTD::__to_address(__str.__get_long_pointer()), __str.__get_long_size()); | 1900 | __init_copy_ctor_external(_VSTD::__to_address(__str.__get_long_pointer()), |
| 1901 | __str.__get_long_size()); | ||
| 1855 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 1902 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 1856 | __get_db()->__insert_c(this); | 1903 | __get_db()->__insert_c(this); |
| 1857 | #endif | 1904 | #endif |
| 1858 | } | 1905 | } |
| 1859 | 1906 | ||
| 1907 | template <class _CharT, class _Traits, class _Allocator> | ||
| 1908 | void basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external( | ||
| 1909 | const value_type* __s, size_type __sz) { | ||
| 1910 | pointer __p; | ||
| 1911 | if (__sz < __min_cap) { | ||
| 1912 | __p = __get_short_pointer(); | ||
| 1913 | __set_short_size(__sz); | ||
| 1914 | } else { | ||
| 1915 | if (__sz > max_size()) | ||
| 1916 | this->__throw_length_error(); | ||
| 1917 | size_t __cap = __recommend(__sz); | ||
| 1918 | __p = __alloc_traits::allocate(__alloc(), __cap + 1); | ||
| 1919 | __set_long_pointer(__p); | ||
| 1920 | __set_long_cap(__cap + 1); | ||
| 1921 | __set_long_size(__sz); | ||
| 1922 | } | ||
| 1923 | traits_type::copy(_VSTD::__to_address(__p), __s, __sz + 1); | ||
| 1924 | } | ||
| 1925 | |||
| 1860 | #ifndef _LIBCPP_CXX03_LANG | 1926 | #ifndef _LIBCPP_CXX03_LANG |
| 1861 | 1927 | ||
| 1862 | template <class _CharT, class _Traits, class _Allocator> | 1928 | template <class _CharT, class _Traits, class _Allocator> |
| ... | @@ -2014,11 +2080,10 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t, const _ | ... | @@ -2014,11 +2080,10 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t, const _ |
| 2014 | 2080 | ||
| 2015 | template <class _CharT, class _Traits, class _Allocator> | 2081 | template <class _CharT, class _Traits, class _Allocator> |
| 2016 | template <class _InputIterator> | 2082 | template <class _InputIterator> |
| 2017 | typename enable_if | 2083 | _EnableIf |
| 2018 | < | 2084 | < |
| 2019 | __is_exactly_cpp17_input_iterator<_InputIterator>::value, | 2085 | __is_exactly_cpp17_input_iterator<_InputIterator>::value |
| 2020 | void | 2086 | > |
| 2021 | >::type | ||
| 2022 | basic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _InputIterator __last) | 2087 | basic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _InputIterator __last) |
| 2023 | { | 2088 | { |
| 2024 | __zero(); | 2089 | __zero(); |
| ... | @@ -2041,11 +2106,10 @@ basic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _Input | ... | @@ -2041,11 +2106,10 @@ basic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _Input |
| 2041 | 2106 | ||
| 2042 | template <class _CharT, class _Traits, class _Allocator> | 2107 | template <class _CharT, class _Traits, class _Allocator> |
| 2043 | template <class _ForwardIterator> | 2108 | template <class _ForwardIterator> |
| 2044 | typename enable_if | 2109 | _EnableIf |
| 2045 | < | 2110 | < |
| 2046 | __is_cpp17_forward_iterator<_ForwardIterator>::value, | 2111 | __is_cpp17_forward_iterator<_ForwardIterator>::value |
| 2047 | void | 2112 | > |
| 2048 | >::type | ||
| 2049 | basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _ForwardIterator __last) | 2113 | basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _ForwardIterator __last) |
| 2050 | { | 2114 | { |
| 2051 | size_type __sz = static_cast<size_type>(_VSTD::distance(__first, __last)); | 2115 | size_type __sz = static_cast<size_type>(_VSTD::distance(__first, __last)); |
| ... | @@ -2197,26 +2261,51 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_t | ... | @@ -2197,26 +2261,51 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_t |
| 2197 | 2261 | ||
| 2198 | // assign | 2262 | // assign |
| 2199 | 2263 | ||
| 2264 | template <class _CharT, class _Traits, class _Allocator> | ||
| 2265 | template <bool __is_short> | ||
| 2266 | basic_string<_CharT, _Traits, _Allocator>& | ||
| 2267 | basic_string<_CharT, _Traits, _Allocator>::__assign_no_alias( | ||
| 2268 | const value_type* __s, size_type __n) { | ||
| 2269 | size_type __cap = __is_short ? __min_cap : __get_long_cap(); | ||
| 2270 | if (__n < __cap) { | ||
| 2271 | pointer __p = __is_short ? __get_short_pointer() : __get_long_pointer(); | ||
| 2272 | __is_short ? __set_short_size(__n) : __set_long_size(__n); | ||
| 2273 | traits_type::copy(_VSTD::__to_address(__p), __s, __n); | ||
| 2274 | traits_type::assign(__p[__n], value_type()); | ||
| 2275 | __invalidate_iterators_past(__n); | ||
| 2276 | } else { | ||
| 2277 | size_type __sz = __is_short ? __get_short_size() : __get_long_size(); | ||
| 2278 | __grow_by_and_replace(__cap - 1, __n - __cap + 1, __sz, 0, __sz, __n, __s); | ||
| 2279 | } | ||
| 2280 | return *this; | ||
| 2281 | } | ||
| 2282 | |||
| 2283 | template <class _CharT, class _Traits, class _Allocator> | ||
| 2284 | basic_string<_CharT, _Traits, _Allocator>& | ||
| 2285 | basic_string<_CharT, _Traits, _Allocator>::__assign_external( | ||
| 2286 | const value_type* __s, size_type __n) { | ||
| 2287 | size_type __cap = capacity(); | ||
| 2288 | if (__cap >= __n) { | ||
| 2289 | value_type* __p = _VSTD::__to_address(__get_pointer()); | ||
| 2290 | traits_type::move(__p, __s, __n); | ||
| 2291 | traits_type::assign(__p[__n], value_type()); | ||
| 2292 | __set_size(__n); | ||
| 2293 | __invalidate_iterators_past(__n); | ||
| 2294 | } else { | ||
| 2295 | size_type __sz = size(); | ||
| 2296 | __grow_by_and_replace(__cap, __n - __cap, __sz, 0, __sz, __n, __s); | ||
| 2297 | } | ||
| 2298 | return *this; | ||
| 2299 | } | ||
| 2300 | |||
| 2200 | template <class _CharT, class _Traits, class _Allocator> | 2301 | template <class _CharT, class _Traits, class _Allocator> |
| 2201 | basic_string<_CharT, _Traits, _Allocator>& | 2302 | basic_string<_CharT, _Traits, _Allocator>& |
| 2202 | basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_type __n) | 2303 | basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_type __n) |
| 2203 | { | 2304 | { |
| 2204 | _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::assign received nullptr"); | 2305 | _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::assign received nullptr"); |
| 2205 | size_type __cap = capacity(); | 2306 | return (_LIBCPP_BUILTIN_CONSTANT_P(__n) && __n < __min_cap) |
| 2206 | if (__cap >= __n) | 2307 | ? __assign_short(__s, __n) |
| 2207 | { | 2308 | : __assign_external(__s, __n); |
| 2208 | value_type* __p = _VSTD::__to_address(__get_pointer()); | ||
| 2209 | traits_type::move(__p, __s, __n); | ||
| 2210 | traits_type::assign(__p[__n], value_type()); | ||
| 2211 | __set_size(__n); | ||
| 2212 | __invalidate_iterators_past(__n); | ||
| 2213 | } | ||
| 2214 | else | ||
| 2215 | { | ||
| 2216 | size_type __sz = size(); | ||
| 2217 | __grow_by_and_replace(__cap, __n - __cap, __sz, 0, __sz, __n, __s); | ||
| 2218 | } | ||
| 2219 | return *this; | ||
| 2220 | } | 2309 | } |
| 2221 | 2310 | ||
| 2222 | template <class _CharT, class _Traits, class _Allocator> | 2311 | template <class _CharT, class _Traits, class _Allocator> |
| ... | @@ -2263,12 +2352,19 @@ template <class _CharT, class _Traits, class _Allocator> | ... | @@ -2263,12 +2352,19 @@ template <class _CharT, class _Traits, class _Allocator> |
| 2263 | basic_string<_CharT, _Traits, _Allocator>& | 2352 | basic_string<_CharT, _Traits, _Allocator>& |
| 2264 | basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str) | 2353 | basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str) |
| 2265 | { | 2354 | { |
| 2266 | if (this != &__str) | 2355 | if (this != &__str) { |
| 2267 | { | 2356 | __copy_assign_alloc(__str); |
| 2268 | __copy_assign_alloc(__str); | 2357 | if (!__is_long()) { |
| 2269 | return assign(__str.data(), __str.size()); | 2358 | if (!__str.__is_long()) { |
| 2359 | __r_.first().__r = __str.__r_.first().__r; | ||
| 2360 | } else { | ||
| 2361 | return __assign_no_alias<true>(__str.data(), __str.size()); | ||
| 2362 | } | ||
| 2363 | } else { | ||
| 2364 | return __assign_no_alias<false>(__str.data(), __str.size()); | ||
| 2270 | } | 2365 | } |
| 2271 | return *this; | 2366 | } |
| 2367 | return *this; | ||
| 2272 | } | 2368 | } |
| 2273 | 2369 | ||
| 2274 | #ifndef _LIBCPP_CXX03_LANG | 2370 | #ifndef _LIBCPP_CXX03_LANG |
| ... | @@ -2326,12 +2422,12 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(basic_string&& __str) | ... | @@ -2326,12 +2422,12 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(basic_string&& __str) |
| 2326 | 2422 | ||
| 2327 | template <class _CharT, class _Traits, class _Allocator> | 2423 | template <class _CharT, class _Traits, class _Allocator> |
| 2328 | template<class _InputIterator> | 2424 | template<class _InputIterator> |
| 2329 | typename enable_if | 2425 | _EnableIf |
| 2330 | < | 2426 | < |
| 2331 | __is_exactly_cpp17_input_iterator <_InputIterator>::value | 2427 | __is_exactly_cpp17_input_iterator <_InputIterator>::value |
| 2332 | || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, | 2428 | || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, |
| 2333 | basic_string<_CharT, _Traits, _Allocator>& | 2429 | basic_string<_CharT, _Traits, _Allocator>& |
| 2334 | >::type | 2430 | > |
| 2335 | basic_string<_CharT, _Traits, _Allocator>::assign(_InputIterator __first, _InputIterator __last) | 2431 | basic_string<_CharT, _Traits, _Allocator>::assign(_InputIterator __first, _InputIterator __last) |
| 2336 | { | 2432 | { |
| 2337 | const basic_string __temp(__first, __last, __alloc()); | 2433 | const basic_string __temp(__first, __last, __alloc()); |
| ... | @@ -2341,12 +2437,12 @@ basic_string<_CharT, _Traits, _Allocator>::assign(_InputIterator __first, _Input | ... | @@ -2341,12 +2437,12 @@ basic_string<_CharT, _Traits, _Allocator>::assign(_InputIterator __first, _Input |
| 2341 | 2437 | ||
| 2342 | template <class _CharT, class _Traits, class _Allocator> | 2438 | template <class _CharT, class _Traits, class _Allocator> |
| 2343 | template<class _ForwardIterator> | 2439 | template<class _ForwardIterator> |
| 2344 | typename enable_if | 2440 | _EnableIf |
| 2345 | < | 2441 | < |
| 2346 | __is_cpp17_forward_iterator<_ForwardIterator>::value | 2442 | __is_cpp17_forward_iterator<_ForwardIterator>::value |
| 2347 | && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, | 2443 | && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, |
| 2348 | basic_string<_CharT, _Traits, _Allocator>& | 2444 | basic_string<_CharT, _Traits, _Allocator>& |
| 2349 | >::type | 2445 | > |
| 2350 | basic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last) | 2446 | basic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last) |
| 2351 | { | 2447 | { |
| 2352 | size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last)); | 2448 | size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last)); |
| ... | @@ -2378,11 +2474,12 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str, siz | ... | @@ -2378,11 +2474,12 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str, siz |
| 2378 | 2474 | ||
| 2379 | template <class _CharT, class _Traits, class _Allocator> | 2475 | template <class _CharT, class _Traits, class _Allocator> |
| 2380 | template <class _Tp> | 2476 | template <class _Tp> |
| 2381 | typename enable_if | 2477 | _EnableIf |
| 2382 | < | 2478 | < |
| 2383 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 2479 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value |
| 2480 | && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value, | ||
| 2384 | basic_string<_CharT, _Traits, _Allocator>& | 2481 | basic_string<_CharT, _Traits, _Allocator>& |
| 2385 | >::type | 2482 | > |
| 2386 | basic_string<_CharT, _Traits, _Allocator>::assign(const _Tp & __t, size_type __pos, size_type __n) | 2483 | basic_string<_CharT, _Traits, _Allocator>::assign(const _Tp & __t, size_type __pos, size_type __n) |
| 2387 | { | 2484 | { |
| 2388 | __self_view __sv = __t; | 2485 | __self_view __sv = __t; |
| ... | @@ -2393,14 +2490,23 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const _Tp & __t, size_type __p | ... | @@ -2393,14 +2490,23 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const _Tp & __t, size_type __p |
| 2393 | } | 2490 | } |
| 2394 | 2491 | ||
| 2395 | 2492 | ||
| 2493 | template <class _CharT, class _Traits, class _Allocator> | ||
| 2494 | basic_string<_CharT, _Traits, _Allocator>& | ||
| 2495 | basic_string<_CharT, _Traits, _Allocator>::__assign_external(const value_type* __s) { | ||
| 2496 | return __assign_external(__s, traits_type::length(__s)); | ||
| 2497 | } | ||
| 2498 | |||
| 2396 | template <class _CharT, class _Traits, class _Allocator> | 2499 | template <class _CharT, class _Traits, class _Allocator> |
| 2397 | basic_string<_CharT, _Traits, _Allocator>& | 2500 | basic_string<_CharT, _Traits, _Allocator>& |
| 2398 | basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s) | 2501 | basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s) |
| 2399 | { | 2502 | { |
| 2400 | _LIBCPP_ASSERT(__s != nullptr, "string::assign received nullptr"); | 2503 | _LIBCPP_ASSERT(__s != nullptr, "string::assign received nullptr"); |
| 2401 | return assign(__s, traits_type::length(__s)); | 2504 | return _LIBCPP_BUILTIN_CONSTANT_P(*__s) |
| 2505 | ? (traits_type::length(__s) < __min_cap | ||
| 2506 | ? __assign_short(__s, traits_type::length(__s)) | ||
| 2507 | : __assign_external(__s, traits_type::length(__s))) | ||
| 2508 | : __assign_external(__s); | ||
| 2402 | } | 2509 | } |
| 2403 | |||
| 2404 | // append | 2510 | // append |
| 2405 | 2511 | ||
| 2406 | template <class _CharT, class _Traits, class _Allocator> | 2512 | template <class _CharT, class _Traits, class _Allocator> |
| ... | @@ -2565,11 +2671,11 @@ basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str, siz | ... | @@ -2565,11 +2671,11 @@ basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str, siz |
| 2565 | 2671 | ||
| 2566 | template <class _CharT, class _Traits, class _Allocator> | 2672 | template <class _CharT, class _Traits, class _Allocator> |
| 2567 | template <class _Tp> | 2673 | template <class _Tp> |
| 2568 | typename enable_if | 2674 | _EnableIf |
| 2569 | < | 2675 | < |
| 2570 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 2676 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value, |
| 2571 | basic_string<_CharT, _Traits, _Allocator>& | 2677 | basic_string<_CharT, _Traits, _Allocator>& |
| 2572 | >::type | 2678 | > |
| 2573 | basic_string<_CharT, _Traits, _Allocator>::append(const _Tp & __t, size_type __pos, size_type __n) | 2679 | basic_string<_CharT, _Traits, _Allocator>::append(const _Tp & __t, size_type __pos, size_type __n) |
| 2574 | { | 2680 | { |
| 2575 | __self_view __sv = __t; | 2681 | __self_view __sv = __t; |
| ... | @@ -2654,12 +2760,12 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n | ... | @@ -2654,12 +2760,12 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n |
| 2654 | 2760 | ||
| 2655 | template <class _CharT, class _Traits, class _Allocator> | 2761 | template <class _CharT, class _Traits, class _Allocator> |
| 2656 | template<class _InputIterator> | 2762 | template<class _InputIterator> |
| 2657 | typename enable_if | 2763 | _EnableIf |
| 2658 | < | 2764 | < |
| 2659 | __is_exactly_cpp17_input_iterator<_InputIterator>::value | 2765 | __is_exactly_cpp17_input_iterator<_InputIterator>::value |
| 2660 | || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, | 2766 | || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, |
| 2661 | typename basic_string<_CharT, _Traits, _Allocator>::iterator | 2767 | typename basic_string<_CharT, _Traits, _Allocator>::iterator |
| 2662 | >::type | 2768 | > |
| 2663 | basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIterator __first, _InputIterator __last) | 2769 | basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIterator __first, _InputIterator __last) |
| 2664 | { | 2770 | { |
| 2665 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 2771 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| ... | @@ -2673,12 +2779,12 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIt | ... | @@ -2673,12 +2779,12 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIt |
| 2673 | 2779 | ||
| 2674 | template <class _CharT, class _Traits, class _Allocator> | 2780 | template <class _CharT, class _Traits, class _Allocator> |
| 2675 | template<class _ForwardIterator> | 2781 | template<class _ForwardIterator> |
| 2676 | typename enable_if | 2782 | _EnableIf |
| 2677 | < | 2783 | < |
| 2678 | __is_cpp17_forward_iterator<_ForwardIterator>::value | 2784 | __is_cpp17_forward_iterator<_ForwardIterator>::value |
| 2679 | && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, | 2785 | && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, |
| 2680 | typename basic_string<_CharT, _Traits, _Allocator>::iterator | 2786 | typename basic_string<_CharT, _Traits, _Allocator>::iterator |
| 2681 | >::type | 2787 | > |
| 2682 | basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last) | 2788 | basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last) |
| 2683 | { | 2789 | { |
| 2684 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 2790 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| ... | @@ -2743,11 +2849,11 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_ | ... | @@ -2743,11 +2849,11 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_ |
| 2743 | 2849 | ||
| 2744 | template <class _CharT, class _Traits, class _Allocator> | 2850 | template <class _CharT, class _Traits, class _Allocator> |
| 2745 | template <class _Tp> | 2851 | template <class _Tp> |
| 2746 | typename enable_if | 2852 | _EnableIf |
| 2747 | < | 2853 | < |
| 2748 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 2854 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value, |
| 2749 | basic_string<_CharT, _Traits, _Allocator>& | 2855 | basic_string<_CharT, _Traits, _Allocator>& |
| 2750 | >::type | 2856 | > |
| 2751 | basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const _Tp& __t, | 2857 | basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const _Tp& __t, |
| 2752 | size_type __pos2, size_type __n) | 2858 | size_type __pos2, size_type __n) |
| 2753 | { | 2859 | { |
| ... | @@ -2852,8 +2958,8 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __ | ... | @@ -2852,8 +2958,8 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __ |
| 2852 | } | 2958 | } |
| 2853 | traits_type::move(__p + __pos, __s, __n2); | 2959 | traits_type::move(__p + __pos, __s, __n2); |
| 2854 | __finish: | 2960 | __finish: |
| 2855 | // __sz += __n2 - __n1; in this and the below function below can cause unsigned integer overflow, | 2961 | // __sz += __n2 - __n1; in this and the below function below can cause unsigned |
| 2856 | // but this is a safe operation, so we disable the check. | 2962 | // integer overflow, but this is a safe operation, so we disable the check. |
| 2857 | __sz += __n2 - __n1; | 2963 | __sz += __n2 - __n1; |
| 2858 | __set_size(__sz); | 2964 | __set_size(__sz); |
| 2859 | __invalidate_iterators_past(__sz); | 2965 | __invalidate_iterators_past(__sz); |
| ... | @@ -2900,11 +3006,11 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __ | ... | @@ -2900,11 +3006,11 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __ |
| 2900 | 3006 | ||
| 2901 | template <class _CharT, class _Traits, class _Allocator> | 3007 | template <class _CharT, class _Traits, class _Allocator> |
| 2902 | template<class _InputIterator> | 3008 | template<class _InputIterator> |
| 2903 | typename enable_if | 3009 | _EnableIf |
| 2904 | < | 3010 | < |
| 2905 | __is_cpp17_input_iterator<_InputIterator>::value, | 3011 | __is_cpp17_input_iterator<_InputIterator>::value, |
| 2906 | basic_string<_CharT, _Traits, _Allocator>& | 3012 | basic_string<_CharT, _Traits, _Allocator>& |
| 2907 | >::type | 3013 | > |
| 2908 | basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, | 3014 | basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, |
| 2909 | _InputIterator __j1, _InputIterator __j2) | 3015 | _InputIterator __j1, _InputIterator __j2) |
| 2910 | { | 3016 | { |
| ... | @@ -2933,11 +3039,11 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type _ | ... | @@ -2933,11 +3039,11 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type _ |
| 2933 | 3039 | ||
| 2934 | template <class _CharT, class _Traits, class _Allocator> | 3040 | template <class _CharT, class _Traits, class _Allocator> |
| 2935 | template <class _Tp> | 3041 | template <class _Tp> |
| 2936 | typename enable_if | 3042 | _EnableIf |
| 2937 | < | 3043 | < |
| 2938 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 3044 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value, |
| 2939 | basic_string<_CharT, _Traits, _Allocator>& | 3045 | basic_string<_CharT, _Traits, _Allocator>& |
| 2940 | >::type | 3046 | > |
| 2941 | basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const _Tp& __t, | 3047 | basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const _Tp& __t, |
| 2942 | size_type __pos2, size_type __n2) | 3048 | size_type __pos2, size_type __n2) |
| 2943 | { | 3049 | { |
| ... | @@ -2991,15 +3097,16 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it | ... | @@ -2991,15 +3097,16 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it |
| 2991 | 3097 | ||
| 2992 | // erase | 3098 | // erase |
| 2993 | 3099 | ||
| 3100 | // 'externally instantiated' erase() implementation, called when __n != npos. | ||
| 3101 | // Does not check __pos against size() | ||
| 2994 | template <class _CharT, class _Traits, class _Allocator> | 3102 | template <class _CharT, class _Traits, class _Allocator> |
| 2995 | basic_string<_CharT, _Traits, _Allocator>& | 3103 | void |
| 2996 | basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos, size_type __n) | 3104 | basic_string<_CharT, _Traits, _Allocator>::__erase_external_with_move( |
| 3105 | size_type __pos, size_type __n) | ||
| 2997 | { | 3106 | { |
| 2998 | size_type __sz = size(); | ||
| 2999 | if (__pos > __sz) | ||
| 3000 | this->__throw_out_of_range(); | ||
| 3001 | if (__n) | 3107 | if (__n) |
| 3002 | { | 3108 | { |
| 3109 | size_type __sz = size(); | ||
| 3003 | value_type* __p = _VSTD::__to_address(__get_pointer()); | 3110 | value_type* __p = _VSTD::__to_address(__get_pointer()); |
| 3004 | __n = _VSTD::min(__n, __sz - __pos); | 3111 | __n = _VSTD::min(__n, __sz - __pos); |
| 3005 | size_type __n_move = __sz - __pos - __n; | 3112 | size_type __n_move = __sz - __pos - __n; |
| ... | @@ -3010,7 +3117,19 @@ basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos, size_type __n) | ... | @@ -3010,7 +3117,19 @@ basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos, size_type __n) |
| 3010 | __invalidate_iterators_past(__sz); | 3117 | __invalidate_iterators_past(__sz); |
| 3011 | traits_type::assign(__p[__sz], value_type()); | 3118 | traits_type::assign(__p[__sz], value_type()); |
| 3012 | } | 3119 | } |
| 3013 | return *this; | 3120 | } |
| 3121 | |||
| 3122 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3123 | basic_string<_CharT, _Traits, _Allocator>& | ||
| 3124 | basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos, | ||
| 3125 | size_type __n) { | ||
| 3126 | if (__pos > size()) this->__throw_out_of_range(); | ||
| 3127 | if (__n == npos) { | ||
| 3128 | __erase_to_end(__pos); | ||
| 3129 | } else { | ||
| 3130 | __erase_external_with_move(__pos, __n); | ||
| 3131 | } | ||
| 3132 | return *this; | ||
| 3014 | } | 3133 | } |
| 3015 | 3134 | ||
| 3016 | template <class _CharT, class _Traits, class _Allocator> | 3135 | template <class _CharT, class _Traits, class _Allocator> |
| ... | @@ -3356,11 +3475,11 @@ basic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str, | ... | @@ -3356,11 +3475,11 @@ basic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str, |
| 3356 | 3475 | ||
| 3357 | template<class _CharT, class _Traits, class _Allocator> | 3476 | template<class _CharT, class _Traits, class _Allocator> |
| 3358 | template <class _Tp> | 3477 | template <class _Tp> |
| 3359 | typename enable_if | 3478 | _EnableIf |
| 3360 | < | 3479 | < |
| 3361 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 3480 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 3362 | typename basic_string<_CharT, _Traits, _Allocator>::size_type | 3481 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 3363 | >::type | 3482 | > |
| 3364 | basic_string<_CharT, _Traits, _Allocator>::find(const _Tp &__t, | 3483 | basic_string<_CharT, _Traits, _Allocator>::find(const _Tp &__t, |
| 3365 | size_type __pos) const | 3484 | size_type __pos) const |
| 3366 | { | 3485 | { |
| ... | @@ -3414,11 +3533,11 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str, | ... | @@ -3414,11 +3533,11 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str, |
| 3414 | 3533 | ||
| 3415 | template<class _CharT, class _Traits, class _Allocator> | 3534 | template<class _CharT, class _Traits, class _Allocator> |
| 3416 | template <class _Tp> | 3535 | template <class _Tp> |
| 3417 | typename enable_if | 3536 | _EnableIf |
| 3418 | < | 3537 | < |
| 3419 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 3538 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 3420 | typename basic_string<_CharT, _Traits, _Allocator>::size_type | 3539 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 3421 | >::type | 3540 | > |
| 3422 | basic_string<_CharT, _Traits, _Allocator>::rfind(const _Tp& __t, | 3541 | basic_string<_CharT, _Traits, _Allocator>::rfind(const _Tp& __t, |
| 3423 | size_type __pos) const | 3542 | size_type __pos) const |
| 3424 | { | 3543 | { |
| ... | @@ -3472,11 +3591,11 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __s | ... | @@ -3472,11 +3591,11 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __s |
| 3472 | 3591 | ||
| 3473 | template<class _CharT, class _Traits, class _Allocator> | 3592 | template<class _CharT, class _Traits, class _Allocator> |
| 3474 | template <class _Tp> | 3593 | template <class _Tp> |
| 3475 | typename enable_if | 3594 | _EnableIf |
| 3476 | < | 3595 | < |
| 3477 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 3596 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 3478 | typename basic_string<_CharT, _Traits, _Allocator>::size_type | 3597 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 3479 | >::type | 3598 | > |
| 3480 | basic_string<_CharT, _Traits, _Allocator>::find_first_of(const _Tp& __t, | 3599 | basic_string<_CharT, _Traits, _Allocator>::find_first_of(const _Tp& __t, |
| 3481 | size_type __pos) const | 3600 | size_type __pos) const |
| 3482 | { | 3601 | { |
| ... | @@ -3530,11 +3649,11 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __st | ... | @@ -3530,11 +3649,11 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __st |
| 3530 | 3649 | ||
| 3531 | template<class _CharT, class _Traits, class _Allocator> | 3650 | template<class _CharT, class _Traits, class _Allocator> |
| 3532 | template <class _Tp> | 3651 | template <class _Tp> |
| 3533 | typename enable_if | 3652 | _EnableIf |
| 3534 | < | 3653 | < |
| 3535 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 3654 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 3536 | typename basic_string<_CharT, _Traits, _Allocator>::size_type | 3655 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 3537 | >::type | 3656 | > |
| 3538 | basic_string<_CharT, _Traits, _Allocator>::find_last_of(const _Tp& __t, | 3657 | basic_string<_CharT, _Traits, _Allocator>::find_last_of(const _Tp& __t, |
| 3539 | size_type __pos) const | 3658 | size_type __pos) const |
| 3540 | { | 3659 | { |
| ... | @@ -3588,11 +3707,11 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const basic_string& | ... | @@ -3588,11 +3707,11 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const basic_string& |
| 3588 | 3707 | ||
| 3589 | template<class _CharT, class _Traits, class _Allocator> | 3708 | template<class _CharT, class _Traits, class _Allocator> |
| 3590 | template <class _Tp> | 3709 | template <class _Tp> |
| 3591 | typename enable_if | 3710 | _EnableIf |
| 3592 | < | 3711 | < |
| 3593 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 3712 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 3594 | typename basic_string<_CharT, _Traits, _Allocator>::size_type | 3713 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 3595 | >::type | 3714 | > |
| 3596 | basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const _Tp& __t, | 3715 | basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const _Tp& __t, |
| 3597 | size_type __pos) const | 3716 | size_type __pos) const |
| 3598 | { | 3717 | { |
| ... | @@ -3647,11 +3766,11 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const basic_string& | ... | @@ -3647,11 +3766,11 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const basic_string& |
| 3647 | 3766 | ||
| 3648 | template<class _CharT, class _Traits, class _Allocator> | 3767 | template<class _CharT, class _Traits, class _Allocator> |
| 3649 | template <class _Tp> | 3768 | template <class _Tp> |
| 3650 | typename enable_if | 3769 | _EnableIf |
| 3651 | < | 3770 | < |
| 3652 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 3771 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 3653 | typename basic_string<_CharT, _Traits, _Allocator>::size_type | 3772 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 3654 | >::type | 3773 | > |
| 3655 | basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const _Tp& __t, | 3774 | basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const _Tp& __t, |
| 3656 | size_type __pos) const | 3775 | size_type __pos) const |
| 3657 | { | 3776 | { |
| ... | @@ -3685,11 +3804,11 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c, | ... | @@ -3685,11 +3804,11 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c, |
| 3685 | 3804 | ||
| 3686 | template <class _CharT, class _Traits, class _Allocator> | 3805 | template <class _CharT, class _Traits, class _Allocator> |
| 3687 | template <class _Tp> | 3806 | template <class _Tp> |
| 3688 | typename enable_if | 3807 | _EnableIf |
| 3689 | < | 3808 | < |
| 3690 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 3809 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 3691 | int | 3810 | int |
| 3692 | >::type | 3811 | > |
| 3693 | basic_string<_CharT, _Traits, _Allocator>::compare(const _Tp& __t) const | 3812 | basic_string<_CharT, _Traits, _Allocator>::compare(const _Tp& __t) const |
| 3694 | { | 3813 | { |
| 3695 | __self_view __sv = __t; | 3814 | __self_view __sv = __t; |
| ... | @@ -3739,11 +3858,11 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, | ... | @@ -3739,11 +3858,11 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, |
| 3739 | 3858 | ||
| 3740 | template <class _CharT, class _Traits, class _Allocator> | 3859 | template <class _CharT, class _Traits, class _Allocator> |
| 3741 | template <class _Tp> | 3860 | template <class _Tp> |
| 3742 | typename enable_if | 3861 | _EnableIf |
| 3743 | < | 3862 | < |
| 3744 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 3863 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 3745 | int | 3864 | int |
| 3746 | >::type | 3865 | > |
| 3747 | basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, | 3866 | basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, |
| 3748 | size_type __n1, | 3867 | size_type __n1, |
| 3749 | const _Tp& __t) const | 3868 | const _Tp& __t) const |
| ... | @@ -3764,11 +3883,12 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, | ... | @@ -3764,11 +3883,12 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, |
| 3764 | 3883 | ||
| 3765 | template <class _CharT, class _Traits, class _Allocator> | 3884 | template <class _CharT, class _Traits, class _Allocator> |
| 3766 | template <class _Tp> | 3885 | template <class _Tp> |
| 3767 | typename enable_if | 3886 | _EnableIf |
| 3768 | < | 3887 | < |
| 3769 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 3888 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value |
| 3889 | && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value, | ||
| 3770 | int | 3890 | int |
| 3771 | >::type | 3891 | > |
| 3772 | basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, | 3892 | basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, |
| 3773 | size_type __n1, | 3893 | size_type __n1, |
| 3774 | const _Tp& __t, | 3894 | const _Tp& __t, |
| ... | @@ -4230,8 +4350,9 @@ _LIBCPP_FUNC_VIS wstring to_wstring(double __val); | ... | @@ -4230,8 +4350,9 @@ _LIBCPP_FUNC_VIS wstring to_wstring(double __val); |
| 4230 | _LIBCPP_FUNC_VIS wstring to_wstring(long double __val); | 4350 | _LIBCPP_FUNC_VIS wstring to_wstring(long double __val); |
| 4231 | 4351 | ||
| 4232 | template<class _CharT, class _Traits, class _Allocator> | 4352 | template<class _CharT, class _Traits, class _Allocator> |
| 4233 | const typename basic_string<_CharT, _Traits, _Allocator>::size_type | 4353 | _LIBCPP_FUNC_VIS |
| 4234 | basic_string<_CharT, _Traits, _Allocator>::npos; | 4354 | const typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 4355 | basic_string<_CharT, _Traits, _Allocator>::npos; | ||
| 4235 | 4356 | ||
| 4236 | template <class _CharT, class _Allocator> | 4357 | template <class _CharT, class _Allocator> |
| 4237 | struct _LIBCPP_TEMPLATE_VIS | 4358 | struct _LIBCPP_TEMPLATE_VIS |
| ... | @@ -4283,15 +4404,25 @@ getline(basic_istream<_CharT, _Traits>&& __is, | ... | @@ -4283,15 +4404,25 @@ getline(basic_istream<_CharT, _Traits>&& __is, |
| 4283 | #endif // _LIBCPP_CXX03_LANG | 4404 | #endif // _LIBCPP_CXX03_LANG |
| 4284 | 4405 | ||
| 4285 | #if _LIBCPP_STD_VER > 17 | 4406 | #if _LIBCPP_STD_VER > 17 |
| 4286 | template<class _CharT, class _Traits, class _Allocator, class _Up> | 4407 | template <class _CharT, class _Traits, class _Allocator, class _Up> |
| 4287 | inline _LIBCPP_INLINE_VISIBILITY | 4408 | inline _LIBCPP_INLINE_VISIBILITY |
| 4288 | void erase(basic_string<_CharT, _Traits, _Allocator>& __str, const _Up& __v) | 4409 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 4289 | { __str.erase(_VSTD::remove(__str.begin(), __str.end(), __v), __str.end()); } | 4410 | erase(basic_string<_CharT, _Traits, _Allocator>& __str, const _Up& __v) { |
| 4411 | auto __old_size = __str.size(); | ||
| 4412 | __str.erase(_VSTD::remove(__str.begin(), __str.end(), __v), __str.end()); | ||
| 4413 | return __old_size - __str.size(); | ||
| 4414 | } | ||
| 4290 | 4415 | ||
| 4291 | template<class _CharT, class _Traits, class _Allocator, class _Predicate> | 4416 | template <class _CharT, class _Traits, class _Allocator, class _Predicate> |
| 4292 | inline _LIBCPP_INLINE_VISIBILITY | 4417 | inline _LIBCPP_INLINE_VISIBILITY |
| 4293 | void erase_if(basic_string<_CharT, _Traits, _Allocator>& __str, _Predicate __pred) | 4418 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 4294 | { __str.erase(_VSTD::remove_if(__str.begin(), __str.end(), __pred), __str.end()); } | 4419 | erase_if(basic_string<_CharT, _Traits, _Allocator>& __str, |
| 4420 | _Predicate __pred) { | ||
| 4421 | auto __old_size = __str.size(); | ||
| 4422 | __str.erase(_VSTD::remove_if(__str.begin(), __str.end(), __pred), | ||
| 4423 | __str.end()); | ||
| 4424 | return __old_size - __str.size(); | ||
| 4425 | } | ||
| 4295 | #endif | 4426 | #endif |
| 4296 | 4427 | ||
| 4297 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 4428 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| ... | @@ -4330,9 +4461,6 @@ basic_string<_CharT, _Traits, _Allocator>::__subscriptable(const const_iterator* | ... | @@ -4330,9 +4461,6 @@ basic_string<_CharT, _Traits, _Allocator>::__subscriptable(const const_iterator* |
| 4330 | 4461 | ||
| 4331 | #endif // _LIBCPP_DEBUG_LEVEL >= 2 | 4462 | #endif // _LIBCPP_DEBUG_LEVEL >= 2 |
| 4332 | 4463 | ||
| 4333 | _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_string<char>) | ||
| 4334 | _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_string<wchar_t>) | ||
| 4335 | |||
| 4336 | #if _LIBCPP_STD_VER > 11 | 4464 | #if _LIBCPP_STD_VER > 11 |
| 4337 | // Literal suffixes for basic_string [basic.string.literals] | 4465 | // Literal suffixes for basic_string [basic.string.literals] |
| 4338 | inline namespace literals | 4466 | inline namespace literals |
lib/libcxx/include/system_error+1| ... | @@ -469,6 +469,7 @@ public: | ... | @@ -469,6 +469,7 @@ public: |
| 469 | system_error(int __ev, const error_category& __ecat, const string& __what_arg); | 469 | system_error(int __ev, const error_category& __ecat, const string& __what_arg); |
| 470 | system_error(int __ev, const error_category& __ecat, const char* __what_arg); | 470 | system_error(int __ev, const error_category& __ecat, const char* __what_arg); |
| 471 | system_error(int __ev, const error_category& __ecat); | 471 | system_error(int __ev, const error_category& __ecat); |
| 472 | system_error(const system_error&) _NOEXCEPT = default; | ||
| 472 | ~system_error() _NOEXCEPT; | 473 | ~system_error() _NOEXCEPT; |
| 473 | 474 | ||
| 474 | _LIBCPP_INLINE_VISIBILITY | 475 | _LIBCPP_INLINE_VISIBILITY |
lib/libcxx/include/thread+13-17| ... | @@ -241,12 +241,19 @@ public: | ... | @@ -241,12 +241,19 @@ public: |
| 241 | #endif | 241 | #endif |
| 242 | ~thread(); | 242 | ~thread(); |
| 243 | 243 | ||
| 244 | #ifndef _LIBCPP_CXX03_LANG | ||
| 245 | _LIBCPP_INLINE_VISIBILITY | 244 | _LIBCPP_INLINE_VISIBILITY |
| 246 | thread(thread&& __t) _NOEXCEPT : __t_(__t.__t_) {__t.__t_ = _LIBCPP_NULL_THREAD;} | 245 | thread(thread&& __t) _NOEXCEPT : __t_(__t.__t_) { |
| 246 | __t.__t_ = _LIBCPP_NULL_THREAD; | ||
| 247 | } | ||
| 248 | |||
| 247 | _LIBCPP_INLINE_VISIBILITY | 249 | _LIBCPP_INLINE_VISIBILITY |
| 248 | thread& operator=(thread&& __t) _NOEXCEPT; | 250 | thread& operator=(thread&& __t) _NOEXCEPT { |
| 249 | #endif // _LIBCPP_CXX03_LANG | 251 | if (!__libcpp_thread_isnull(&__t_)) |
| 252 | terminate(); | ||
| 253 | __t_ = __t.__t_; | ||
| 254 | __t.__t_ = _LIBCPP_NULL_THREAD; | ||
| 255 | return *this; | ||
| 256 | } | ||
| 250 | 257 | ||
| 251 | _LIBCPP_INLINE_VISIBILITY | 258 | _LIBCPP_INLINE_VISIBILITY |
| 252 | void swap(thread& __t) _NOEXCEPT {_VSTD::swap(__t_, __t.__t_);} | 259 | void swap(thread& __t) _NOEXCEPT {_VSTD::swap(__t_, __t.__t_);} |
| ... | @@ -304,17 +311,6 @@ thread::thread(_Fp&& __f, _Args&&... __args) | ... | @@ -304,17 +311,6 @@ thread::thread(_Fp&& __f, _Args&&... __args) |
| 304 | __throw_system_error(__ec, "thread constructor failed"); | 311 | __throw_system_error(__ec, "thread constructor failed"); |
| 305 | } | 312 | } |
| 306 | 313 | ||
| 307 | inline | ||
| 308 | thread& | ||
| 309 | thread::operator=(thread&& __t) _NOEXCEPT | ||
| 310 | { | ||
| 311 | if (!__libcpp_thread_isnull(&__t_)) | ||
| 312 | terminate(); | ||
| 313 | __t_ = __t.__t_; | ||
| 314 | __t.__t_ = _LIBCPP_NULL_THREAD; | ||
| 315 | return *this; | ||
| 316 | } | ||
| 317 | |||
| 318 | #else // _LIBCPP_CXX03_LANG | 314 | #else // _LIBCPP_CXX03_LANG |
| 319 | 315 | ||
| 320 | template <class _Fp> | 316 | template <class _Fp> |
| ... | @@ -369,9 +365,9 @@ sleep_for(const chrono::duration<_Rep, _Period>& __d) | ... | @@ -369,9 +365,9 @@ sleep_for(const chrono::duration<_Rep, _Period>& __d) |
| 369 | { | 365 | { |
| 370 | #if defined(_LIBCPP_COMPILER_GCC) && (__powerpc__ || __POWERPC__) | 366 | #if defined(_LIBCPP_COMPILER_GCC) && (__powerpc__ || __POWERPC__) |
| 371 | // GCC's long double const folding is incomplete for IBM128 long doubles. | 367 | // GCC's long double const folding is incomplete for IBM128 long doubles. |
| 372 | _LIBCPP_CONSTEXPR duration<long double> _Max = nanoseconds::max(); | ||
| 373 | #else | ||
| 374 | _LIBCPP_CONSTEXPR duration<long double> _Max = duration<long double>(ULLONG_MAX/1000000000ULL) ; | 368 | _LIBCPP_CONSTEXPR duration<long double> _Max = duration<long double>(ULLONG_MAX/1000000000ULL) ; |
| 369 | #else | ||
| 370 | _LIBCPP_CONSTEXPR duration<long double> _Max = nanoseconds::max(); | ||
| 375 | #endif | 371 | #endif |
| 376 | nanoseconds __ns; | 372 | nanoseconds __ns; |
| 377 | if (__d < _Max) | 373 | if (__d < _Max) |
lib/libcxx/include/type_traits+391-56| ... | @@ -544,6 +544,18 @@ template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp | ... | @@ -544,6 +544,18 @@ template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp |
| 544 | 544 | ||
| 545 | // is_same | 545 | // is_same |
| 546 | 546 | ||
| 547 | #if __has_keyword(__is_same) | ||
| 548 | |||
| 549 | template <class _Tp, class _Up> | ||
| 550 | struct _LIBCPP_TEMPLATE_VIS is_same : _BoolConstant<__is_same(_Tp, _Up)> { }; | ||
| 551 | |||
| 552 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | ||
| 553 | template <class _Tp, class _Up> | ||
| 554 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_same_v = __is_same(_Tp, _Up); | ||
| 555 | #endif | ||
| 556 | |||
| 557 | #else | ||
| 558 | |||
| 547 | template <class _Tp, class _Up> struct _LIBCPP_TEMPLATE_VIS is_same : public false_type {}; | 559 | template <class _Tp, class _Up> struct _LIBCPP_TEMPLATE_VIS is_same : public false_type {}; |
| 548 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_same<_Tp, _Tp> : public true_type {}; | 560 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_same<_Tp, _Tp> : public true_type {}; |
| 549 | 561 | ||
| ... | @@ -553,6 +565,8 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_same_v | ... | @@ -553,6 +565,8 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_same_v |
| 553 | = is_same<_Tp, _Up>::value; | 565 | = is_same<_Tp, _Up>::value; |
| 554 | #endif | 566 | #endif |
| 555 | 567 | ||
| 568 | #endif // __is_same | ||
| 569 | |||
| 556 | template <class _Tp, class _Up> | 570 | template <class _Tp, class _Up> |
| 557 | using _IsSame = _BoolConstant< | 571 | using _IsSame = _BoolConstant< |
| 558 | #ifdef __clang__ | 572 | #ifdef __clang__ |
| ... | @@ -656,6 +670,18 @@ struct __two {char __lx[2];}; | ... | @@ -656,6 +670,18 @@ struct __two {char __lx[2];}; |
| 656 | 670 | ||
| 657 | // is_const | 671 | // is_const |
| 658 | 672 | ||
| 673 | #if __has_keyword(__is_const) | ||
| 674 | |||
| 675 | template <class _Tp> | ||
| 676 | struct _LIBCPP_TEMPLATE_VIS is_const : _BoolConstant<__is_const(_Tp)> { }; | ||
| 677 | |||
| 678 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | ||
| 679 | template <class _Tp> | ||
| 680 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_const_v = __is_const(_Tp); | ||
| 681 | #endif | ||
| 682 | |||
| 683 | #else | ||
| 684 | |||
| 659 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const : public false_type {}; | 685 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const : public false_type {}; |
| 660 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const<_Tp const> : public true_type {}; | 686 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const<_Tp const> : public true_type {}; |
| 661 | 687 | ||
| ... | @@ -665,8 +691,22 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_const_v | ... | @@ -665,8 +691,22 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_const_v |
| 665 | = is_const<_Tp>::value; | 691 | = is_const<_Tp>::value; |
| 666 | #endif | 692 | #endif |
| 667 | 693 | ||
| 694 | #endif // __has_keyword(__is_const) | ||
| 695 | |||
| 668 | // is_volatile | 696 | // is_volatile |
| 669 | 697 | ||
| 698 | #if __has_keyword(__is_volatile) | ||
| 699 | |||
| 700 | template <class _Tp> | ||
| 701 | struct _LIBCPP_TEMPLATE_VIS is_volatile : _BoolConstant<__is_volatile(_Tp)> { }; | ||
| 702 | |||
| 703 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | ||
| 704 | template <class _Tp> | ||
| 705 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_volatile_v = __is_volatile(_Tp); | ||
| 706 | #endif | ||
| 707 | |||
| 708 | #else | ||
| 709 | |||
| 670 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile : public false_type {}; | 710 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile : public false_type {}; |
| 671 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile<_Tp volatile> : public true_type {}; | 711 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile<_Tp volatile> : public true_type {}; |
| 672 | 712 | ||
| ... | @@ -676,37 +716,87 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_volatile_v | ... | @@ -676,37 +716,87 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_volatile_v |
| 676 | = is_volatile<_Tp>::value; | 716 | = is_volatile<_Tp>::value; |
| 677 | #endif | 717 | #endif |
| 678 | 718 | ||
| 719 | #endif // __has_keyword(__is_volatile) | ||
| 720 | |||
| 679 | // remove_const | 721 | // remove_const |
| 680 | 722 | ||
| 723 | #if __has_keyword(__remove_const) | ||
| 724 | |||
| 725 | template <class _Tp> | ||
| 726 | struct _LIBCPP_TEMPLATE_VIS remove_const {typedef __remove_const(_Tp) type;}; | ||
| 727 | |||
| 728 | #if _LIBCPP_STD_VER > 11 | ||
| 729 | template <class _Tp> using remove_const_t = __remove_const(_Tp); | ||
| 730 | #endif | ||
| 731 | |||
| 732 | #else | ||
| 733 | |||
| 681 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const {typedef _Tp type;}; | 734 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const {typedef _Tp type;}; |
| 682 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const<const _Tp> {typedef _Tp type;}; | 735 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const<const _Tp> {typedef _Tp type;}; |
| 683 | #if _LIBCPP_STD_VER > 11 | 736 | #if _LIBCPP_STD_VER > 11 |
| 684 | template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type; | 737 | template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type; |
| 685 | #endif | 738 | #endif |
| 686 | 739 | ||
| 740 | #endif // __has_keyword(__remove_const) | ||
| 741 | |||
| 687 | // remove_volatile | 742 | // remove_volatile |
| 688 | 743 | ||
| 744 | #if __has_keyword(__remove_volatile) | ||
| 745 | |||
| 746 | template <class _Tp> | ||
| 747 | struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef __remove_volatile(_Tp) type;}; | ||
| 748 | |||
| 749 | #if _LIBCPP_STD_VER > 11 | ||
| 750 | template <class _Tp> using remove_volatile_t = __remove_volatile(_Tp); | ||
| 751 | #endif | ||
| 752 | |||
| 753 | #else | ||
| 754 | |||
| 689 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef _Tp type;}; | 755 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef _Tp type;}; |
| 690 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile<volatile _Tp> {typedef _Tp type;}; | 756 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile<volatile _Tp> {typedef _Tp type;}; |
| 691 | #if _LIBCPP_STD_VER > 11 | 757 | #if _LIBCPP_STD_VER > 11 |
| 692 | template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type; | 758 | template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type; |
| 693 | #endif | 759 | #endif |
| 694 | 760 | ||
| 761 | #endif // __has_keyword(__remove_volatile) | ||
| 762 | |||
| 695 | // remove_cv | 763 | // remove_cv |
| 696 | 764 | ||
| 765 | #if __has_keyword(__remove_cv) | ||
| 766 | |||
| 767 | template <class _Tp> | ||
| 768 | struct _LIBCPP_TEMPLATE_VIS remove_cv {typedef __remove_cv(_Tp) type;}; | ||
| 769 | |||
| 770 | #if _LIBCPP_STD_VER > 11 | ||
| 771 | template <class _Tp> using remove_cv_t = __remove_cv(_Tp); | ||
| 772 | #endif | ||
| 773 | |||
| 774 | #else | ||
| 775 | |||
| 697 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv | 776 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv |
| 698 | {typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;}; | 777 | {typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;}; |
| 699 | #if _LIBCPP_STD_VER > 11 | 778 | #if _LIBCPP_STD_VER > 11 |
| 700 | template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type; | 779 | template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type; |
| 701 | #endif | 780 | #endif |
| 702 | 781 | ||
| 782 | #endif // __has_keyword(__remove_cv) | ||
| 783 | |||
| 703 | // is_void | 784 | // is_void |
| 704 | 785 | ||
| 705 | template <class _Tp> struct __libcpp_is_void : public false_type {}; | 786 | #if __has_keyword(__is_void) |
| 706 | template <> struct __libcpp_is_void<void> : public true_type {}; | 787 | |
| 788 | template <class _Tp> | ||
| 789 | struct _LIBCPP_TEMPLATE_VIS is_void : _BoolConstant<__is_void(_Tp)> { }; | ||
| 790 | |||
| 791 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | ||
| 792 | template <class _Tp> | ||
| 793 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_void_v = __is_void(_Tp); | ||
| 794 | #endif | ||
| 795 | |||
| 796 | #else | ||
| 707 | 797 | ||
| 708 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_void | 798 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_void |
| 709 | : public __libcpp_is_void<typename remove_cv<_Tp>::type> {}; | 799 | : public is_same<typename remove_cv<_Tp>::type, void> {}; |
| 710 | 800 | ||
| 711 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | 801 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
| 712 | template <class _Tp> | 802 | template <class _Tp> |
| ... | @@ -714,6 +804,8 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_void_v | ... | @@ -714,6 +804,8 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_void_v |
| 714 | = is_void<_Tp>::value; | 804 | = is_void<_Tp>::value; |
| 715 | #endif | 805 | #endif |
| 716 | 806 | ||
| 807 | #endif // __has_keyword(__is_void) | ||
| 808 | |||
| 717 | // __is_nullptr_t | 809 | // __is_nullptr_t |
| 718 | 810 | ||
| 719 | template <class _Tp> struct __is_nullptr_t_impl : public false_type {}; | 811 | template <class _Tp> struct __is_nullptr_t_impl : public false_type {}; |
| ... | @@ -735,34 +827,20 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_null_pointer_v | ... | @@ -735,34 +827,20 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_null_pointer_v |
| 735 | 827 | ||
| 736 | // is_integral | 828 | // is_integral |
| 737 | 829 | ||
| 738 | template <class _Tp> struct __libcpp_is_integral : public false_type {}; | 830 | #if __has_keyword(__is_integral) |
| 739 | template <> struct __libcpp_is_integral<bool> : public true_type {}; | 831 | |
| 740 | template <> struct __libcpp_is_integral<char> : public true_type {}; | 832 | template <class _Tp> |
| 741 | template <> struct __libcpp_is_integral<signed char> : public true_type {}; | 833 | struct _LIBCPP_TEMPLATE_VIS is_integral : _BoolConstant<__is_integral(_Tp)> { }; |
| 742 | template <> struct __libcpp_is_integral<unsigned char> : public true_type {}; | 834 | |
| 743 | template <> struct __libcpp_is_integral<wchar_t> : public true_type {}; | 835 | #if _LIBCPP_STD_VER > 14 |
| 744 | #ifndef _LIBCPP_NO_HAS_CHAR8_T | 836 | template <class _Tp> |
| 745 | template <> struct __libcpp_is_integral<char8_t> : public true_type {}; | 837 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_integral_v = __is_integral(_Tp); |
| 746 | #endif | ||
| 747 | #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS | ||
| 748 | template <> struct __libcpp_is_integral<char16_t> : public true_type {}; | ||
| 749 | template <> struct __libcpp_is_integral<char32_t> : public true_type {}; | ||
| 750 | #endif // _LIBCPP_HAS_NO_UNICODE_CHARS | ||
| 751 | template <> struct __libcpp_is_integral<short> : public true_type {}; | ||
| 752 | template <> struct __libcpp_is_integral<unsigned short> : public true_type {}; | ||
| 753 | template <> struct __libcpp_is_integral<int> : public true_type {}; | ||
| 754 | template <> struct __libcpp_is_integral<unsigned int> : public true_type {}; | ||
| 755 | template <> struct __libcpp_is_integral<long> : public true_type {}; | ||
| 756 | template <> struct __libcpp_is_integral<unsigned long> : public true_type {}; | ||
| 757 | template <> struct __libcpp_is_integral<long long> : public true_type {}; | ||
| 758 | template <> struct __libcpp_is_integral<unsigned long long> : public true_type {}; | ||
| 759 | #ifndef _LIBCPP_HAS_NO_INT128 | ||
| 760 | template <> struct __libcpp_is_integral<__int128_t> : public true_type {}; | ||
| 761 | template <> struct __libcpp_is_integral<__uint128_t> : public true_type {}; | ||
| 762 | #endif | 838 | #endif |
| 763 | 839 | ||
| 840 | #else | ||
| 841 | |||
| 764 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_integral | 842 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_integral |
| 765 | : public __libcpp_is_integral<typename remove_cv<_Tp>::type> {}; | 843 | : public _BoolConstant<__libcpp_is_integral<typename remove_cv<_Tp>::type>::value> {}; |
| 766 | 844 | ||
| 767 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | 845 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
| 768 | template <class _Tp> | 846 | template <class _Tp> |
| ... | @@ -770,6 +848,8 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_integral_v | ... | @@ -770,6 +848,8 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_integral_v |
| 770 | = is_integral<_Tp>::value; | 848 | = is_integral<_Tp>::value; |
| 771 | #endif | 849 | #endif |
| 772 | 850 | ||
| 851 | #endif // __has_keyword(__is_integral) | ||
| 852 | |||
| 773 | // is_floating_point | 853 | // is_floating_point |
| 774 | 854 | ||
| 775 | template <class _Tp> struct __libcpp_is_floating_point : public false_type {}; | 855 | template <class _Tp> struct __libcpp_is_floating_point : public false_type {}; |
| ... | @@ -788,6 +868,18 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_floating_point_v | ... | @@ -788,6 +868,18 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_floating_point_v |
| 788 | 868 | ||
| 789 | // is_array | 869 | // is_array |
| 790 | 870 | ||
| 871 | #if __has_keyword(__is_array) | ||
| 872 | |||
| 873 | template <class _Tp> | ||
| 874 | struct _LIBCPP_TEMPLATE_VIS is_array : _BoolConstant<__is_array(_Tp)> { }; | ||
| 875 | |||
| 876 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | ||
| 877 | template <class _Tp> | ||
| 878 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_array_v = __is_array(_Tp); | ||
| 879 | #endif | ||
| 880 | |||
| 881 | #else | ||
| 882 | |||
| 791 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array | 883 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array |
| 792 | : public false_type {}; | 884 | : public false_type {}; |
| 793 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[]> | 885 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[]> |
| ... | @@ -801,8 +893,23 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_array_v | ... | @@ -801,8 +893,23 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_array_v |
| 801 | = is_array<_Tp>::value; | 893 | = is_array<_Tp>::value; |
| 802 | #endif | 894 | #endif |
| 803 | 895 | ||
| 896 | #endif // __has_keyword(__is_array) | ||
| 897 | |||
| 804 | // is_pointer | 898 | // is_pointer |
| 805 | 899 | ||
| 900 | // In clang 10.0.0 and earlier __is_pointer didn't work with Objective-C types. | ||
| 901 | #if __has_keyword(__is_pointer) && _LIBCPP_CLANG_VER > 1000 | ||
| 902 | |||
| 903 | template<class _Tp> | ||
| 904 | struct _LIBCPP_TEMPLATE_VIS is_pointer : _BoolConstant<__is_pointer(_Tp)> { }; | ||
| 905 | |||
| 906 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | ||
| 907 | template <class _Tp> | ||
| 908 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pointer_v = __is_pointer(_Tp); | ||
| 909 | #endif | ||
| 910 | |||
| 911 | #else // __has_keyword(__is_pointer) | ||
| 912 | |||
| 806 | template <class _Tp> struct __libcpp_is_pointer : public false_type {}; | 913 | template <class _Tp> struct __libcpp_is_pointer : public false_type {}; |
| 807 | template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {}; | 914 | template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {}; |
| 808 | 915 | ||
| ... | @@ -823,8 +930,36 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pointer_v | ... | @@ -823,8 +930,36 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pointer_v |
| 823 | = is_pointer<_Tp>::value; | 930 | = is_pointer<_Tp>::value; |
| 824 | #endif | 931 | #endif |
| 825 | 932 | ||
| 933 | #endif // __has_keyword(__is_pointer) | ||
| 934 | |||
| 826 | // is_reference | 935 | // is_reference |
| 827 | 936 | ||
| 937 | #if __has_keyword(__is_lvalue_reference) && \ | ||
| 938 | __has_keyword(__is_rvalue_reference) && \ | ||
| 939 | __has_keyword(__is_reference) | ||
| 940 | |||
| 941 | template<class _Tp> | ||
| 942 | struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> { }; | ||
| 943 | |||
| 944 | template<class _Tp> | ||
| 945 | struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : _BoolConstant<__is_rvalue_reference(_Tp)> { }; | ||
| 946 | |||
| 947 | template<class _Tp> | ||
| 948 | struct _LIBCPP_TEMPLATE_VIS is_reference : _BoolConstant<__is_reference(_Tp)> { }; | ||
| 949 | |||
| 950 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | ||
| 951 | template <class _Tp> | ||
| 952 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_reference_v = __is_reference(_Tp); | ||
| 953 | |||
| 954 | template <class _Tp> | ||
| 955 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_lvalue_reference_v = __is_lvalue_reference(_Tp); | ||
| 956 | |||
| 957 | template <class _Tp> | ||
| 958 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_rvalue_reference_v = __is_rvalue_reference(_Tp); | ||
| 959 | #endif | ||
| 960 | |||
| 961 | #else // __has_keyword(__is_lvalue_reference) && etc... | ||
| 962 | |||
| 828 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {}; | 963 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {}; |
| 829 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {}; | 964 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {}; |
| 830 | 965 | ||
| ... | @@ -848,6 +983,9 @@ template <class _Tp> | ... | @@ -848,6 +983,9 @@ template <class _Tp> |
| 848 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_rvalue_reference_v | 983 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_rvalue_reference_v |
| 849 | = is_rvalue_reference<_Tp>::value; | 984 | = is_rvalue_reference<_Tp>::value; |
| 850 | #endif | 985 | #endif |
| 986 | |||
| 987 | #endif // __has_keyword(__is_lvalue_reference) && etc... | ||
| 988 | |||
| 851 | // is_union | 989 | // is_union |
| 852 | 990 | ||
| 853 | #if __has_feature(is_union) || defined(_LIBCPP_COMPILER_GCC) | 991 | #if __has_feature(is_union) || defined(_LIBCPP_COMPILER_GCC) |
| ... | @@ -928,6 +1066,19 @@ template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> { | ... | @@ -928,6 +1066,19 @@ template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> { |
| 928 | }; | 1066 | }; |
| 929 | }; | 1067 | }; |
| 930 | 1068 | ||
| 1069 | #if __has_keyword(__is_member_function_pointer) | ||
| 1070 | |||
| 1071 | template<class _Tp> | ||
| 1072 | struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer | ||
| 1073 | : _BoolConstant<__is_member_function_pointer(_Tp)> { }; | ||
| 1074 | |||
| 1075 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | ||
| 1076 | template <class _Tp> | ||
| 1077 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_function_pointer_v | ||
| 1078 | = __is_member_function_pointer(_Tp); | ||
| 1079 | #endif | ||
| 1080 | |||
| 1081 | #else // __has_keyword(__is_member_function_pointer) | ||
| 931 | 1082 | ||
| 932 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer | 1083 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer |
| 933 | : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_func > {}; | 1084 | : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_func > {}; |
| ... | @@ -938,8 +1089,22 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_function_pointer_v | ... | @@ -938,8 +1089,22 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_function_pointer_v |
| 938 | = is_member_function_pointer<_Tp>::value; | 1089 | = is_member_function_pointer<_Tp>::value; |
| 939 | #endif | 1090 | #endif |
| 940 | 1091 | ||
| 1092 | #endif // __has_keyword(__is_member_function_pointer) | ||
| 1093 | |||
| 941 | // is_member_pointer | 1094 | // is_member_pointer |
| 942 | 1095 | ||
| 1096 | #if __has_keyword(__is_member_pointer) | ||
| 1097 | |||
| 1098 | template<class _Tp> | ||
| 1099 | struct _LIBCPP_TEMPLATE_VIS is_member_pointer : _BoolConstant<__is_member_pointer(_Tp)> { }; | ||
| 1100 | |||
| 1101 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | ||
| 1102 | template <class _Tp> | ||
| 1103 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_pointer_v = __is_member_pointer(_Tp); | ||
| 1104 | #endif | ||
| 1105 | |||
| 1106 | #else // __has_keyword(__is_member_pointer) | ||
| 1107 | |||
| 943 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_pointer | 1108 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_pointer |
| 944 | : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_member > {}; | 1109 | : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_member > {}; |
| 945 | 1110 | ||
| ... | @@ -949,8 +1114,24 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_pointer_v | ... | @@ -949,8 +1114,24 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_pointer_v |
| 949 | = is_member_pointer<_Tp>::value; | 1114 | = is_member_pointer<_Tp>::value; |
| 950 | #endif | 1115 | #endif |
| 951 | 1116 | ||
| 1117 | #endif // __has_keyword(__is_member_pointer) | ||
| 1118 | |||
| 952 | // is_member_object_pointer | 1119 | // is_member_object_pointer |
| 953 | 1120 | ||
| 1121 | #if __has_keyword(__is_member_object_pointer) | ||
| 1122 | |||
| 1123 | template<class _Tp> | ||
| 1124 | struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer | ||
| 1125 | : _BoolConstant<__is_member_object_pointer(_Tp)> { }; | ||
| 1126 | |||
| 1127 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | ||
| 1128 | template <class _Tp> | ||
| 1129 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_object_pointer_v | ||
| 1130 | = __is_member_object_pointer(_Tp); | ||
| 1131 | #endif | ||
| 1132 | |||
| 1133 | #else // __has_keyword(__is_member_object_pointer) | ||
| 1134 | |||
| 954 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer | 1135 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer |
| 955 | : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_obj > {}; | 1136 | : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_obj > {}; |
| 956 | 1137 | ||
| ... | @@ -960,6 +1141,8 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_object_pointer_v | ... | @@ -960,6 +1141,8 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_object_pointer_v |
| 960 | = is_member_object_pointer<_Tp>::value; | 1141 | = is_member_object_pointer<_Tp>::value; |
| 961 | #endif | 1142 | #endif |
| 962 | 1143 | ||
| 1144 | #endif // __has_keyword(__is_member_object_pointer) | ||
| 1145 | |||
| 963 | // is_enum | 1146 | // is_enum |
| 964 | 1147 | ||
| 965 | #if __has_feature(is_enum) || defined(_LIBCPP_COMPILER_GCC) | 1148 | #if __has_feature(is_enum) || defined(_LIBCPP_COMPILER_GCC) |
| ... | @@ -967,6 +1150,11 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_object_pointer_v | ... | @@ -967,6 +1150,11 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_object_pointer_v |
| 967 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum | 1150 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum |
| 968 | : public integral_constant<bool, __is_enum(_Tp)> {}; | 1151 | : public integral_constant<bool, __is_enum(_Tp)> {}; |
| 969 | 1152 | ||
| 1153 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | ||
| 1154 | template <class _Tp> | ||
| 1155 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_enum_v = __is_enum(_Tp); | ||
| 1156 | #endif | ||
| 1157 | |||
| 970 | #else | 1158 | #else |
| 971 | 1159 | ||
| 972 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum | 1160 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum |
| ... | @@ -981,16 +1169,17 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum | ... | @@ -981,16 +1169,17 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum |
| 981 | !is_class<_Tp>::value && | 1169 | !is_class<_Tp>::value && |
| 982 | !is_function<_Tp>::value > {}; | 1170 | !is_function<_Tp>::value > {}; |
| 983 | 1171 | ||
| 984 | #endif | ||
| 985 | |||
| 986 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | 1172 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
| 987 | template <class _Tp> | 1173 | template <class _Tp> |
| 988 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_enum_v | 1174 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_enum_v |
| 989 | = is_enum<_Tp>::value; | 1175 | = is_enum<_Tp>::value; |
| 990 | #endif | 1176 | #endif |
| 991 | 1177 | ||
| 1178 | #endif // __has_feature(is_enum) || defined(_LIBCPP_COMPILER_GCC) | ||
| 1179 | |||
| 992 | // is_arithmetic | 1180 | // is_arithmetic |
| 993 | 1181 | ||
| 1182 | |||
| 994 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_arithmetic | 1183 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_arithmetic |
| 995 | : public integral_constant<bool, is_integral<_Tp>::value || | 1184 | : public integral_constant<bool, is_integral<_Tp>::value || |
| 996 | is_floating_point<_Tp>::value> {}; | 1185 | is_floating_point<_Tp>::value> {}; |
| ... | @@ -1003,6 +1192,20 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_arithmetic_v | ... | @@ -1003,6 +1192,20 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_arithmetic_v |
| 1003 | 1192 | ||
| 1004 | // is_fundamental | 1193 | // is_fundamental |
| 1005 | 1194 | ||
| 1195 | // In clang 9 and lower, this builtin did not work for nullptr_t. Additionally, in C++03 mode, | ||
| 1196 | // nullptr isn't defined by the compiler so, this builtin won't work. | ||
| 1197 | #if __has_keyword(__is_fundamental) && _LIBCPP_CLANG_VER > 900 && !defined(_LIBCPP_CXX03_LANG) | ||
| 1198 | |||
| 1199 | template<class _Tp> | ||
| 1200 | struct _LIBCPP_TEMPLATE_VIS is_fundamental : _BoolConstant<__is_fundamental(_Tp)> { }; | ||
| 1201 | |||
| 1202 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | ||
| 1203 | template <class _Tp> | ||
| 1204 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_fundamental_v = __is_fundamental(_Tp); | ||
| 1205 | #endif | ||
| 1206 | |||
| 1207 | #else // __has_keyword(__is_fundamental) | ||
| 1208 | |||
| 1006 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_fundamental | 1209 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_fundamental |
| 1007 | : public integral_constant<bool, is_void<_Tp>::value || | 1210 | : public integral_constant<bool, is_void<_Tp>::value || |
| 1008 | __is_nullptr_t<_Tp>::value || | 1211 | __is_nullptr_t<_Tp>::value || |
| ... | @@ -1014,13 +1217,34 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_fundamental_v | ... | @@ -1014,13 +1217,34 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_fundamental_v |
| 1014 | = is_fundamental<_Tp>::value; | 1217 | = is_fundamental<_Tp>::value; |
| 1015 | #endif | 1218 | #endif |
| 1016 | 1219 | ||
| 1220 | #endif // __has_keyword(__is_fundamental) | ||
| 1221 | |||
| 1017 | // is_scalar | 1222 | // is_scalar |
| 1018 | 1223 | ||
| 1224 | // >= 11 because in C++03 nullptr isn't actually nullptr | ||
| 1225 | #if __has_keyword(__is_scalar) && !defined(_LIBCPP_CXX03_LANG) | ||
| 1226 | |||
| 1227 | template<class _Tp> | ||
| 1228 | struct _LIBCPP_TEMPLATE_VIS is_scalar : _BoolConstant<__is_scalar(_Tp)> { }; | ||
| 1229 | |||
| 1230 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | ||
| 1231 | template <class _Tp> | ||
| 1232 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_scalar_v = __is_scalar(_Tp); | ||
| 1233 | #endif | ||
| 1234 | |||
| 1235 | #else // __has_keyword(__is_scalar) | ||
| 1236 | |||
| 1237 | template <class _Tp> struct __is_block : false_type {}; | ||
| 1238 | #if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) | ||
| 1239 | template <class _Rp, class ..._Args> struct __is_block<_Rp (^)(_Args...)> : true_type {}; | ||
| 1240 | #endif | ||
| 1241 | |||
| 1019 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_scalar | 1242 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_scalar |
| 1020 | : public integral_constant<bool, is_arithmetic<_Tp>::value || | 1243 | : public integral_constant<bool, is_arithmetic<_Tp>::value || |
| 1021 | is_member_pointer<_Tp>::value || | 1244 | is_member_pointer<_Tp>::value || |
| 1022 | is_pointer<_Tp>::value || | 1245 | is_pointer<_Tp>::value || |
| 1023 | __is_nullptr_t<_Tp>::value || | 1246 | __is_nullptr_t<_Tp>::value || |
| 1247 | __is_block<_Tp>::value || | ||
| 1024 | is_enum<_Tp>::value > {}; | 1248 | is_enum<_Tp>::value > {}; |
| 1025 | 1249 | ||
| 1026 | template <> struct _LIBCPP_TEMPLATE_VIS is_scalar<nullptr_t> : public true_type {}; | 1250 | template <> struct _LIBCPP_TEMPLATE_VIS is_scalar<nullptr_t> : public true_type {}; |
| ... | @@ -1031,8 +1255,22 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_scalar_v | ... | @@ -1031,8 +1255,22 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_scalar_v |
| 1031 | = is_scalar<_Tp>::value; | 1255 | = is_scalar<_Tp>::value; |
| 1032 | #endif | 1256 | #endif |
| 1033 | 1257 | ||
| 1258 | #endif // __has_keyword(__is_scalar) | ||
| 1259 | |||
| 1034 | // is_object | 1260 | // is_object |
| 1035 | 1261 | ||
| 1262 | #if __has_keyword(__is_object) | ||
| 1263 | |||
| 1264 | template<class _Tp> | ||
| 1265 | struct _LIBCPP_TEMPLATE_VIS is_object : _BoolConstant<__is_object(_Tp)> { }; | ||
| 1266 | |||
| 1267 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | ||
| 1268 | template <class _Tp> | ||
| 1269 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_object_v = __is_object(_Tp); | ||
| 1270 | #endif | ||
| 1271 | |||
| 1272 | #else // __has_keyword(__is_object) | ||
| 1273 | |||
| 1036 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_object | 1274 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_object |
| 1037 | : public integral_constant<bool, is_scalar<_Tp>::value || | 1275 | : public integral_constant<bool, is_scalar<_Tp>::value || |
| 1038 | is_array<_Tp>::value || | 1276 | is_array<_Tp>::value || |
| ... | @@ -1045,8 +1283,23 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_object_v | ... | @@ -1045,8 +1283,23 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_object_v |
| 1045 | = is_object<_Tp>::value; | 1283 | = is_object<_Tp>::value; |
| 1046 | #endif | 1284 | #endif |
| 1047 | 1285 | ||
| 1286 | #endif // __has_keyword(__is_object) | ||
| 1287 | |||
| 1048 | // is_compound | 1288 | // is_compound |
| 1049 | 1289 | ||
| 1290 | // >= 11 because in C++03 nullptr isn't actually nullptr | ||
| 1291 | #if __has_keyword(__is_compound) && !defined(_LIBCPP_CXX03_LANG) | ||
| 1292 | |||
| 1293 | template<class _Tp> | ||
| 1294 | struct _LIBCPP_TEMPLATE_VIS is_compound : _BoolConstant<__is_compound(_Tp)> { }; | ||
| 1295 | |||
| 1296 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | ||
| 1297 | template <class _Tp> | ||
| 1298 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_compound_v = __is_compound(_Tp); | ||
| 1299 | #endif | ||
| 1300 | |||
| 1301 | #else // __has_keyword(__is_compound) | ||
| 1302 | |||
| 1050 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_compound | 1303 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_compound |
| 1051 | : public integral_constant<bool, !is_fundamental<_Tp>::value> {}; | 1304 | : public integral_constant<bool, !is_fundamental<_Tp>::value> {}; |
| 1052 | 1305 | ||
| ... | @@ -1056,6 +1309,7 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_compound_v | ... | @@ -1056,6 +1309,7 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_compound_v |
| 1056 | = is_compound<_Tp>::value; | 1309 | = is_compound<_Tp>::value; |
| 1057 | #endif | 1310 | #endif |
| 1058 | 1311 | ||
| 1312 | #endif // __has_keyword(__is_compound) | ||
| 1059 | 1313 | ||
| 1060 | // __is_referenceable [defns.referenceable] | 1314 | // __is_referenceable [defns.referenceable] |
| 1061 | 1315 | ||
| ... | @@ -1100,6 +1354,13 @@ template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type; | ... | @@ -1100,6 +1354,13 @@ template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type; |
| 1100 | 1354 | ||
| 1101 | // remove_reference | 1355 | // remove_reference |
| 1102 | 1356 | ||
| 1357 | #if __has_keyword(__remove_reference) | ||
| 1358 | |||
| 1359 | template<class _Tp> | ||
| 1360 | struct _LIBCPP_TEMPLATE_VIS remove_reference { typedef __remove_reference(_Tp) type; }; | ||
| 1361 | |||
| 1362 | #else // __has_keyword(__remove_reference) | ||
| 1363 | |||
| 1103 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _LIBCPP_NODEBUG_TYPE _Tp type;}; | 1364 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _LIBCPP_NODEBUG_TYPE _Tp type;}; |
| 1104 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;}; | 1365 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;}; |
| 1105 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;}; | 1366 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;}; |
| ... | @@ -1108,6 +1369,8 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typede | ... | @@ -1108,6 +1369,8 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typede |
| 1108 | template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type; | 1369 | template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type; |
| 1109 | #endif | 1370 | #endif |
| 1110 | 1371 | ||
| 1372 | #endif // __has_keyword(__remove_reference) | ||
| 1373 | |||
| 1111 | // add_lvalue_reference | 1374 | // add_lvalue_reference |
| 1112 | 1375 | ||
| 1113 | template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _LIBCPP_NODEBUG_TYPE _Tp type; }; | 1376 | template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _LIBCPP_NODEBUG_TYPE _Tp type; }; |
| ... | @@ -1215,6 +1478,19 @@ template<class _Tp> using type_identity_t = typename type_identity<_Tp>::type; | ... | @@ -1215,6 +1478,19 @@ template<class _Tp> using type_identity_t = typename type_identity<_Tp>::type; |
| 1215 | 1478 | ||
| 1216 | // is_signed | 1479 | // is_signed |
| 1217 | 1480 | ||
| 1481 | // In clang 9 and earlier, this builtin did not work for floating points or enums | ||
| 1482 | #if __has_keyword(__is_signed) && _LIBCPP_CLANG_VER > 900 | ||
| 1483 | |||
| 1484 | template<class _Tp> | ||
| 1485 | struct _LIBCPP_TEMPLATE_VIS is_signed : _BoolConstant<__is_signed(_Tp)> { }; | ||
| 1486 | |||
| 1487 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | ||
| 1488 | template <class _Tp> | ||
| 1489 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_signed_v = __is_signed(_Tp); | ||
| 1490 | #endif | ||
| 1491 | |||
| 1492 | #else // __has_keyword(__is_signed) | ||
| 1493 | |||
| 1218 | template <class _Tp, bool = is_integral<_Tp>::value> | 1494 | template <class _Tp, bool = is_integral<_Tp>::value> |
| 1219 | struct __libcpp_is_signed_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(-1) < _Tp(0)) {}; | 1495 | struct __libcpp_is_signed_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(-1) < _Tp(0)) {}; |
| 1220 | 1496 | ||
| ... | @@ -1234,8 +1510,22 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_signed_v | ... | @@ -1234,8 +1510,22 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_signed_v |
| 1234 | = is_signed<_Tp>::value; | 1510 | = is_signed<_Tp>::value; |
| 1235 | #endif | 1511 | #endif |
| 1236 | 1512 | ||
| 1513 | #endif // __has_keyword(__is_signed) | ||
| 1514 | |||
| 1237 | // is_unsigned | 1515 | // is_unsigned |
| 1238 | 1516 | ||
| 1517 | #if __has_keyword(__is_unsigned) | ||
| 1518 | |||
| 1519 | template<class _Tp> | ||
| 1520 | struct _LIBCPP_TEMPLATE_VIS is_unsigned : _BoolConstant<__is_unsigned(_Tp)> { }; | ||
| 1521 | |||
| 1522 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | ||
| 1523 | template <class _Tp> | ||
| 1524 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_unsigned_v = __is_unsigned(_Tp); | ||
| 1525 | #endif | ||
| 1526 | |||
| 1527 | #else // __has_keyword(__is_unsigned) | ||
| 1528 | |||
| 1239 | template <class _Tp, bool = is_integral<_Tp>::value> | 1529 | template <class _Tp, bool = is_integral<_Tp>::value> |
| 1240 | struct __libcpp_is_unsigned_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(0) < _Tp(-1)) {}; | 1530 | struct __libcpp_is_unsigned_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(0) < _Tp(-1)) {}; |
| 1241 | 1531 | ||
| ... | @@ -1255,6 +1545,8 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_unsigned_v | ... | @@ -1255,6 +1545,8 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_unsigned_v |
| 1255 | = is_unsigned<_Tp>::value; | 1545 | = is_unsigned<_Tp>::value; |
| 1256 | #endif | 1546 | #endif |
| 1257 | 1547 | ||
| 1548 | #endif // __has_keyword(__is_unsigned) | ||
| 1549 | |||
| 1258 | // rank | 1550 | // rank |
| 1259 | 1551 | ||
| 1260 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank | 1552 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank |
| ... | @@ -1272,6 +1564,19 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t rank_v | ... | @@ -1272,6 +1564,19 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t rank_v |
| 1272 | 1564 | ||
| 1273 | // extent | 1565 | // extent |
| 1274 | 1566 | ||
| 1567 | #if __has_keyword(__array_extent) | ||
| 1568 | |||
| 1569 | template<class _Tp, size_t _Dim = 0> | ||
| 1570 | struct _LIBCPP_TEMPLATE_VIS extent | ||
| 1571 | : integral_constant<size_t, __array_extent(_Tp, _Dim)> { }; | ||
| 1572 | |||
| 1573 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | ||
| 1574 | template <class _Tp, unsigned _Ip = 0> | ||
| 1575 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t extent_v = __array_extent(_Tp, _Ip); | ||
| 1576 | #endif | ||
| 1577 | |||
| 1578 | #else // __has_keyword(__array_extent) | ||
| 1579 | |||
| 1275 | template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TEMPLATE_VIS extent | 1580 | template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TEMPLATE_VIS extent |
| 1276 | : public integral_constant<size_t, 0> {}; | 1581 | : public integral_constant<size_t, 0> {}; |
| 1277 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], 0> | 1582 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], 0> |
| ... | @@ -1289,6 +1594,8 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t extent_v | ... | @@ -1289,6 +1594,8 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t extent_v |
| 1289 | = extent<_Tp, _Ip>::value; | 1594 | = extent<_Tp, _Ip>::value; |
| 1290 | #endif | 1595 | #endif |
| 1291 | 1596 | ||
| 1597 | #endif // __has_keyword(__array_extent) | ||
| 1598 | |||
| 1292 | // remove_extent | 1599 | // remove_extent |
| 1293 | 1600 | ||
| 1294 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent | 1601 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent |
| ... | @@ -2041,9 +2348,33 @@ struct _LIBCPP_TEMPLATE_VIS make_unsigned | ... | @@ -2041,9 +2348,33 @@ struct _LIBCPP_TEMPLATE_VIS make_unsigned |
| 2041 | template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type; | 2348 | template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type; |
| 2042 | #endif | 2349 | #endif |
| 2043 | 2350 | ||
| 2351 | #if _LIBCPP_STD_VER > 14 | ||
| 2352 | template <class...> using void_t = void; | ||
| 2353 | #endif | ||
| 2354 | |||
| 2355 | #if _LIBCPP_STD_VER > 17 | ||
| 2356 | // Let COND_RES(X, Y) be: | ||
| 2357 | template <class _Tp, class _Up> | ||
| 2358 | using __cond_type = decltype(false ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()); | ||
| 2359 | |||
| 2360 | template <class _Tp, class _Up, class = void> | ||
| 2361 | struct __common_type3 {}; | ||
| 2362 | |||
| 2363 | // sub-bullet 4 - "if COND_RES(CREF(D1), CREF(D2)) denotes a type..." | ||
| 2364 | template <class _Tp, class _Up> | ||
| 2365 | struct __common_type3<_Tp, _Up, void_t<__cond_type<const _Tp&, const _Up&>>> | ||
| 2366 | { | ||
| 2367 | using type = remove_cvref_t<__cond_type<const _Tp&, const _Up&>>; | ||
| 2368 | }; | ||
| 2369 | |||
| 2370 | template <class _Tp, class _Up, class = void> | ||
| 2371 | struct __common_type2_imp : __common_type3<_Tp, _Up> {}; | ||
| 2372 | #else | ||
| 2044 | template <class _Tp, class _Up, class = void> | 2373 | template <class _Tp, class _Up, class = void> |
| 2045 | struct __common_type2_imp {}; | 2374 | struct __common_type2_imp {}; |
| 2375 | #endif | ||
| 2046 | 2376 | ||
| 2377 | // sub-bullet 3 - "if decay_t<decltype(false ? declval<D1>() : declval<D2>())> ..." | ||
| 2047 | template <class _Tp, class _Up> | 2378 | template <class _Tp, class _Up> |
| 2048 | struct __common_type2_imp<_Tp, _Up, | 2379 | struct __common_type2_imp<_Tp, _Up, |
| 2049 | typename __void_t<decltype( | 2380 | typename __void_t<decltype( |
| ... | @@ -2107,6 +2438,7 @@ struct _LIBCPP_TEMPLATE_VIS common_type<_Tp> | ... | @@ -2107,6 +2438,7 @@ struct _LIBCPP_TEMPLATE_VIS common_type<_Tp> |
| 2107 | 2438 | ||
| 2108 | // bullet 3 - sizeof...(Tp) == 2 | 2439 | // bullet 3 - sizeof...(Tp) == 2 |
| 2109 | 2440 | ||
| 2441 | // sub-bullet 1 - "If is_same_v<T1, D1> is false or ..." | ||
| 2110 | template <class _Tp, class _Up> | 2442 | template <class _Tp, class _Up> |
| 2111 | struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up> | 2443 | struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up> |
| 2112 | : conditional< | 2444 | : conditional< |
| ... | @@ -2134,6 +2466,18 @@ template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type | ... | @@ -2134,6 +2466,18 @@ template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type |
| 2134 | 2466 | ||
| 2135 | template<typename, typename _Tp> struct __select_2nd { typedef _LIBCPP_NODEBUG_TYPE _Tp type; }; | 2467 | template<typename, typename _Tp> struct __select_2nd { typedef _LIBCPP_NODEBUG_TYPE _Tp type; }; |
| 2136 | 2468 | ||
| 2469 | #if __has_keyword(__is_assignable) | ||
| 2470 | |||
| 2471 | template<class _Tp, class _Up> | ||
| 2472 | struct _LIBCPP_TEMPLATE_VIS is_assignable : _BoolConstant<__is_assignable(_Tp, _Up)> { }; | ||
| 2473 | |||
| 2474 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | ||
| 2475 | template <class _Tp, class _Arg> | ||
| 2476 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_assignable_v = __is_assignable(_Tp, _Arg); | ||
| 2477 | #endif | ||
| 2478 | |||
| 2479 | #else // __has_keyword(__is_assignable) | ||
| 2480 | |||
| 2137 | template <class _Tp, class _Arg> | 2481 | template <class _Tp, class _Arg> |
| 2138 | typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type | 2482 | typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type |
| 2139 | __is_assignable_test(int); | 2483 | __is_assignable_test(int); |
| ... | @@ -2162,6 +2506,8 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_assignable_v | ... | @@ -2162,6 +2506,8 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_assignable_v |
| 2162 | = is_assignable<_Tp, _Arg>::value; | 2506 | = is_assignable<_Tp, _Arg>::value; |
| 2163 | #endif | 2507 | #endif |
| 2164 | 2508 | ||
| 2509 | #endif // __has_keyword(__is_assignable) | ||
| 2510 | |||
| 2165 | // is_copy_assignable | 2511 | // is_copy_assignable |
| 2166 | 2512 | ||
| 2167 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_copy_assignable | 2513 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_copy_assignable |
| ... | @@ -2188,6 +2534,18 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_move_assignable_v | ... | @@ -2188,6 +2534,18 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_move_assignable_v |
| 2188 | 2534 | ||
| 2189 | // is_destructible | 2535 | // is_destructible |
| 2190 | 2536 | ||
| 2537 | #if __has_keyword(__is_destructible) | ||
| 2538 | |||
| 2539 | template<class _Tp> | ||
| 2540 | struct _LIBCPP_TEMPLATE_VIS is_destructible : _BoolConstant<__is_destructible(_Tp)> { }; | ||
| 2541 | |||
| 2542 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | ||
| 2543 | template <class _Tp> | ||
| 2544 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_destructible_v = __is_destructible(_Tp); | ||
| 2545 | #endif | ||
| 2546 | |||
| 2547 | #else // __has_keyword(__is_destructible) | ||
| 2548 | |||
| 2191 | // if it's a reference, return true | 2549 | // if it's a reference, return true |
| 2192 | // if it's a function, return false | 2550 | // if it's a function, return false |
| 2193 | // if it's void, return false | 2551 | // if it's void, return false |
| ... | @@ -2250,6 +2608,8 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_destructible_v | ... | @@ -2250,6 +2608,8 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_destructible_v |
| 2250 | = is_destructible<_Tp>::value; | 2608 | = is_destructible<_Tp>::value; |
| 2251 | #endif | 2609 | #endif |
| 2252 | 2610 | ||
| 2611 | #endif // __has_keyword(__is_destructible) | ||
| 2612 | |||
| 2253 | // move | 2613 | // move |
| 2254 | 2614 | ||
| 2255 | template <class _Tp> | 2615 | template <class _Tp> |
| ... | @@ -3879,7 +4239,6 @@ struct underlying_type : __underlying_type_impl<_Tp, is_enum<_Tp>::value> {}; | ... | @@ -3879,7 +4239,6 @@ struct underlying_type : __underlying_type_impl<_Tp, is_enum<_Tp>::value> {}; |
| 3879 | template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type; | 4239 | template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type; |
| 3880 | #endif | 4240 | #endif |
| 3881 | 4241 | ||
| 3882 | |||
| 3883 | template <class _Tp, bool = is_enum<_Tp>::value> | 4242 | template <class _Tp, bool = is_enum<_Tp>::value> |
| 3884 | struct __sfinae_underlying_type | 4243 | struct __sfinae_underlying_type |
| 3885 | { | 4244 | { |
| ... | @@ -3962,8 +4321,6 @@ struct __has_operator_addressof | ... | @@ -3962,8 +4321,6 @@ struct __has_operator_addressof |
| 3962 | 4321 | ||
| 3963 | #if _LIBCPP_STD_VER > 14 | 4322 | #if _LIBCPP_STD_VER > 14 |
| 3964 | 4323 | ||
| 3965 | template <class...> using void_t = void; | ||
| 3966 | |||
| 3967 | template <class... _Args> | 4324 | template <class... _Args> |
| 3968 | struct conjunction : _And<_Args...> {}; | 4325 | struct conjunction : _And<_Args...> {}; |
| 3969 | template<class... _Args> | 4326 | template<class... _Args> |
| ... | @@ -4040,29 +4397,7 @@ _LIBCPP_END_NAMESPACE_STD | ... | @@ -4040,29 +4397,7 @@ _LIBCPP_END_NAMESPACE_STD |
| 4040 | // std::byte | 4397 | // std::byte |
| 4041 | namespace std // purposefully not versioned | 4398 | namespace std // purposefully not versioned |
| 4042 | { | 4399 | { |
| 4043 | template <class _Integer> | 4400 | |
| 4044 | constexpr typename enable_if<is_integral_v<_Integer>, byte>::type & | ||
| 4045 | operator<<=(byte& __lhs, _Integer __shift) noexcept | ||
| 4046 | { return __lhs = __lhs << __shift; } | ||
| 4047 | |||
| 4048 | template <class _Integer> | ||
| 4049 | constexpr typename enable_if<is_integral_v<_Integer>, byte>::type | ||
| 4050 | operator<< (byte __lhs, _Integer __shift) noexcept | ||
| 4051 | { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) << __shift)); } | ||
| 4052 | |||
| 4053 | template <class _Integer> | ||
| 4054 | constexpr typename enable_if<is_integral_v<_Integer>, byte>::type & | ||
| 4055 | operator>>=(byte& __lhs, _Integer __shift) noexcept | ||
| 4056 | { return __lhs = __lhs >> __shift; } | ||
| 4057 | |||
| 4058 | template <class _Integer> | ||
| 4059 | constexpr typename enable_if<is_integral_v<_Integer>, byte>::type | ||
| 4060 | operator>> (byte __lhs, _Integer __shift) noexcept | ||
| 4061 | { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) >> __shift)); } | ||
| 4062 | |||
| 4063 | template <class _Integer> | ||
| 4064 | constexpr typename enable_if<is_integral_v<_Integer>, _Integer>::type | ||
| 4065 | to_integer(byte __b) noexcept { return static_cast<_Integer>(__b); } | ||
| 4066 | 4401 | ||
| 4067 | } | 4402 | } |
| 4068 | #endif | 4403 | #endif |
lib/libcxx/include/typeinfo+9-4| ... | @@ -60,6 +60,7 @@ public: | ... | @@ -60,6 +60,7 @@ public: |
| 60 | #include <exception> | 60 | #include <exception> |
| 61 | #include <cstddef> | 61 | #include <cstddef> |
| 62 | #include <cstdint> | 62 | #include <cstdint> |
| 63 | #include <type_traits> | ||
| 63 | #ifdef _LIBCPP_NO_EXCEPTIONS | 64 | #ifdef _LIBCPP_NO_EXCEPTIONS |
| 64 | #include <cstdlib> | 65 | #include <cstdlib> |
| 65 | #endif | 66 | #endif |
| ... | @@ -120,6 +121,7 @@ public: | ... | @@ -120,6 +121,7 @@ public: |
| 120 | // ========================================================================== // | 121 | // ========================================================================== // |
| 121 | // ------------------------------------------------------------------------- // | 122 | // ------------------------------------------------------------------------- // |
| 122 | // Unique | 123 | // Unique |
| 124 | // (_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION = 1) | ||
| 123 | // ------------------------------------------------------------------------- // | 125 | // ------------------------------------------------------------------------- // |
| 124 | // This implementation of type_info assumes a unique copy of the RTTI for a | 126 | // This implementation of type_info assumes a unique copy of the RTTI for a |
| 125 | // given type inside a program. This is a valid assumption when abiding to | 127 | // given type inside a program. This is a valid assumption when abiding to |
| ... | @@ -129,6 +131,7 @@ public: | ... | @@ -129,6 +131,7 @@ public: |
| 129 | // a deep string comparison. | 131 | // a deep string comparison. |
| 130 | // -------------------------------------------------------------------------- // | 132 | // -------------------------------------------------------------------------- // |
| 131 | // NonUnique | 133 | // NonUnique |
| 134 | // (_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION = 2) | ||
| 132 | // -------------------------------------------------------------------------- // | 135 | // -------------------------------------------------------------------------- // |
| 133 | // This implementation of type_info does not assume there is always a unique | 136 | // This implementation of type_info does not assume there is always a unique |
| 134 | // copy of the RTTI for a given type inside a program. For various reasons | 137 | // copy of the RTTI for a given type inside a program. For various reasons |
| ... | @@ -138,6 +141,7 @@ public: | ... | @@ -138,6 +141,7 @@ public: |
| 138 | // comparison is equal. | 141 | // comparison is equal. |
| 139 | // -------------------------------------------------------------------------- // | 142 | // -------------------------------------------------------------------------- // |
| 140 | // NonUniqueARMRTTIBit | 143 | // NonUniqueARMRTTIBit |
| 144 | // (selected on ARM64 regardless of _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION) | ||
| 141 | // -------------------------------------------------------------------------- // | 145 | // -------------------------------------------------------------------------- // |
| 142 | // This implementation of type_info does not assume always a unique copy of | 146 | // This implementation of type_info does not assume always a unique copy of |
| 143 | // the RTTI for a given type inside a program. It packs the pointer to the | 147 | // the RTTI for a given type inside a program. It packs the pointer to the |
| ... | @@ -255,12 +259,12 @@ struct __type_info_implementations { | ... | @@ -255,12 +259,12 @@ struct __type_info_implementations { |
| 255 | typedef | 259 | typedef |
| 256 | #if defined(__APPLE__) && defined(__LP64__) && !defined(__x86_64__) | 260 | #if defined(__APPLE__) && defined(__LP64__) && !defined(__x86_64__) |
| 257 | __non_unique_arm_rtti_bit_impl | 261 | __non_unique_arm_rtti_bit_impl |
| 258 | #elif _LIBCPP_HAS_MERGED_TYPEINFO_NAMES_DEFAULT == 0 | 262 | #elif _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 1 |
| 259 | __non_unique_impl | ||
| 260 | #elif _LIBCPP_HAS_MERGED_TYPEINFO_NAMES_DEFAULT == 1 | ||
| 261 | __unique_impl | 263 | __unique_impl |
| 264 | #elif _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 2 | ||
| 265 | __non_unique_impl | ||
| 262 | #else | 266 | #else |
| 263 | # error invalid configuration for _LIBCPP_HAS_MERGED_TYPEINFO_NAMES_DEFAULT | 267 | # error invalid configuration for _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION |
| 264 | #endif | 268 | #endif |
| 265 | __impl; | 269 | __impl; |
| 266 | }; | 270 | }; |
| ... | @@ -318,6 +322,7 @@ class _LIBCPP_EXCEPTION_ABI bad_cast | ... | @@ -318,6 +322,7 @@ class _LIBCPP_EXCEPTION_ABI bad_cast |
| 318 | { | 322 | { |
| 319 | public: | 323 | public: |
| 320 | bad_cast() _NOEXCEPT; | 324 | bad_cast() _NOEXCEPT; |
| 325 | bad_cast(const bad_cast&) _NOEXCEPT = default; | ||
| 321 | virtual ~bad_cast() _NOEXCEPT; | 326 | virtual ~bad_cast() _NOEXCEPT; |
| 322 | virtual const char* what() const _NOEXCEPT; | 327 | virtual const char* what() const _NOEXCEPT; |
| 323 | }; | 328 | }; |
lib/libcxx/include/unordered_map+18-8| ... | @@ -386,10 +386,12 @@ template <class Key, class T, class Hash, class Pred, class Alloc> | ... | @@ -386,10 +386,12 @@ template <class Key, class T, class Hash, class Pred, class Alloc> |
| 386 | noexcept(noexcept(x.swap(y))); | 386 | noexcept(noexcept(x.swap(y))); |
| 387 | 387 | ||
| 388 | template <class K, class T, class H, class P, class A, class Predicate> | 388 | template <class K, class T, class H, class P, class A, class Predicate> |
| 389 | void erase_if(unordered_set<K, T, H, P, A>& c, Predicate pred); // C++20 | 389 | typename unordered_map<K, T, H, P, A>::size_type |
| 390 | erase_if(unordered_map<K, T, H, P, A>& c, Predicate pred); // C++20 | ||
| 390 | 391 | ||
| 391 | template <class K, class T, class H, class P, class A, class Predicate> | 392 | template <class K, class T, class H, class P, class A, class Predicate> |
| 392 | void erase_if(unordered_multiset<K, T, H, P, A>& c, Predicate pred); // C++20 | 393 | typename unordered_multimap<K, T, H, P, A>::size_type |
| 394 | erase_if(unordered_multimap<K, T, H, P, A>& c, Predicate pred); // C++20 | ||
| 393 | 395 | ||
| 394 | template <class Key, class T, class Hash, class Pred, class Alloc> | 396 | template <class Key, class T, class Hash, class Pred, class Alloc> |
| 395 | bool | 397 | bool |
| ... | @@ -1704,10 +1706,14 @@ swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, | ... | @@ -1704,10 +1706,14 @@ swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, |
| 1704 | } | 1706 | } |
| 1705 | 1707 | ||
| 1706 | #if _LIBCPP_STD_VER > 17 | 1708 | #if _LIBCPP_STD_VER > 17 |
| 1707 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc, class _Predicate> | 1709 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc, |
| 1710 | class _Predicate> | ||
| 1708 | inline _LIBCPP_INLINE_VISIBILITY | 1711 | inline _LIBCPP_INLINE_VISIBILITY |
| 1709 | void erase_if(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __c, _Predicate __pred) | 1712 | typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::size_type |
| 1710 | { __libcpp_erase_if_container(__c, __pred); } | 1713 | erase_if(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __c, |
| 1714 | _Predicate __pred) { | ||
| 1715 | return __libcpp_erase_if_container(__c, __pred); | ||
| 1716 | } | ||
| 1711 | #endif | 1717 | #endif |
| 1712 | 1718 | ||
| 1713 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | 1719 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| ... | @@ -2402,10 +2408,14 @@ swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, | ... | @@ -2402,10 +2408,14 @@ swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, |
| 2402 | } | 2408 | } |
| 2403 | 2409 | ||
| 2404 | #if _LIBCPP_STD_VER > 17 | 2410 | #if _LIBCPP_STD_VER > 17 |
| 2405 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc, class _Predicate> | 2411 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc, |
| 2412 | class _Predicate> | ||
| 2406 | inline _LIBCPP_INLINE_VISIBILITY | 2413 | inline _LIBCPP_INLINE_VISIBILITY |
| 2407 | void erase_if(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __c, _Predicate __pred) | 2414 | typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::size_type |
| 2408 | { __libcpp_erase_if_container(__c, __pred); } | 2415 | erase_if(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __c, |
| 2416 | _Predicate __pred) { | ||
| 2417 | return __libcpp_erase_if_container(__c, __pred); | ||
| 2418 | } | ||
| 2409 | #endif | 2419 | #endif |
| 2410 | 2420 | ||
| 2411 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | 2421 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
lib/libcxx/include/unordered_set+18-8| ... | @@ -341,10 +341,12 @@ template <class Value, class Hash, class Pred, class Alloc> | ... | @@ -341,10 +341,12 @@ template <class Value, class Hash, class Pred, class Alloc> |
| 341 | noexcept(noexcept(x.swap(y))); | 341 | noexcept(noexcept(x.swap(y))); |
| 342 | 342 | ||
| 343 | template <class K, class T, class H, class P, class A, class Predicate> | 343 | template <class K, class T, class H, class P, class A, class Predicate> |
| 344 | void erase_if(unordered_set<K, T, H, P, A>& c, Predicate pred); // C++20 | 344 | typename unordered_set<K, T, H, P, A>::size_type |
| 345 | erase_if(unordered_set<K, T, H, P, A>& c, Predicate pred); // C++20 | ||
| 345 | 346 | ||
| 346 | template <class K, class T, class H, class P, class A, class Predicate> | 347 | template <class K, class T, class H, class P, class A, class Predicate> |
| 347 | void erase_if(unordered_multiset<K, T, H, P, A>& c, Predicate pred); // C++20 | 348 | typename unordered_multiset<K, T, H, P, A>::size_type |
| 349 | erase_if(unordered_multiset<K, T, H, P, A>& c, Predicate pred); // C++20 | ||
| 348 | 350 | ||
| 349 | 351 | ||
| 350 | template <class Value, class Hash, class Pred, class Alloc> | 352 | template <class Value, class Hash, class Pred, class Alloc> |
| ... | @@ -1006,10 +1008,14 @@ swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, | ... | @@ -1006,10 +1008,14 @@ swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, |
| 1006 | } | 1008 | } |
| 1007 | 1009 | ||
| 1008 | #if _LIBCPP_STD_VER > 17 | 1010 | #if _LIBCPP_STD_VER > 17 |
| 1009 | template <class _Value, class _Hash, class _Pred, class _Alloc, class _Predicate> | 1011 | template <class _Value, class _Hash, class _Pred, class _Alloc, |
| 1012 | class _Predicate> | ||
| 1010 | inline _LIBCPP_INLINE_VISIBILITY | 1013 | inline _LIBCPP_INLINE_VISIBILITY |
| 1011 | void erase_if(unordered_set<_Value, _Hash, _Pred, _Alloc>& __c, _Predicate __pred) | 1014 | typename unordered_set<_Value, _Hash, _Pred, _Alloc>::size_type |
| 1012 | { __libcpp_erase_if_container(__c, __pred); } | 1015 | erase_if(unordered_set<_Value, _Hash, _Pred, _Alloc>& __c, |
| 1016 | _Predicate __pred) { | ||
| 1017 | return __libcpp_erase_if_container(__c, __pred); | ||
| 1018 | } | ||
| 1013 | #endif | 1019 | #endif |
| 1014 | 1020 | ||
| 1015 | template <class _Value, class _Hash, class _Pred, class _Alloc> | 1021 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| ... | @@ -1637,10 +1643,14 @@ swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, | ... | @@ -1637,10 +1643,14 @@ swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, |
| 1637 | } | 1643 | } |
| 1638 | 1644 | ||
| 1639 | #if _LIBCPP_STD_VER > 17 | 1645 | #if _LIBCPP_STD_VER > 17 |
| 1640 | template <class _Value, class _Hash, class _Pred, class _Alloc, class _Predicate> | 1646 | template <class _Value, class _Hash, class _Pred, class _Alloc, |
| 1647 | class _Predicate> | ||
| 1641 | inline _LIBCPP_INLINE_VISIBILITY | 1648 | inline _LIBCPP_INLINE_VISIBILITY |
| 1642 | void erase_if(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __c, _Predicate __pred) | 1649 | typename unordered_multiset<_Value, _Hash, _Pred, _Alloc>::size_type |
| 1643 | { __libcpp_erase_if_container(__c, __pred); } | 1650 | erase_if(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __c, |
| 1651 | _Predicate __pred) { | ||
| 1652 | return __libcpp_erase_if_container(__c, __pred); | ||
| 1653 | } | ||
| 1644 | #endif | 1654 | #endif |
| 1645 | 1655 | ||
| 1646 | template <class _Value, class _Hash, class _Pred, class _Alloc> | 1656 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
lib/libcxx/include/variant+14-8| ... | @@ -1063,18 +1063,24 @@ public: | ... | @@ -1063,18 +1063,24 @@ public: |
| 1063 | } | 1063 | } |
| 1064 | __impl __tmp(_VSTD::move(*__rhs)); | 1064 | __impl __tmp(_VSTD::move(*__rhs)); |
| 1065 | #ifndef _LIBCPP_NO_EXCEPTIONS | 1065 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1066 | // EXTENSION: When the move construction of `__lhs` into `__rhs` throws | 1066 | if constexpr (__all<is_nothrow_move_constructible_v<_Types>...>::value) { |
| 1067 | // and `__tmp` is nothrow move constructible then we move `__tmp` back | ||
| 1068 | // into `__rhs` and provide the strong exception safety guarantee. | ||
| 1069 | try { | ||
| 1070 | this->__generic_construct(*__rhs, _VSTD::move(*__lhs)); | 1067 | this->__generic_construct(*__rhs, _VSTD::move(*__lhs)); |
| 1071 | } catch (...) { | 1068 | } else { |
| 1072 | if (__tmp.__move_nothrow()) { | 1069 | // EXTENSION: When the move construction of `__lhs` into `__rhs` throws |
| 1073 | this->__generic_construct(*__rhs, _VSTD::move(__tmp)); | 1070 | // and `__tmp` is nothrow move constructible then we move `__tmp` back |
| 1071 | // into `__rhs` and provide the strong exception safety guarantee. | ||
| 1072 | try { | ||
| 1073 | this->__generic_construct(*__rhs, _VSTD::move(*__lhs)); | ||
| 1074 | } catch (...) { | ||
| 1075 | if (__tmp.__move_nothrow()) { | ||
| 1076 | this->__generic_construct(*__rhs, _VSTD::move(__tmp)); | ||
| 1077 | } | ||
| 1078 | throw; | ||
| 1074 | } | 1079 | } |
| 1075 | throw; | ||
| 1076 | } | 1080 | } |
| 1077 | #else | 1081 | #else |
| 1082 | // this isn't consolidated with the `if constexpr` branch above due to | ||
| 1083 | // `throw` being ill-formed with exceptions disabled even when discarded. | ||
| 1078 | this->__generic_construct(*__rhs, _VSTD::move(*__lhs)); | 1084 | this->__generic_construct(*__rhs, _VSTD::move(*__lhs)); |
| 1079 | #endif | 1085 | #endif |
| 1080 | this->__generic_construct(*__lhs, _VSTD::move(__tmp)); | 1086 | this->__generic_construct(*__lhs, _VSTD::move(__tmp)); |
lib/libcxx/include/vector+27-16| ... | @@ -261,9 +261,11 @@ void swap(vector<T,Allocator>& x, vector<T,Allocator>& y) | ... | @@ -261,9 +261,11 @@ void swap(vector<T,Allocator>& x, vector<T,Allocator>& y) |
| 261 | noexcept(noexcept(x.swap(y))); | 261 | noexcept(noexcept(x.swap(y))); |
| 262 | 262 | ||
| 263 | template <class T, class Allocator, class U> | 263 | template <class T, class Allocator, class U> |
| 264 | void erase(vector<T, Allocator>& c, const U& value); // C++20 | 264 | typename vector<T, Allocator>::size_type |
| 265 | erase(vector<T, Allocator>& c, const U& value); // C++20 | ||
| 265 | template <class T, class Allocator, class Predicate> | 266 | template <class T, class Allocator, class Predicate> |
| 266 | void erase_if(vector<T, Allocator>& c, Predicate pred); // C++20 | 267 | typename vector<T, Allocator>::size_type |
| 268 | erase_if(vector<T, Allocator>& c, Predicate pred); // C++20 | ||
| 267 | 269 | ||
| 268 | } // std | 270 | } // std |
| 269 | 271 | ||
| ... | @@ -1041,8 +1043,9 @@ void | ... | @@ -1041,8 +1043,9 @@ void |
| 1041 | vector<_Tp, _Allocator>::__construct_at_end(size_type __n) | 1043 | vector<_Tp, _Allocator>::__construct_at_end(size_type __n) |
| 1042 | { | 1044 | { |
| 1043 | _ConstructTransaction __tx(*this, __n); | 1045 | _ConstructTransaction __tx(*this, __n); |
| 1044 | for (; __tx.__pos_ != __tx.__new_end_; ++__tx.__pos_) { | 1046 | const_pointer __new_end = __tx.__new_end_; |
| 1045 | __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__tx.__pos_)); | 1047 | for (pointer __pos = __tx.__pos_; __pos != __new_end; ++__pos, __tx.__pos_ = __pos) { |
| 1048 | __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__pos)); | ||
| 1046 | } | 1049 | } |
| 1047 | } | 1050 | } |
| 1048 | 1051 | ||
| ... | @@ -1058,8 +1061,9 @@ void | ... | @@ -1058,8 +1061,9 @@ void |
| 1058 | vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) | 1061 | vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) |
| 1059 | { | 1062 | { |
| 1060 | _ConstructTransaction __tx(*this, __n); | 1063 | _ConstructTransaction __tx(*this, __n); |
| 1061 | for (; __tx.__pos_ != __tx.__new_end_; ++__tx.__pos_) { | 1064 | const_pointer __new_end = __tx.__new_end_; |
| 1062 | __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__tx.__pos_), __x); | 1065 | for (pointer __pos = __tx.__pos_; __pos != __new_end; ++__pos, __tx.__pos_ = __pos) { |
| 1066 | __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__pos), __x); | ||
| 1063 | } | 1067 | } |
| 1064 | } | 1068 | } |
| 1065 | 1069 | ||
| ... | @@ -1751,9 +1755,10 @@ vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointe | ... | @@ -1751,9 +1755,10 @@ vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointe |
| 1751 | { | 1755 | { |
| 1752 | pointer __i = __from_s + __n; | 1756 | pointer __i = __from_s + __n; |
| 1753 | _ConstructTransaction __tx(*this, __from_e - __i); | 1757 | _ConstructTransaction __tx(*this, __from_e - __i); |
| 1754 | for (; __i < __from_e; ++__i, ++__tx.__pos_) { | 1758 | for (pointer __pos = __tx.__pos_; __i < __from_e; |
| 1759 | ++__i, ++__pos, __tx.__pos_ = __pos) { | ||
| 1755 | __alloc_traits::construct(this->__alloc(), | 1760 | __alloc_traits::construct(this->__alloc(), |
| 1756 | _VSTD::__to_address(__tx.__pos_), | 1761 | _VSTD::__to_address(__pos), |
| 1757 | _VSTD::move(*__i)); | 1762 | _VSTD::move(*__i)); |
| 1758 | } | 1763 | } |
| 1759 | } | 1764 | } |
| ... | @@ -1956,8 +1961,8 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __firs | ... | @@ -1956,8 +1961,8 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __firs |
| 1956 | #endif // _LIBCPP_NO_EXCEPTIONS | 1961 | #endif // _LIBCPP_NO_EXCEPTIONS |
| 1957 | } | 1962 | } |
| 1958 | __p = _VSTD::rotate(__p, __old_last, this->__end_); | 1963 | __p = _VSTD::rotate(__p, __old_last, this->__end_); |
| 1959 | insert(__make_iter(__p), make_move_iterator(__v.begin()), | 1964 | insert(__make_iter(__p), _VSTD::make_move_iterator(__v.begin()), |
| 1960 | make_move_iterator(__v.end())); | 1965 | _VSTD::make_move_iterator(__v.end())); |
| 1961 | return begin() + __off; | 1966 | return begin() + __off; |
| 1962 | } | 1967 | } |
| 1963 | 1968 | ||
| ... | @@ -3389,14 +3394,20 @@ swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y) | ... | @@ -3389,14 +3394,20 @@ swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y) |
| 3389 | 3394 | ||
| 3390 | #if _LIBCPP_STD_VER > 17 | 3395 | #if _LIBCPP_STD_VER > 17 |
| 3391 | template <class _Tp, class _Allocator, class _Up> | 3396 | template <class _Tp, class _Allocator, class _Up> |
| 3392 | inline _LIBCPP_INLINE_VISIBILITY | 3397 | inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::size_type |
| 3393 | void erase(vector<_Tp, _Allocator>& __c, const _Up& __v) | 3398 | erase(vector<_Tp, _Allocator>& __c, const _Up& __v) { |
| 3394 | { __c.erase(_VSTD::remove(__c.begin(), __c.end(), __v), __c.end()); } | 3399 | auto __old_size = __c.size(); |
| 3400 | __c.erase(_VSTD::remove(__c.begin(), __c.end(), __v), __c.end()); | ||
| 3401 | return __old_size - __c.size(); | ||
| 3402 | } | ||
| 3395 | 3403 | ||
| 3396 | template <class _Tp, class _Allocator, class _Predicate> | 3404 | template <class _Tp, class _Allocator, class _Predicate> |
| 3397 | inline _LIBCPP_INLINE_VISIBILITY | 3405 | inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::size_type |
| 3398 | void erase_if(vector<_Tp, _Allocator>& __c, _Predicate __pred) | 3406 | erase_if(vector<_Tp, _Allocator>& __c, _Predicate __pred) { |
| 3399 | { __c.erase(_VSTD::remove_if(__c.begin(), __c.end(), __pred), __c.end()); } | 3407 | auto __old_size = __c.size(); |
| 3408 | __c.erase(_VSTD::remove_if(__c.begin(), __c.end(), __pred), __c.end()); | ||
| 3409 | return __old_size - __c.size(); | ||
| 3410 | } | ||
| 3400 | #endif | 3411 | #endif |
| 3401 | 3412 | ||
| 3402 | _LIBCPP_END_NAMESPACE_STD | 3413 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/version+16-5| ... | @@ -21,7 +21,8 @@ __cpp_lib_allocator_traits_is_always_equal 201411L <memory> <scoped | ... | @@ -21,7 +21,8 @@ __cpp_lib_allocator_traits_is_always_equal 201411L <memory> <scoped |
| 21 | <unordered_map> <unordered_set> | 21 | <unordered_map> <unordered_set> |
| 22 | __cpp_lib_any 201606L <any> | 22 | __cpp_lib_any 201606L <any> |
| 23 | __cpp_lib_apply 201603L <tuple> | 23 | __cpp_lib_apply 201603L <tuple> |
| 24 | __cpp_lib_array_constexpr 201603L <iterator> <array> | 24 | __cpp_lib_array_constexpr 201811L <iterator> <array> |
| 25 | 201603L // C++17 | ||
| 25 | __cpp_lib_as_const 201510L <utility> | 26 | __cpp_lib_as_const 201510L <utility> |
| 26 | __cpp_lib_atomic_is_always_lock_free 201603L <atomic> | 27 | __cpp_lib_atomic_is_always_lock_free 201603L <atomic> |
| 27 | __cpp_lib_atomic_ref 201806L <atomic> | 28 | __cpp_lib_atomic_ref 201806L <atomic> |
| ... | @@ -44,7 +45,7 @@ __cpp_lib_constexpr_swap_algorithms 201806L <algorithm> | ... | @@ -44,7 +45,7 @@ __cpp_lib_constexpr_swap_algorithms 201806L <algorithm> |
| 44 | __cpp_lib_destroying_delete 201806L <new> | 45 | __cpp_lib_destroying_delete 201806L <new> |
| 45 | __cpp_lib_enable_shared_from_this 201603L <memory> | 46 | __cpp_lib_enable_shared_from_this 201603L <memory> |
| 46 | __cpp_lib_endian 201907L <bit> | 47 | __cpp_lib_endian 201907L <bit> |
| 47 | __cpp_lib_erase_if 201811L <string> <deque> <forward_list> | 48 | __cpp_lib_erase_if 202002L <string> <deque> <forward_list> |
| 48 | <list> <vector> <map> | 49 | <list> <vector> <map> |
| 49 | <set> <unordered_map> <unordered_set> | 50 | <set> <unordered_map> <unordered_set> |
| 50 | __cpp_lib_exchange_function 201304L <utility> | 51 | __cpp_lib_exchange_function 201304L <utility> |
| ... | @@ -74,6 +75,7 @@ __cpp_lib_make_from_tuple 201606L <tuple> | ... | @@ -74,6 +75,7 @@ __cpp_lib_make_from_tuple 201606L <tuple> |
| 74 | __cpp_lib_make_reverse_iterator 201402L <iterator> | 75 | __cpp_lib_make_reverse_iterator 201402L <iterator> |
| 75 | __cpp_lib_make_unique 201304L <memory> | 76 | __cpp_lib_make_unique 201304L <memory> |
| 76 | __cpp_lib_map_try_emplace 201411L <map> | 77 | __cpp_lib_map_try_emplace 201411L <map> |
| 78 | __cpp_lib_math_constants 201907L <numbers> | ||
| 77 | __cpp_lib_math_special_functions 201603L <cmath> | 79 | __cpp_lib_math_special_functions 201603L <cmath> |
| 78 | __cpp_lib_memory_resource 201603L <memory_resource> | 80 | __cpp_lib_memory_resource 201603L <memory_resource> |
| 79 | __cpp_lib_node_extract 201606L <map> <set> <unordered_map> | 81 | __cpp_lib_node_extract 201606L <map> <set> <unordered_map> |
| ... | @@ -98,9 +100,11 @@ __cpp_lib_shared_mutex 201505L <shared_mutex> | ... | @@ -98,9 +100,11 @@ __cpp_lib_shared_mutex 201505L <shared_mutex> |
| 98 | __cpp_lib_shared_ptr_arrays 201611L <memory> | 100 | __cpp_lib_shared_ptr_arrays 201611L <memory> |
| 99 | __cpp_lib_shared_ptr_weak_type 201606L <memory> | 101 | __cpp_lib_shared_ptr_weak_type 201606L <memory> |
| 100 | __cpp_lib_shared_timed_mutex 201402L <shared_mutex> | 102 | __cpp_lib_shared_timed_mutex 201402L <shared_mutex> |
| 103 | __cpp_lib_span 202002L <span> | ||
| 101 | __cpp_lib_string_udls 201304L <string> | 104 | __cpp_lib_string_udls 201304L <string> |
| 102 | __cpp_lib_string_view 201606L <string> <string_view> | 105 | __cpp_lib_string_view 201606L <string> <string_view> |
| 103 | __cpp_lib_three_way_comparison 201711L <compare> | 106 | __cpp_lib_three_way_comparison 201711L <compare> |
| 107 | __cpp_lib_to_array 201907L <array> | ||
| 104 | __cpp_lib_to_chars 201611L <utility> | 108 | __cpp_lib_to_chars 201611L <utility> |
| 105 | __cpp_lib_transformation_trait_aliases 201304L <type_traits> | 109 | __cpp_lib_transformation_trait_aliases 201304L <type_traits> |
| 106 | __cpp_lib_transparent_operators 201510L <functional> | 110 | __cpp_lib_transparent_operators 201510L <functional> |
| ... | @@ -167,7 +171,7 @@ __cpp_lib_void_t 201411L <type_traits> | ... | @@ -167,7 +171,7 @@ __cpp_lib_void_t 201411L <type_traits> |
| 167 | // # define __cpp_lib_execution 201603L | 171 | // # define __cpp_lib_execution 201603L |
| 168 | # define __cpp_lib_filesystem 201703L | 172 | # define __cpp_lib_filesystem 201703L |
| 169 | # define __cpp_lib_gcd_lcm 201606L | 173 | # define __cpp_lib_gcd_lcm 201606L |
| 170 | # define __cpp_lib_hardware_interference_size 201703L | 174 | // # define __cpp_lib_hardware_interference_size 201703L |
| 171 | # if defined(_LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS) | 175 | # if defined(_LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS) |
| 172 | # define __cpp_lib_has_unique_object_representations 201606L | 176 | # define __cpp_lib_has_unique_object_representations 201606L |
| 173 | # endif | 177 | # endif |
| ... | @@ -210,6 +214,8 @@ __cpp_lib_void_t 201411L <type_traits> | ... | @@ -210,6 +214,8 @@ __cpp_lib_void_t 201411L <type_traits> |
| 210 | #endif | 214 | #endif |
| 211 | 215 | ||
| 212 | #if _LIBCPP_STD_VER > 17 | 216 | #if _LIBCPP_STD_VER > 17 |
| 217 | # undef __cpp_lib_array_constexpr | ||
| 218 | # define __cpp_lib_array_constexpr 201811L | ||
| 213 | # if !defined(_LIBCPP_HAS_NO_THREADS) | 219 | # if !defined(_LIBCPP_HAS_NO_THREADS) |
| 214 | // # define __cpp_lib_atomic_ref 201806L | 220 | // # define __cpp_lib_atomic_ref 201806L |
| 215 | # endif | 221 | # endif |
| ... | @@ -225,15 +231,20 @@ __cpp_lib_void_t 201411L <type_traits> | ... | @@ -225,15 +231,20 @@ __cpp_lib_void_t 201411L <type_traits> |
| 225 | # define __cpp_lib_destroying_delete 201806L | 231 | # define __cpp_lib_destroying_delete 201806L |
| 226 | # endif | 232 | # endif |
| 227 | # define __cpp_lib_endian 201907L | 233 | # define __cpp_lib_endian 201907L |
| 228 | # define __cpp_lib_erase_if 201811L | 234 | # define __cpp_lib_erase_if 202002L |
| 229 | // # define __cpp_lib_generic_unordered_lookup 201811L | 235 | // # define __cpp_lib_generic_unordered_lookup 201811L |
| 230 | # define __cpp_lib_interpolate 201902L | 236 | # define __cpp_lib_interpolate 201902L |
| 231 | # if !defined(_LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED) | 237 | # if !defined(_LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED) |
| 232 | # define __cpp_lib_is_constant_evaluated 201811L | 238 | # define __cpp_lib_is_constant_evaluated 201811L |
| 233 | # endif | 239 | # endif |
| 234 | // # define __cpp_lib_list_remove_return_type 201806L | 240 | # define __cpp_lib_list_remove_return_type 201806L |
| 241 | # if defined(__cpp_concepts) && __cpp_concepts >= 201811L | ||
| 242 | # define __cpp_lib_math_constants 201907L | ||
| 243 | # endif | ||
| 235 | // # define __cpp_lib_ranges 201811L | 244 | // # define __cpp_lib_ranges 201811L |
| 245 | # define __cpp_lib_span 202002L | ||
| 236 | // # define __cpp_lib_three_way_comparison 201711L | 246 | // # define __cpp_lib_three_way_comparison 201711L |
| 247 | # define __cpp_lib_to_array 201907L | ||
| 237 | #endif | 248 | #endif |
| 238 | 249 | ||
| 239 | #endif // _LIBCPP_VERSIONH | 250 | #endif // _LIBCPP_VERSIONH |
lib/libcxx/include/wchar.h+1| ... | @@ -106,6 +106,7 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len, | ... | @@ -106,6 +106,7 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len, |
| 106 | */ | 106 | */ |
| 107 | 107 | ||
| 108 | #include <__config> | 108 | #include <__config> |
| 109 | #include <stddef.h> | ||
| 109 | 110 | ||
| 110 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 111 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 111 | #pragma GCC system_header | 112 | #pragma GCC system_header |
lib/libcxx/src/algorithm.cpp-48| ... | @@ -7,13 +7,6 @@ | ... | @@ -7,13 +7,6 @@ |
| 7 | //===----------------------------------------------------------------------===// | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | ||
| 9 | #include "algorithm" | 9 | #include "algorithm" |
| 10 | #include "random" | ||
| 11 | #ifndef _LIBCPP_HAS_NO_THREADS | ||
| 12 | #include "mutex" | ||
| 13 | #if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB) | ||
| 14 | #pragma comment(lib, "pthread") | ||
| 15 | #endif | ||
| 16 | #endif | ||
| 17 | 10 | ||
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | 11 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 19 | 12 | ||
| ... | @@ -51,45 +44,4 @@ template bool __insertion_sort_incomplete<__less<long double>&, long double*>(lo | ... | @@ -51,45 +44,4 @@ template bool __insertion_sort_incomplete<__less<long double>&, long double*>(lo |
| 51 | 44 | ||
| 52 | template unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&); | 45 | template unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&); |
| 53 | 46 | ||
| 54 | #ifndef _LIBCPP_HAS_NO_THREADS | ||
| 55 | _LIBCPP_SAFE_STATIC static __libcpp_mutex_t __rs_mut = _LIBCPP_MUTEX_INITIALIZER; | ||
| 56 | #endif | ||
| 57 | unsigned __rs_default::__c_ = 0; | ||
| 58 | |||
| 59 | __rs_default::__rs_default() | ||
| 60 | { | ||
| 61 | #ifndef _LIBCPP_HAS_NO_THREADS | ||
| 62 | __libcpp_mutex_lock(&__rs_mut); | ||
| 63 | #endif | ||
| 64 | __c_ = 1; | ||
| 65 | } | ||
| 66 | |||
| 67 | __rs_default::__rs_default(const __rs_default&) | ||
| 68 | { | ||
| 69 | ++__c_; | ||
| 70 | } | ||
| 71 | |||
| 72 | __rs_default::~__rs_default() | ||
| 73 | { | ||
| 74 | #ifndef _LIBCPP_HAS_NO_THREADS | ||
| 75 | if (--__c_ == 0) | ||
| 76 | __libcpp_mutex_unlock(&__rs_mut); | ||
| 77 | #else | ||
| 78 | --__c_; | ||
| 79 | #endif | ||
| 80 | } | ||
| 81 | |||
| 82 | __rs_default::result_type | ||
| 83 | __rs_default::operator()() | ||
| 84 | { | ||
| 85 | static mt19937 __rs_g; | ||
| 86 | return __rs_g(); | ||
| 87 | } | ||
| 88 | |||
| 89 | __rs_default | ||
| 90 | __rs_get() | ||
| 91 | { | ||
| 92 | return __rs_default(); | ||
| 93 | } | ||
| 94 | |||
| 95 | _LIBCPP_END_NAMESPACE_STD | 47 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/src/atomic.cpp created+189| ... | @@ -0,0 +1,189 @@ | ||
| 1 | //===------------------------- atomic.cpp ---------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #include <__config> | ||
| 10 | #ifndef _LIBCPP_HAS_NO_THREADS | ||
| 11 | |||
| 12 | #include <climits> | ||
| 13 | #include <atomic> | ||
| 14 | #include <functional> | ||
| 15 | |||
| 16 | #include <iostream> | ||
| 17 | |||
| 18 | #ifdef __linux__ | ||
| 19 | |||
| 20 | #include <unistd.h> | ||
| 21 | #include <linux/futex.h> | ||
| 22 | #include <sys/syscall.h> | ||
| 23 | |||
| 24 | #else // <- Add other operating systems here | ||
| 25 | |||
| 26 | // Baseline needs no new headers | ||
| 27 | |||
| 28 | #endif | ||
| 29 | |||
| 30 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 31 | |||
| 32 | #ifdef __linux__ | ||
| 33 | |||
| 34 | static void __libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr, | ||
| 35 | __cxx_contention_t __val) | ||
| 36 | { | ||
| 37 | static constexpr timespec __timeout = { 2, 0 }; | ||
| 38 | syscall(SYS_futex, __ptr, FUTEX_WAIT_PRIVATE, __val, &__timeout, 0, 0); | ||
| 39 | } | ||
| 40 | |||
| 41 | static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile* __ptr, | ||
| 42 | bool __notify_one) | ||
| 43 | { | ||
| 44 | syscall(SYS_futex, __ptr, FUTEX_WAKE_PRIVATE, __notify_one ? 1 : INT_MAX, 0, 0, 0); | ||
| 45 | } | ||
| 46 | |||
| 47 | #elif defined(__APPLE__) && defined(_LIBCPP_USE_ULOCK) | ||
| 48 | |||
| 49 | extern "C" int __ulock_wait(uint32_t operation, void *addr, uint64_t value, | ||
| 50 | 		uint32_t timeout); /* timeout is specified in microseconds */ | ||
| 51 | extern "C" int __ulock_wake(uint32_t operation, void *addr, uint64_t wake_value); | ||
| 52 | |||
| 53 | #define UL_COMPARE_AND_WAIT				1 | ||
| 54 | #define ULF_WAKE_ALL					0x00000100 | ||
| 55 | |||
| 56 | static void __libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr, | ||
| 57 | __cxx_contention_t __val) | ||
| 58 | { | ||
| 59 | __ulock_wait(UL_COMPARE_AND_WAIT, | ||
| 60 | const_cast<__cxx_atomic_contention_t*>(__ptr), __val, 0); | ||
| 61 | } | ||
| 62 | |||
| 63 | static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile* __ptr, | ||
| 64 | bool __notify_one) | ||
| 65 | { | ||
| 66 | __ulock_wake(UL_COMPARE_AND_WAIT | (__notify_one ? 0 : ULF_WAKE_ALL), | ||
| 67 | const_cast<__cxx_atomic_contention_t*>(__ptr), 0); | ||
| 68 | } | ||
| 69 | |||
| 70 | #else // <- Add other operating systems here | ||
| 71 | |||
| 72 | // Baseline is just a timed backoff | ||
| 73 | |||
| 74 | static void __libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr, | ||
| 75 | __cxx_contention_t __val) | ||
| 76 | { | ||
| 77 | __libcpp_thread_poll_with_backoff([=]() -> bool { | ||
| 78 | return !__cxx_nonatomic_compare_equal(__cxx_atomic_load(__ptr, memory_order_relaxed), __val); | ||
| 79 | }, __libcpp_timed_backoff_policy()); | ||
| 80 | } | ||
| 81 | |||
| 82 | static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile*, bool) { } | ||
| 83 | |||
| 84 | #endif // __linux__ | ||
| 85 | |||
| 86 | static constexpr size_t __libcpp_contention_table_size = (1 << 8); /* < there's no magic in this number */ | ||
| 87 | |||
| 88 | struct alignas(64) /* aim to avoid false sharing */ __libcpp_contention_table_entry | ||
| 89 | { | ||
| 90 | __cxx_atomic_contention_t __contention_state; | ||
| 91 | __cxx_atomic_contention_t __platform_state; | ||
| 92 | inline constexpr __libcpp_contention_table_entry() : | ||
| 93 | __contention_state(0), __platform_state(0) { } | ||
| 94 | }; | ||
| 95 | |||
| 96 | static __libcpp_contention_table_entry __libcpp_contention_table[ __libcpp_contention_table_size ]; | ||
| 97 | |||
| 98 | static hash<void const volatile*> __libcpp_contention_hasher; | ||
| 99 | |||
| 100 | static __libcpp_contention_table_entry* __libcpp_contention_state(void const volatile * p) | ||
| 101 | { | ||
| 102 | return &__libcpp_contention_table[__libcpp_contention_hasher(p) & (__libcpp_contention_table_size - 1)]; | ||
| 103 | } | ||
| 104 | |||
| 105 | /* Given an atomic to track contention and an atomic to actually wait on, which may be | ||
| 106 | the same atomic, we try to detect contention to avoid spuriously calling the platform. */ | ||
| 107 | |||
| 108 | static void __libcpp_contention_notify(__cxx_atomic_contention_t volatile* __contention_state, | ||
| 109 | __cxx_atomic_contention_t const volatile* __platform_state, | ||
| 110 | bool __notify_one) | ||
| 111 | { | ||
| 112 | if(0 != __cxx_atomic_load(__contention_state, memory_order_seq_cst)) | ||
| 113 | // We only call 'wake' if we consumed a contention bit here. | ||
| 114 | __libcpp_platform_wake_by_address(__platform_state, __notify_one); | ||
| 115 | } | ||
| 116 | static __cxx_contention_t __libcpp_contention_monitor_for_wait(__cxx_atomic_contention_t volatile* __contention_state, | ||
| 117 | __cxx_atomic_contention_t const volatile* __platform_state) | ||
| 118 | { | ||
| 119 | // We will monitor this value. | ||
| 120 | return __cxx_atomic_load(__platform_state, memory_order_acquire); | ||
| 121 | } | ||
| 122 | static void __libcpp_contention_wait(__cxx_atomic_contention_t volatile* __contention_state, | ||
| 123 | __cxx_atomic_contention_t const volatile* __platform_state, | ||
| 124 | __cxx_contention_t __old_value) | ||
| 125 | { | ||
| 126 | __cxx_atomic_fetch_add(__contention_state, __cxx_contention_t(1), memory_order_seq_cst); | ||
| 127 | // We sleep as long as the monitored value hasn't changed. | ||
| 128 | __libcpp_platform_wait_on_address(__platform_state, __old_value); | ||
| 129 | __cxx_atomic_fetch_sub(__contention_state, __cxx_contention_t(1), memory_order_release); | ||
| 130 | } | ||
| 131 | |||
| 132 | /* When the incoming atomic is the wrong size for the platform wait size, need to | ||
| 133 | launder the value sequence through an atomic from our table. */ | ||
| 134 | |||
| 135 | static void __libcpp_atomic_notify(void const volatile* __location) | ||
| 136 | { | ||
| 137 | auto const __entry = __libcpp_contention_state(__location); | ||
| 138 | // The value sequence laundering happens on the next line below. | ||
| 139 | __cxx_atomic_fetch_add(&__entry->__platform_state, __cxx_contention_t(1), memory_order_release); | ||
| 140 | __libcpp_contention_notify(&__entry->__contention_state, | ||
| 141 | &__entry->__platform_state, | ||
| 142 | false /* when laundering, we can't handle notify_one */); | ||
| 143 | } | ||
| 144 | _LIBCPP_EXPORTED_FROM_ABI | ||
| 145 | void __cxx_atomic_notify_one(void const volatile* __location) | ||
| 146 | { __libcpp_atomic_notify(__location); } | ||
| 147 | _LIBCPP_EXPORTED_FROM_ABI | ||
| 148 | void __cxx_atomic_notify_all(void const volatile* __location) | ||
| 149 | { __libcpp_atomic_notify(__location); } | ||
| 150 | _LIBCPP_EXPORTED_FROM_ABI | ||
| 151 | __cxx_contention_t __libcpp_atomic_monitor(void const volatile* __location) | ||
| 152 | { | ||
| 153 | auto const __entry = __libcpp_contention_state(__location); | ||
| 154 | return __libcpp_contention_monitor_for_wait(&__entry->__contention_state, &__entry->__platform_state); | ||
| 155 | } | ||
| 156 | _LIBCPP_EXPORTED_FROM_ABI | ||
| 157 | void __libcpp_atomic_wait(void const volatile* __location, __cxx_contention_t __old_value) | ||
| 158 | { | ||
| 159 | auto const __entry = __libcpp_contention_state(__location); | ||
| 160 | __libcpp_contention_wait(&__entry->__contention_state, &__entry->__platform_state, __old_value); | ||
| 161 | } | ||
| 162 | |||
| 163 | /* When the incoming atomic happens to be the platform wait size, we still need to use the | ||
| 164 | table for the contention detection, but we can use the atomic directly for the wait. */ | ||
| 165 | |||
| 166 | _LIBCPP_EXPORTED_FROM_ABI | ||
| 167 | void __cxx_atomic_notify_one(__cxx_atomic_contention_t const volatile* __location) | ||
| 168 | { | ||
| 169 | __libcpp_contention_notify(&__libcpp_contention_state(__location)->__contention_state, __location, true); | ||
| 170 | } | ||
| 171 | _LIBCPP_EXPORTED_FROM_ABI | ||
| 172 | void __cxx_atomic_notify_all(__cxx_atomic_contention_t const volatile* __location) | ||
| 173 | { | ||
| 174 | __libcpp_contention_notify(&__libcpp_contention_state(__location)->__contention_state, __location, false); | ||
| 175 | } | ||
| 176 | _LIBCPP_EXPORTED_FROM_ABI | ||
| 177 | __cxx_contention_t __libcpp_atomic_monitor(__cxx_atomic_contention_t const volatile* __location) | ||
| 178 | { | ||
| 179 | return __libcpp_contention_monitor_for_wait(&__libcpp_contention_state(__location)->__contention_state, __location); | ||
| 180 | } | ||
| 181 | _LIBCPP_EXPORTED_FROM_ABI | ||
| 182 | void __libcpp_atomic_wait(__cxx_atomic_contention_t const volatile* __location, __cxx_contention_t __old_value) | ||
| 183 | { | ||
| 184 | __libcpp_contention_wait(&__libcpp_contention_state(__location)->__contention_state, __location, __old_value); | ||
| 185 | } | ||
| 186 | |||
| 187 | _LIBCPP_END_NAMESPACE_STD | ||
| 188 | |||
| 189 | #endif //_LIBCPP_HAS_NO_THREADS | ||
lib/libcxx/src/barrier.cpp created+103| ... | @@ -0,0 +1,103 @@ | ||
| 1 | //===------------------------- barrier.cpp ---------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #include <__config> | ||
| 10 | |||
| 11 | #ifndef _LIBCPP_HAS_NO_THREADS | ||
| 12 | |||
| 13 | #include <barrier> | ||
| 14 | #include <thread> | ||
| 15 | |||
| 16 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 17 | |||
| 18 | #if !defined(_LIBCPP_HAS_NO_TREE_BARRIER) && (_LIBCPP_STD_VER > 11) | ||
| 19 | |||
| 20 | class __barrier_algorithm_base { | ||
| 21 | public: | ||
| 22 | struct alignas(64) /* naturally-align the heap state */ __state_t | ||
| 23 | { | ||
| 24 | struct { | ||
| 25 | __atomic_base<__barrier_phase_t> __phase = ATOMIC_VAR_INIT(0); | ||
| 26 | } __tickets[64]; | ||
| 27 | }; | ||
| 28 | |||
| 29 | ptrdiff_t& __expected; | ||
| 30 | unique_ptr<char[]> __state_allocation; | ||
| 31 | __state_t* __state; | ||
| 32 | |||
| 33 | _LIBCPP_HIDDEN | ||
| 34 | __barrier_algorithm_base(ptrdiff_t& __expected) | ||
| 35 | : __expected(__expected) | ||
| 36 | { | ||
| 37 | size_t const __count = (__expected + 1) >> 1; | ||
| 38 | size_t const __size = sizeof(__state_t) * __count; | ||
| 39 | size_t __allocation_size = __size + alignof(__state_t); | ||
| 40 | __state_allocation = unique_ptr<char[]>(new char[__allocation_size]); | ||
| 41 | void* __allocation = __state_allocation.get(); | ||
| 42 | void* const __state_ = align(alignof(__state_t), __size, __allocation, __allocation_size); | ||
| 43 | __state = new (__state_) __barrier_algorithm_base::__state_t[__count]; | ||
| 44 | } | ||
| 45 | _LIBCPP_HIDDEN | ||
| 46 | bool __arrive(__barrier_phase_t __old_phase) | ||
| 47 | { | ||
| 48 | __barrier_phase_t const __half_step = __old_phase + 1, | ||
| 49 | __full_step = __old_phase + 2; | ||
| 50 | size_t __current_expected = __expected, | ||
| 51 | __current = hash<thread::id>()(this_thread::get_id()) % ((__expected + 1) >> 1); | ||
| 52 | for(int __round = 0;; ++__round) { | ||
| 53 | if(__current_expected <= 1) | ||
| 54 | return true; | ||
| 55 | size_t const __end_node = ((__current_expected + 1) >> 1), | ||
| 56 | __last_node = __end_node - 1; | ||
| 57 | for(;;++__current) { | ||
| 58 | if(__current == __end_node) | ||
| 59 | __current = 0; | ||
| 60 | __barrier_phase_t expect = __old_phase; | ||
| 61 | if(__current == __last_node && (__current_expected & 1)) | ||
| 62 | { | ||
| 63 | if(__state[__current].__tickets[__round].__phase.compare_exchange_strong(expect, __full_step, memory_order_acq_rel)) | ||
| 64 | break; // I'm 1 in 1, go to next __round | ||
| 65 | } | ||
| 66 | else if(__state[__current].__tickets[__round].__phase.compare_exchange_strong(expect, __half_step, memory_order_acq_rel)) | ||
| 67 | { | ||
| 68 | return false; // I'm 1 in 2, done with arrival | ||
| 69 | } | ||
| 70 | else if(expect == __half_step) | ||
| 71 | { | ||
| 72 | if(__state[__current].__tickets[__round].__phase.compare_exchange_strong(expect, __full_step, memory_order_acq_rel)) | ||
| 73 | break; // I'm 2 in 2, go to next __round | ||
| 74 | } | ||
| 75 | } | ||
| 76 | __current_expected = __last_node + 1; | ||
| 77 | __current >>= 1; | ||
| 78 | } | ||
| 79 | } | ||
| 80 | }; | ||
| 81 | |||
| 82 | _LIBCPP_EXPORTED_FROM_ABI | ||
| 83 | __barrier_algorithm_base * __construct_barrier_algorithm_base(ptrdiff_t& __expected) | ||
| 84 | { | ||
| 85 | return new __barrier_algorithm_base(__expected); | ||
| 86 | } | ||
| 87 | _LIBCPP_EXPORTED_FROM_ABI | ||
| 88 | bool __arrive_barrier_algorithm_base(__barrier_algorithm_base* __barrier, | ||
| 89 | __barrier_phase_t __old_phase) | ||
| 90 | { | ||
| 91 | return __barrier->__arrive(__old_phase); | ||
| 92 | } | ||
| 93 | _LIBCPP_EXPORTED_FROM_ABI | ||
| 94 | void __destroy_barrier_algorithm_base(__barrier_algorithm_base* __barrier) | ||
| 95 | { | ||
| 96 | delete __barrier; | ||
| 97 | } | ||
| 98 | |||
| 99 | #endif //!defined(_LIBCPP_HAS_NO_TREE_BARRIER) && (_LIBCPP_STD_VER >= 11) | ||
| 100 | |||
| 101 | _LIBCPP_END_NAMESPACE_STD | ||
| 102 | |||
| 103 | #endif //_LIBCPP_HAS_NO_THREADS | ||
lib/libcxx/src/charconv.cpp+9-9| ... | @@ -32,7 +32,7 @@ static constexpr char cDigitsLut[200] = { | ... | @@ -32,7 +32,7 @@ static constexpr char cDigitsLut[200] = { |
| 32 | 32 | ||
| 33 | template <typename T> | 33 | template <typename T> |
| 34 | inline _LIBCPP_INLINE_VISIBILITY char* | 34 | inline _LIBCPP_INLINE_VISIBILITY char* |
| 35 | append1(char* buffer, T i) | 35 | append1(char* buffer, T i) noexcept |
| 36 | { | 36 | { |
| 37 | *buffer = '0' + static_cast<char>(i); | 37 | *buffer = '0' + static_cast<char>(i); |
| 38 | return buffer + 1; | 38 | return buffer + 1; |
| ... | @@ -40,7 +40,7 @@ append1(char* buffer, T i) | ... | @@ -40,7 +40,7 @@ append1(char* buffer, T i) |
| 40 | 40 | ||
| 41 | template <typename T> | 41 | template <typename T> |
| 42 | inline _LIBCPP_INLINE_VISIBILITY char* | 42 | inline _LIBCPP_INLINE_VISIBILITY char* |
| 43 | append2(char* buffer, T i) | 43 | append2(char* buffer, T i) noexcept |
| 44 | { | 44 | { |
| 45 | memcpy(buffer, &cDigitsLut[(i)*2], 2); | 45 | memcpy(buffer, &cDigitsLut[(i)*2], 2); |
| 46 | return buffer + 2; | 46 | return buffer + 2; |
| ... | @@ -48,21 +48,21 @@ append2(char* buffer, T i) | ... | @@ -48,21 +48,21 @@ append2(char* buffer, T i) |
| 48 | 48 | ||
| 49 | template <typename T> | 49 | template <typename T> |
| 50 | inline _LIBCPP_INLINE_VISIBILITY char* | 50 | inline _LIBCPP_INLINE_VISIBILITY char* |
| 51 | append3(char* buffer, T i) | 51 | append3(char* buffer, T i) noexcept |
| 52 | { | 52 | { |
| 53 | return append2(append1(buffer, (i) / 100), (i) % 100); | 53 | return append2(append1(buffer, (i) / 100), (i) % 100); |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | template <typename T> | 56 | template <typename T> |
| 57 | inline _LIBCPP_INLINE_VISIBILITY char* | 57 | inline _LIBCPP_INLINE_VISIBILITY char* |
| 58 | append4(char* buffer, T i) | 58 | append4(char* buffer, T i) noexcept |
| 59 | { | 59 | { |
| 60 | return append2(append2(buffer, (i) / 100), (i) % 100); | 60 | return append2(append2(buffer, (i) / 100), (i) % 100); |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | template <typename T> | 63 | template <typename T> |
| 64 | inline _LIBCPP_INLINE_VISIBILITY char* | 64 | inline _LIBCPP_INLINE_VISIBILITY char* |
| 65 | append2_no_zeros(char* buffer, T v) | 65 | append2_no_zeros(char* buffer, T v) noexcept |
| 66 | { | 66 | { |
| 67 | if (v < 10) | 67 | if (v < 10) |
| 68 | return append1(buffer, v); | 68 | return append1(buffer, v); |
| ... | @@ -72,7 +72,7 @@ append2_no_zeros(char* buffer, T v) | ... | @@ -72,7 +72,7 @@ append2_no_zeros(char* buffer, T v) |
| 72 | 72 | ||
| 73 | template <typename T> | 73 | template <typename T> |
| 74 | inline _LIBCPP_INLINE_VISIBILITY char* | 74 | inline _LIBCPP_INLINE_VISIBILITY char* |
| 75 | append4_no_zeros(char* buffer, T v) | 75 | append4_no_zeros(char* buffer, T v) noexcept |
| 76 | { | 76 | { |
| 77 | if (v < 100) | 77 | if (v < 100) |
| 78 | return append2_no_zeros(buffer, v); | 78 | return append2_no_zeros(buffer, v); |
| ... | @@ -84,7 +84,7 @@ append4_no_zeros(char* buffer, T v) | ... | @@ -84,7 +84,7 @@ append4_no_zeros(char* buffer, T v) |
| 84 | 84 | ||
| 85 | template <typename T> | 85 | template <typename T> |
| 86 | inline _LIBCPP_INLINE_VISIBILITY char* | 86 | inline _LIBCPP_INLINE_VISIBILITY char* |
| 87 | append8_no_zeros(char* buffer, T v) | 87 | append8_no_zeros(char* buffer, T v) noexcept |
| 88 | { | 88 | { |
| 89 | if (v < 10000) | 89 | if (v < 10000) |
| 90 | { | 90 | { |
| ... | @@ -99,7 +99,7 @@ append8_no_zeros(char* buffer, T v) | ... | @@ -99,7 +99,7 @@ append8_no_zeros(char* buffer, T v) |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | char* | 101 | char* |
| 102 | __u32toa(uint32_t value, char* buffer) | 102 | __u32toa(uint32_t value, char* buffer) _NOEXCEPT |
| 103 | { | 103 | { |
| 104 | if (value < 100000000) | 104 | if (value < 100000000) |
| 105 | { | 105 | { |
| ... | @@ -120,7 +120,7 @@ __u32toa(uint32_t value, char* buffer) | ... | @@ -120,7 +120,7 @@ __u32toa(uint32_t value, char* buffer) |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | char* | 122 | char* |
| 123 | __u64toa(uint64_t value, char* buffer) | 123 | __u64toa(uint64_t value, char* buffer) _NOEXCEPT |
| 124 | { | 124 | { |
| 125 | if (value < 100000000) | 125 | if (value < 100000000) |
| 126 | { | 126 | { |
lib/libcxx/src/chrono.cpp+31-89| ... | @@ -9,36 +9,32 @@ | ... | @@ -9,36 +9,32 @@ |
| 9 | #include "chrono" | 9 | #include "chrono" |
| 10 | #include "cerrno" // errno | 10 | #include "cerrno" // errno |
| 11 | #include "system_error" // __throw_system_error | 11 | #include "system_error" // __throw_system_error |
| 12 | #include <time.h> // clock_gettime, CLOCK_MONOTONIC and CLOCK_REALTIME | 12 | #include <time.h> // clock_gettime and CLOCK_{MONOTONIC,REALTIME,MONOTONIC_RAW} |
| 13 | #include "include/apple_availability.h" | 13 | #include "include/apple_availability.h" |
| 14 | 14 | ||
| 15 | #if !defined(__APPLE__) | 15 | #if __has_include(<unistd.h>) |
| 16 | #include <unistd.h> | ||
| 17 | #endif | ||
| 18 | |||
| 19 | #if !defined(__APPLE__) && _POSIX_TIMERS > 0 | ||
| 16 | #define _LIBCPP_USE_CLOCK_GETTIME | 20 | #define _LIBCPP_USE_CLOCK_GETTIME |
| 17 | #endif // __APPLE__ | 21 | #endif |
| 18 | 22 | ||
| 19 | #if defined(_LIBCPP_WIN32API) | 23 | #if defined(_LIBCPP_WIN32API) |
| 20 | #define WIN32_LEAN_AND_MEAN | 24 | # define WIN32_LEAN_AND_MEAN |
| 21 | #define VC_EXTRA_LEAN | 25 | # define VC_EXTRA_LEAN |
| 22 | #include <windows.h> | 26 | # include <windows.h> |
| 23 | #if _WIN32_WINNT >= _WIN32_WINNT_WIN8 | 27 | # if _WIN32_WINNT >= _WIN32_WINNT_WIN8 |
| 24 | #include <winapifamily.h> | 28 | # include <winapifamily.h> |
| 25 | #endif | 29 | # endif |
| 26 | #else | 30 | #else |
| 27 | #if !defined(CLOCK_REALTIME) || !defined(_LIBCPP_USE_CLOCK_GETTIME) | 31 | # if !defined(CLOCK_REALTIME) |
| 28 | #include <sys/time.h> // for gettimeofday and timeval | 32 | # include <sys/time.h> // for gettimeofday and timeval |
| 29 | #endif // !defined(CLOCK_REALTIME) | 33 | # endif // !defined(CLOCK_REALTIME) |
| 30 | #endif // defined(_LIBCPP_WIN32API) | 34 | #endif // defined(_LIBCPP_WIN32API) |
| 31 | 35 | ||
| 32 | #if !defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) | ||
| 33 | #if __APPLE__ | ||
| 34 | #include <mach/mach_time.h> // mach_absolute_time, mach_timebase_info_data_t | ||
| 35 | #elif !defined(_LIBCPP_WIN32API) && !defined(CLOCK_MONOTONIC) | ||
| 36 | #error "Monotonic clock not implemented" | ||
| 37 | #endif | ||
| 38 | #endif | ||
| 39 | |||
| 40 | #if defined(__ELF__) && defined(_LIBCPP_LINK_RT_LIB) | 36 | #if defined(__ELF__) && defined(_LIBCPP_LINK_RT_LIB) |
| 41 | #pragma comment(lib, "rt") | 37 | # pragma comment(lib, "rt") |
| 42 | #endif | 38 | #endif |
| 43 | 39 | ||
| 44 | _LIBCPP_BEGIN_NAMESPACE_STD | 40 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | @@ -78,7 +74,7 @@ system_clock::now() _NOEXCEPT | ... | @@ -78,7 +74,7 @@ system_clock::now() _NOEXCEPT |
| 78 | static_cast<__int64>(ft.dwLowDateTime)}; | 74 | static_cast<__int64>(ft.dwLowDateTime)}; |
| 79 | return time_point(duration_cast<duration>(d - nt_to_unix_epoch)); | 75 | return time_point(duration_cast<duration>(d - nt_to_unix_epoch)); |
| 80 | #else | 76 | #else |
| 81 | #if defined(_LIBCPP_USE_CLOCK_GETTIME) && defined(CLOCK_REALTIME) | 77 | #if defined(CLOCK_REALTIME) |
| 82 | struct timespec tp; | 78 | struct timespec tp; |
| 83 | if (0 != clock_gettime(CLOCK_REALTIME, &tp)) | 79 | if (0 != clock_gettime(CLOCK_REALTIME, &tp)) |
| 84 | __throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed"); | 80 | __throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed"); |
| ... | @@ -87,7 +83,7 @@ system_clock::now() _NOEXCEPT | ... | @@ -87,7 +83,7 @@ system_clock::now() _NOEXCEPT |
| 87 | timeval tv; | 83 | timeval tv; |
| 88 | gettimeofday(&tv, 0); | 84 | gettimeofday(&tv, 0); |
| 89 | return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec)); | 85 | return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec)); |
| 90 | #endif // _LIBCPP_USE_CLOCK_GETTIME && CLOCK_REALTIME | 86 | #endif // CLOCK_REALTIME |
| 91 | #endif | 87 | #endif |
| 92 | } | 88 | } |
| 93 | 89 | ||
| ... | @@ -114,71 +110,24 @@ const bool steady_clock::is_steady; | ... | @@ -114,71 +110,24 @@ const bool steady_clock::is_steady; |
| 114 | 110 | ||
| 115 | #if defined(__APPLE__) | 111 | #if defined(__APPLE__) |
| 116 | 112 | ||
| 117 | // Darwin libc versions >= 1133 provide ns precision via CLOCK_UPTIME_RAW | 113 | #if !defined(CLOCK_MONOTONIC_RAW) |
| 118 | #if defined(_LIBCPP_USE_CLOCK_GETTIME) && defined(CLOCK_UPTIME_RAW) | 114 | # error "Building libc++ on Apple platforms requires CLOCK_MONOTONIC_RAW" |
| 115 | #endif | ||
| 116 | |||
| 117 | // On Apple platforms, only CLOCK_UPTIME_RAW, CLOCK_MONOTONIC_RAW or | ||
| 118 | // mach_absolute_time are able to time functions in the nanosecond range. | ||
| 119 | // Furthermore, only CLOCK_MONOTONIC_RAW is truly monotonic, because it | ||
| 120 | // also counts cycles when the system is asleep. Thus, it is the only | ||
| 121 | // acceptable implementation of steady_clock. | ||
| 119 | steady_clock::time_point | 122 | steady_clock::time_point |
| 120 | steady_clock::now() _NOEXCEPT | 123 | steady_clock::now() _NOEXCEPT |
| 121 | { | 124 | { |
| 122 | struct timespec tp; | 125 | struct timespec tp; |
| 123 | if (0 != clock_gettime(CLOCK_UPTIME_RAW, &tp)) | 126 | if (0 != clock_gettime(CLOCK_MONOTONIC_RAW, &tp)) |
| 124 | __throw_system_error(errno, "clock_gettime(CLOCK_UPTIME_RAW) failed"); | 127 | __throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC_RAW) failed"); |
| 125 | return time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec)); | 128 | return time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec)); |
| 126 | } | 129 | } |
| 127 | 130 | ||
| 128 | #else | ||
| 129 | // mach_absolute_time() * MachInfo.numer / MachInfo.denom is the number of | ||
| 130 | // nanoseconds since the computer booted up. MachInfo.numer and MachInfo.denom | ||
| 131 | // are run time constants supplied by the OS. This clock has no relationship | ||
| 132 | // to the Gregorian calendar. It's main use is as a high resolution timer. | ||
| 133 | |||
| 134 | // MachInfo.numer / MachInfo.denom is often 1 on the latest equipment. Specialize | ||
| 135 | // for that case as an optimization. | ||
| 136 | |||
| 137 | static | ||
| 138 | steady_clock::rep | ||
| 139 | steady_simplified() | ||
| 140 | { | ||
| 141 | return static_cast<steady_clock::rep>(mach_absolute_time()); | ||
| 142 | } | ||
| 143 | |||
| 144 | static | ||
| 145 | double | ||
| 146 | compute_steady_factor() | ||
| 147 | { | ||
| 148 | mach_timebase_info_data_t MachInfo; | ||
| 149 | mach_timebase_info(&MachInfo); | ||
| 150 | return static_cast<double>(MachInfo.numer) / MachInfo.denom; | ||
| 151 | } | ||
| 152 | |||
| 153 | static | ||
| 154 | steady_clock::rep | ||
| 155 | steady_full() | ||
| 156 | { | ||
| 157 | static const double factor = compute_steady_factor(); | ||
| 158 | return static_cast<steady_clock::rep>(mach_absolute_time() * factor); | ||
| 159 | } | ||
| 160 | |||
| 161 | typedef steady_clock::rep (*FP)(); | ||
| 162 | |||
| 163 | static | ||
| 164 | FP | ||
| 165 | init_steady_clock() | ||
| 166 | { | ||
| 167 | mach_timebase_info_data_t MachInfo; | ||
| 168 | mach_timebase_info(&MachInfo); | ||
| 169 | if (MachInfo.numer == MachInfo.denom) | ||
| 170 | return &steady_simplified; | ||
| 171 | return &steady_full; | ||
| 172 | } | ||
| 173 | |||
| 174 | steady_clock::time_point | ||
| 175 | steady_clock::now() _NOEXCEPT | ||
| 176 | { | ||
| 177 | static FP fp = init_steady_clock(); | ||
| 178 | return time_point(duration(fp())); | ||
| 179 | } | ||
| 180 | #endif // defined(_LIBCPP_USE_CLOCK_GETTIME) && defined(CLOCK_UPTIME_RAW) | ||
| 181 | |||
| 182 | #elif defined(_LIBCPP_WIN32API) | 131 | #elif defined(_LIBCPP_WIN32API) |
| 183 | 132 | ||
| 184 | // https://msdn.microsoft.com/en-us/library/windows/desktop/ms644905(v=vs.85).aspx says: | 133 | // https://msdn.microsoft.com/en-us/library/windows/desktop/ms644905(v=vs.85).aspx says: |
| ... | @@ -206,13 +155,6 @@ steady_clock::now() _NOEXCEPT | ... | @@ -206,13 +155,6 @@ steady_clock::now() _NOEXCEPT |
| 206 | 155 | ||
| 207 | #elif defined(CLOCK_MONOTONIC) | 156 | #elif defined(CLOCK_MONOTONIC) |
| 208 | 157 | ||
| 209 | // On Apple platforms only CLOCK_UPTIME_RAW or mach_absolute_time are able to | ||
| 210 | // time functions in the nanosecond range. Thus, they are the only acceptable | ||
| 211 | // implementations of steady_clock. | ||
| 212 | #ifdef __APPLE__ | ||
| 213 | #error "Never use CLOCK_MONOTONIC for steady_clock::now on Apple platforms" | ||
| 214 | #endif | ||
| 215 | |||
| 216 | steady_clock::time_point | 158 | steady_clock::time_point |
| 217 | steady_clock::now() _NOEXCEPT | 159 | steady_clock::now() _NOEXCEPT |
| 218 | { | 160 | { |
| ... | @@ -223,7 +165,7 @@ steady_clock::now() _NOEXCEPT | ... | @@ -223,7 +165,7 @@ steady_clock::now() _NOEXCEPT |
| 223 | } | 165 | } |
| 224 | 166 | ||
| 225 | #else | 167 | #else |
| 226 | #error "Monotonic clock not implemented" | 168 | # error "Monotonic clock not implemented" |
| 227 | #endif | 169 | #endif |
| 228 | 170 | ||
| 229 | #endif // !_LIBCPP_HAS_NO_MONOTONIC_CLOCK | 171 | #endif // !_LIBCPP_HAS_NO_MONOTONIC_CLOCK |
lib/libcxx/src/filesystem/int128_builtins.cpp created+54| ... | @@ -0,0 +1,54 @@ | ||
| 1 | /*===-- int128_builtins.cpp - Implement __muloti4 --------------------------=== | ||
| 2 | * | ||
| 3 | * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | * See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | * | ||
| 7 | * ===----------------------------------------------------------------------=== | ||
| 8 | * | ||
| 9 | * This file implements __muloti4, and is stolen from the compiler_rt library. | ||
| 10 | * | ||
| 11 | * FIXME: we steal and re-compile it into filesystem, which uses __int128_t, | ||
| 12 | * and requires this builtin when sanitized. See llvm.org/PR30643 | ||
| 13 | * | ||
| 14 | * ===----------------------------------------------------------------------=== | ||
| 15 | */ | ||
| 16 | #include "__config" | ||
| 17 | #include "climits" | ||
| 18 | |||
| 19 | #if !defined(_LIBCPP_HAS_NO_INT128) | ||
| 20 | |||
| 21 | extern "C" __attribute__((no_sanitize("undefined"))) _LIBCPP_FUNC_VIS | ||
| 22 | __int128_t __muloti4(__int128_t a, __int128_t b, int* overflow) { | ||
| 23 | const int N = (int)(sizeof(__int128_t) * CHAR_BIT); | ||
| 24 | const __int128_t MIN = (__int128_t)1 << (N - 1); | ||
| 25 | const __int128_t MAX = ~MIN; | ||
| 26 | *overflow = 0; | ||
| 27 | __int128_t result = a * b; | ||
| 28 | if (a == MIN) { | ||
| 29 | if (b != 0 && b != 1) | ||
| 30 | *overflow = 1; | ||
| 31 | return result; | ||
| 32 | } | ||
| 33 | if (b == MIN) { | ||
| 34 | if (a != 0 && a != 1) | ||
| 35 | *overflow = 1; | ||
| 36 | return result; | ||
| 37 | } | ||
| 38 | __int128_t sa = a >> (N - 1); | ||
| 39 | __int128_t abs_a = (a ^ sa) - sa; | ||
| 40 | __int128_t sb = b >> (N - 1); | ||
| 41 | __int128_t abs_b = (b ^ sb) - sb; | ||
| 42 | if (abs_a < 2 || abs_b < 2) | ||
| 43 | return result; | ||
| 44 | if (sa == sb) { | ||
| 45 | if (abs_a > MAX / abs_b) | ||
| 46 | *overflow = 1; | ||
| 47 | } else { | ||
| 48 | if (abs_a > MIN / -abs_b) | ||
| 49 | *overflow = 1; | ||
| 50 | } | ||
| 51 | return result; | ||
| 52 | } | ||
| 53 | |||
| 54 | #endif | ||
lib/libcxx/src/filesystem/operations.cpp+4-8| ... | @@ -36,13 +36,9 @@ | ... | @@ -36,13 +36,9 @@ |
| 36 | #define _LIBCPP_USE_COPYFILE | 36 | #define _LIBCPP_USE_COPYFILE |
| 37 | #endif | 37 | #endif |
| 38 | 38 | ||
| 39 | #if !defined(__APPLE__) | 39 | #if !defined(CLOCK_REALTIME) |
| 40 | #define _LIBCPP_USE_CLOCK_GETTIME | ||
| 41 | #endif | ||
| 42 | |||
| 43 | #if !defined(CLOCK_REALTIME) || !defined(_LIBCPP_USE_CLOCK_GETTIME) | ||
| 44 | #include <sys/time.h> // for gettimeofday and timeval | 40 | #include <sys/time.h> // for gettimeofday and timeval |
| 45 | #endif // !defined(CLOCK_REALTIME) | 41 | #endif // !defined(CLOCK_REALTIME) |
| 46 | 42 | ||
| 47 | #if defined(__ELF__) && defined(_LIBCPP_LINK_RT_LIB) | 43 | #if defined(__ELF__) && defined(_LIBCPP_LINK_RT_LIB) |
| 48 | #pragma comment(lib, "rt") | 44 | #pragma comment(lib, "rt") |
| ... | @@ -490,7 +486,7 @@ const bool _FilesystemClock::is_steady; | ... | @@ -490,7 +486,7 @@ const bool _FilesystemClock::is_steady; |
| 490 | 486 | ||
| 491 | _FilesystemClock::time_point _FilesystemClock::now() noexcept { | 487 | _FilesystemClock::time_point _FilesystemClock::now() noexcept { |
| 492 | typedef chrono::duration<rep> __secs; | 488 | typedef chrono::duration<rep> __secs; |
| 493 | #if defined(_LIBCPP_USE_CLOCK_GETTIME) && defined(CLOCK_REALTIME) | 489 | #if defined(CLOCK_REALTIME) |
| 494 | typedef chrono::duration<rep, nano> __nsecs; | 490 | typedef chrono::duration<rep, nano> __nsecs; |
| 495 | struct timespec tp; | 491 | struct timespec tp; |
| 496 | if (0 != clock_gettime(CLOCK_REALTIME, &tp)) | 492 | if (0 != clock_gettime(CLOCK_REALTIME, &tp)) |
| ... | @@ -502,7 +498,7 @@ _FilesystemClock::time_point _FilesystemClock::now() noexcept { | ... | @@ -502,7 +498,7 @@ _FilesystemClock::time_point _FilesystemClock::now() noexcept { |
| 502 | timeval tv; | 498 | timeval tv; |
| 503 | gettimeofday(&tv, 0); | 499 | gettimeofday(&tv, 0); |
| 504 | return time_point(__secs(tv.tv_sec) + __microsecs(tv.tv_usec)); | 500 | return time_point(__secs(tv.tv_sec) + __microsecs(tv.tv_usec)); |
| 505 | #endif // _LIBCPP_USE_CLOCK_GETTIME && CLOCK_REALTIME | 501 | #endif // CLOCK_REALTIME |
| 506 | } | 502 | } |
| 507 | 503 | ||
| 508 | filesystem_error::~filesystem_error() {} | 504 | filesystem_error::~filesystem_error() {} |
lib/libcxx/src/include/apple_availability.h+8-8| ... | @@ -29,20 +29,20 @@ | ... | @@ -29,20 +29,20 @@ |
| 29 | #endif // __ENVIRONMENT_.*_VERSION_MIN_REQUIRED__ | 29 | #endif // __ENVIRONMENT_.*_VERSION_MIN_REQUIRED__ |
| 30 | 30 | ||
| 31 | #if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) | 31 | #if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) |
| 32 | #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101200 | 32 | #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101500 |
| 33 | #define _LIBCPP_USE_CLOCK_GETTIME | 33 | #define _LIBCPP_USE_ULOCK |
| 34 | #endif | 34 | #endif |
| 35 | #elif defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) | 35 | #elif defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) |
| 36 | #if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 100000 | 36 | #if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 130000 |
| 37 | #define _LIBCPP_USE_CLOCK_GETTIME | 37 | #define _LIBCPP_USE_ULOCK |
| 38 | #endif | 38 | #endif |
| 39 | #elif defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) | 39 | #elif defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) |
| 40 | #if __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 100000 | 40 | #if __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 130000 |
| 41 | #define _LIBCPP_USE_CLOCK_GETTIME | 41 | #define _LIBCPP_USE_ULOCK |
| 42 | #endif | 42 | #endif |
| 43 | #elif defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) | 43 | #elif defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) |
| 44 | #if __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 30000 | 44 | #if __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 60000 |
| 45 | #define _LIBCPP_USE_CLOCK_GETTIME | 45 | #define _LIBCPP_USE_ULOCK |
| 46 | #endif | 46 | #endif |
| 47 | #endif // __ENVIRONMENT_.*_VERSION_MIN_REQUIRED__ | 47 | #endif // __ENVIRONMENT_.*_VERSION_MIN_REQUIRED__ |
| 48 | 48 |
lib/libcxx/src/locale.cpp+2-2| ... | @@ -536,7 +536,7 @@ locale::operator=(const locale& other) _NOEXCEPT | ... | @@ -536,7 +536,7 @@ locale::operator=(const locale& other) _NOEXCEPT |
| 536 | 536 | ||
| 537 | locale::locale(const char* name) | 537 | locale::locale(const char* name) |
| 538 | : __locale_(name ? new __imp(name) | 538 | : __locale_(name ? new __imp(name) |
| 539 | : (__throw_runtime_error("locale constructed with null"), (__imp*)0)) | 539 | : (__throw_runtime_error("locale constructed with null"), nullptr)) |
| 540 | { | 540 | { |
| 541 | __locale_->__add_shared(); | 541 | __locale_->__add_shared(); |
| 542 | } | 542 | } |
| ... | @@ -549,7 +549,7 @@ locale::locale(const string& name) | ... | @@ -549,7 +549,7 @@ locale::locale(const string& name) |
| 549 | 549 | ||
| 550 | locale::locale(const locale& other, const char* name, category c) | 550 | locale::locale(const locale& other, const char* name, category c) |
| 551 | : __locale_(name ? new __imp(*other.__locale_, name, c) | 551 | : __locale_(name ? new __imp(*other.__locale_, name, c) |
| 552 | : (__throw_runtime_error("locale constructed with null"), (__imp*)0)) | 552 | : (__throw_runtime_error("locale constructed with null"), nullptr)) |
| 553 | { | 553 | { |
| 554 | __locale_->__add_shared(); | 554 | __locale_->__add_shared(); |
| 555 | } | 555 | } |
lib/libcxx/src/random_shuffle.cpp created+61| ... | @@ -0,0 +1,61 @@ | ||
| 1 | //===----------------------- random_shuffle.cpp ---------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #include "algorithm" | ||
| 10 | #include "random" | ||
| 11 | #ifndef _LIBCPP_HAS_NO_THREADS | ||
| 12 | # include "mutex" | ||
| 13 | # if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB) | ||
| 14 | # pragma comment(lib, "pthread") | ||
| 15 | # endif | ||
| 16 | #endif | ||
| 17 | |||
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 19 | |||
| 20 | #ifndef _LIBCPP_HAS_NO_THREADS | ||
| 21 | _LIBCPP_SAFE_STATIC static __libcpp_mutex_t __rs_mut = _LIBCPP_MUTEX_INITIALIZER; | ||
| 22 | #endif | ||
| 23 | unsigned __rs_default::__c_ = 0; | ||
| 24 | |||
| 25 | __rs_default::__rs_default() | ||
| 26 | { | ||
| 27 | #ifndef _LIBCPP_HAS_NO_THREADS | ||
| 28 | __libcpp_mutex_lock(&__rs_mut); | ||
| 29 | #endif | ||
| 30 | __c_ = 1; | ||
| 31 | } | ||
| 32 | |||
| 33 | __rs_default::__rs_default(const __rs_default&) | ||
| 34 | { | ||
| 35 | ++__c_; | ||
| 36 | } | ||
| 37 | |||
| 38 | __rs_default::~__rs_default() | ||
| 39 | { | ||
| 40 | #ifndef _LIBCPP_HAS_NO_THREADS | ||
| 41 | if (--__c_ == 0) | ||
| 42 | __libcpp_mutex_unlock(&__rs_mut); | ||
| 43 | #else | ||
| 44 | --__c_; | ||
| 45 | #endif | ||
| 46 | } | ||
| 47 | |||
| 48 | __rs_default::result_type | ||
| 49 | __rs_default::operator()() | ||
| 50 | { | ||
| 51 | static mt19937 __rs_g; | ||
| 52 | return __rs_g(); | ||
| 53 | } | ||
| 54 | |||
| 55 | __rs_default | ||
| 56 | __rs_get() | ||
| 57 | { | ||
| 58 | return __rs_default(); | ||
| 59 | } | ||
| 60 | |||
| 61 | _LIBCPP_END_NAMESPACE_STD | ||
lib/libcxx/src/string.cpp+7-2| ... | @@ -20,8 +20,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -20,8 +20,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | ||
| 21 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __basic_string_common<true>; | 21 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __basic_string_common<true>; |
| 22 | 22 | ||
| 23 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_string<char>; | 23 | #ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION |
| 24 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_string<wchar_t>; | 24 | _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, char) |
| 25 | _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, wchar_t) | ||
| 26 | #else | ||
| 27 | _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, char) | ||
| 28 | _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, wchar_t) | ||
| 29 | #endif | ||
| 25 | 30 | ||
| 26 | template | 31 | template |
| 27 | string | 32 | string |
lib/libcxx/src/thread.cpp+3-3| ... | @@ -23,9 +23,9 @@ | ... | @@ -23,9 +23,9 @@ |
| 23 | # endif | 23 | # endif |
| 24 | #endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) | 24 | #endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) |
| 25 | 25 | ||
| 26 | #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__CloudABI__) || defined(__Fuchsia__) || defined(__wasi__) | 26 | #if __has_include(<unistd.h>) |
| 27 | # include <unistd.h> | 27 | #include <unistd.h> |
| 28 | #endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__CloudABI__) || defined(__Fuchsia__) || defined(__wasi__) | 28 | #endif |
| 29 | 29 | ||
| 30 | #if defined(__NetBSD__) | 30 | #if defined(__NetBSD__) |
| 31 | #pragma weak pthread_create // Do not create libpthread dependency | 31 | #pragma weak pthread_create // Do not create libpthread dependency |