authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-08-04 17:26:02-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-08-04 17:26:02-07:00
log54b67c20259f697f1e0c4532a5ee7e5d3f01eb1e
treed91b41ddd5dd4b9b941691722ce6427b3b82fe59
parent16513fee6c9c229e40f5abd82220a6f30e8e2180

libcxx: update from LLVM 10 to 11rc1


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) _NOEXCEPT1122 __bit_iterator(const __type_for_copy_to_const& __it) _NOEXCEPT
1123 : __seg_(__it.__seg_), __ctz_(__it.__ctz_) {}1123 : __seg_(__it.__seg_), __ctz_(__it.__ctz_) {}
11241124
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 _NOEXCEPT1140 _LIBCPP_INLINE_VISIBILITY reference operator*() const _NOEXCEPT
1126 {return reference(__seg_, __storage_type(1) << __ctz_);}1141 {return reference(__seg_, __storage_type(1) << __ctz_);}
11271142
lib/libcxx/include/__config+71-42
...@@ -32,7 +32,7 @@...@@ -32,7 +32,7 @@
32# define _GNUC_VER_NEW 032# define _GNUC_VER_NEW 0
33#endif33#endif
3434
35#define _LIBCPP_VERSION 1000035#define _LIBCPP_VERSION 11000
3636
37#ifndef _LIBCPP_ABI_VERSION37#ifndef _LIBCPP_ABI_VERSION
38# define _LIBCPP_ABI_VERSION 138# define _LIBCPP_ABI_VERSION 1
...@@ -102,6 +102,9 @@...@@ -102,6 +102,9 @@
102# define _LIBCPP_ABI_OPTIMIZED_FUNCTION102# 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_NONZERO104# 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 == 1108#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 support110// Enable compiling copies of now inline methods into the dylib to support
...@@ -395,12 +398,12 @@...@@ -395,12 +398,12 @@
395398
396#if defined(_LIBCPP_COMPILER_CLANG)399#if defined(_LIBCPP_COMPILER_CLANG)
397400
398// _LIBCPP_ALTERNATE_STRING_LAYOUT is an old name for401#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_LAYOUT406# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
404#endif407#endif
405408
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;
416typedef __char32_t char32_t;419typedef __char32_t char32_t;
417#endif420#endif
418421
419#if !(__has_feature(cxx_exceptions)) && !defined(_LIBCPP_NO_EXCEPTIONS)422#if !__has_feature(cxx_exceptions)
420#define _LIBCPP_NO_EXCEPTIONS423# define _LIBCPP_NO_EXCEPTIONS
421#endif
422
423#if !(__has_feature(cxx_rtti)) && !defined(_LIBCPP_NO_RTTI)
424#define _LIBCPP_NO_RTTI
425#endif424#endif
426425
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_WEAK466#define _LIBCPP_HAS_OBJC_ARC_WEAK
468#endif467#endif
469468
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_CONSTEXPR478#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
472#endif479#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_LAUNDER499#define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER
493#endif500#endif
494501
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_REPRESENTATIONS507#define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS
497#endif508#endif
...@@ -513,8 +524,8 @@ typedef __char32_t char32_t;...@@ -513,8 +524,8 @@ typedef __char32_t char32_t;
513524
514#define _LIBCPP_NORETURN __attribute__((noreturn))525#define _LIBCPP_NORETURN __attribute__((noreturn))
515526
516#if !__EXCEPTIONS && !defined(_LIBCPP_NO_EXCEPTIONS)527#if !__EXCEPTIONS
517#define _LIBCPP_NO_EXCEPTIONS528# define _LIBCPP_NO_EXCEPTIONS
518#endif529#endif
519530
520// Determine if GCC supports relaxed constexpr531// Determine if GCC supports relaxed constexpr
...@@ -533,9 +544,7 @@ typedef __char32_t char32_t;...@@ -533,9 +544,7 @@ typedef __char32_t char32_t;
533544
534#if _GNUC_VER >= 700545#if _GNUC_VER >= 700
535#define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER546#define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER
536#endif547#define _LIBCPP_COMPILER_HAS_BUILTIN_CONSTANT_P
537
538#if _GNUC_VER >= 700
539#define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS548#define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS
540#endif549#endif
541550
...@@ -745,14 +754,14 @@ typedef __char32_t char32_t;...@@ -745,14 +754,14 @@ typedef __char32_t char32_t;
745# endif754# endif
746#endif755#endif
747756
748#ifndef _LIBCPP_HAS_MERGED_TYPEINFO_NAMES_DEFAULT757#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 0759# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 2
751#else760# else
752// TODO: This isn't strictly correct on ELF platforms due to llvm.org/PR37398761 // 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 1763# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 1
755#endif764# endif
756#endif765#endif
757766
758#ifndef _LIBCPP_HIDE_FROM_ABI767#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#endif911#endif
903912
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 1919#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#endif1105#endif
10931106
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#endif1114#endif
11071115
1108#ifndef _LIBCPP_WEAK1116#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_PTHREAD1134# define _LIBCPP_HAS_THREAD_API_PTHREAD
1127# elif defined(__Fuchsia__)1135# elif defined(__Fuchsia__)
1128# define _LIBCPP_HAS_THREAD_API_C111136 // 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_WIN321139# define _LIBCPP_HAS_THREAD_API_WIN32
1131# else1140# 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(
13601369
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_ACCESS1395 _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#else1438#else
1425# define _LIBCPP_AVAILABILITY_SHARED_MUTEX1439# define _LIBCPP_AVAILABILITY_SHARED_MUTEX
1426# define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS1440# 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_FILESYSTEM1449# define _LIBCPP_AVAILABILITY_FILESYSTEM
1436# define _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH1450# define _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH
1437# define _LIBCPP_AVAILABILITY_FILESYSTEM_POP1451# define _LIBCPP_AVAILABILITY_FILESYSTEM_POP
1452# define _LIBCPP_AVAILABILITY_TO_CHARS
1453# define _LIBCPP_AVAILABILITY_SYNC
1438#endif1454#endif
14391455
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_MODE1534# define _LIBCPP_FOPEN_CLOEXEC_MODE
1519#endif1535#endif
15201536
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 // __cplusplus1550#endif // __cplusplus
15221551
1523#endif // _LIBCPP_CONFIG1552#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_EXTERNAL27#cmakedefine _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL
28#cmakedefine _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS28#cmakedefine _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS
29#cmakedefine _LIBCPP_NO_VCRUNTIME29#cmakedefine _LIBCPP_NO_VCRUNTIME
30#cmakedefine01 _LIBCPP_HAS_MERGED_TYPEINFO_NAMES_DEFAULT30#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_ALGORITHMS34#cmakedefine _LIBCPP_HAS_PARALLEL_ALGORITHMS
3335
lib/libcxx/include/__functional_base+2-2
...@@ -522,7 +522,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -522,7 +522,7 @@ inline _LIBCPP_INLINE_VISIBILITY
522reference_wrapper<_Tp>522reference_wrapper<_Tp>
523ref(reference_wrapper<_Tp> __t) _NOEXCEPT523ref(reference_wrapper<_Tp> __t) _NOEXCEPT
524{524{
525 return ref(__t.get());525 return _VSTD::ref(__t.get());
526}526}
527527
528template <class _Tp>528template <class _Tp>
...@@ -538,7 +538,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -538,7 +538,7 @@ inline _LIBCPP_INLINE_VISIBILITY
538reference_wrapper<const _Tp>538reference_wrapper<const _Tp>
539cref(reference_wrapper<_Tp> __t) _NOEXCEPT539cref(reference_wrapper<_Tp> __t) _NOEXCEPT
540{540{
541 return cref(__t.get());541 return _VSTD::cref(__t.get());
542}542}
543543
544#ifndef _LIBCPP_CXX03_LANG544#ifndef _LIBCPP_CXX03_LANG
lib/libcxx/include/__libcpp_version+1-1
...@@ -1 +1 @@...@@ -1 +1 @@
110000111000
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#endif506#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
7070
71_LIBCPP_BEGIN_NAMESPACE_STD71_LIBCPP_BEGIN_NAMESPACE_STD
7272
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_traits190// char_traits
74191
75template <class _CharT>192template <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#endif37#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;
65typedef pthread_cond_t __libcpp_condvar_t;71typedef pthread_cond_t __libcpp_condvar_t;
66#define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER72#define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER
6773
74#ifndef _LIBCPP_NO_NATIVE_SEMAPHORES
75// Semaphore
76typedef sem_t __libcpp_semaphore_t;
77# define _LIBCPP_SEMAPHORE_MAX SEM_VALUE_MAX
78#endif
79
68// Execute once80// Execute once
69typedef pthread_once_t __libcpp_exec_once_flag;81typedef pthread_once_t __libcpp_exec_once_flag;
70#define _LIBCPP_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT82#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];
127typedef void* __libcpp_condvar_t;139typedef void* __libcpp_condvar_t;
128#define _LIBCPP_CONDVAR_INITIALIZER 0140#define _LIBCPP_CONDVAR_INITIALIZER 0
129141
142// Semaphore
143typedef void* __libcpp_semaphore_t;
144
130// Execute Once145// Execute Once
131typedef void* __libcpp_exec_once_flag;146typedef void* __libcpp_exec_once_flag;
132#define _LIBCPP_EXEC_ONCE_INITIALIZER 0147#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_VISIBILITY206_LIBCPP_THREAD_ABI_VISIBILITY
192int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv);207int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv);
193208
209#ifndef _LIBCPP_NO_NATIVE_SEMAPHORES
210
211// Semaphore
212_LIBCPP_THREAD_ABI_VISIBILITY
213bool __libcpp_semaphore_init(__libcpp_semaphore_t* __sem, int __init);
214
215_LIBCPP_THREAD_ABI_VISIBILITY
216bool __libcpp_semaphore_destroy(__libcpp_semaphore_t* __sem);
217
218_LIBCPP_THREAD_ABI_VISIBILITY
219bool __libcpp_semaphore_post(__libcpp_semaphore_t* __sem);
220
221_LIBCPP_THREAD_ABI_VISIBILITY
222bool __libcpp_semaphore_wait(__libcpp_semaphore_t* __sem);
223
224_LIBCPP_THREAD_ABI_VISIBILITY
225bool __libcpp_semaphore_wait_timed(__libcpp_semaphore_t* __sem, chrono::nanoseconds const& __ns);
226
227#endif // _LIBCPP_NO_NATIVE_SEMAPHORES
228
194// Execute once229// Execute once
195_LIBCPP_THREAD_ABI_VISIBILITY230_LIBCPP_THREAD_ABI_VISIBILITY
196int __libcpp_execute_once(__libcpp_exec_once_flag *flag,231int __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);
242277
243#endif // !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)278#endif // !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
244279
280struct __libcpp_timed_backoff_policy {
281 _LIBCPP_THREAD_ABI_VISIBILITY
282 bool operator()(chrono::nanoseconds __elapsed) const;
283};
284
285inline _LIBCPP_INLINE_VISIBILITY
286bool __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
299static _LIBCPP_CONSTEXPR const int __libcpp_polling_count = 64;
300
301template<class _Fn, class _BFn>
302_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
303bool __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))
247324
325
248namespace __thread_detail {326namespace __thread_detail {
249327
250inline __libcpp_timespec_t __convert_to_timespec(const chrono::nanoseconds& __ns)328inline __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}
366444
445#ifndef _LIBCPP_NO_NATIVE_SEMAPHORES
446
447// Semaphore
448bool __libcpp_semaphore_init(__libcpp_semaphore_t* __sem, int __init)
449{
450 return sem_init(__sem, 0, __init) == 0;
451}
452
453bool __libcpp_semaphore_destroy(__libcpp_semaphore_t* __sem)
454{
455 return sem_destroy(__sem) == 0;
456}
457
458bool __libcpp_semaphore_post(__libcpp_semaphore_t* __sem)
459{
460 return sem_post(__sem) == 0;
461}
462
463bool __libcpp_semaphore_wait(__libcpp_semaphore_t* __sem)
464{
465 return sem_wait(__sem) == 0;
466}
467
468bool __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 once477// Execute once
368int __libcpp_execute_once(__libcpp_exec_once_flag *flag,478int __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)
600710
601#endif711#endif
602712
713
603#endif // !_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL || _LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL714#endif // !_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL || _LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL
604715
605class _LIBCPP_TYPE_VIS thread;716class _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;
3333
34 // No explicit construct/copy/destroy for aggregate type34 // 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
3737
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
4343
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
4848
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
5353
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;
5858
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++1461 const_reference operator[](size_type n) const; // constexpr in C++14
62 const_reference at(size_type n) const; // constexpr in C++1462 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
6464
65 reference front();65 reference front(); // constexpr in C++17
66 const_reference front() const; // constexpr in C++1466 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++1468 const_reference back() const; // constexpr in C++14
6969
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};
7373
74 template <class T, class... U>74template <class T, class... U>
75 array(T, U...) -> array<T, 1 + sizeof...(U)>;75 array(T, U...) -> array<T, 1 + sizeof...(U)>; // C++17
7676
77template <class T, size_t N>77template <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
79template <class T, size_t N>79template <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
81template <class T, size_t N>81template <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
83template <class T, size_t N>83template <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
85template <class T, size_t N>85template <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
87template <class T, size_t N>87template <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
8989
90template <class T, size_t N >90template <class T, size_t N >
91 void swap(array<T,N>& x, array<T,N>& y) noexcept(noexcept(x.swap(y))); // C++1791 void swap(array<T,N>& x, array<T,N>& y) noexcept(noexcept(x.swap(y))); // constexpr in C++20
92
93template <class T, size_t N>
94 constexpr array<remove_cv_t<T>, N> to_array(T (&a)[N]); // C++20
95template <class T, size_t N>
96 constexpr array<remove_cv_t<T>, N> to_array(T (&&a)[N]); // C++20
9297
93template <class T> struct tuple_size;98template <class T> struct tuple_size;
94template <size_t I, class T> struct tuple_element;99template <size_t I, class T> struct tuple_element;
95template <class T, size_t N> struct tuple_size<array<T, N>>;100template <class T, size_t N> struct tuple_size<array<T, N>>;
96template <size_t I, class T, size_t N> struct tuple_element<I, array<T, N>>;101template <size_t I, class T, size_t N> struct tuple_element<I, array<T, N>>;
97template <size_t I, class T, size_t N> T& get(array<T, N>&) noexcept; // constexpr in C++14102template <size_t I, class T, size_t N> T& get(array<T, N>&) noexcept; // constexpr in C++14
98template <size_t I, class T, size_t N> const T& get(const array<T, N>&) noexcept; // constexpr in C++14103template <size_t I, class T, size_t N> const T& get(const array<T, N>&) noexcept; // constexpr in C++14
99template <size_t I, class T, size_t N> T&& get(array<T, N>&&) noexcept; // constexpr in C++14104template <size_t I, class T, size_t N> T&& get(array<T, N>&&) noexcept; // constexpr in C++14
100template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexcept; // constexpr in C++14105template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexcept; // constexpr in C++14
101106
102} // std107} // 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];
144149
145 // No explicit construct/copy/destroy for aggregate type150 // 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 }
149155
150 _LIBCPP_INLINE_VISIBILITY156 _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 }
154160
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_VISIBILITY192 _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_VISIBILITY194 _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;}
190196
191 // element access:197 // element access:
192 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14198 _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_CXX11203 _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 }
196208
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 }
199215
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];}
204227
205 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14228 _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};
210233
211
212template <class _Tp, size_t _Size>
213_LIBCPP_CONSTEXPR_AFTER_CXX14
214typename array<_Tp, _Size>::reference
215array<_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
223template <class _Tp, size_t _Size>
224_LIBCPP_CONSTEXPR_AFTER_CXX11
225typename array<_Tp, _Size>::const_reference
226array<_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
233template <class _Tp>234template <class _Tp>
234struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0>235struct _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)];
255256
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 type262 // 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 }
261268
262 _LIBCPP_INLINE_VISIBILITY269 _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 }
267274
268 // iterators:275 // iterators:
269 _LIBCPP_INLINE_VISIBILITY276 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
270 iterator begin() _NOEXCEPT {return iterator(data());}277 iterator begin() _NOEXCEPT {return iterator(data());}
271 _LIBCPP_INLINE_VISIBILITY278 _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_VISIBILITY280 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
274 iterator end() _NOEXCEPT {return iterator(data());}281 iterator end() _NOEXCEPT {return iterator(data());}
275 _LIBCPP_INLINE_VISIBILITY282 _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());}
277284
278 _LIBCPP_INLINE_VISIBILITY285 _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_VISIBILITY287 _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_VISIBILITY289 _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_VISIBILITY291 _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());}
286293
287 _LIBCPP_INLINE_VISIBILITY294 _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_VISIBILITY296 _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_VISIBILITY298 _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_VISIBILITY300 _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();}
295302
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;}
303310
304 // element access:311 // element access:
305 _LIBCPP_INLINE_VISIBILITY312 _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 }
316323
317 _LIBCPP_INLINE_VISIBILITY324 _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 }
322329
323 _LIBCPP_INLINE_VISIBILITY330 _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 }
328335
329 _LIBCPP_INLINE_VISIBILITY336 _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 }
334341
335 _LIBCPP_INLINE_VISIBILITY342 _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 }
340347
341 _LIBCPP_INLINE_VISIBILITY348 _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 }
346353
347 _LIBCPP_INLINE_VISIBILITY354 _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};
358360
359361
360#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES362#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
361template<class _Tp, class... _Args,363template<class _Tp, class... _Args,
362 class = typename enable_if<(is_same_v<_Tp, _Args> && ...), void>::type364 class = _EnableIf<__all<_IsSame<_Tp, _Args>::value...>::value>
363 >365 >
364array(_Tp, _Args...)366array(_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}
416418
417template <class _Tp, size_t _Size>419template <class _Tp, size_t _Size>
418inline _LIBCPP_INLINE_VISIBILITY420inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
419typename enable_if421typename 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
479481
480#endif // !_LIBCPP_CXX03_LANG482#endif // !_LIBCPP_CXX03_LANG
481483
484#if _LIBCPP_STD_VER > 17
485
486template <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
492template <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
498template <typename _Tp, size_t _Size>
499_LIBCPP_INLINE_VISIBILITY constexpr array<remove_cv_t<_Tp>, _Size>
500to_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
510template <typename _Tp, size_t _Size>
511_LIBCPP_INLINE_VISIBILITY constexpr array<remove_cv_t<_Tp>, _Size>
512to_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_STD525_LIBCPP_END_NAMESPACE_STD
483526
484#endif // _LIBCPP_ARRAY527#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 unspecified54#define ATOMIC_LLONG_LOCK_FREE unspecified
55#define ATOMIC_POINTER_LOCK_FREE unspecified55#define ATOMIC_POINTER_LOCK_FREE unspecified
5656
57// flag type and operations
58
59typedef 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
71bool
72 atomic_flag_test_and_set(volatile atomic_flag* obj) noexcept;
73
74bool
75 atomic_flag_test_and_set(atomic_flag* obj) noexcept;
76
77bool
78 atomic_flag_test_and_set_explicit(volatile atomic_flag* obj,
79 memory_order m) noexcept;
80
81bool
82 atomic_flag_test_and_set_explicit(atomic_flag* obj, memory_order m) noexcept;
83
84void
85 atomic_flag_clear(volatile atomic_flag* obj) noexcept;
86
87void
88 atomic_flag_clear(atomic_flag* obj) noexcept;
89
90void
91 atomic_flag_clear_explicit(volatile atomic_flag* obj, memory_order m) noexcept;
92
93void
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
99template <class T>57template <class T>
100struct atomic58struct 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;
12898
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};
137106
138template <>107template <>
139struct atomic<integral>108struct 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;
169150
170 integral151 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 integral153 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 integral155 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 integral157 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 integral159 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;
185161
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};
213188
214template <class T>189template <class T>
215struct atomic<T*>190struct 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;
248235
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};
270256
271257
272template <class T>258template <class T>
273 bool259 bool atomic_is_lock_free(const volatile atomic<T>* obj) noexcept;
274 atomic_is_lock_free(const volatile atomic<T>* obj) noexcept;260
261template <class T>
262 bool atomic_is_lock_free(const atomic<T>* obj) noexcept;
263
264template <class T>
265 void atomic_store(volatile atomic<T>* obj, T desr) noexcept;
266
267template <class T>
268 void atomic_store(atomic<T>* obj, T desr) noexcept;
269
270template <class T>
271 void atomic_store_explicit(volatile atomic<T>* obj, T desr, memory_order m) noexcept;
272
273template <class T>
274 void atomic_store_explicit(atomic<T>* obj, T desr, memory_order m) noexcept;
275
276template <class T>
277 T atomic_load(const volatile atomic<T>* obj) noexcept;
275278
276template <class T>279template <class T>
277 bool280 T atomic_load(const atomic<T>* obj) noexcept;
278 atomic_is_lock_free(const atomic<T>* obj) noexcept;
279281
280template <class T>282template <class T>
281 void283 T atomic_load_explicit(const volatile atomic<T>* obj, memory_order m) noexcept;
282 atomic_init(volatile atomic<T>* obj, T desr) noexcept;
283284
284template <class T>285template <class T>
285 void286 T atomic_load_explicit(const atomic<T>* obj, memory_order m) noexcept;
286 atomic_init(atomic<T>* obj, T desr) noexcept;
287287
288template <class T>288template <class T>
289 void289 T atomic_exchange(volatile atomic<T>* obj, T desr) noexcept;
290 atomic_store(volatile atomic<T>* obj, T desr) noexcept;
291290
292template <class T>291template <class T>
293 void292 T atomic_exchange(atomic<T>* obj, T desr) noexcept;
294 atomic_store(atomic<T>* obj, T desr) noexcept;
295293
296template <class T>294template <class T>
297 void295 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;
299296
300template <class T>297template <class T>
301 void298 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;
303299
304template <class T>300template <class T>
305 T301 bool atomic_compare_exchange_weak(volatile atomic<T>* obj, T* expc, T desr) noexcept;
306 atomic_load(const volatile atomic<T>* obj) noexcept;
307302
308template <class T>303template <class T>
309 T304 bool atomic_compare_exchange_weak(atomic<T>* obj, T* expc, T desr) noexcept;
310 atomic_load(const atomic<T>* obj) noexcept;
311305
312template <class T>306template <class T>
313 T307 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;
315308
316template <class T>309template <class T>
317 T310 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;
319311
320template <class T>312template <class T>
321 T313 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;
323316
324template <class T>317template <class T>
325 T318 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;
327320
328template <class T>321template <class T>
329 T322 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;
331325
332template <class T>326template <class T>
333 T327 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;
335330
336template <class T>331template <class T>
337 bool332 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;
339333
340template <class T>334template <class T>
341 bool335 void atomic_wait(const atomic<T>* obj, T old) noexcept;
342 atomic_compare_exchange_weak(atomic<T>* obj, T* expc, T desr) noexcept;
343336
344template <class T>337template <class T>
345 bool338 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;
347339
348template <class T>340template <class T>
349 bool341 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;
351342
352template <class T>343template <class T>
353 bool344 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;
357345
358template <class T>346template <class T>
359 bool347 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;
362348
363template <class T>349template <class T>
364 bool350 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;
368351
369template <class T>352template <class T>
370 bool353 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;
374354
375template <class Integral>355template <class Integral>
376 Integral356 Integral atomic_fetch_add(volatile atomic<Integral>* obj, Integral op) noexcept;
377 atomic_fetch_add(volatile atomic<Integral>* obj, Integral op) noexcept;
378357
379template <class Integral>358template <class Integral>
380 Integral359 Integral atomic_fetch_add(atomic<Integral>* obj, Integral op) noexcept;
381 atomic_fetch_add(atomic<Integral>* obj, Integral op) noexcept;
382360
383template <class Integral>361template <class Integral>
384 Integral362 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;
387template <class Integral>364template <class Integral>
388 Integral365 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;
391template <class Integral>367template <class Integral>
392 Integral368 Integral atomic_fetch_sub(volatile atomic<Integral>* obj, Integral op) noexcept;
393 atomic_fetch_sub(volatile atomic<Integral>* obj, Integral op) noexcept;
394369
395template <class Integral>370template <class Integral>
396 Integral371 Integral atomic_fetch_sub(atomic<Integral>* obj, Integral op) noexcept;
397 atomic_fetch_sub(atomic<Integral>* obj, Integral op) noexcept;
398372
399template <class Integral>373template <class Integral>
400 Integral374 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
403template <class Integral>377template <class Integral>
404 Integral378 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
407template <class Integral>381template <class Integral>
408 Integral382 Integral atomic_fetch_and(volatile atomic<Integral>* obj, Integral op) noexcept;
409 atomic_fetch_and(volatile atomic<Integral>* obj, Integral op) noexcept;
410383
411template <class Integral>384template <class Integral>
412 Integral385 Integral atomic_fetch_and(atomic<Integral>* obj, Integral op) noexcept;
413 atomic_fetch_and(atomic<Integral>* obj, Integral op) noexcept;
414386
415template <class Integral>387template <class Integral>
416 Integral388 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
419template <class Integral>391template <class Integral>
420 Integral392 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
423template <class Integral>395template <class Integral>
424 Integral396 Integral atomic_fetch_or(volatile atomic<Integral>* obj, Integral op) noexcept;
425 atomic_fetch_or(volatile atomic<Integral>* obj, Integral op) noexcept;
426397
427template <class Integral>398template <class Integral>
428 Integral399 Integral atomic_fetch_or(atomic<Integral>* obj, Integral op) noexcept;
429 atomic_fetch_or(atomic<Integral>* obj, Integral op) noexcept;
430400
431template <class Integral>401template <class Integral>
432 Integral402 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
435template <class Integral>405template <class Integral>
436 Integral406 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
439template <class Integral>409template <class Integral>
440 Integral410 Integral atomic_fetch_xor(volatile atomic<Integral>* obj, Integral op) noexcept;
441 atomic_fetch_xor(volatile atomic<Integral>* obj, Integral op) noexcept;
442411
443template <class Integral>412template <class Integral>
444 Integral413 Integral atomic_fetch_xor(atomic<Integral>* obj, Integral op) noexcept;
445 atomic_fetch_xor(atomic<Integral>* obj, Integral op) noexcept;
446414
447template <class Integral>415template <class Integral>
448 Integral416 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
451template <class Integral>419template <class Integral>
452 Integral420 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;
455422
456template <class T>423template <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;
459425
460template <class T>426template <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;
463428
464template <class T>429template <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
468template <class T>433template <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;
471435
472template <class T>436template <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;
475438
476template <class T>439template <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;
479441
480template <class T>442template <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
484template <class T>446template <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;
487448
488// Atomics for standard typedef types449// Atomics for standard typedef types
489450
...@@ -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;
516typedef atomic<uint_fast8_t> atomic_uint_fast8_t;477typedef atomic<uint_fast8_t> atomic_uint_fast8_t;
517typedef atomic<int_fast16_t> atomic_int_fast16_t;478typedef atomic<int_fast16_t> atomic_int_fast16_t;
518typedef atomic<uint_fast16_t> atomic_uint_fast16_t;479typedef atomic<uint_fast16_t> atomic_uint_fast16_t;
519typedef atomic<int_fast32_t> atomic_int_fast32_t;480typedef atomic<int_fast32_t> atomic_int_fast32_t;
520typedef atomic<uint_fast32_t> atomic_uint_fast32_t;481typedef atomic<uint_fast32_t> atomic_uint_fast32_t;
521typedef atomic<int_fast64_t> atomic_int_fast64_t;482typedef atomic<int_fast64_t> atomic_int_fast64_t;
522typedef atomic<uint_fast64_t> atomic_uint_fast64_t;483typedef 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;
537typedef atomic<intmax_t> atomic_intmax_t;498typedef atomic<intmax_t> atomic_intmax_t;
538typedef atomic<uintmax_t> atomic_uintmax_t;499typedef atomic<uintmax_t> atomic_uintmax_t;
539500
501// flag type and operations
502
503typedef 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
525bool atomic_flag_test(volatile atomic_flag* obj) noexcept;
526bool atomic_flag_test(atomic_flag* obj) noexcept;
527bool atomic_flag_test_explicit(volatile atomic_flag* obj,
528 memory_order m) noexcept;
529bool atomic_flag_test_explicit(atomic_flag* obj, memory_order m) noexcept;
530bool atomic_flag_test_and_set(volatile atomic_flag* obj) noexcept;
531bool atomic_flag_test_and_set(atomic_flag* obj) noexcept;
532bool atomic_flag_test_and_set_explicit(volatile atomic_flag* obj,
533 memory_order m) noexcept;
534bool atomic_flag_test_and_set_explicit(atomic_flag* obj, memory_order m) noexcept;
535void atomic_flag_clear(volatile atomic_flag* obj) noexcept;
536void atomic_flag_clear(atomic_flag* obj) noexcept;
537void atomic_flag_clear_explicit(volatile atomic_flag* obj, memory_order m) noexcept;
538void atomic_flag_clear_explicit(atomic_flag* obj, memory_order m) noexcept;
539
540void atomic_wait(const volatile atomic_flag* obj, T old) noexcept;
541void atomic_wait(const atomic_flag* obj, T old) noexcept;
542void atomic_wait_explicit(const volatile atomic_flag* obj, T old, memory_order m) noexcept;
543void atomic_wait_explicit(const atomic_flag* obj, T old, memory_order m) noexcept;
544void atomic_one(volatile atomic_flag* obj) noexcept;
545void atomic_one(atomic_flag* obj) noexcept;
546void atomic_all(volatile atomic_flag* obj) noexcept;
547void atomic_all(atomic_flag* obj) noexcept;
548
540// fences549// fences
541550
542void atomic_thread_fence(memory_order m) noexcept;551void atomic_thread_fence(memory_order m) noexcept;
543void atomic_signal_fence(memory_order m) noexcept;552void atomic_signal_fence(memory_order m) noexcept;
544553
554// deprecated
555
556template <class T>
557 void atomic_init(volatile atomic<T>* obj, typename atomic<T>::value_type desr) noexcept;
558
559template <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} // std566} // std
546567
547*/568*/
548569
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>
554577
...@@ -629,6 +652,11 @@ typedef enum memory_order {...@@ -629,6 +652,11 @@ typedef enum memory_order {
629652
630#endif // _LIBCPP_STD_VER > 17653#endif // _LIBCPP_STD_VER > 17
631654
655template <typename _Tp> _LIBCPP_INLINE_VISIBILITY
656bool __cxx_nonatomic_compare_equal(_Tp const& __lhs, _Tp const& __rhs) {
657 return memcmp(&__lhs, &__rhs, sizeof(_Tp)) == 0;
658}
659
632static_assert((is_same<underlying_type<memory_order>::type, __memory_order_underlying_t>::value),660static_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");
634662
...@@ -1218,9 +1246,9 @@ _LIBCPP_INLINE_VISIBILITY...@@ -1218,9 +1246,9 @@ _LIBCPP_INLINE_VISIBILITY
1218bool __cxx_atomic_compare_exchange_strong(volatile __cxx_atomic_lock_impl<_Tp>* __a,1246bool __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 else1254 else
...@@ -1247,9 +1275,9 @@ _LIBCPP_INLINE_VISIBILITY...@@ -1247,9 +1275,9 @@ _LIBCPP_INLINE_VISIBILITY
1247bool __cxx_atomic_compare_exchange_weak(volatile __cxx_atomic_lock_impl<_Tp>* __a,1275bool __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 else1283 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};
14541482
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
1491using __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
1505template <class _Atp, class _Fn>
1506struct __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
1527template <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
1537template <class _Tp>
1538_LIBCPP_INLINE_VISIBILITY void __cxx_atomic_notify_all(__cxx_atomic_impl<_Tp> const volatile*) { }
1539template <class _Tp>
1540_LIBCPP_INLINE_VISIBILITY void __cxx_atomic_notify_one(__cxx_atomic_impl<_Tp> const volatile*) { }
1541template <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
1549template <class _Atp, class _Tp>
1550struct __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
1560template <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>
14561571
1457template <class _Tp, bool = is_integral<_Tp>::value && !is_same<_Tp, bool>::value>1572template <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) _NOEXCEPT1647 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);}
15341649
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_VISIBILITY1663 _LIBCPP_INLINE_VISIBILITY
1536 __atomic_base() _NOEXCEPT _LIBCPP_DEFAULT1664 __atomic_base() _NOEXCEPT _LIBCPP_DEFAULT
15371665
...@@ -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#else1673#else
1546private:1674private:
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#endif1681#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_VISIBILITY1778 _LIBCPP_INLINE_VISIBILITY
1647 atomic() _NOEXCEPT _LIBCPP_DEFAULT1779 atomic() _NOEXCEPT _LIBCPP_DEFAULT
1648 _LIBCPP_INLINE_VISIBILITY1780 _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_VISIBILITY1799 _LIBCPP_INLINE_VISIBILITY
1667 atomic() _NOEXCEPT _LIBCPP_DEFAULT1800 atomic() _NOEXCEPT _LIBCPP_DEFAULT
1668 _LIBCPP_INLINE_VISIBILITY1801 _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}
19492082
2083// atomic_wait
2084
2085template <class _Tp>
2086_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
2087void atomic_wait(const volatile atomic<_Tp>* __o,
2088 typename atomic<_Tp>::value_type __v) _NOEXCEPT
2089{
2090 return __o->wait(__v);
2091}
2092
2093template <class _Tp>
2094_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
2095void 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
2103template <class _Tp>
2104_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
2105void 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
2113template <class _Tp>
2114_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
2115void 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
2125template <class _Tp>
2126_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
2127void atomic_notify_one(volatile atomic<_Tp>* __o) _NOEXCEPT
2128{
2129 __o->notify_one();
2130}
2131template <class _Tp>
2132_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
2133void atomic_notify_one(atomic<_Tp>* __o) _NOEXCEPT
2134{
2135 __o->notify_one();
2136}
2137
2138// atomic_notify_one
2139
2140template <class _Tp>
2141_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
2142void atomic_notify_all(volatile atomic<_Tp>* __o) _NOEXCEPT
2143{
2144 __o->notify_all();
2145}
2146template <class _Tp>
2147_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
2148void atomic_notify_all(atomic<_Tp>* __o) _NOEXCEPT
2149{
2150 __o->notify_all();
2151}
2152
1950// atomic_fetch_add2153// atomic_fetch_add
19512154
1952template <class _Tp>2155template <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_;
22812484
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_VISIBILITY2492 _LIBCPP_INLINE_VISIBILITY
2283 bool test_and_set(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT2493 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) _NOEXCEPT2502 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);}
22942504
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_VISIBILITY2524 _LIBCPP_INLINE_VISIBILITY
2296 atomic_flag() _NOEXCEPT _LIBCPP_DEFAULT2525 atomic_flag() _NOEXCEPT _LIBCPP_DEFAULT
22972526
...@@ -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#else2534#else
2306private:2535private:
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#endif2542#endif
2311} atomic_flag;2543} atomic_flag;
23122544
2545
2546inline _LIBCPP_INLINE_VISIBILITY
2547bool
2548atomic_flag_test(const volatile atomic_flag* __o) _NOEXCEPT
2549{
2550 return __o->test();
2551}
2552
2553inline _LIBCPP_INLINE_VISIBILITY
2554bool
2555atomic_flag_test(const atomic_flag* __o) _NOEXCEPT
2556{
2557 return __o->test();
2558}
2559
2560inline _LIBCPP_INLINE_VISIBILITY
2561bool
2562atomic_flag_test_explicit(const volatile atomic_flag* __o, memory_order __m) _NOEXCEPT
2563{
2564 return __o->test(__m);
2565}
2566
2567inline _LIBCPP_INLINE_VISIBILITY
2568bool
2569atomic_flag_test_explicit(const atomic_flag* __o, memory_order __m) _NOEXCEPT
2570{
2571 return __o->test(__m);
2572}
2573
2313inline _LIBCPP_INLINE_VISIBILITY2574inline _LIBCPP_INLINE_VISIBILITY
2314bool2575bool
2315atomic_flag_test_and_set(volatile atomic_flag* __o) _NOEXCEPT2576atomic_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}
23682629
2630inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_SYNC
2631void
2632atomic_flag_wait(const volatile atomic_flag* __o, bool __v) _NOEXCEPT
2633{
2634 __o->wait(__v);
2635}
2636
2637inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_SYNC
2638void
2639atomic_flag_wait(const atomic_flag* __o, bool __v) _NOEXCEPT
2640{
2641 __o->wait(__v);
2642}
2643
2644inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_SYNC
2645void
2646atomic_flag_wait_explicit(const volatile atomic_flag* __o,
2647 bool __v, memory_order __m) _NOEXCEPT
2648{
2649 __o->wait(__v, __m);
2650}
2651
2652inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_SYNC
2653void
2654atomic_flag_wait_explicit(const atomic_flag* __o,
2655 bool __v, memory_order __m) _NOEXCEPT
2656{
2657 __o->wait(__v, __m);
2658}
2659
2660inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_SYNC
2661void
2662atomic_flag_notify_one(volatile atomic_flag* __o) _NOEXCEPT
2663{
2664 __o->notify_one();
2665}
2666
2667inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_SYNC
2668void
2669atomic_flag_notify_one(atomic_flag* __o) _NOEXCEPT
2670{
2671 __o->notify_one();
2672}
2673
2674inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_SYNC
2675void
2676atomic_flag_notify_all(volatile atomic_flag* __o) _NOEXCEPT
2677{
2678 __o->notify_all();
2679}
2680
2681inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_SYNC
2682void
2683atomic_flag_notify_all(atomic_flag* __o) _NOEXCEPT
2684{
2685 __o->notify_all();
2686}
2687
2369// fences2688// fences
23702689
2371inline _LIBCPP_INLINE_VISIBILITY2690inline _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;
2434typedef atomic<intmax_t> atomic_intmax_t;2753typedef atomic<intmax_t> atomic_intmax_t;
2435typedef atomic<uintmax_t> atomic_uintmax_t;2754typedef atomic<uintmax_t> atomic_uintmax_t;
24362755
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
2765typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, long long>::type __libcpp_signed_lock_free;
2766typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned long long>::type __libcpp_unsigned_lock_free;
2767#elif ATOMIC_INT_LOCK_FREE == 2
2768typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, int>::type __libcpp_signed_lock_free;
2769typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned int>::type __libcpp_unsigned_lock_free;
2770#elif ATOMIC_SHORT_LOCK_FREE == 2
2771typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, short>::type __libcpp_signed_lock_free;
2772typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned short>::type __libcpp_unsigned_lock_free;
2773#elif ATOMIC_CHAR_LOCK_FREE == 2
2774typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, char>::type __libcpp_signed_lock_free;
2775typedef 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
2780typedef atomic<__libcpp_signed_lock_free> atomic_signed_lock_free;
2781typedef 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}
24392785
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
16namespace 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
64struct __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
76The default implementation of __barrier_base is a classic tree barrier.
77
78It 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
88using __barrier_phase_t = uint8_t;
89
90class __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
96bool __arrive_barrier_algorithm_base(__barrier_algorithm_base* __barrier,
97 __barrier_phase_t __old_phase);
98
99_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI
100void __destroy_barrier_algorithm_base(__barrier_algorithm_base* __barrier);
101
102template<class _CompletionF>
103class __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
112public:
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
160The alternative implementation of __barrier_base is a central barrier.
161
162Two 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
171template<class _CompletionF>
172class __barrier_base {
173
174 __atomic_base<ptrdiff_t> __expected;
175 __atomic_base<ptrdiff_t> __arrived;
176 _CompletionF __completion;
177 __atomic_base<bool> __phase;
178public:
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
217template<>
218class __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
235public:
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
277template<class _CompletionF = __empty_completion>
278class barrier {
279
280 __barrier_base<_CompletionF> __b;
281public:
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 @@
1515
16namespace std {16namespace std {
1717
18 // [bit.pow.two], integral powers of 2
18 template <class T>19 template <class T>
19 constexpr bool ispow2(T x) noexcept; // C++2020 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++2026 constexpr T log2p1(T x) noexcept; // C++20
2627
27 // 23.20.2, rotating28 // [bit.rotate], rotating
28 template<class T>29 template<class T>
29 constexpr T rotl(T x, unsigned int s) noexcept; // C++2030 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++2032 constexpr T rotr(T x, unsigned int s) noexcept; // C++20
3233
33 // 23.20.3, counting34 // [bit.count], counting
34 template<class T>35 template<class T>
35 constexpr int countl_zero(T x) noexcept; // C++2036 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++2044 constexpr int popcount(T x) noexcept; // C++20
4445
45 // 20.15.9, endian46 // [bit.endian], endian
46 enum class endian {47 enum class endian {
47 little = see below, // C++2048 little = see below, // C++20
48 big = see below, // C++2049 big = see below, // C++20
...@@ -350,7 +351,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR...@@ -350,7 +351,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
350bool __ispow2(_Tp __t) _NOEXCEPT351bool __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}
355356
356357
lib/libcxx/include/charconv+11-2
...@@ -73,6 +73,7 @@ namespace std {...@@ -73,6 +73,7 @@ namespace std {
7373
74*/74*/
7575
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_STD93_LIBCPP_BEGIN_NAMESPACE_STD
9394
94namespace __itoa {95namespace __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}
9899
99#ifndef _LIBCPP_CXX03_LANG100#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#endif169#endif
169170
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#endif192#endif
191193
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}
293296
294template <typename _Tp>297template <typename _Tp>
298_LIBCPP_AVAILABILITY_TO_CHARS
295inline _LIBCPP_INLINE_VISIBILITY to_chars_result299inline _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}
307311
308template <typename _Tp>312template <typename _Tp>
313_LIBCPP_AVAILABILITY_TO_CHARS
309inline _LIBCPP_INLINE_VISIBILITY to_chars_result314inline _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}
338343
339template <typename _Tp>344template <typename _Tp>
345_LIBCPP_AVAILABILITY_TO_CHARS
340inline _LIBCPP_INLINE_VISIBILITY to_chars_result346inline _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}
353359
354template <typename _Tp>360template <typename _Tp>
361_LIBCPP_AVAILABILITY_TO_CHARS
355inline _LIBCPP_INLINE_VISIBILITY to_chars_result362inline _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}
381388
382template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>389template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
390_LIBCPP_AVAILABILITY_TO_CHARS
383inline _LIBCPP_INLINE_VISIBILITY to_chars_result391inline _LIBCPP_INLINE_VISIBILITY to_chars_result
384to_chars(char* __first, char* __last, _Tp __value)392to_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}
388396
389template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>397template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
398_LIBCPP_AVAILABILITY_TO_CHARS
390inline _LIBCPP_INLINE_VISIBILITY to_chars_result399inline _LIBCPP_INLINE_VISIBILITY to_chars_result
391to_chars(char* __first, char* __last, _Tp __value, int __base)400to_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}
24602460
lib/libcxx/include/cmath+4
...@@ -296,6 +296,10 @@ floating_point trunc (arithmetic x);...@@ -296,6 +296,10 @@ floating_point trunc (arithmetic x);
296float truncf(float x);296float truncf(float x);
297long double truncl(long double x);297long double truncl(long double x);
298298
299constexpr float lerp(float a, float b, float t) noexcept; // C++20
300constexpr double lerp(double a, double b, double t) noexcept; // C++20
301constexpr long double lerp(long double a, long double b, long double t) noexcept; // C++20
302
299} // std303} // std
300304
301*/305*/
lib/libcxx/include/codecvt+36-36
...@@ -102,11 +102,11 @@ protected:...@@ -102,11 +102,11 @@ protected:
102 virtual result102 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};
111111
112template <>112template <>
...@@ -137,11 +137,11 @@ protected:...@@ -137,11 +137,11 @@ protected:
137 virtual result137 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};
146146
147template <>147template <>
...@@ -172,11 +172,11 @@ protected:...@@ -172,11 +172,11 @@ protected:
172 virtual result172 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};
181181
182template <class _Elem, unsigned long _Maxcode = 0x10ffff,182template <class _Elem, unsigned long _Maxcode = 0x10ffff,
...@@ -225,11 +225,11 @@ protected:...@@ -225,11 +225,11 @@ protected:
225 virtual result225 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};
234234
235template <>235template <>
...@@ -260,11 +260,11 @@ protected:...@@ -260,11 +260,11 @@ protected:
260 virtual result260 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};
269269
270template <>270template <>
...@@ -295,11 +295,11 @@ protected:...@@ -295,11 +295,11 @@ protected:
295 virtual result295 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};
304304
305template <>305template <>
...@@ -330,11 +330,11 @@ protected:...@@ -330,11 +330,11 @@ protected:
330 virtual result330 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};
339339
340template <>340template <>
...@@ -365,11 +365,11 @@ protected:...@@ -365,11 +365,11 @@ protected:
365 virtual result365 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};
374374
375template <>375template <>
...@@ -400,11 +400,11 @@ protected:...@@ -400,11 +400,11 @@ protected:
400 virtual result400 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};
409409
410template <class _Elem, unsigned long _Maxcode = 0x10ffff,410template <class _Elem, unsigned long _Maxcode = 0x10ffff,
...@@ -453,11 +453,11 @@ protected:...@@ -453,11 +453,11 @@ protected:
453 virtual result453 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};
462462
463template <>463template <>
...@@ -488,11 +488,11 @@ protected:...@@ -488,11 +488,11 @@ protected:
488 virtual result488 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};
497497
498template <>498template <>
...@@ -523,11 +523,11 @@ protected:...@@ -523,11 +523,11 @@ protected:
523 virtual result523 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};
532532
533template <class _Elem, unsigned long _Maxcode = 0x10ffff,533template <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*/
48126
...@@ -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;
249327
250#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR328#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#endif333#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;
365445
366#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR446#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#endif451#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;
491573
492#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR574#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#endif579#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>
248249
...@@ -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 else1409 else
1409 __is.setstate(ios_base::failbit);1410 __is.setstate(__is.failbit);
1410 }1411 }
1411 else1412 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 else1420 else
1420 __is.setstate(ios_base::failbit);1421 __is.setstate(__is.failbit);
1421 }1422 }
1422 else1423 else
1423 __is.setstate(ios_base::failbit);1424 __is.setstate(__is.failbit);
1424 }1425 }
1425 else1426 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 else1432 else
1432 __is.setstate(ios_base::failbit);1433 __is.setstate(__is.failbit);
1433 }1434 }
1434 }1435 }
1435 else1436 else
1436 __is.setstate(ios_base::failbit);1437 __is.setstate(__is.failbit);
1437 return __is;1438 return __is;
1438}1439}
14391440
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
15namespace 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
154template<class _Tp, class _Up>
155concept __same_as_impl = _VSTD::_IsSame<_Tp, _Up>::value;
156
157template<class _Tp, class _Up>
158concept 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:
2525
26 ptrdiff_t26 ptrdiff_t
27 size_t27 size_t
28 max_align_t28 max_align_t // C++11
29 nullptr_t29 nullptr_t
30 byte // C++1730 byte // C++17
3131
...@@ -49,12 +49,34 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -49,12 +49,34 @@ _LIBCPP_BEGIN_NAMESPACE_STD
49using ::ptrdiff_t;49using ::ptrdiff_t;
50using ::size_t;50using ::size_t;
5151
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.
55using ::max_align_t;53using ::max_align_t;
56#else54#endif
57typedef long double max_align_t;55
56template <class _Tp> struct __libcpp_is_integral { enum { value = 0 }; };
57template <> struct __libcpp_is_integral<bool> { enum { value = 1 }; };
58template <> struct __libcpp_is_integral<char> { enum { value = 1 }; };
59template <> struct __libcpp_is_integral<signed char> { enum { value = 1 }; };
60template <> struct __libcpp_is_integral<unsigned char> { enum { value = 1 }; };
61template <> struct __libcpp_is_integral<wchar_t> { enum { value = 1 }; };
62#ifndef _LIBCPP_NO_HAS_CHAR8_T
63template <> struct __libcpp_is_integral<char8_t> { enum { value = 1 }; };
64#endif
65#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
66template <> struct __libcpp_is_integral<char16_t> { enum { value = 1 }; };
67template <> struct __libcpp_is_integral<char32_t> { enum { value = 1 }; };
68#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
69template <> struct __libcpp_is_integral<short> { enum { value = 1 }; };
70template <> struct __libcpp_is_integral<unsigned short> { enum { value = 1 }; };
71template <> struct __libcpp_is_integral<int> { enum { value = 1 }; };
72template <> struct __libcpp_is_integral<unsigned int> { enum { value = 1 }; };
73template <> struct __libcpp_is_integral<long> { enum { value = 1 }; };
74template <> struct __libcpp_is_integral<unsigned long> { enum { value = 1 }; };
75template <> struct __libcpp_is_integral<long long> { enum { value = 1 }; };
76template <> struct __libcpp_is_integral<unsigned long long> { enum { value = 1 }; };
77#ifndef _LIBCPP_HAS_NO_INT128
78template <> struct __libcpp_is_integral<__int128_t> { enum { value = 1 }; };
79template <> struct __libcpp_is_integral<__uint128_t> { enum { value = 1 }; };
58#endif80#endif
5981
60_LIBCPP_END_NAMESPACE_STD82_LIBCPP_END_NAMESPACE_STD
...@@ -64,6 +86,11 @@ namespace std // purposefully not versioned...@@ -64,6 +86,11 @@ namespace std // purposefully not versioned
64{86{
65enum class byte : unsigned char {};87enum class byte : unsigned char {};
6688
89
90template <bool> struct __enable_if_integral_imp {};
91template <> struct __enable_if_integral_imp<true> { using type = byte; };
92template <class _Tp> using _EnableByteOverload = typename __enable_if_integral_imp<__libcpp_is_integral<_Tp>::value>::type;
93
67constexpr byte operator| (byte __lhs, byte __rhs) noexcept94constexpr 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}
107134template <class _Integer>
135 constexpr _EnableByteOverload<_Integer> &
136 operator<<=(byte& __lhs, _Integer __shift) noexcept
137 { return __lhs = __lhs << __shift; }
138
139template <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
144template <class _Integer>
145 constexpr _EnableByteOverload<_Integer> &
146 operator>>=(byte& __lhs, _Integer __shift) noexcept
147 { return __lhs = __lhs >> __shift; }
148
149template <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
154template <class _Integer, class = _EnableByteOverload<_Integer> >
155 constexpr _Integer
156 to_integer(byte __b) noexcept { return static_cast<_Integer>(__b); }
108}157}
109158
110#include <type_traits> // rest of byte
111#endif159#endif
112160
113#endif // _LIBCPP_CSTDDEF161#endif // _LIBCPP_CSTDDEF
lib/libcxx/include/cstdio+4
...@@ -131,9 +131,13 @@ using ::putc;...@@ -131,9 +131,13 @@ using ::putc;
131using ::ungetc;131using ::ungetc;
132using ::fread;132using ::fread;
133using ::fwrite;133using ::fwrite;
134#ifndef _LIBCPP_HAS_NO_FGETPOS_FSETPOS
134using ::fgetpos;135using ::fgetpos;
136#endif
135using ::fseek;137using ::fseek;
138#ifndef _LIBCPP_HAS_NO_FGETPOS_FSETPOS
136using ::fsetpos;139using ::fsetpos;
140#endif
137using ::ftell;141using ::ftell;
138using ::rewind;142using ::rewind;
139using ::clearerr;143using ::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)));
151151
152template <class T, class Allocator, class U>152template <class T, class Allocator, class U>
153 void erase(deque<T, Allocator>& c, const U& value); // C++20153 typename deque<T, Allocator>::size_type
154 erase(deque<T, Allocator>& c, const U& value); // C++20
154template <class T, class Allocator, class Predicate>155template <class T, class Allocator, class Predicate>
155 void erase_if(deque<T, Allocator>& c, Predicate pred); // C++20156 typename deque<T, Allocator>::size_type
157 erase_if(deque<T, Allocator>& c, Predicate pred); // C++20
156158
157} // std159} // std
158160
...@@ -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)
30213023
3022#if _LIBCPP_STD_VER > 173024#if _LIBCPP_STD_VER > 17
3023template <class _Tp, class _Allocator, class _Up>3025template <class _Tp, class _Allocator, class _Up>
3024inline _LIBCPP_INLINE_VISIBILITY3026inline _LIBCPP_INLINE_VISIBILITY typename deque<_Tp, _Allocator>::size_type
3025void erase(deque<_Tp, _Allocator>& __c, const _Up& __v)3027erase(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}
30273032
3028template <class _Tp, class _Allocator, class _Predicate>3033template <class _Tp, class _Allocator, class _Predicate>
3029inline _LIBCPP_INLINE_VISIBILITY3034inline _LIBCPP_INLINE_VISIBILITY typename deque<_Tp, _Allocator>::size_type
3030void erase_if(deque<_Tp, _Allocator>& __c, _Predicate __pred)3035erase_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#endif3040#endif
30333041
30343042
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{
99public:99public:
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_VISIBILITY1346 _LIBCPP_INLINE_VISIBILITY
1347 const path& path2() const noexcept { return __storage_->__p2_; }1347 const path& path2() const noexcept { return __storage_->__p2_; }
13481348
1349 filesystem_error(const filesystem_error&) = default;
1349 ~filesystem_error() override; // key function1350 ~filesystem_error() override; // key function
13501351
1351 _LIBCPP_INLINE_VISIBILITY1352 _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)));
170170
171template <class T, class Allocator, class U>171template <class T, class Allocator, class U>
172 void erase(forward_list<T, Allocator>& c, const U& value); // C++20172 typename forward_list<T, Allocator>::size_type
173 erase(forward_list<T, Allocator>& c, const U& value); // C++20
173template <class T, class Allocator, class Predicate>174template <class T, class Allocator, class Predicate>
174 void erase_if(forward_list<T, Allocator>& c, Predicate pred); // C++20175 typename forward_list<T, Allocator>::size_type
176 erase_if(forward_list<T, Allocator>& c, Predicate pred); // C++20
175177
176} // std178} // std
177179
...@@ -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 > 171767#if _LIBCPP_STD_VER > 17
1766template <class _Tp, class _Allocator, class _Predicate>1768template <class _Tp, class _Allocator, class _Predicate>
1767inline _LIBCPP_INLINE_VISIBILITY1769inline _LIBCPP_INLINE_VISIBILITY
1768void 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}
17701774
1771template <class _Tp, class _Allocator, class _Up>1775template <class _Tp, class _Allocator, class _Up>
1772inline _LIBCPP_INLINE_VISIBILITY1776inline _LIBCPP_INLINE_VISIBILITY
1773void 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#endif1781#endif
17761782
1777_LIBCPP_END_NAMESPACE_STD1783_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
508508
509#include <__functional_base>509#include <__functional_base>
510510
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_header516#pragma GCC system_header
513#endif517#endif
...@@ -1434,7 +1438,14 @@ void __throw_bad_function_call()...@@ -1434,7 +1438,14 @@ void __throw_bad_function_call()
1434#endif1438#endif
1435}1439}
14361440
1437template<class _Fp> class _LIBCPP_TEMPLATE_VIS function; // undefined1441#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
1448template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
14381449
1439namespace __function1450namespace __function
1440{1451{
...@@ -1477,6 +1488,12 @@ template <class _Fp>...@@ -1477,6 +1488,12 @@ template <class _Fp>
1477_LIBCPP_INLINE_VISIBILITY1488_LIBCPP_INLINE_VISIBILITY
1478bool __not_null(function<_Fp> const& __f) { return !!__f; }1489bool __not_null(function<_Fp> const& __f) { return !!__f; }
14791490
1491#ifdef _LIBCPP_HAS_EXTENSION_BLOCKS
1492template <class _Rp, class ..._Args>
1493_LIBCPP_INLINE_VISIBILITY
1494bool __not_null(_Rp (^__p)(_Args...)) { return __p; }
1495#endif
1496
1480} // namespace __function1497} // namespace __function
14811498
1482#ifndef _LIBCPP_CXX03_LANG1499#ifndef _LIBCPP_CXX03_LANG
...@@ -1611,7 +1628,7 @@ public:...@@ -1611,7 +1628,7 @@ public:
16111628
1612// __base provides an abstract interface for copyable functors.1629// __base provides an abstract interface for copyable functors.
16131630
1614template<class _Fp> class __base;1631template<class _Fp> class _LIBCPP_TEMPLATE_VIS __base;
16151632
1616template<class _Rp, class ..._ArgTypes>1633template<class _Rp, class ..._ArgTypes>
1617class __base<_Rp(_ArgTypes...)>1634class __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_RTTI2255#endif // _LIBCPP_NO_RTTI
2239};2256};
22402257
2258#if defined(_LIBCPP_HAS_BLOCKS_RUNTIME) && !defined(_LIBCPP_HAS_OBJC_ARC)
2259
2260template<class _Rp1, class ..._ArgTypes1, class _Alloc, class _Rp, class ..._ArgTypes>
2261class __func<_Rp1(^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)>
2262 : public __base<_Rp(_ArgTypes...)>
2263{
2264 typedef _Rp1(^__block_type)(_ArgTypes1...);
2265 __block_type __f_;
2266
2267public:
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} // __function2324} // __function
22422325
2243template<class _Rp, class ..._ArgTypes>2326template<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...)>
22552338
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 };
22732356
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;
2276public:2359public:
2277 typedef _Rp result_type;2360 typedef _Rp result_type;
22782361
...@@ -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);
22882371
2289#if _LIBCPP_STD_VER <= 142372#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#endif2385#endif
23032386
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&&);
23092392
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 sequence3053 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 checks3056 // 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 *__first23059 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 found3072 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 __first13074 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 pattern3092 // 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 here3099 const _RandomAccessIterator1 __s = __last1 - (__len2 - 1); // Start of pattern match can't go beyond here
30173100
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 source3118 ++__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++173163#endif // > C++17
30813164
3082template <class _Container, class _Predicate>3165template <class _Container, class _Predicate>
3083inline void __libcpp_erase_if_container( _Container& __c, _Predicate __pred)3166inline 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 else3172 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}
30933180
3094_LIBCPP_END_NAMESPACE_STD3181_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/future+1
...@@ -506,6 +506,7 @@ public:...@@ -506,6 +506,7 @@ public:
506 _LIBCPP_INLINE_VISIBILITY506 _LIBCPP_INLINE_VISIBILITY
507 const error_code& code() const _NOEXCEPT {return __ec_;}507 const error_code& code() const _NOEXCEPT {return __ec_;}
508508
509 future_error(const future_error&) _NOEXCEPT = default;
509 virtual ~future_error() _NOEXCEPT;510 virtual ~future_error() _NOEXCEPT;
510};511};
511512
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
431public:431public:
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};
436437
437_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY438_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}
844845
845inline _LIBCPP_INLINE_VISIBILITY846inline
846ios_base&847ios_base&
847boolalpha(ios_base& __str)848boolalpha(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}
852853
853inline _LIBCPP_INLINE_VISIBILITY854inline
854ios_base&855ios_base&
855noboolalpha(ios_base& __str)856noboolalpha(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}
860861
861inline _LIBCPP_INLINE_VISIBILITY862inline
862ios_base&863ios_base&
863showbase(ios_base& __str)864showbase(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}
868869
869inline _LIBCPP_INLINE_VISIBILITY870inline
870ios_base&871ios_base&
871noshowbase(ios_base& __str)872noshowbase(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}
876877
877inline _LIBCPP_INLINE_VISIBILITY878inline
878ios_base&879ios_base&
879showpoint(ios_base& __str)880showpoint(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}
884885
885inline _LIBCPP_INLINE_VISIBILITY886inline
886ios_base&887ios_base&
887noshowpoint(ios_base& __str)888noshowpoint(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}
892893
893inline _LIBCPP_INLINE_VISIBILITY894inline
894ios_base&895ios_base&
895showpos(ios_base& __str)896showpos(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}
900901
901inline _LIBCPP_INLINE_VISIBILITY902inline
902ios_base&903ios_base&
903noshowpos(ios_base& __str)904noshowpos(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}
908909
909inline _LIBCPP_INLINE_VISIBILITY910inline
910ios_base&911ios_base&
911skipws(ios_base& __str)912skipws(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}
916917
917inline _LIBCPP_INLINE_VISIBILITY918inline
918ios_base&919ios_base&
919noskipws(ios_base& __str)920noskipws(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}
924925
925inline _LIBCPP_INLINE_VISIBILITY926inline
926ios_base&927ios_base&
927uppercase(ios_base& __str)928uppercase(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}
932933
933inline _LIBCPP_INLINE_VISIBILITY934inline
934ios_base&935ios_base&
935nouppercase(ios_base& __str)936nouppercase(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}
940941
941inline _LIBCPP_INLINE_VISIBILITY942inline
942ios_base&943ios_base&
943unitbuf(ios_base& __str)944unitbuf(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}
948949
949inline _LIBCPP_INLINE_VISIBILITY950inline
950ios_base&951ios_base&
951nounitbuf(ios_base& __str)952nounitbuf(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}
956957
957inline _LIBCPP_INLINE_VISIBILITY958inline
958ios_base&959ios_base&
959internal(ios_base& __str)960internal(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}
964965
965inline _LIBCPP_INLINE_VISIBILITY966inline
966ios_base&967ios_base&
967left(ios_base& __str)968left(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}
972973
973inline _LIBCPP_INLINE_VISIBILITY974inline
974ios_base&975ios_base&
975right(ios_base& __str)976right(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}
980981
981inline _LIBCPP_INLINE_VISIBILITY982inline
982ios_base&983ios_base&
983dec(ios_base& __str)984dec(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}
988989
989inline _LIBCPP_INLINE_VISIBILITY990inline
990ios_base&991ios_base&
991hex(ios_base& __str)992hex(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}
996997
997inline _LIBCPP_INLINE_VISIBILITY998inline
998ios_base&999ios_base&
999oct(ios_base& __str)1000oct(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}
10041005
1005inline _LIBCPP_INLINE_VISIBILITY1006inline
1006ios_base&1007ios_base&
1007fixed(ios_base& __str)1008fixed(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}
10121013
1013inline _LIBCPP_INLINE_VISIBILITY1014inline
1014ios_base&1015ios_base&
1015scientific(ios_base& __str)1016scientific(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}
10201021
1021inline _LIBCPP_INLINE_VISIBILITY1022inline
1022ios_base&1023ios_base&
1023hexfloat(ios_base& __str)1024hexfloat(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}
10281029
1029inline _LIBCPP_INLINE_VISIBILITY1030inline
1030ios_base&1031ios_base&
1031defaultfloat(ios_base& __str)1032defaultfloat(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 {};
54struct random_access_iterator_tag : public bidirectional_iterator_tag {};54struct random_access_iterator_tag : public bidirectional_iterator_tag {};
5555
56// 27.4.3, iterator operations56// 27.4.3, iterator operations
57// extension: second argument not conforming to C++0357template <class InputIterator, class Distance> // constexpr in C++17
58template <class InputIterator> // constexpr in C++1758 constexpr void advance(InputIterator& i, Distance n);
59 constexpr void advance(InputIterator& i,
60 typename iterator_traits<InputIterator>::difference_type n);
6159
62template <class InputIterator> // constexpr in C++1760template <class InputIterator> // constexpr in C++17
63 constexpr typename iterator_traits<InputIterator>::difference_type61 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}
665663
666template <class _InputIter>664template <class _InputIter, class _Distance>
667inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14665inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
668void advance(_InputIter& __i,666void 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}
675674
...@@ -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");
715714
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
16namespace 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
56class latch
57{
58 __atomic_base<ptrdiff_t> __a;
59
60public:
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)));
171171
172template <class T, class Allocator, class U>172template <class T, class Allocator, class U>
173 void erase(list<T, Allocator>& c, const U& value); // C++20173 typename list<T, Allocator>::size_type
174 erase(list<T, Allocator>& c, const U& value); // C++20
174template <class T, class Allocator, class Predicate>175template <class T, class Allocator, class Predicate>
175 void erase_if(list<T, Allocator>& c, Predicate pred); // C++20176 typename list<T, Allocator>::size_type
177 erase_if(list<T, Allocator>& c, Predicate pred); // C++20
176178
177} // std179} // std
178180
...@@ -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)
24712473
2472#if _LIBCPP_STD_VER > 172474#if _LIBCPP_STD_VER > 17
2473template <class _Tp, class _Allocator, class _Predicate>2475template <class _Tp, class _Allocator, class _Predicate>
2474inline _LIBCPP_INLINE_VISIBILITY2476inline _LIBCPP_INLINE_VISIBILITY typename list<_Tp, _Allocator>::size_type
2475void erase_if(list<_Tp, _Allocator>& __c, _Predicate __pred)2477erase_if(list<_Tp, _Allocator>& __c, _Predicate __pred) {
2476{ __c.remove_if(__pred); }2478 return __c.remove_if(__pred);
2479}
24772480
2478template <class _Tp, class _Allocator, class _Up>2481template <class _Tp, class _Allocator, class _Up>
2479inline _LIBCPP_INLINE_VISIBILITY2482inline _LIBCPP_INLINE_VISIBILITY typename list<_Tp, _Allocator>::size_type
2480void erase(list<_Tp, _Allocator>& __c, const _Up& __v)2483erase(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#endif2486#endif
24832487
2484_LIBCPP_END_NAMESPACE_STD2488_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)));
255255
256template <class Key, class T, class Compare, class Allocator, class Predicate>256template <class Key, class T, class Compare, class Allocator, class Predicate>
257 void erase_if(map<Key, T, Compare, Allocator>& c, Predicate pred); // C++20257typename map<Key, T, Compare, Allocator>::size_type
258erase_if(map<Key, T, Compare, Allocator>& c, Predicate pred); // C++20
258259
259260
260template <class Key, class T, class Compare = less<Key>,261template <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)));
470471
471template <class Key, class T, class Compare, class Allocator, class Predicate>472template <class Key, class T, class Compare, class Allocator, class Predicate>
472 void erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20473typename multimap<Key, T, Compare, Allocator>::size_type
474erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20
473475
474} // std476} // std
475477
...@@ -1653,10 +1655,13 @@ swap(map<_Key, _Tp, _Compare, _Allocator>& __x,...@@ -1653,10 +1655,13 @@ swap(map<_Key, _Tp, _Compare, _Allocator>& __x,
1653}1655}
16541656
1655#if _LIBCPP_STD_VER > 171657#if _LIBCPP_STD_VER > 17
1656template <class _Key, class _Tp, class _Compare, class _Allocator, class _Predicate>1658template <class _Key, class _Tp, class _Compare, class _Allocator,
1659 class _Predicate>
1657inline _LIBCPP_INLINE_VISIBILITY1660inline _LIBCPP_INLINE_VISIBILITY
1658void 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#endif1665#endif
16611666
16621667
...@@ -2235,10 +2240,14 @@ swap(multimap<_Key, _Tp, _Compare, _Allocator>& __x,...@@ -2235,10 +2240,14 @@ swap(multimap<_Key, _Tp, _Compare, _Allocator>& __x,
2235}2240}
22362241
2237#if _LIBCPP_STD_VER > 172242#if _LIBCPP_STD_VER > 17
2238template <class _Key, class _Tp, class _Compare, class _Allocator, class _Predicate>2243template <class _Key, class _Tp, class _Compare, class _Allocator,
2244 class _Predicate>
2239inline _LIBCPP_INLINE_VISIBILITY2245inline _LIBCPP_INLINE_VISIBILITY
2240void 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#endif2251#endif
22432252
2244_LIBCPP_END_NAMESPACE_STD2253_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_header297#pragma GCC system_header
298#endif298#endif
299299
300#define _LIBCPP_STDLIB_INCLUDE_NEXT
301#include <stdlib.h>
302
303#include_next <math.h>300#include_next <math.h>
304301
305#ifdef __cplusplus302#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.
309extern "C++" {306extern "C++" {
310307
308#include <stdlib.h>
311#include <type_traits>309#include <type_traits>
312#include <limits>310#include <limits>
313311
...@@ -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 // isunordered758#endif // isunordered
761759
762// abs760// abs
763761//
764#undef abs762// 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)
772inline _LIBCPP_INLINE_VISIBILITY long abs(long __x) _NOEXCEPT {
773 return ::labs(__x);
774}
775#ifndef _LIBCPP_HAS_NO_LONG_LONG
776inline _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__))
784inline _LIBCPP_INLINE_VISIBILITY float abs(float __lcpp_x) _NOEXCEPT {
785 return ::fabsf(__lcpp_x);
786}
787
788inline _LIBCPP_INLINE_VISIBILITY double abs(double __lcpp_x) _NOEXCEPT {
789 return ::fabs(__lcpp_x);
790}
791
792inline _LIBCPP_INLINE_VISIBILITY long double
793abs(long double __lcpp_x) _NOEXCEPT {
794 return ::fabsl(__lcpp_x);
795}
796#endif // !(defined(_AIX) || defined(__sun__))
797763
798// div764// div
799765//
800#undef div766// 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)
808inline _LIBCPP_INLINE_VISIBILITY ldiv_t div(long __x, long __y) _NOEXCEPT {
809 return ::ldiv(__x, __y);
810}
811#ifndef _LIBCPP_HAS_NO_LONG_LONG
812inline _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
818767
819// acos768// acos
820769
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_equal80 typedef Alloc::is_always_equal
81 | is_empty is_always_equal;81 | is_empty is_always_equal;
8282
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>>;
8585
86 static pointer allocate(allocator_type& a, size_type n); // [[nodiscard]] in C++2086 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};
102102
103template <>103template <>
104class allocator<void>104class allocator<void> // deprecated in C++17, removed in C++20
105{105{
106public:106public:
107 typedef void* pointer;107 typedef void* pointer;
...@@ -115,30 +115,37 @@ template <class T>...@@ -115,30 +115,37 @@ template <class T>
115class allocator115class allocator
116{116{
117public:117public:
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
125126
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;
127133
128 constexpr allocator() noexcept; // constexpr in C++20134 constexpr allocator() noexcept; // constexpr in C++20
129 constexpr allocator(const allocator&) noexcept; // constexpr in C++20135 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++20137 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};
143150
144template <class T, class U>151template <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};
445452
453template<class T>
454shared_ptr(weak_ptr<T>) -> shared_ptr<T>;
455template<class T, class D>
456shared_ptr(unique_ptr<T, D>) -> shared_ptr<T>;
457
446// shared_ptr comparisons:458// shared_ptr comparisons:
447template<class T, class U>459template<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};
543555
556template<class T>
557weak_ptr(shared_ptr<T>) -> weak_ptr<T>;
558
544// weak_ptr specialized algorithms:559// weak_ptr specialized algorithms:
545template<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b) noexcept;560template<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b) noexcept;
546561
...@@ -705,8 +720,9 @@ _ValueType __libcpp_acquire_load(_ValueType const* __value) {...@@ -705,8 +720,9 @@ _ValueType __libcpp_acquire_load(_ValueType const* __value) {
705720
706template <class _Tp> class allocator;721template <class _Tp> class allocator;
707722
723#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
708template <>724template <>
709class _LIBCPP_TEMPLATE_VIS allocator<void>725class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 allocator<void>
710{726{
711public:727public:
712 typedef void* pointer;728 typedef void* pointer;
...@@ -717,7 +733,7 @@ public:...@@ -717,7 +733,7 @@ public:
717};733};
718734
719template <>735template <>
720class _LIBCPP_TEMPLATE_VIS allocator<const void>736class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 allocator<const void>
721{737{
722public:738public:
723 typedef const void* pointer;739 typedef const void* pointer;
...@@ -726,6 +742,7 @@ public:...@@ -726,6 +742,7 @@ public:
726742
727 template <class _Up> struct rebind {typedef allocator<_Up> other;};743 template <class _Up> struct rebind {typedef allocator<_Up> other;};
728};744};
745#endif
729746
730// pointer_traits747// pointer_traits
731748
...@@ -838,7 +855,9 @@ struct __has_rebind...@@ -838,7 +855,9 @@ struct __has_rebind
838private:855private:
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
842public:861public:
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
1266private:1285private:
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
1270public:1291public:
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>
1280template <class _Tp, class _Up, bool = __has_rebind_other<_Tp, _Up>::value>1301template <class _Tp, class _Up, bool = __has_rebind_other<_Tp, _Up>::value>
1281struct __allocator_traits_rebind1302struct __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};
12851308
1286#ifndef _LIBCPP_HAS_NO_VARIADICS
1287
1288template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up>1309template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up>
1289struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, true>1310struct __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};
12931316
1294template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up>1317template <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};
12991322
1300#else // _LIBCPP_HAS_NO_VARIADICS
1301
1302template <template <class> class _Alloc, class _Tp, class _Up>
1303struct __allocator_traits_rebind<_Alloc<_Tp>, _Up, true>
1304{
1305 typedef typename _Alloc<_Tp>::template rebind<_Up>::other type;
1306};
1307
1308template <template <class> class _Alloc, class _Tp, class _Up>
1309struct __allocator_traits_rebind<_Alloc<_Tp>, _Up, false>
1310{
1311 typedef _Alloc<_Up> type;
1312};
1313
1314template <template <class, class> class _Alloc, class _Tp, class _A0, class _Up>
1315struct __allocator_traits_rebind<_Alloc<_Tp, _A0>, _Up, true>
1316{
1317 typedef typename _Alloc<_Tp, _A0>::template rebind<_Up>::other type;
1318};
1319
1320template <template <class, class> class _Alloc, class _Tp, class _A0, class _Up>
1321struct __allocator_traits_rebind<_Alloc<_Tp, _A0>, _Up, false>
1322{
1323 typedef _Alloc<_Up, _A0> type;
1324};
1325
1326template <template <class, class, class> class _Alloc, class _Tp, class _A0,
1327 class _A1, class _Up>
1328struct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1>, _Up, true>
1329{
1330 typedef typename _Alloc<_Tp, _A0, _A1>::template rebind<_Up>::other type;
1331};
1332
1333template <template <class, class, class> class _Alloc, class _Tp, class _A0,
1334 class _A1, class _Up>
1335struct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1>, _Up, false>
1336{
1337 typedef _Alloc<_Up, _A0, _A1> type;
1338};
1339
1340template <template <class, class, class, class> class _Alloc, class _Tp, class _A0,
1341 class _A1, class _A2, class _Up>
1342struct __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
1347template <template <class, class, class, class> class _Alloc, class _Tp, class _A0,
1348 class _A1, class _A2, class _Up>
1349struct __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_LANG1323#ifndef _LIBCPP_CXX03_LANG
13571324
1325_LIBCPP_SUPPRESS_DEPRECATED_PUSH
1358template <class _Alloc, class _SizeType, class _ConstVoidPtr>1326template <class _Alloc, class _SizeType, class _ConstVoidPtr>
1359auto1327auto
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
13621331
1363template <class _Alloc, class _SizeType, class _ConstVoidPtr>1332template <class _Alloc, class _SizeType, class _ConstVoidPtr>
1364auto1333auto
...@@ -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&& __
13671336
1368template <class _Alloc, class _SizeType, class _ConstVoidPtr>1337template <class _Alloc, class _SizeType, class _ConstVoidPtr>
1369struct __has_allocate_hint1338struct __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};
13781344
...@@ -1386,33 +1352,26 @@ struct __has_allocate_hint...@@ -1386,33 +1352,26 @@ struct __has_allocate_hint
13861352
1387#endif // _LIBCPP_CXX03_LANG1353#endif // _LIBCPP_CXX03_LANG
13881354
1389#if !defined(_LIBCPP_CXX03_LANG)1355_LIBCPP_SUPPRESS_DEPRECATED_PUSH
1356template <class _Alloc, class ..._Args,
1357 class = decltype(_VSTD::declval<_Alloc>().construct(_VSTD::declval<_Args>()...))>
1358static true_type __test_has_construct(int);
1359_LIBCPP_SUPPRESS_DEPRECATED_POP
13901360
1391template <class _Alloc, class _Tp, class ..._Args>1361template <class _Alloc, class...>
1392decltype(_VSTD::declval<_Alloc>().construct(_VSTD::declval<_Tp*>(),1362static false_type __test_has_construct(...);
1393 _VSTD::declval<_Args>()...),1363
1394 true_type())1364template <class _Alloc, class ..._Args>
1395__has_construct_test(_Alloc&& __a, _Tp* __p, _Args&& ...__args);1365struct __has_construct : decltype(__test_has_construct<_Alloc, _Args...>(0)) {};
13961366
1397template <class _Alloc, class _Pointer, class ..._Args>1367#if !defined(_LIBCPP_CXX03_LANG)
1398false_type
1399__has_construct_test(const _Alloc& __a, _Pointer&& __p, _Args&& ...__args);
1400
1401template <class _Alloc, class _Pointer, class ..._Args>
1402struct __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};
14111368
1369_LIBCPP_SUPPRESS_DEPRECATED_PUSH
1412template <class _Alloc, class _Pointer>1370template <class _Alloc, class _Pointer>
1413auto1371auto
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
14161375
1417template <class _Alloc, class _Pointer>1376template <class _Alloc, class _Pointer>
1418auto1377auto
...@@ -1421,18 +1380,17 @@ __has_destroy_test(const _Alloc& __a, _Pointer&& __p)...@@ -1421,18 +1380,17 @@ __has_destroy_test(const _Alloc& __a, _Pointer&& __p)
14211380
1422template <class _Alloc, class _Pointer>1381template <class _Alloc, class _Pointer>
1423struct __has_destroy1382struct __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};
14311387
1388_LIBCPP_SUPPRESS_DEPRECATED_PUSH
1432template <class _Alloc>1389template <class _Alloc>
1433auto1390auto
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
14361394
1437template <class _Alloc>1395template <class _Alloc>
1438auto1396auto
...@@ -1441,10 +1399,7 @@ __has_max_size_test(const volatile _Alloc& __a)...@@ -1441,10 +1399,7 @@ __has_max_size_test(const volatile _Alloc& __a)
14411399
1442template <class _Alloc>1400template <class _Alloc>
1443struct __has_max_size1401struct __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};
14501405
...@@ -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)
14601415
1461template <class _Alloc>1416template <class _Alloc>
1462struct __has_select_on_container_copy_construction1417struct __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};
14691421
1470#else // _LIBCPP_CXX03_LANG1422#else // _LIBCPP_CXX03_LANG
14711423
1472template <class _Alloc, class _Pointer, class _Tp, class = void>
1473struct __has_construct : std::false_type {};
1474
1475template <class _Alloc, class _Pointer, class _Tp>
1476struct __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
1480template <class _Alloc, class _Pointer, class = void>1424template <class _Alloc, class _Pointer, class = void>
1481struct __has_destroy : false_type {};1425struct __has_destroy : false_type {};
14821426
...@@ -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) _NOEXCEPT1532 static void deallocate(allocator_type& __a, pointer __p, size_type __n) _NOEXCEPT
1589 {__a.deallocate(__p, __n);}1533 {__a.deallocate(__p, __n);}
15901534
1591#ifndef _LIBCPP_HAS_NO_VARIADICS
1592 template <class _Tp, class... _Args>1535 template <class _Tp, class... _Args>
1593 _LIBCPP_INLINE_VISIBILITY1536 _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
16261540
1627 template <class _Tp>1541 template <class _Tp>
1628 _LIBCPP_INLINE_VISIBILITY1542 _LIBCPP_INLINE_VISIBILITY
...@@ -1695,7 +1609,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits...@@ -1695,7 +1609,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
1695 static1609 static
1696 typename enable_if1610 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_VISIBILITY1669 _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_VISIBILITY1677 _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);}
17631681
1764#ifndef _LIBCPP_HAS_NO_VARIADICS
1765 template <class _Tp, class... _Args>1682 template <class _Tp, class... _Args>
1766 _LIBCPP_INLINE_VISIBILITY1683 _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_VISIBILITY1692 _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
17891697
1790 template <class _Tp>1698 template <class _Tp>
1791 _LIBCPP_INLINE_VISIBILITY1699 _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_VISIBILITY1707 _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:
18001712
1801 _LIBCPP_INLINE_VISIBILITY1713 _LIBCPP_INLINE_VISIBILITY
1802 static size_type __max_size(true_type, const allocator_type& __a) _NOEXCEPT1714 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_VISIBILITY1721 _LIBCPP_INLINE_VISIBILITY
1805 static size_type __max_size(false_type, const allocator_type&) _NOEXCEPT1722 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>
1831class _LIBCPP_TEMPLATE_VIS allocator1748class _LIBCPP_TEMPLATE_VIS allocator
1832{1749{
1833public:1750public:
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;
18411763
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;
18441766
1845 template <class _Up> struct rebind {typedef allocator<_Up> other;};
1846
1847 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171767 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1848 allocator() _NOEXCEPT {}1768 allocator() _NOEXCEPT {}
18491769
...@@ -1851,103 +1771,67 @@ public:...@@ -1851,103 +1771,67 @@ public:
1851 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171771 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1852 allocator(const allocator<_Up>&) _NOEXCEPT {}1772 allocator(const allocator<_Up>&) _NOEXCEPT {}
18531773
1854 _LIBCPP_INLINE_VISIBILITY pointer address(reference __x) const _NOEXCEPT1774#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 _NOEXCEPT1778 _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_VISIBILITY1781#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) _NOEXCEPT1791
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 _NOEXCEPT1799
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_VISIBILITY1805 _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
1873 void1806 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_VISIBILITY1812#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};
19331814
1934template <class _Tp>1815template <class _Tp>
1935class _LIBCPP_TEMPLATE_VIS allocator<const _Tp>1816class _LIBCPP_TEMPLATE_VIS allocator<const _Tp>
1936{1817{
1937public:1818public:
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;
19451831
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;
19481834
1949 template <class _Up> struct rebind {typedef allocator<_Up> other;};
1950
1951 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171835 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1952 allocator() _NOEXCEPT {}1836 allocator() _NOEXCEPT {}
19531837
...@@ -1955,22 +1839,36 @@ public:...@@ -1955,22 +1839,36 @@ public:
1955 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171839 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1956 allocator(const allocator<_Up>&) _NOEXCEPT {}1840 allocator(const allocator<_Up>&) _NOEXCEPT {}
19571841
1958 _LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT1842#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) _NOEXCEPT1856
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 _NOEXCEPT1864
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_VISIBILITY1871 _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
1974 void1872 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};
20341933
2035template <class _Tp, class _Up>1934template <class _Tp, class _Up>
...@@ -2134,39 +2033,39 @@ private:...@@ -2134,39 +2033,39 @@ private:
2134public:2033public:
2135 typedef _Tp element_type;2034 typedef _Tp element_type;
21362035
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_;}
21482047
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 }
21652064
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};
21722071
...@@ -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::exception3292 : public std::exception
3394{3293{
3395public:3294public:
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:
36283529
3629template<class _Tp> class _LIBCPP_TEMPLATE_VIS enable_shared_from_this;3530template<class _Tp> class _LIBCPP_TEMPLATE_VIS enable_shared_from_this;
36303531
3532template<class _Tp, class _Up>
3533struct __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
3631template<class _Tp>3540template<class _Tp>
3632class _LIBCPP_TEMPLATE_VIS shared_ptr3541class _LIBCPP_TEMPLATE_VIS shared_ptr
3633{3542{
3634public:3543public:
3635 typedef _Tp element_type;
3636
3637#if _LIBCPP_STD_VER > 143544#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#endif3549#endif
3550
3640private:3551private:
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_VISIBILITY3576 _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_REFERENCES3580#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3670 _LIBCPP_INLINE_VISIBILITY3581 _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_REFERENCES3586#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#endif3598#endif
3688#endif3599#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_if3602 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 __nat3616 __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
37283618
3729 ~shared_ptr();3619 ~shared_ptr();
37303620
...@@ -3733,7 +3623,7 @@ public:...@@ -3733,7 +3623,7 @@ public:
3733 template<class _Yp>3623 template<class _Yp>
3734 typename enable_if3624 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 >::type3628 >::type
3739 _LIBCPP_INLINE_VISIBILITY3629 _LIBCPP_INLINE_VISIBILITY
...@@ -3744,8 +3634,8 @@ public:...@@ -3744,8 +3634,8 @@ public:
3744 template<class _Yp>3634 template<class _Yp>
3745 typename enable_if3635 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 >::type3639 >::type
3750 _LIBCPP_INLINE_VISIBILITY3640 _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_if3686 typename enable_if
3797 <3687 <
3798 is_convertible<_Yp*, element_type*>::value,3688 __compatible_with<_Yp, element_type>::value,
3799 void3689 void
3800 >::type3690 >::type
3801 _LIBCPP_INLINE_VISIBILITY3691 _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_if3694 typename enable_if
3805 <3695 <
3806 is_convertible<_Yp*, element_type*>::value,3696 __compatible_with<_Yp, element_type>::value,
3807 void3697 void
3808 >::type3698 >::type
3809 _LIBCPP_INLINE_VISIBILITY3699 _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_if3702 typename enable_if
3813 <3703 <
3814 is_convertible<_Yp*, element_type*>::value,3704 __compatible_with<_Yp, element_type>::value,
3815 void3705 void
3816 >::type3706 >::type
3817 _LIBCPP_INLINE_VISIBILITY3707 _LIBCPP_INLINE_VISIBILITY
...@@ -3823,7 +3713,12 @@ public:...@@ -3823,7 +3713,12 @@ public:
3823 typename add_lvalue_reference<element_type>::type operator*() const _NOEXCEPT3713 typename add_lvalue_reference<element_type>::type operator*() const _NOEXCEPT
3824 {return *__ptr_;}3714 {return *__ptr_;}
3825 _LIBCPP_INLINE_VISIBILITY3715 _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_VISIBILITY3722 _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_VISIBILITY3724 _LIBCPP_INLINE_VISIBILITY
...@@ -3843,6 +3738,17 @@ public:...@@ -3843,6 +3738,17 @@ public:
3843 __owner_equivalent(const shared_ptr& __p) const3738 __owner_equivalent(const shared_ptr& __p) const
3844 {return __cntrl_ == __p.__cntrl_;}3739 {return __cntrl_ == __p.__cntrl_;}
38453740
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_RTTI3752#ifndef _LIBCPP_NO_RTTI
3847 template <class _Dp>3753 template <class _Dp>
3848 _LIBCPP_INLINE_VISIBILITY3754 _LIBCPP_INLINE_VISIBILITY
...@@ -3854,7 +3760,7 @@ public:...@@ -3854,7 +3760,7 @@ public:
38543760
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 }
38653771
3866 template<class _Alloc, class ..._Args>
3867 static
3868 shared_ptr<_Tp>
3869 allocate_shared(const _Alloc& __a, _Args&& ...__args);
3870
3871private:3772private:
3872 template <class _Yp, bool = is_function<_Yp>::value>3773 template <class _Yp, bool = is_function<_Yp>::value>
3873 struct __shared_ptr_default_allocator3774 struct __shared_ptr_default_allocator
...@@ -3900,10 +3801,28 @@ private:...@@ -3900,10 +3801,28 @@ private:
39003801
3901 _LIBCPP_INLINE_VISIBILITY void __enable_weak_this(...) _NOEXCEPT {}3802 _LIBCPP_INLINE_VISIBILITY void __enable_weak_this(...) _NOEXCEPT {}
39023803
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};
39063819
3820#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
3821template<class _Tp>
3822shared_ptr(weak_ptr<_Tp>) -> shared_ptr<_Tp>;
3823template<class _Tp, class _Dp>
3824shared_ptr(unique_ptr<_Tp, _Dp>) -> shared_ptr<_Tp>;
3825#endif
39073826
3908template<class _Tp>3827template<class _Tp>
3909inline3828inline
...@@ -3926,13 +3845,13 @@ shared_ptr<_Tp>::shared_ptr(nullptr_t) _NOEXCEPT...@@ -3926,13 +3845,13 @@ shared_ptr<_Tp>::shared_ptr(nullptr_t) _NOEXCEPT
3926template<class _Tp>3845template<class _Tp>
3927template<class _Yp>3846template<class _Yp>
3928shared_ptr<_Tp>::shared_ptr(_Yp* __p,3847shared_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,
3940template<class _Tp>3859template<class _Tp>
3941template<class _Yp, class _Dp>3860template<class _Yp, class _Dp>
3942shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d,3861shared_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_EXCEPTIONS3865#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)
3986template<class _Tp>3905template<class _Tp>
3987template<class _Yp, class _Dp, class _Alloc>3906template<class _Yp, class _Dp, class _Alloc>
3988shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a,3907shared_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_EXCEPTIONS3911#ifndef _LIBCPP_NO_EXCEPTIONS
...@@ -4064,7 +3983,7 @@ template<class _Tp>...@@ -4064,7 +3983,7 @@ template<class _Tp>
4064template<class _Yp>3983template<class _Yp>
4065inline3984inline
4066shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r,3985shared_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 _NOEXCEPT3987 _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>
4089template<class _Yp>4008template<class _Yp>
4090inline4009inline
4091shared_ptr<_Tp>::shared_ptr(shared_ptr<_Yp>&& __r,4010shared_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 _NOEXCEPT4012 _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,
41204039
4121template<class _Tp>4040template<class _Tp>
4122template <class _Yp, class _Dp>4041template <class _Yp, class _Dp>
4123#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
4124shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r,4042shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r,
4125#else
4126shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r,
4127#endif
4128 typename enable_if4043 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,
41504065
4151template<class _Tp>4066template<class _Tp>
4152template <class _Yp, class _Dp>4067template <class _Yp, class _Dp>
4153#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
4154shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r,4068shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r,
4155#else
4156shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r,
4157#endif
4158 typename enable_if4069 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}
41824093
4183template<class _Tp>
4184template<class _Alloc, class ..._Args>
4185shared_ptr<_Tp>
4186shared_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
4203template<class _Tp>4094template<class _Tp>
4204shared_ptr<_Tp>::~shared_ptr()4095shared_ptr<_Tp>::~shared_ptr()
4205{4096{
...@@ -4221,7 +4112,7 @@ template<class _Yp>...@@ -4221,7 +4112,7 @@ template<class _Yp>
4221inline4112inline
4222typename enable_if4113typename 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>::type4117>::type
4227shared_ptr<_Tp>::operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT4118shared_ptr<_Tp>::operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT
...@@ -4246,7 +4137,7 @@ template<class _Yp>...@@ -4246,7 +4137,7 @@ template<class _Yp>
4246inline4137inline
4247typename enable_if4138typename 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>::type4142>::type
4252shared_ptr<_Tp>::operator=(shared_ptr<_Yp>&& __r)4143shared_ptr<_Tp>::operator=(shared_ptr<_Yp>&& __r)
...@@ -4347,7 +4238,7 @@ template<class _Yp>...@@ -4347,7 +4238,7 @@ template<class _Yp>
4347inline4238inline
4348typename enable_if4239typename 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 void4242 void
4352>::type4243>::type
4353shared_ptr<_Tp>::reset(_Yp* __p)4244shared_ptr<_Tp>::reset(_Yp* __p)
...@@ -4360,7 +4251,7 @@ template<class _Yp, class _Dp>...@@ -4360,7 +4251,7 @@ template<class _Yp, class _Dp>
4360inline4251inline
4361typename enable_if4252typename 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 void4255 void
4365>::type4256>::type
4366shared_ptr<_Tp>::reset(_Yp* __p, _Dp __d)4257shared_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>
4373inline4264inline
4374typename enable_if4265typename 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 void4268 void
4378>::type4269>::type
4379shared_ptr<_Tp>::reset(_Yp* __p, _Dp __d, _Alloc __a)4270shared_ptr<_Tp>::reset(_Yp* __p, _Dp __d, _Alloc __a)
...@@ -4412,7 +4303,19 @@ typename enable_if...@@ -4412,7 +4303,19 @@ typename enable_if
4412>::type4303>::type
4413allocate_shared(const _Alloc& __a, _Args&& ...__args)4304allocate_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}
44174320
4418template<class _Tp, class _Up>4321template<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
45754478
4576template<class _Tp, class _Up>4479template<class _Tp, class _Up>
4577inline _LIBCPP_INLINE_VISIBILITY4480inline _LIBCPP_INLINE_VISIBILITY
4578typename enable_if4481shared_ptr<_Tp>
4579<
4580 !is_array<_Tp>::value && !is_array<_Up>::value,
4581 shared_ptr<_Tp>
4582>::type
4583static_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT4482static_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}
45874488
4588template<class _Tp, class _Up>4489template<class _Tp, class _Up>
4589inline _LIBCPP_INLINE_VISIBILITY4490inline _LIBCPP_INLINE_VISIBILITY
4590typename enable_if4491shared_ptr<_Tp>
4591<
4592 !is_array<_Tp>::value && !is_array<_Up>::value,
4593 shared_ptr<_Tp>
4594>::type
4595dynamic_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT4492dynamic_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}
46004498
4601template<class _Tp, class _Up>4499template<class _Tp, class _Up>
4602typename enable_if4500shared_ptr<_Tp>
4603<
4604 is_array<_Tp>::value == is_array<_Up>::value,
4605 shared_ptr<_Tp>
4606>::type
4607const_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT4501const_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}
46124506
4507template<class _Tp, class _Up>
4508shared_ptr<_Tp>
4509reinterpret_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_RTTI4516#ifndef _LIBCPP_NO_RTTI
46144517
4615template<class _Dp, class _Tp>4518template<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};
47144617
4618#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
4619template<class _Tp>
4620weak_ptr(shared_ptr<_Tp>) -> weak_ptr<_Tp>;
4621#endif
4622
4715template<class _Tp>4623template<class _Tp>
4716inline4624inline
4717_LIBCPP_CONSTEXPR4625_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_VISIBILITY4916 _LIBCPP_INLINE_VISIBILITY
5009 result_type operator()(const argument_type& __ptr) const _NOEXCEPT4917 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};
50144922
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_list428 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
16namespace 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
77namespace numbers {
78
79template <class T>
80inline constexpr bool __false = false;
81
82template <class T>
83struct __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
88template <class T> inline constexpr T e_v = __illformed<T>{};
89template <class T> inline constexpr T log2e_v = __illformed<T>{};
90template <class T> inline constexpr T log10e_v = __illformed<T>{};
91template <class T> inline constexpr T pi_v = __illformed<T>{};
92template <class T> inline constexpr T inv_pi_v = __illformed<T>{};
93template <class T> inline constexpr T inv_sqrtpi_v = __illformed<T>{};
94template <class T> inline constexpr T ln2_v = __illformed<T>{};
95template <class T> inline constexpr T ln10_v = __illformed<T>{};
96template <class T> inline constexpr T sqrt2_v = __illformed<T>{};
97template <class T> inline constexpr T sqrt3_v = __illformed<T>{};
98template <class T> inline constexpr T inv_sqrt3_v = __illformed<T>{};
99template <class T> inline constexpr T egamma_v = __illformed<T>{};
100template <class T> inline constexpr T phi_v = __illformed<T>{};
101
102template <class T>
103concept __floating_point = std::is_floating_point_v<T>;
104
105template <__floating_point T> inline constexpr T e_v<T> = 2.718281828459045235360287471352662;
106template <__floating_point T> inline constexpr T log2e_v<T> = 1.442695040888963407359924681001892;
107template <__floating_point T> inline constexpr T log10e_v<T> = 0.434294481903251827651128918916605;
108template <__floating_point T> inline constexpr T pi_v<T> = 3.141592653589793238462643383279502;
109template <__floating_point T> inline constexpr T inv_pi_v<T> = 0.318309886183790671537767526745028;
110template <__floating_point T> inline constexpr T inv_sqrtpi_v<T> = 0.564189583547756286948079451560772;
111template <__floating_point T> inline constexpr T ln2_v<T> = 0.693147180559945309417232121458176;
112template <__floating_point T> inline constexpr T ln10_v<T> = 2.302585092994045684017991454684364;
113template <__floating_point T> inline constexpr T sqrt2_v<T> = 1.414213562373095048801688724209698;
114template <__floating_point T> inline constexpr T sqrt3_v<T> = 1.732050807568877293527446341505872;
115template <__floating_point T> inline constexpr T inv_sqrt3_v<T> = 0.577350269189625764509148780501957;
116template <__floating_point T> inline constexpr T egamma_v<T> = 0.577215664901532860606512090082402;
117template <__floating_point T> inline constexpr T phi_v<T> = 1.618033988749894848204586834365638;
118
119inline constexpr double e = e_v<double>;
120inline constexpr double log2e = log2e_v<double>;
121inline constexpr double log10e = log10e_v<double>;
122inline constexpr double pi = pi_v<double>;
123inline constexpr double inv_pi = inv_pi_v<double>;
124inline constexpr double inv_sqrtpi = inv_sqrtpi_v<double>;
125inline constexpr double ln2 = ln2_v<double>;
126inline constexpr double ln10 = ln10_v<double>;
127inline constexpr double sqrt2 = sqrt2_v<double>;
128inline constexpr double sqrt3 = sqrt3_v<double>;
129inline constexpr double inv_sqrt3 = inv_sqrt3_v<double>;
130inline constexpr double egamma = egamma_v<double>;
131inline 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}
10001000
1001template <class _CharT, class _Traits>1001template <class _CharT, class _Traits>
1002inline _LIBCPP_INLINE_VISIBILITY1002inline
1003basic_ostream<_CharT, _Traits>&1003basic_ostream<_CharT, _Traits>&
1004endl(basic_ostream<_CharT, _Traits>& __os)1004endl(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}
10101010
1011template <class _CharT, class _Traits>1011template <class _CharT, class _Traits>
1012inline _LIBCPP_INLINE_VISIBILITY1012inline
1013basic_ostream<_CharT, _Traits>&1013basic_ostream<_CharT, _Traits>&
1014ends(basic_ostream<_CharT, _Traits>& __os)1014ends(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}
10191019
1020template <class _CharT, class _Traits>1020template <class _CharT, class _Traits>
1021inline _LIBCPP_INLINE_VISIBILITY1021inline
1022basic_ostream<_CharT, _Traits>&1022basic_ostream<_CharT, _Traits>&
1023flush(basic_ostream<_CharT, _Traits>& __os)1023flush(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}
40704075
lib/libcxx/include/regex+47-21
...@@ -21,7 +21,7 @@ namespace std...@@ -21,7 +21,7 @@ namespace std
21namespace regex_constants21namespace regex_constants
22{22{
2323
24emum syntax_option_type24enum 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);
633633
634template <class traits, class charT, class ST, class SA, class FST, class FSA>>634template <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 __m680 regex_constants::match_flag_type m
681 = regex_constants::match_default) = delete; // C++14681 = 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;
698typedef regex_iterator<wstring::const_iterator> wsregex_iterator;698typedef regex_iterator<wstring::const_iterator> wsregex_iterator;
699699
700template <class BidirectionalIterator,700template <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>>
703class regex_token_iterator703class 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&);
742742
...@@ -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_;
978public:978public:
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_VISIBILITY982 _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
10041017
1005 static const char_class_type __regex_word = ctype_base::__regex_word;1018 static const char_class_type __regex_word = ctype_base::__regex_word;
1006private:1019private:
...@@ -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);
28392852
2853 bool __test_back_ref(_CharT c);
2854
2840 _LIBCPP_INLINE_VISIBILITY2855 _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}
46624669
4670template <class _CharT, class _Traits>
4671bool
4672basic_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
4663template <class _CharT, class _Traits>4686template <class _CharT, class _Traits>
4664void4687void
4665basic_regex<_CharT, _Traits>::__push_loop(size_t __min, size_t __max,4688basic_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) const5941 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
16namespace std {
17
18template<ptrdiff_t least_max_value = implementation-defined>
19class counting_semaphore
20{
21public:
22static constexpr ptrdiff_t max() noexcept;
23
24constexpr explicit counting_semaphore(ptrdiff_t desired);
25~counting_semaphore();
26
27counting_semaphore(const counting_semaphore&) = delete;
28counting_semaphore& operator=(const counting_semaphore&) = delete;
29
30void release(ptrdiff_t update = 1);
31void acquire();
32bool try_acquire() noexcept;
33template<class Rep, class Period>
34 bool try_acquire_for(const chrono::duration<Rep, Period>& rel_time);
35template<class Clock, class Duration>
36 bool try_acquire_until(const chrono::time_point<Clock, Duration>& abs_time);
37
38private:
39ptrdiff_t counter; // exposition only
40};
41
42using 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
68user-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
71It is a typical Dijsktra semaphore algorithm over atomics, wait and notify
72functions. It avoids contention against users' own use of those facilities.
73
74*/
75
76class __atomic_semaphore_base
77{
78 __atomic_base<ptrdiff_t> __a;
79
80public:
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
126is, every call is routed to the OS in the most direct manner possible.
127
128*/
129
130class __platform_semaphore_base
131{
132 __libcpp_semaphore_t __semaphore;
133
134public:
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
163template<ptrdiff_t __least_max_value>
164using __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
171template<ptrdiff_t __least_max_value>
172using __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
179template<ptrdiff_t __least_max_value = _LIBCPP_SEMAPHORE_MAX>
180class counting_semaphore
181{
182 __semaphore_base<__least_max_value> __semaphore;
183
184public:
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
229using 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)));
217217
218template <class Key, class Compare, class Allocator, class Predicate>218template <class Key, class Compare, class Allocator, class Predicate>
219 void erase_if(set<Key, Compare, Allocator>& c, Predicate pred); // C++20219typename set<Key, Compare, Allocator>::size_type
220erase_if(set<Key, Compare, Allocator>& c, Predicate pred); // C++20
220221
221template <class Key, class Compare = less<Key>,222template <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)));
418419
419template <class Key, class Compare, class Allocator, class Predicate>420template <class Key, class Compare, class Allocator, class Predicate>
420 void erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20421typename multiset<Key, Compare, Allocator>::size_type
422erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20
421423
422} // std424} // std
423425
...@@ -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 > 17962#if _LIBCPP_STD_VER > 17
961template <class _Key, class _Compare, class _Allocator, class _Predicate>963template <class _Key, class _Compare, class _Allocator, class _Predicate>
962inline _LIBCPP_INLINE_VISIBILITY964inline _LIBCPP_INLINE_VISIBILITY
963void 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#endif969#endif
966970
967template <class _Key, class _Compare = less<_Key>,971template <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 > 171488#if _LIBCPP_STD_VER > 17
1485template <class _Key, class _Compare, class _Allocator, class _Predicate>1489template <class _Key, class _Compare, class _Allocator, class _Predicate>
1486inline _LIBCPP_INLINE_VISIBILITY1490inline _LIBCPP_INLINE_VISIBILITY
1487void 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#endif1495#endif
14901496
1491_LIBCPP_END_NAMESPACE_STD1497_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;
5351
54 // [span.cons], span constructors, copy, assignment, and destructor52 // [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;
7371
...@@ -97,12 +95,8 @@ public:...@@ -97,12 +95,8 @@ public:
97 // [span.iterators], span iterator support95 // [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;
106100
107private:101private:
108 pointer data_; // exposition only102 pointer data_; // exposition only
...@@ -129,11 +123,10 @@ template<class Container>...@@ -129,11 +123,10 @@ template<class Container>
129*/123*/
130124
131#include <__config>125#include <__config>
132#include <cstddef> // for ptrdiff_t
133#include <iterator> // for iterators
134#include <array> // for array126#include <array> // for array
135#include <type_traits> // for remove_cv, etc
136#include <cstddef> // for byte127#include <cstddef> // for byte
128#include <iterator> // for iterators
129#include <type_traits> // for remove_cv, etc
137130
138#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)131#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
139#pragma GCC system_header132#pragma GCC system_header
...@@ -143,7 +136,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -143,7 +136,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
143136
144#if _LIBCPP_STD_VER > 17137#if _LIBCPP_STD_VER > 17
145138
146inline constexpr size_t dynamic_extent = numeric_limits<size_t>::max();139inline constexpr size_t dynamic_extent = (numeric_limits<size_t>::max)();
147template <typename _Tp, size_t _Extent = dynamic_extent> class span;140template <typename _Tp, size_t _Extent = dynamic_extent> class span;
148141
149142
...@@ -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>;
208199
209 static constexpr size_type extent = _Extent;200 static constexpr size_type extent = _Extent;
210201
211// [span.cons], span constructors, copy, assignment, and destructor202// [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} {}
214205
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;
217208
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)"); }
222213
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 }
226241
227 template <class _OtherElementType>242 template <class _OtherElementType>
228 _LIBCPP_INLINE_VISIBILITY243 _LIBCPP_INLINE_VISIBILITY
...@@ -234,7 +249,7 @@ public:...@@ -234,7 +249,7 @@ public:
234249
235 template <class _OtherElementType>250 template <class _OtherElementType>
236 _LIBCPP_INLINE_VISIBILITY251 _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) noexcept255 nullptr_t> = nullptr) noexcept
...@@ -248,7 +263,7 @@ public:...@@ -248,7 +263,7 @@ public:
248 constexpr span<element_type, _Count> first() const noexcept263 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 }
253268
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 noexcept271 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 }
261276
262 _LIBCPP_INLINE_VISIBILITY277 _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 }
284302
285303
...@@ -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 }
297315
...@@ -301,19 +319,19 @@ public:...@@ -301,19 +319,19 @@ public:
301319
302 _LIBCPP_INLINE_VISIBILITY constexpr reference operator[](size_type __idx) const noexcept320 _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 }
307325
308 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept326 _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 }
313331
314 _LIBCPP_INLINE_VISIBILITY constexpr reference back() const noexcept332 _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 }
319337
...@@ -322,25 +340,14 @@ public:...@@ -322,25 +340,14 @@ public:
322// [span.iter], span iterator support340// [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 }
338345
339 _LIBCPP_INLINE_VISIBILITY span<const byte, _Extent * sizeof(element_type)> __as_bytes() const noexcept346 _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()}; }
341348
342 _LIBCPP_INLINE_VISIBILITY span<byte, _Extent * sizeof(element_type)> __as_writable_bytes() const noexcept349 _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()}; }
344351
345private:352private:
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>;
369374
370 static constexpr size_type extent = dynamic_extent;375 static constexpr size_type extent = dynamic_extent;
371376
...@@ -382,13 +387,15 @@ public:...@@ -382,13 +387,15 @@ public:
382 _LIBCPP_INLINE_VISIBILITY387 _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} {}
384389
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_VISIBILITY392 _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} {}
388394
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_VISIBILITY397 _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} {}
392399
393 template <class _Container>400 template <class _Container>
394 _LIBCPP_INLINE_VISIBILITY401 _LIBCPP_INLINE_VISIBILITY
...@@ -418,7 +425,7 @@ public:...@@ -418,7 +425,7 @@ public:
418 constexpr span<element_type, _Count> first() const noexcept425 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 }
423430
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 noexcept433 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 }
431438
432 _LIBCPP_INLINE_VISIBILITY439 _LIBCPP_INLINE_VISIBILITY
...@@ -445,11 +452,11 @@ public:...@@ -445,11 +452,11 @@ public:
445452
446 template <size_t _Offset, size_t _Count = dynamic_extent>453 template <size_t _Offset, size_t _Count = dynamic_extent>
447 _LIBCPP_INLINE_VISIBILITY454 _LIBCPP_INLINE_VISIBILITY
448 constexpr span<_Tp, dynamic_extent> subspan() const noexcept455 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 }
454461
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 }
466473
...@@ -470,7 +477,7 @@ public:...@@ -470,7 +477,7 @@ public:
470477
471 _LIBCPP_INLINE_VISIBILITY constexpr reference operator[](size_type __idx) const noexcept478 _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 }
476483
...@@ -492,23 +499,8 @@ public:...@@ -492,23 +499,8 @@ public:
492// [span.iter], span iterator support499// [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 }
512504
513 _LIBCPP_INLINE_VISIBILITY span<const byte, dynamic_extent> __as_bytes() const noexcept505 _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};
523515
524// tuple interface
525template <class _Tp, size_t _Size>
526struct _LIBCPP_TEMPLATE_VIS tuple_size<span<_Tp, _Size>>
527 : public integral_constant<size_t, _Size> {};
528
529template <class _Tp>
530struct _LIBCPP_TEMPLATE_VIS tuple_size<span<_Tp, dynamic_extent>>; // declared but not defined
531
532
533template <size_t _Ip, class _Tp, size_t _Size>
534struct _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
541template <size_t _Ip, class _Tp, size_t _Size>
542_LIBCPP_INLINE_VISIBILITY constexpr
543_Tp&
544get(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_bytes516// as_bytes & as_writable_bytes
553template <class _Tp, size_t _Extent>517template <class _Tp, size_t _Extent>
554_LIBCPP_INLINE_VISIBILITY518_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(); }
564528
565template <class _Tp, size_t _Extent>
566_LIBCPP_INLINE_VISIBILITY
567constexpr void swap(span<_Tp, _Extent> &__lhs, span<_Tp, _Extent> &__rhs) noexcept
568{ __lhs.swap(__rhs); }
569
570
571// Deduction guides529// Deduction guides
572template<class _Tp, size_t _Sz>530template<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:
3131
32 ptrdiff_t32 ptrdiff_t
33 size_t33 size_t
34 max_align_t34 max_align_t // C++11
35 nullptr_t35 nullptr_t
3636
37*/37*/
...@@ -51,12 +51,6 @@ extern "C++" {...@@ -51,12 +51,6 @@ extern "C++" {
51using std::nullptr_t;51using std::nullptr_t;
52}52}
5353
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__)
57typedef long double max_align_t;
58#endif
59
60#endif54#endif
6155
62#endif // _LIBCPP_STDDEF_H56#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) {}
130130
131#ifndef _LIBCPP_ABI_VCRUNTIME131#ifndef _LIBCPP_ABI_VCRUNTIME
132 domain_error(const domain_error&) _NOEXCEPT = default;
132 virtual ~domain_error() _NOEXCEPT;133 virtual ~domain_error() _NOEXCEPT;
133#endif134#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) {}
142143
143#ifndef _LIBCPP_ABI_VCRUNTIME144#ifndef _LIBCPP_ABI_VCRUNTIME
145 invalid_argument(const invalid_argument&) _NOEXCEPT = default;
144 virtual ~invalid_argument() _NOEXCEPT;146 virtual ~invalid_argument() _NOEXCEPT;
145#endif147#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_VCRUNTIME156#ifndef _LIBCPP_ABI_VCRUNTIME
157 length_error(const length_error&) _NOEXCEPT = default;
155 virtual ~length_error() _NOEXCEPT;158 virtual ~length_error() _NOEXCEPT;
156#endif159#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) {}
165168
166#ifndef _LIBCPP_ABI_VCRUNTIME169#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#endif172#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) {}
177181
178#ifndef _LIBCPP_ABI_VCRUNTIME182#ifndef _LIBCPP_ABI_VCRUNTIME
183 range_error(const range_error&) _NOEXCEPT = default;
179 virtual ~range_error() _NOEXCEPT;184 virtual ~range_error() _NOEXCEPT;
180#endif185#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) {}
189194
190#ifndef _LIBCPP_ABI_VCRUNTIME195#ifndef _LIBCPP_ABI_VCRUNTIME
196 overflow_error(const overflow_error&) _NOEXCEPT = default;
191 virtual ~overflow_error() _NOEXCEPT;197 virtual ~overflow_error() _NOEXCEPT;
192#endif198#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) {}
201207
202#ifndef _LIBCPP_ABI_VCRUNTIME208#ifndef _LIBCPP_ABI_VCRUNTIME
209 underflow_error(const underflow_error&) _NOEXCEPT = default;
203 virtual ~underflow_error() _NOEXCEPT;210 virtual ~underflow_error() _NOEXCEPT;
204#endif211#endif
205};212};
lib/libcxx/include/stdlib.h+58-6
...@@ -7,16 +7,12 @@...@@ -7,16 +7,12 @@
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
99
10#if defined(__need_malloc_and_calloc) || defined(_LIBCPP_STDLIB_INCLUDE_NEXT)10#if defined(__need_malloc_and_calloc)
1111
12#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)12#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
13#pragma GCC system_header13#pragma GCC system_header
14#endif14#endif
1515
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>
2117
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>
9894
99#ifdef __cplusplus95#ifdef __cplusplus
100#include <math.h>96extern "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)
107inline _LIBCPP_INLINE_VISIBILITY long abs(long __x) _NOEXCEPT {
108 return __builtin_labs(__x);
109}
110#ifndef _LIBCPP_HAS_NO_LONG_LONG
111inline _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__))
118inline _LIBCPP_INLINE_VISIBILITY float abs(float __lcpp_x) _NOEXCEPT {
119 return __builtin_fabsf(__lcpp_x); // Use builtins to prevent needing math.h
120}
121
122inline _LIBCPP_INLINE_VISIBILITY double abs(double __lcpp_x) _NOEXCEPT {
123 return __builtin_fabs(__lcpp_x);
124}
125
126inline _LIBCPP_INLINE_VISIBILITY long double
127abs(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)
142inline _LIBCPP_INLINE_VISIBILITY ldiv_t div(long __x, long __y) _NOEXCEPT {
143 return ::ldiv(__x, __y);
144}
145#ifndef _LIBCPP_HAS_NO_LONG_LONG
146inline _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 // __cplusplus153#endif // __cplusplus
102154
103#endif // _LIBCPP_STDLIB_H155#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>&
437getline(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str);437getline(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str);
438438
439template<class charT, class traits, class Allocator, class U>439template<class charT, class traits, class Allocator, class U>
440void erase(basic_string<charT, traits, Allocator>& c, const U& value); // C++20440typename basic_string<charT, traits, Allocator>::size_type
441erase(basic_string<charT, traits, Allocator>& c, const U& value); // C++20
441template<class charT, class traits, class Allocator, class Predicate>442template<class charT, class traits, class Allocator, class Predicate>
442void erase_if(basic_string<charT, traits, Allocator>& c, Predicate pred); // C++20443typename basic_string<charT, traits, Allocator>::size_type
444erase_if(basic_string<charT, traits, Allocator>& c, Predicate pred); // C++20
443445
444typedef basic_string<char> string;446typedef basic_string<char> string;
445typedef basic_string<wchar_t> wstring;447typedef 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) {};
644646
645template <class _CharT, class _Traits, class _Tp>647template <class _CharT, class _Traits, class _Tp>
646struct __can_be_converted_to_string_view : public _LIBCPP_BOOL_CONSTANT(648struct __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 > {};
649652
650#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT653#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
651654
...@@ -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");
690693
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;
700698
...@@ -784,6 +782,7 @@ private:...@@ -784,6 +782,7 @@ private:
784 __compressed_pair<__rep, allocator_type> __r_;782 __compressed_pair<__rep, allocator_type> __r_;
785783
786public:784public:
785 _LIBCPP_FUNC_VIS
787 static const size_type npos = -1;786 static const size_type npos = -1;
788787
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_LANG812#endif // _LIBCPP_CXX03_LANG
814813
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_VISIBILITY815 _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# endif821# endif
823 }822 }
824823
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_VISIBILITY825 _LIBCPP_INLINE_VISIBILITY
827 basic_string(const _CharT* __s, const _Allocator& __a);826 basic_string(const _CharT* __s, const _Allocator& __a);
828827
...@@ -833,7 +832,7 @@ public:...@@ -833,7 +832,7 @@ public:
833 _LIBCPP_INLINE_VISIBILITY832 _LIBCPP_INLINE_VISIBILITY
834 basic_string(size_type __n, _CharT __c);833 basic_string(size_type __n, _CharT __c);
835834
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_VISIBILITY836 _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);
839838
...@@ -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());
845844
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_VIS846 _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());
850849
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_VIS852 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
853 explicit basic_string(const _Tp& __t);853 explicit basic_string(const _Tp& __t);
854854
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_VIS856 _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);
858858
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_VISIBILITY860 _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_VISIBILITY863 _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_LANG865#ifndef _LIBCPP_CXX03_LANG
...@@ -876,7 +876,7 @@ public:...@@ -876,7 +876,7 @@ public:
876876
877 basic_string& operator=(const basic_string& __str);877 basic_string& operator=(const basic_string& __str);
878878
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);}
882882
...@@ -976,11 +976,12 @@ public:...@@ -976,11 +976,12 @@ public:
976976
977 template <class _Tp>977 template <class _Tp>
978 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS978 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
979 typename enable_if979 _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 >::type984 >
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:
993994
994 template <class _Tp>995 template <class _Tp>
995 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS996 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
996 typename enable_if997 _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 >::type1001 >
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);
10031004
1004 template <class _Tp>1005 template <class _Tp>
1005 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1006 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1006 typename enable_if1007 _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 >::type1012 >
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_VIS1025 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1024 typename enable_if1026 _EnableIf
1025 <1027 <
1026 __is_exactly_cpp17_input_iterator<_InputIterator>::value1028 __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 >::type1031 >
1030 _LIBCPP_INLINE_VISIBILITY1032 _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_VIS1039 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1038 typename enable_if1040 _EnableIf
1039 <1041 <
1040 __is_cpp17_forward_iterator<_ForwardIterator>::value1042 __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 >::type1045 >
1044 _LIBCPP_INLINE_VISIBILITY1046 _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:
10611063
1062 template <class _Tp>1064 template <class _Tp>
1063 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1065 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1064 typename enable_if1066 _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 >::type1070 >
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_VISIBILITY1072 _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_VIS1082 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1081 typename enable_if1083 _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 >::type1088 >
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_VIS1094 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1092 typename enable_if1095 _EnableIf
1093 <1096 <
1094 __is_exactly_cpp17_input_iterator<_InputIterator>::value1097 __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 >::type1100 >
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_VIS1103 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1101 typename enable_if1104 _EnableIf
1102 <1105 <
1103 __is_cpp17_forward_iterator<_ForwardIterator>::value1106 __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 >::type1109 >
1107 assign(_ForwardIterator __first, _ForwardIterator __last);1110 assign(_ForwardIterator __first, _ForwardIterator __last);
1108#ifndef _LIBCPP_CXX03_LANG1111#ifndef _LIBCPP_CXX03_LANG
1109 _LIBCPP_INLINE_VISIBILITY1112 _LIBCPP_INLINE_VISIBILITY
...@@ -1115,21 +1118,21 @@ public:...@@ -1115,21 +1118,21 @@ public:
11151118
1116 template <class _Tp>1119 template <class _Tp>
1117 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1120 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1118 typename enable_if1121 _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 >::type1125 >
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()); }
11251128
1126 template <class _Tp>1129 template <class _Tp>
1127 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1130 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1128 typename enable_if1131 _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 >::type1135 >
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_VIS1145 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1143 typename enable_if1146 _EnableIf
1144 <1147 <
1145 __is_exactly_cpp17_input_iterator<_InputIterator>::value1148 __is_exactly_cpp17_input_iterator<_InputIterator>::value
1146 || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value,1149 || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value,
1147 iterator1150 iterator
1148 >::type1151 >
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_VIS1154 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1152 typename enable_if1155 _EnableIf
1153 <1156 <
1154 __is_cpp17_forward_iterator<_ForwardIterator>::value1157 __is_cpp17_forward_iterator<_ForwardIterator>::value
1155 && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value,1158 && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value,
1156 iterator1159 iterator
1157 >::type1160 >
1158 insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last);1161 insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last);
1159#ifndef _LIBCPP_CXX03_LANG1162#ifndef _LIBCPP_CXX03_LANG
1160 _LIBCPP_INLINE_VISIBILITY1163 _LIBCPP_INLINE_VISIBILITY
...@@ -1173,20 +1176,20 @@ public:...@@ -1173,20 +1176,20 @@ public:
11731176
1174 template <class _Tp>1177 template <class _Tp>
1175 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1178 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1176 typename enable_if1179 _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 >::type1183 >
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_VIS1187 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1185 typename enable_if1188 _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 >::type1192 >
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:
11961199
1197 template <class _Tp>1200 template <class _Tp>
1198 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1201 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1199 typename enable_if1202 _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 >::type1206 >
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); }
12051208
1206 _LIBCPP_INLINE_VISIBILITY1209 _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_VIS1216 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1214 typename enable_if1217 _EnableIf
1215 <1218 <
1216 __is_cpp17_input_iterator<_InputIterator>::value,1219 __is_cpp17_input_iterator<_InputIterator>::value,
1217 basic_string&1220 basic_string&
1218 >::type1221 >
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_LANG1223#ifndef _LIBCPP_CXX03_LANG
1221 _LIBCPP_INLINE_VISIBILITY1224 _LIBCPP_INLINE_VISIBILITY
...@@ -1253,11 +1256,11 @@ public:...@@ -1253,11 +1256,11 @@ public:
12531256
1254 template <class _Tp>1257 template <class _Tp>
1255 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1258 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1256 typename enable_if1259 _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_type1262 size_type
1260 >::type1263 >
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_VISIBILITY1266 _LIBCPP_INLINE_VISIBILITY
...@@ -1269,11 +1272,11 @@ public:...@@ -1269,11 +1272,11 @@ public:
12691272
1270 template <class _Tp>1273 template <class _Tp>
1271 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1274 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1272 typename enable_if1275 _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_type1278 size_type
1276 >::type1279 >
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_VISIBILITY1282 _LIBCPP_INLINE_VISIBILITY
...@@ -1285,11 +1288,11 @@ public:...@@ -1285,11 +1288,11 @@ public:
12851288
1286 template <class _Tp>1289 template <class _Tp>
1287 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1290 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1288 typename enable_if1291 _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_type1294 size_type
1292 >::type1295 >
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_VISIBILITY1298 _LIBCPP_INLINE_VISIBILITY
...@@ -1302,11 +1305,11 @@ public:...@@ -1302,11 +1305,11 @@ public:
13021305
1303 template <class _Tp>1306 template <class _Tp>
1304 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1307 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1305 typename enable_if1308 _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_type1311 size_type
1309 >::type1312 >
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_VISIBILITY1315 _LIBCPP_INLINE_VISIBILITY
...@@ -1319,11 +1322,11 @@ public:...@@ -1319,11 +1322,11 @@ public:
13191322
1320 template <class _Tp>1323 template <class _Tp>
1321 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1324 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1322 typename enable_if1325 _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_type1328 size_type
1326 >::type1329 >
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_VISIBILITY1332 _LIBCPP_INLINE_VISIBILITY
...@@ -1336,11 +1339,11 @@ public:...@@ -1336,11 +1339,11 @@ public:
13361339
1337 template <class _Tp>1340 template <class _Tp>
1338 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1341 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1339 typename enable_if1342 _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_type1345 size_type
1343 >::type1346 >
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_VISIBILITY1349 _LIBCPP_INLINE_VISIBILITY
...@@ -1353,20 +1356,20 @@ public:...@@ -1353,20 +1356,20 @@ public:
13531356
1354 template <class _Tp>1357 template <class _Tp>
1355 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1358 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1356 typename enable_if1359 _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 int1362 int
1360 >::type1363 >
1361 compare(const _Tp &__t) const;1364 compare(const _Tp &__t) const;
13621365
1363 template <class _Tp>1366 template <class _Tp>
1364 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1367 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1365 typename enable_if1368 _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 int1371 int
1369 >::type1372 >
1370 compare(size_type __pos1, size_type __n1, const _Tp& __t) const;1373 compare(size_type __pos1, size_type __n1, const _Tp& __t) const;
13711374
1372 _LIBCPP_INLINE_VISIBILITY1375 _LIBCPP_INLINE_VISIBILITY
...@@ -1375,11 +1378,11 @@ public:...@@ -1375,11 +1378,11 @@ public:
13751378
1376 template <class _Tp>1379 template <class _Tp>
1377 inline _LIBCPP_INLINE_VISIBILITY1380 inline _LIBCPP_INLINE_VISIBILITY
1378 typename enable_if1381 _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 int1384 int
1382 >::type1385 >
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 inline1546 inline
1544 void __init(size_type __n, value_type __c);1547 void __init(size_type __n, value_type __c);
15451548
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 inline1560 inline
1548 typename enable_if1561 _EnableIf
1549 <1562 <
1550 __is_exactly_cpp17_input_iterator<_InputIterator>::value,1563 __is_exactly_cpp17_input_iterator<_InputIterator>::value
1551 void1564 >
1552 >::type
1553 __init(_InputIterator __first, _InputIterator __last);1565 __init(_InputIterator __first, _InputIterator __last);
15541566
1555 template <class _ForwardIterator>1567 template <class _ForwardIterator>
1556 inline1568 inline
1557 typename enable_if1569 _EnableIf
1558 <1570 <
1559 __is_cpp17_forward_iterator<_ForwardIterator>::value,1571 __is_cpp17_forward_iterator<_ForwardIterator>::value
1560 void1572 >
1561 >::type
1562 __init(_ForwardIterator __first, _ForwardIterator __last);1573 __init(_ForwardIterator __first, _ForwardIterator __last);
15631574
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);
15691580
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_VISIBILITY1587 _LIBCPP_INLINE_VISIBILITY
1571 void __erase_to_end(size_type __pos);1588 void __erase_to_end(size_type __pos);
15721589
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_VISIBILITY1594 _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 _NOEXCEPT1659 _NOEXCEPT
1639 {}1660 {}
16401661
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);
16431677
...@@ -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};
16501684
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_GUIDES1696#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
1652template<class _InputIterator,1697template<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>::type1701 class = _EnableIf<__is_allocator<_Allocator>::value>
1657 >1702 >
1658basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())1703basic_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())
1661template<class _CharT,1706template<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>::type1709 class = _EnableIf<__is_allocator<_Allocator>::value>
1665 >1710 >
1666explicit basic_string(basic_string_view<_CharT, _Traits>, const _Allocator& = _Allocator())1711explicit 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
1669template<class _CharT,1714template<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_type1718 class _Sz = typename allocator_traits<_Allocator>::size_type
1674 >1719 >
1675basic_string(basic_string_view<_CharT, _Traits>, _Sz, _Sz, const _Allocator& = _Allocator())1720basic_string(basic_string_view<_CharT, _Traits>, _Sz, _Sz, const _Allocator& = _Allocator())
1676 -> basic_string<_CharT, _Traits, _Allocator>;1721 -> basic_string<_CharT, _Traits, _Allocator>;
1677#endif1722#endif
16781723
1679
1680template <class _CharT, class _Traits, class _Allocator>1724template <class _CharT, class _Traits, class _Allocator>
1681inline1725inline
1682void1726void
...@@ -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 else1883 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 >= 21887#if _LIBCPP_DEBUG_LEVEL >= 2
1842 __get_db()->__insert_c(this);1888 __get_db()->__insert_c(this);
1843#endif1889#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 else1899 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 >= 21902#if _LIBCPP_DEBUG_LEVEL >= 2
1856 __get_db()->__insert_c(this);1903 __get_db()->__insert_c(this);
1857#endif1904#endif
1858}1905}
18591906
1907template <class _CharT, class _Traits, class _Allocator>
1908void 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_LANG1926#ifndef _LIBCPP_CXX03_LANG
18611927
1862template <class _CharT, class _Traits, class _Allocator>1928template <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 _
20142080
2015template <class _CharT, class _Traits, class _Allocator>2081template <class _CharT, class _Traits, class _Allocator>
2016template <class _InputIterator>2082template <class _InputIterator>
2017typename enable_if2083_EnableIf
2018<2084<
2019 __is_exactly_cpp17_input_iterator<_InputIterator>::value,2085 __is_exactly_cpp17_input_iterator<_InputIterator>::value
2020 void2086>
2021>::type
2022basic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _InputIterator __last)2087basic_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
20412106
2042template <class _CharT, class _Traits, class _Allocator>2107template <class _CharT, class _Traits, class _Allocator>
2043template <class _ForwardIterator>2108template <class _ForwardIterator>
2044typename enable_if2109_EnableIf
2045<2110<
2046 __is_cpp17_forward_iterator<_ForwardIterator>::value,2111 __is_cpp17_forward_iterator<_ForwardIterator>::value
2047 void2112>
2048>::type
2049basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _ForwardIterator __last)2113basic_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
21972261
2198// assign2262// assign
21992263
2264template <class _CharT, class _Traits, class _Allocator>
2265template <bool __is_short>
2266basic_string<_CharT, _Traits, _Allocator>&
2267basic_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
2283template <class _CharT, class _Traits, class _Allocator>
2284basic_string<_CharT, _Traits, _Allocator>&
2285basic_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
2200template <class _CharT, class _Traits, class _Allocator>2301template <class _CharT, class _Traits, class _Allocator>
2201basic_string<_CharT, _Traits, _Allocator>&2302basic_string<_CharT, _Traits, _Allocator>&
2202basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_type __n)2303basic_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}
22212310
2222template <class _CharT, class _Traits, class _Allocator>2311template <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>
2263basic_string<_CharT, _Traits, _Allocator>&2352basic_string<_CharT, _Traits, _Allocator>&
2264basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str)2353basic_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}
22732369
2274#ifndef _LIBCPP_CXX03_LANG2370#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)
23262422
2327template <class _CharT, class _Traits, class _Allocator>2423template <class _CharT, class _Traits, class _Allocator>
2328template<class _InputIterator>2424template<class _InputIterator>
2329typename enable_if2425_EnableIf
2330<2426<
2331 __is_exactly_cpp17_input_iterator <_InputIterator>::value2427 __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>::type2430>
2335basic_string<_CharT, _Traits, _Allocator>::assign(_InputIterator __first, _InputIterator __last)2431basic_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
23412437
2342template <class _CharT, class _Traits, class _Allocator>2438template <class _CharT, class _Traits, class _Allocator>
2343template<class _ForwardIterator>2439template<class _ForwardIterator>
2344typename enable_if2440_EnableIf
2345<2441<
2346 __is_cpp17_forward_iterator<_ForwardIterator>::value2442 __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>::type2445>
2350basic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last)2446basic_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
23782474
2379template <class _CharT, class _Traits, class _Allocator>2475template <class _CharT, class _Traits, class _Allocator>
2380template <class _Tp>2476template <class _Tp>
2381typename enable_if2477_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>::type2482>
2386basic_string<_CharT, _Traits, _Allocator>::assign(const _Tp & __t, size_type __pos, size_type __n)2483basic_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}
23942491
23952492
2493template <class _CharT, class _Traits, class _Allocator>
2494basic_string<_CharT, _Traits, _Allocator>&
2495basic_string<_CharT, _Traits, _Allocator>::__assign_external(const value_type* __s) {
2496 return __assign_external(__s, traits_type::length(__s));
2497}
2498
2396template <class _CharT, class _Traits, class _Allocator>2499template <class _CharT, class _Traits, class _Allocator>
2397basic_string<_CharT, _Traits, _Allocator>&2500basic_string<_CharT, _Traits, _Allocator>&
2398basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s)2501basic_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// append2510// append
24052511
2406template <class _CharT, class _Traits, class _Allocator>2512template <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
25652671
2566template <class _CharT, class _Traits, class _Allocator>2672template <class _CharT, class _Traits, class _Allocator>
2567template <class _Tp>2673template <class _Tp>
2568 typename enable_if2674 _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 >::type2678 >
2573basic_string<_CharT, _Traits, _Allocator>::append(const _Tp & __t, size_type __pos, size_type __n)2679basic_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
26542760
2655template <class _CharT, class _Traits, class _Allocator>2761template <class _CharT, class _Traits, class _Allocator>
2656template<class _InputIterator>2762template<class _InputIterator>
2657typename enable_if2763_EnableIf
2658<2764<
2659 __is_exactly_cpp17_input_iterator<_InputIterator>::value2765 __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>::iterator2767 typename basic_string<_CharT, _Traits, _Allocator>::iterator
2662>::type2768>
2663basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIterator __first, _InputIterator __last)2769basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIterator __first, _InputIterator __last)
2664{2770{
2665#if _LIBCPP_DEBUG_LEVEL >= 22771#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
26732779
2674template <class _CharT, class _Traits, class _Allocator>2780template <class _CharT, class _Traits, class _Allocator>
2675template<class _ForwardIterator>2781template<class _ForwardIterator>
2676typename enable_if2782_EnableIf
2677<2783<
2678 __is_cpp17_forward_iterator<_ForwardIterator>::value2784 __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>::iterator2786 typename basic_string<_CharT, _Traits, _Allocator>::iterator
2681>::type2787>
2682basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last)2788basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last)
2683{2789{
2684#if _LIBCPP_DEBUG_LEVEL >= 22790#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_
27432849
2744template <class _CharT, class _Traits, class _Allocator>2850template <class _CharT, class _Traits, class _Allocator>
2745template <class _Tp>2851template <class _Tp>
2746typename enable_if2852_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>::type2856>
2751basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const _Tp& __t,2857basic_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 __
29003006
2901template <class _CharT, class _Traits, class _Allocator>3007template <class _CharT, class _Traits, class _Allocator>
2902template<class _InputIterator>3008template<class _InputIterator>
2903typename enable_if3009_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>::type3013>
2908basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2,3014basic_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 _
29333039
2934template <class _CharT, class _Traits, class _Allocator>3040template <class _CharT, class _Traits, class _Allocator>
2935template <class _Tp>3041template <class _Tp>
2936typename enable_if3042_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>::type3046>
2941basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const _Tp& __t,3047basic_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
29913097
2992// erase3098// erase
29933099
3100// 'externally instantiated' erase() implementation, called when __n != npos.
3101// Does not check __pos against size()
2994template <class _CharT, class _Traits, class _Allocator>3102template <class _CharT, class _Traits, class _Allocator>
2995basic_string<_CharT, _Traits, _Allocator>&3103void
2996basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos, size_type __n)3104basic_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
3122template <class _CharT, class _Traits, class _Allocator>
3123basic_string<_CharT, _Traits, _Allocator>&
3124basic_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}
30153134
3016template <class _CharT, class _Traits, class _Allocator>3135template <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,
33563475
3357template<class _CharT, class _Traits, class _Allocator>3476template<class _CharT, class _Traits, class _Allocator>
3358template <class _Tp>3477template <class _Tp>
3359typename enable_if3478_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_type3481 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3363>::type3482>
3364basic_string<_CharT, _Traits, _Allocator>::find(const _Tp &__t,3483basic_string<_CharT, _Traits, _Allocator>::find(const _Tp &__t,
3365 size_type __pos) const3484 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,
34143533
3415template<class _CharT, class _Traits, class _Allocator>3534template<class _CharT, class _Traits, class _Allocator>
3416template <class _Tp>3535template <class _Tp>
3417typename enable_if3536_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_type3539 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3421>::type3540>
3422basic_string<_CharT, _Traits, _Allocator>::rfind(const _Tp& __t,3541basic_string<_CharT, _Traits, _Allocator>::rfind(const _Tp& __t,
3423 size_type __pos) const3542 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
34723591
3473template<class _CharT, class _Traits, class _Allocator>3592template<class _CharT, class _Traits, class _Allocator>
3474template <class _Tp>3593template <class _Tp>
3475typename enable_if3594_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_type3597 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3479>::type3598>
3480basic_string<_CharT, _Traits, _Allocator>::find_first_of(const _Tp& __t,3599basic_string<_CharT, _Traits, _Allocator>::find_first_of(const _Tp& __t,
3481 size_type __pos) const3600 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
35303649
3531template<class _CharT, class _Traits, class _Allocator>3650template<class _CharT, class _Traits, class _Allocator>
3532template <class _Tp>3651template <class _Tp>
3533typename enable_if3652_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_type3655 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3537>::type3656>
3538basic_string<_CharT, _Traits, _Allocator>::find_last_of(const _Tp& __t,3657basic_string<_CharT, _Traits, _Allocator>::find_last_of(const _Tp& __t,
3539 size_type __pos) const3658 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&
35883707
3589template<class _CharT, class _Traits, class _Allocator>3708template<class _CharT, class _Traits, class _Allocator>
3590template <class _Tp>3709template <class _Tp>
3591typename enable_if3710_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_type3713 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3595>::type3714>
3596basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const _Tp& __t,3715basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const _Tp& __t,
3597 size_type __pos) const3716 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&
36473766
3648template<class _CharT, class _Traits, class _Allocator>3767template<class _CharT, class _Traits, class _Allocator>
3649template <class _Tp>3768template <class _Tp>
3650typename enable_if3769_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_type3772 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3654>::type3773>
3655basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const _Tp& __t,3774basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const _Tp& __t,
3656 size_type __pos) const3775 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,
36853804
3686template <class _CharT, class _Traits, class _Allocator>3805template <class _CharT, class _Traits, class _Allocator>
3687template <class _Tp>3806template <class _Tp>
3688typename enable_if3807_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 int3810 int
3692>::type3811>
3693basic_string<_CharT, _Traits, _Allocator>::compare(const _Tp& __t) const3812basic_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,
37393858
3740template <class _CharT, class _Traits, class _Allocator>3859template <class _CharT, class _Traits, class _Allocator>
3741template <class _Tp>3860template <class _Tp>
3742typename enable_if3861_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 int3864 int
3746>::type3865>
3747basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,3866basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
3748 size_type __n1,3867 size_type __n1,
3749 const _Tp& __t) const3868 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,
37643883
3765template <class _CharT, class _Traits, class _Allocator>3884template <class _CharT, class _Traits, class _Allocator>
3766template <class _Tp>3885template <class _Tp>
3767typename enable_if3886_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 int3890 int
3771>::type3891>
3772basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,3892basic_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);
42314351
4232template<class _CharT, class _Traits, class _Allocator>4352template<class _CharT, class _Traits, class _Allocator>
4233 const typename basic_string<_CharT, _Traits, _Allocator>::size_type4353_LIBCPP_FUNC_VIS
4234 basic_string<_CharT, _Traits, _Allocator>::npos;4354const typename basic_string<_CharT, _Traits, _Allocator>::size_type
4355 basic_string<_CharT, _Traits, _Allocator>::npos;
42354356
4236template <class _CharT, class _Allocator>4357template <class _CharT, class _Allocator>
4237struct _LIBCPP_TEMPLATE_VIS4358struct _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_LANG4404#endif // _LIBCPP_CXX03_LANG
42844405
4285#if _LIBCPP_STD_VER > 174406#if _LIBCPP_STD_VER > 17
4286template<class _CharT, class _Traits, class _Allocator, class _Up>4407template <class _CharT, class _Traits, class _Allocator, class _Up>
4287inline _LIBCPP_INLINE_VISIBILITY4408inline _LIBCPP_INLINE_VISIBILITY
4288void 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}
42904415
4291template<class _CharT, class _Traits, class _Allocator, class _Predicate>4416template <class _CharT, class _Traits, class _Allocator, class _Predicate>
4292inline _LIBCPP_INLINE_VISIBILITY4417inline _LIBCPP_INLINE_VISIBILITY
4293void 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#endif4426#endif
42964427
4297#if _LIBCPP_DEBUG_LEVEL >= 24428#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*
43304461
4331#endif // _LIBCPP_DEBUG_LEVEL >= 24462#endif // _LIBCPP_DEBUG_LEVEL >= 2
43324463
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 > 114464#if _LIBCPP_STD_VER > 11
4337// Literal suffixes for basic_string [basic.string.literals]4465// Literal suffixes for basic_string [basic.string.literals]
4338inline namespace literals4466inline 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;
473474
474 _LIBCPP_INLINE_VISIBILITY475 _LIBCPP_INLINE_VISIBILITY
lib/libcxx/include/thread+13-17
...@@ -241,12 +241,19 @@ public:...@@ -241,12 +241,19 @@ public:
241#endif241#endif
242 ~thread();242 ~thread();
243243
244#ifndef _LIBCPP_CXX03_LANG
245 _LIBCPP_INLINE_VISIBILITY244 _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_VISIBILITY249 _LIBCPP_INLINE_VISIBILITY
248 thread& operator=(thread&& __t) _NOEXCEPT;250 thread& operator=(thread&& __t) _NOEXCEPT {
249#endif // _LIBCPP_CXX03_LANG251 if (!__libcpp_thread_isnull(&__t_))
252 terminate();
253 __t_ = __t.__t_;
254 __t.__t_ = _LIBCPP_NULL_THREAD;
255 return *this;
256 }
250257
251 _LIBCPP_INLINE_VISIBILITY258 _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}
306313
307inline
308thread&
309thread::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_LANG314#else // _LIBCPP_CXX03_LANG
319315
320template <class _Fp>316template <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#endif371#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
544544
545// is_same545// is_same
546546
547#if __has_keyword(__is_same)
548
549template <class _Tp, class _Up>
550struct _LIBCPP_TEMPLATE_VIS is_same : _BoolConstant<__is_same(_Tp, _Up)> { };
551
552#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
553template <class _Tp, class _Up>
554_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_same_v = __is_same(_Tp, _Up);
555#endif
556
557#else
558
547template <class _Tp, class _Up> struct _LIBCPP_TEMPLATE_VIS is_same : public false_type {};559template <class _Tp, class _Up> struct _LIBCPP_TEMPLATE_VIS is_same : public false_type {};
548template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_same<_Tp, _Tp> : public true_type {};560template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_same<_Tp, _Tp> : public true_type {};
549561
...@@ -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#endif566#endif
555567
568#endif // __is_same
569
556template <class _Tp, class _Up>570template <class _Tp, class _Up>
557using _IsSame = _BoolConstant<571using _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];};
656670
657// is_const671// is_const
658672
673#if __has_keyword(__is_const)
674
675template <class _Tp>
676struct _LIBCPP_TEMPLATE_VIS is_const : _BoolConstant<__is_const(_Tp)> { };
677
678#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
679template <class _Tp>
680_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_const_v = __is_const(_Tp);
681#endif
682
683#else
684
659template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const : public false_type {};685template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const : public false_type {};
660template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const<_Tp const> : public true_type {};686template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const<_Tp const> : public true_type {};
661687
...@@ -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#endif692#endif
667693
694#endif // __has_keyword(__is_const)
695
668// is_volatile696// is_volatile
669697
698#if __has_keyword(__is_volatile)
699
700template <class _Tp>
701struct _LIBCPP_TEMPLATE_VIS is_volatile : _BoolConstant<__is_volatile(_Tp)> { };
702
703#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
704template <class _Tp>
705_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_volatile_v = __is_volatile(_Tp);
706#endif
707
708#else
709
670template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile : public false_type {};710template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile : public false_type {};
671template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile<_Tp volatile> : public true_type {};711template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile<_Tp volatile> : public true_type {};
672712
...@@ -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#endif717#endif
678718
719#endif // __has_keyword(__is_volatile)
720
679// remove_const721// remove_const
680722
723#if __has_keyword(__remove_const)
724
725template <class _Tp>
726struct _LIBCPP_TEMPLATE_VIS remove_const {typedef __remove_const(_Tp) type;};
727
728#if _LIBCPP_STD_VER > 11
729template <class _Tp> using remove_const_t = __remove_const(_Tp);
730#endif
731
732#else
733
681template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const {typedef _Tp type;};734template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const {typedef _Tp type;};
682template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const<const _Tp> {typedef _Tp type;};735template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const<const _Tp> {typedef _Tp type;};
683#if _LIBCPP_STD_VER > 11736#if _LIBCPP_STD_VER > 11
684template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type;737template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type;
685#endif738#endif
686739
740#endif // __has_keyword(__remove_const)
741
687// remove_volatile742// remove_volatile
688743
744#if __has_keyword(__remove_volatile)
745
746template <class _Tp>
747struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef __remove_volatile(_Tp) type;};
748
749#if _LIBCPP_STD_VER > 11
750template <class _Tp> using remove_volatile_t = __remove_volatile(_Tp);
751#endif
752
753#else
754
689template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef _Tp type;};755template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef _Tp type;};
690template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile<volatile _Tp> {typedef _Tp type;};756template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile<volatile _Tp> {typedef _Tp type;};
691#if _LIBCPP_STD_VER > 11757#if _LIBCPP_STD_VER > 11
692template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type;758template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type;
693#endif759#endif
694760
761#endif // __has_keyword(__remove_volatile)
762
695// remove_cv763// remove_cv
696764
765#if __has_keyword(__remove_cv)
766
767template <class _Tp>
768struct _LIBCPP_TEMPLATE_VIS remove_cv {typedef __remove_cv(_Tp) type;};
769
770#if _LIBCPP_STD_VER > 11
771template <class _Tp> using remove_cv_t = __remove_cv(_Tp);
772#endif
773
774#else
775
697template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv776template <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 > 11778#if _LIBCPP_STD_VER > 11
700template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type;779template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type;
701#endif780#endif
702781
782#endif // __has_keyword(__remove_cv)
783
703// is_void784// is_void
704785
705template <class _Tp> struct __libcpp_is_void : public false_type {};786#if __has_keyword(__is_void)
706template <> struct __libcpp_is_void<void> : public true_type {};787
788template <class _Tp>
789struct _LIBCPP_TEMPLATE_VIS is_void : _BoolConstant<__is_void(_Tp)> { };
790
791#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
792template <class _Tp>
793_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_void_v = __is_void(_Tp);
794#endif
795
796#else
707797
708template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_void798template <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> {};
710800
711#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)801#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
712template <class _Tp>802template <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#endif805#endif
716806
807#endif // __has_keyword(__is_void)
808
717// __is_nullptr_t809// __is_nullptr_t
718810
719template <class _Tp> struct __is_nullptr_t_impl : public false_type {};811template <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
735827
736// is_integral828// is_integral
737829
738template <class _Tp> struct __libcpp_is_integral : public false_type {};830#if __has_keyword(__is_integral)
739template <> struct __libcpp_is_integral<bool> : public true_type {};831
740template <> struct __libcpp_is_integral<char> : public true_type {};832template <class _Tp>
741template <> struct __libcpp_is_integral<signed char> : public true_type {};833struct _LIBCPP_TEMPLATE_VIS is_integral : _BoolConstant<__is_integral(_Tp)> { };
742template <> struct __libcpp_is_integral<unsigned char> : public true_type {};834
743template <> struct __libcpp_is_integral<wchar_t> : public true_type {};835#if _LIBCPP_STD_VER > 14
744#ifndef _LIBCPP_NO_HAS_CHAR8_T836template <class _Tp>
745template <> 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
748template <> struct __libcpp_is_integral<char16_t> : public true_type {};
749template <> struct __libcpp_is_integral<char32_t> : public true_type {};
750#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
751template <> struct __libcpp_is_integral<short> : public true_type {};
752template <> struct __libcpp_is_integral<unsigned short> : public true_type {};
753template <> struct __libcpp_is_integral<int> : public true_type {};
754template <> struct __libcpp_is_integral<unsigned int> : public true_type {};
755template <> struct __libcpp_is_integral<long> : public true_type {};
756template <> struct __libcpp_is_integral<unsigned long> : public true_type {};
757template <> struct __libcpp_is_integral<long long> : public true_type {};
758template <> struct __libcpp_is_integral<unsigned long long> : public true_type {};
759#ifndef _LIBCPP_HAS_NO_INT128
760template <> struct __libcpp_is_integral<__int128_t> : public true_type {};
761template <> struct __libcpp_is_integral<__uint128_t> : public true_type {};
762#endif838#endif
763839
840#else
841
764template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_integral842template <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> {};
766844
767#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)845#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
768template <class _Tp>846template <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#endif849#endif
772850
851#endif // __has_keyword(__is_integral)
852
773// is_floating_point853// is_floating_point
774854
775template <class _Tp> struct __libcpp_is_floating_point : public false_type {};855template <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
788868
789// is_array869// is_array
790870
871#if __has_keyword(__is_array)
872
873template <class _Tp>
874struct _LIBCPP_TEMPLATE_VIS is_array : _BoolConstant<__is_array(_Tp)> { };
875
876#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
877template <class _Tp>
878_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_array_v = __is_array(_Tp);
879#endif
880
881#else
882
791template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array883template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array
792 : public false_type {};884 : public false_type {};
793template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[]>885template <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#endif894#endif
803895
896#endif // __has_keyword(__is_array)
897
804// is_pointer898// is_pointer
805899
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
903template<class _Tp>
904struct _LIBCPP_TEMPLATE_VIS is_pointer : _BoolConstant<__is_pointer(_Tp)> { };
905
906#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
907template <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
806template <class _Tp> struct __libcpp_is_pointer : public false_type {};913template <class _Tp> struct __libcpp_is_pointer : public false_type {};
807template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {};914template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {};
808915
...@@ -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#endif931#endif
825932
933#endif // __has_keyword(__is_pointer)
934
826// is_reference935// is_reference
827936
937#if __has_keyword(__is_lvalue_reference) && \
938 __has_keyword(__is_rvalue_reference) && \
939 __has_keyword(__is_reference)
940
941template<class _Tp>
942struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> { };
943
944template<class _Tp>
945struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : _BoolConstant<__is_rvalue_reference(_Tp)> { };
946
947template<class _Tp>
948struct _LIBCPP_TEMPLATE_VIS is_reference : _BoolConstant<__is_reference(_Tp)> { };
949
950#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
951template <class _Tp>
952_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_reference_v = __is_reference(_Tp);
953
954template <class _Tp>
955_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_lvalue_reference_v = __is_lvalue_reference(_Tp);
956
957template <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
828template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {};963template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {};
829template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {};964template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {};
830965
...@@ -848,6 +983,9 @@ template <class _Tp>...@@ -848,6 +983,9 @@ template <class _Tp>
848_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_rvalue_reference_v983_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_rvalue_reference_v
849 = is_rvalue_reference<_Tp>::value;984 = is_rvalue_reference<_Tp>::value;
850#endif985#endif
986
987#endif // __has_keyword(__is_lvalue_reference) && etc...
988
851// is_union989// is_union
852990
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};
9301068
1069#if __has_keyword(__is_member_function_pointer)
1070
1071template<class _Tp>
1072struct _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)
1076template <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)
9311082
932template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer1083template <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#endif1090#endif
9401091
1092#endif // __has_keyword(__is_member_function_pointer)
1093
941// is_member_pointer1094// is_member_pointer
9421095
1096#if __has_keyword(__is_member_pointer)
1097
1098template<class _Tp>
1099struct _LIBCPP_TEMPLATE_VIS is_member_pointer : _BoolConstant<__is_member_pointer(_Tp)> { };
1100
1101#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1102template <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
943template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_pointer1108template <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 > {};
9451110
...@@ -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#endif1115#endif
9511116
1117#endif // __has_keyword(__is_member_pointer)
1118
952// is_member_object_pointer1119// is_member_object_pointer
9531120
1121#if __has_keyword(__is_member_object_pointer)
1122
1123template<class _Tp>
1124struct _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)
1128template <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
954template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer1135template <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 > {};
9561137
...@@ -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#endif1142#endif
9621143
1144#endif // __has_keyword(__is_member_object_pointer)
1145
963// is_enum1146// is_enum
9641147
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
967template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum1150template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum
968 : public integral_constant<bool, __is_enum(_Tp)> {};1151 : public integral_constant<bool, __is_enum(_Tp)> {};
9691152
1153#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1154template <class _Tp>
1155_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_enum_v = __is_enum(_Tp);
1156#endif
1157
970#else1158#else
9711159
972template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum1160template <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 > {};
9831171
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)
987template <class _Tp>1173template <class _Tp>
988_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_enum_v1174_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_enum_v
989 = is_enum<_Tp>::value;1175 = is_enum<_Tp>::value;
990#endif1176#endif
9911177
1178#endif // __has_feature(is_enum) || defined(_LIBCPP_COMPILER_GCC)
1179
992// is_arithmetic1180// is_arithmetic
9931181
1182
994template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_arithmetic1183template <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
10031192
1004// is_fundamental1193// is_fundamental
10051194
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
1199template<class _Tp>
1200struct _LIBCPP_TEMPLATE_VIS is_fundamental : _BoolConstant<__is_fundamental(_Tp)> { };
1201
1202#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1203template <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
1006template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_fundamental1209template <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#endif1218#endif
10161219
1220#endif // __has_keyword(__is_fundamental)
1221
1017// is_scalar1222// is_scalar
10181223
1224// >= 11 because in C++03 nullptr isn't actually nullptr
1225#if __has_keyword(__is_scalar) && !defined(_LIBCPP_CXX03_LANG)
1226
1227template<class _Tp>
1228struct _LIBCPP_TEMPLATE_VIS is_scalar : _BoolConstant<__is_scalar(_Tp)> { };
1229
1230#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1231template <class _Tp>
1232_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_scalar_v = __is_scalar(_Tp);
1233#endif
1234
1235#else // __has_keyword(__is_scalar)
1236
1237template <class _Tp> struct __is_block : false_type {};
1238#if defined(_LIBCPP_HAS_EXTENSION_BLOCKS)
1239template <class _Rp, class ..._Args> struct __is_block<_Rp (^)(_Args...)> : true_type {};
1240#endif
1241
1019template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_scalar1242template <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 > {};
10251249
1026template <> struct _LIBCPP_TEMPLATE_VIS is_scalar<nullptr_t> : public true_type {};1250template <> 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#endif1256#endif
10331257
1258#endif // __has_keyword(__is_scalar)
1259
1034// is_object1260// is_object
10351261
1262#if __has_keyword(__is_object)
1263
1264template<class _Tp>
1265struct _LIBCPP_TEMPLATE_VIS is_object : _BoolConstant<__is_object(_Tp)> { };
1266
1267#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1268template <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
1036template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_object1274template <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#endif1284#endif
10471285
1286#endif // __has_keyword(__is_object)
1287
1048// is_compound1288// is_compound
10491289
1290// >= 11 because in C++03 nullptr isn't actually nullptr
1291#if __has_keyword(__is_compound) && !defined(_LIBCPP_CXX03_LANG)
1292
1293template<class _Tp>
1294struct _LIBCPP_TEMPLATE_VIS is_compound : _BoolConstant<__is_compound(_Tp)> { };
1295
1296#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1297template <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
1050template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_compound1303template <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> {};
10521305
...@@ -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#endif1310#endif
10581311
1312#endif // __has_keyword(__is_compound)
10591313
1060// __is_referenceable [defns.referenceable]1314// __is_referenceable [defns.referenceable]
10611315
...@@ -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;
11001354
1101// remove_reference1355// remove_reference
11021356
1357#if __has_keyword(__remove_reference)
1358
1359template<class _Tp>
1360struct _LIBCPP_TEMPLATE_VIS remove_reference { typedef __remove_reference(_Tp) type; };
1361
1362#else // __has_keyword(__remove_reference)
1363
1103template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};1364template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1104template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};1365template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1105template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};1366template <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
1108template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;1369template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
1109#endif1370#endif
11101371
1372#endif // __has_keyword(__remove_reference)
1373
1111// add_lvalue_reference1374// add_lvalue_reference
11121375
1113template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _LIBCPP_NODEBUG_TYPE _Tp type; };1376template <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;
12151478
1216// is_signed1479// is_signed
12171480
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
1484template<class _Tp>
1485struct _LIBCPP_TEMPLATE_VIS is_signed : _BoolConstant<__is_signed(_Tp)> { };
1486
1487#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1488template <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
1218template <class _Tp, bool = is_integral<_Tp>::value>1494template <class _Tp, bool = is_integral<_Tp>::value>
1219struct __libcpp_is_signed_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(-1) < _Tp(0)) {};1495struct __libcpp_is_signed_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(-1) < _Tp(0)) {};
12201496
...@@ -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#endif1511#endif
12361512
1513#endif // __has_keyword(__is_signed)
1514
1237// is_unsigned1515// is_unsigned
12381516
1517#if __has_keyword(__is_unsigned)
1518
1519template<class _Tp>
1520struct _LIBCPP_TEMPLATE_VIS is_unsigned : _BoolConstant<__is_unsigned(_Tp)> { };
1521
1522#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1523template <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
1239template <class _Tp, bool = is_integral<_Tp>::value>1529template <class _Tp, bool = is_integral<_Tp>::value>
1240struct __libcpp_is_unsigned_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(0) < _Tp(-1)) {};1530struct __libcpp_is_unsigned_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(0) < _Tp(-1)) {};
12411531
...@@ -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#endif1546#endif
12571547
1548#endif // __has_keyword(__is_unsigned)
1549
1258// rank1550// rank
12591551
1260template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank1552template <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
12721564
1273// extent1565// extent
12741566
1567#if __has_keyword(__array_extent)
1568
1569template<class _Tp, size_t _Dim = 0>
1570struct _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)
1574template <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
1275template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TEMPLATE_VIS extent1580template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TEMPLATE_VIS extent
1276 : public integral_constant<size_t, 0> {};1581 : public integral_constant<size_t, 0> {};
1277template <class _Tp> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], 0>1582template <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#endif1595#endif
12911596
1597#endif // __has_keyword(__array_extent)
1598
1292// remove_extent1599// remove_extent
12931600
1294template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent1601template <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
2041template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;2348template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
2042#endif2349#endif
20432350
2351#if _LIBCPP_STD_VER > 14
2352template <class...> using void_t = void;
2353#endif
2354
2355#if _LIBCPP_STD_VER > 17
2356// Let COND_RES(X, Y) be:
2357template <class _Tp, class _Up>
2358using __cond_type = decltype(false ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>());
2359
2360template <class _Tp, class _Up, class = void>
2361struct __common_type3 {};
2362
2363// sub-bullet 4 - "if COND_RES(CREF(D1), CREF(D2)) denotes a type..."
2364template <class _Tp, class _Up>
2365struct __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
2370template <class _Tp, class _Up, class = void>
2371struct __common_type2_imp : __common_type3<_Tp, _Up> {};
2372#else
2044template <class _Tp, class _Up, class = void>2373template <class _Tp, class _Up, class = void>
2045struct __common_type2_imp {};2374struct __common_type2_imp {};
2375#endif
20462376
2377// sub-bullet 3 - "if decay_t<decltype(false ? declval<D1>() : declval<D2>())> ..."
2047template <class _Tp, class _Up>2378template <class _Tp, class _Up>
2048struct __common_type2_imp<_Tp, _Up,2379struct __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>
21072438
2108// bullet 3 - sizeof...(Tp) == 22439// bullet 3 - sizeof...(Tp) == 2
21092440
2441// sub-bullet 1 - "If is_same_v<T1, D1> is false or ..."
2110template <class _Tp, class _Up>2442template <class _Tp, class _Up>
2111struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up>2443struct _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
21342466
2135template<typename, typename _Tp> struct __select_2nd { typedef _LIBCPP_NODEBUG_TYPE _Tp type; };2467template<typename, typename _Tp> struct __select_2nd { typedef _LIBCPP_NODEBUG_TYPE _Tp type; };
21362468
2469#if __has_keyword(__is_assignable)
2470
2471template<class _Tp, class _Up>
2472struct _LIBCPP_TEMPLATE_VIS is_assignable : _BoolConstant<__is_assignable(_Tp, _Up)> { };
2473
2474#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2475template <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
2137template <class _Tp, class _Arg>2481template <class _Tp, class _Arg>
2138typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type2482typename __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#endif2507#endif
21642508
2509#endif // __has_keyword(__is_assignable)
2510
2165// is_copy_assignable2511// is_copy_assignable
21662512
2167template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_copy_assignable2513template <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
21882534
2189// is_destructible2535// is_destructible
21902536
2537#if __has_keyword(__is_destructible)
2538
2539template<class _Tp>
2540struct _LIBCPP_TEMPLATE_VIS is_destructible : _BoolConstant<__is_destructible(_Tp)> { };
2541
2542#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2543template <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 true2549// if it's a reference, return true
2192// if it's a function, return false2550// if it's a function, return false
2193// if it's void, return false2551// 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#endif2609#endif
22522610
2611#endif // __has_keyword(__is_destructible)
2612
2253// move2613// move
22542614
2255template <class _Tp>2615template <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> {};
3879template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;4239template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
3880#endif4240#endif
38814241
3882
3883template <class _Tp, bool = is_enum<_Tp>::value>4242template <class _Tp, bool = is_enum<_Tp>::value>
3884struct __sfinae_underlying_type4243struct __sfinae_underlying_type
3885{4244{
...@@ -3962,8 +4321,6 @@ struct __has_operator_addressof...@@ -3962,8 +4321,6 @@ struct __has_operator_addressof
39624321
3963#if _LIBCPP_STD_VER > 144322#if _LIBCPP_STD_VER > 14
39644323
3965template <class...> using void_t = void;
3966
3967template <class... _Args>4324template <class... _Args>
3968struct conjunction : _And<_Args...> {};4325struct conjunction : _And<_Args...> {};
3969template<class... _Args>4326template<class... _Args>
...@@ -4040,29 +4397,7 @@ _LIBCPP_END_NAMESPACE_STD...@@ -4040,29 +4397,7 @@ _LIBCPP_END_NAMESPACE_STD
4040// std::byte4397// std::byte
4041namespace std // purposefully not versioned4398namespace std // purposefully not versioned
4042{4399{
4043template <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
4048template <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
4053template <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
4058template <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
4063template <class _Integer>
4064 constexpr typename enable_if<is_integral_v<_Integer>, _Integer>::type
4065 to_integer(byte __b) noexcept { return static_cast<_Integer>(__b); }
40664401
4067}4402}
4068#endif4403#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_EXCEPTIONS64#ifdef _LIBCPP_NO_EXCEPTIONS
64#include <cstdlib>65#include <cstdlib>
65#endif66#endif
...@@ -120,6 +121,7 @@ public:...@@ -120,6 +121,7 @@ public:
120// ========================================================================== //121// ========================================================================== //
121// ------------------------------------------------------------------------- //122// ------------------------------------------------------------------------- //
122// Unique123// Unique
124// (_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION = 1)
123// ------------------------------------------------------------------------- //125// ------------------------------------------------------------------------- //
124// This implementation of type_info assumes a unique copy of the RTTI for a126// 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 to127// 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// NonUnique133// NonUnique
134// (_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION = 2)
132// -------------------------------------------------------------------------- //135// -------------------------------------------------------------------------- //
133// This implementation of type_info does not assume there is always a unique136// 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 reasons137// 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// NonUniqueARMRTTIBit143// 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 of146// 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 the147// 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 typedef259 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_impl261 __non_unique_arm_rtti_bit_impl
258#elif _LIBCPP_HAS_MERGED_TYPEINFO_NAMES_DEFAULT == 0262#elif _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 1
259 __non_unique_impl
260#elif _LIBCPP_HAS_MERGED_TYPEINFO_NAMES_DEFAULT == 1
261 __unique_impl263 __unique_impl
264#elif _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 2
265 __non_unique_impl
262#else266#else
263# error invalid configuration for _LIBCPP_HAS_MERGED_TYPEINFO_NAMES_DEFAULT267# error invalid configuration for _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION
264#endif268#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)));
387387
388template <class K, class T, class H, class P, class A, class Predicate>388template <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++20389 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
390391
391template <class K, class T, class H, class P, class A, class Predicate>392template <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++20393 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
393395
394template <class Key, class T, class Hash, class Pred, class Alloc>396template <class Key, class T, class Hash, class Pred, class Alloc>
395 bool397 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}
17051707
1706#if _LIBCPP_STD_VER > 171708#if _LIBCPP_STD_VER > 17
1707template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc, class _Predicate>1709template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc,
1710 class _Predicate>
1708inline _LIBCPP_INLINE_VISIBILITY1711inline _LIBCPP_INLINE_VISIBILITY
1709void 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#endif1717#endif
17121718
1713template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>1719template <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}
24032409
2404#if _LIBCPP_STD_VER > 172410#if _LIBCPP_STD_VER > 17
2405template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc, class _Predicate>2411template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc,
2412 class _Predicate>
2406inline _LIBCPP_INLINE_VISIBILITY2413inline _LIBCPP_INLINE_VISIBILITY
2407void 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#endif2419#endif
24102420
2411template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>2421template <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)));
342342
343template <class K, class T, class H, class P, class A, class Predicate>343template <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++20344 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
345346
346template <class K, class T, class H, class P, class A, class Predicate>347template <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++20348 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
348350
349351
350template <class Value, class Hash, class Pred, class Alloc>352template <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}
10071009
1008#if _LIBCPP_STD_VER > 171010#if _LIBCPP_STD_VER > 17
1009template <class _Value, class _Hash, class _Pred, class _Alloc, class _Predicate>1011template <class _Value, class _Hash, class _Pred, class _Alloc,
1012 class _Predicate>
1010inline _LIBCPP_INLINE_VISIBILITY1013inline _LIBCPP_INLINE_VISIBILITY
1011void 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#endif1019#endif
10141020
1015template <class _Value, class _Hash, class _Pred, class _Alloc>1021template <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}
16381644
1639#if _LIBCPP_STD_VER > 171645#if _LIBCPP_STD_VER > 17
1640template <class _Value, class _Hash, class _Pred, class _Alloc, class _Predicate>1646template <class _Value, class _Hash, class _Pred, class _Alloc,
1647 class _Predicate>
1641inline _LIBCPP_INLINE_VISIBILITY1648inline _LIBCPP_INLINE_VISIBILITY
1642void 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#endif1654#endif
16451655
1646template <class _Value, class _Hash, class _Pred, class _Alloc>1656template <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_EXCEPTIONS1065#ifndef _LIBCPP_NO_EXCEPTIONS
1066 // EXTENSION: When the move construction of `__lhs` into `__rhs` throws1066 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#else1081#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#endif1085#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)));
262262
263template <class T, class Allocator, class U>263template <class T, class Allocator, class U>
264 void erase(vector<T, Allocator>& c, const U& value); // C++20264typename vector<T, Allocator>::size_type
265erase(vector<T, Allocator>& c, const U& value); // C++20
265template <class T, class Allocator, class Predicate>266template <class T, class Allocator, class Predicate>
266 void erase_if(vector<T, Allocator>& c, Predicate pred); // C++20267typename vector<T, Allocator>::size_type
268erase_if(vector<T, Allocator>& c, Predicate pred); // C++20
267269
268} // std270} // std
269271
...@@ -1041,8 +1043,9 @@ void...@@ -1041,8 +1043,9 @@ void
1041vector<_Tp, _Allocator>::__construct_at_end(size_type __n)1043vector<_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}
10481051
...@@ -1058,8 +1061,9 @@ void...@@ -1058,8 +1061,9 @@ void
1058vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)1061vector<_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}
10651069
...@@ -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_EXCEPTIONS1961#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}
19631968
...@@ -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)
33893394
3390#if _LIBCPP_STD_VER > 173395#if _LIBCPP_STD_VER > 17
3391template <class _Tp, class _Allocator, class _Up>3396template <class _Tp, class _Allocator, class _Up>
3392inline _LIBCPP_INLINE_VISIBILITY3397inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::size_type
3393void erase(vector<_Tp, _Allocator>& __c, const _Up& __v)3398erase(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}
33953403
3396template <class _Tp, class _Allocator, class _Predicate>3404template <class _Tp, class _Allocator, class _Predicate>
3397inline _LIBCPP_INLINE_VISIBILITY3405inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::size_type
3398void erase_if(vector<_Tp, _Allocator>& __c, _Predicate __pred)3406erase_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#endif3411#endif
34013412
3402_LIBCPP_END_NAMESPACE_STD3413_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 201603L171// # define __cpp_lib_execution 201603L
168# define __cpp_lib_filesystem 201703L172# define __cpp_lib_filesystem 201703L
169# define __cpp_lib_gcd_lcm 201606L173# define __cpp_lib_gcd_lcm 201606L
170# define __cpp_lib_hardware_interference_size 201703L174// # 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 201606L176# define __cpp_lib_has_unique_object_representations 201606L
173# endif177# endif
...@@ -210,6 +214,8 @@ __cpp_lib_void_t 201411L <type_traits>...@@ -210,6 +214,8 @@ __cpp_lib_void_t 201411L <type_traits>
210#endif214#endif
211215
212#if _LIBCPP_STD_VER > 17216#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 201806L220// # define __cpp_lib_atomic_ref 201806L
215# endif221# 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 201806L231# define __cpp_lib_destroying_delete 201806L
226# endif232# endif
227# define __cpp_lib_endian 201907L233# define __cpp_lib_endian 201907L
228# define __cpp_lib_erase_if 201811L234# define __cpp_lib_erase_if 202002L
229// # define __cpp_lib_generic_unordered_lookup 201811L235// # define __cpp_lib_generic_unordered_lookup 201811L
230# define __cpp_lib_interpolate 201902L236# 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 201811L238# define __cpp_lib_is_constant_evaluated 201811L
233# endif239# endif
234// # define __cpp_lib_list_remove_return_type 201806L240# 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 201811L244// # define __cpp_lib_ranges 201811L
245# define __cpp_lib_span 202002L
236// # define __cpp_lib_three_way_comparison 201711L246// # define __cpp_lib_three_way_comparison 201711L
247# define __cpp_lib_to_array 201907L
237#endif248#endif
238249
239#endif // _LIBCPP_VERSIONH250#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*/
107107
108#include <__config>108#include <__config>
109#include <stddef.h>
109110
110#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)111#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
111#pragma GCC system_header112#pragma GCC system_header
lib/libcxx/src/algorithm.cpp-48
...@@ -7,13 +7,6 @@...@@ -7,13 +7,6 @@
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
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
1710
18_LIBCPP_BEGIN_NAMESPACE_STD11_LIBCPP_BEGIN_NAMESPACE_STD
1912
...@@ -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
5144
52template unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&);45template unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&);
5346
54#ifndef _LIBCPP_HAS_NO_THREADS
55_LIBCPP_SAFE_STATIC static __libcpp_mutex_t __rs_mut = _LIBCPP_MUTEX_INITIALIZER;
56#endif
57unsigned __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_STD47_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
34static 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
41static 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
49extern "C" int __ulock_wait(uint32_t operation, void *addr, uint64_t value,
50 uint32_t timeout); /* timeout is specified in microseconds */
51extern "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
56static 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
63static 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
74static 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
82static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile*, bool) { }
83
84#endif // __linux__
85
86static constexpr size_t __libcpp_contention_table_size = (1 << 8); /* < there's no magic in this number */
87
88struct 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
96static __libcpp_contention_table_entry __libcpp_contention_table[ __libcpp_contention_table_size ];
97
98static hash<void const volatile*> __libcpp_contention_hasher;
99
100static __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
108static 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}
116static __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}
122static 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
135static 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
145void __cxx_atomic_notify_one(void const volatile* __location)
146 { __libcpp_atomic_notify(__location); }
147_LIBCPP_EXPORTED_FROM_ABI
148void __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
157void __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
167void __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
172void __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
182void __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
20class __barrier_algorithm_base {
21public:
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
88bool __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
94void __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] = {
3232
33template <typename T>33template <typename T>
34inline _LIBCPP_INLINE_VISIBILITY char*34inline _LIBCPP_INLINE_VISIBILITY char*
35append1(char* buffer, T i)35append1(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)
4040
41template <typename T>41template <typename T>
42inline _LIBCPP_INLINE_VISIBILITY char*42inline _LIBCPP_INLINE_VISIBILITY char*
43append2(char* buffer, T i)43append2(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)
4848
49template <typename T>49template <typename T>
50inline _LIBCPP_INLINE_VISIBILITY char*50inline _LIBCPP_INLINE_VISIBILITY char*
51append3(char* buffer, T i)51append3(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}
5555
56template <typename T>56template <typename T>
57inline _LIBCPP_INLINE_VISIBILITY char*57inline _LIBCPP_INLINE_VISIBILITY char*
58append4(char* buffer, T i)58append4(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}
6262
63template <typename T>63template <typename T>
64inline _LIBCPP_INLINE_VISIBILITY char*64inline _LIBCPP_INLINE_VISIBILITY char*
65append2_no_zeros(char* buffer, T v)65append2_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)
7272
73template <typename T>73template <typename T>
74inline _LIBCPP_INLINE_VISIBILITY char*74inline _LIBCPP_INLINE_VISIBILITY char*
75append4_no_zeros(char* buffer, T v)75append4_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)
8484
85template <typename T>85template <typename T>
86inline _LIBCPP_INLINE_VISIBILITY char*86inline _LIBCPP_INLINE_VISIBILITY char*
87append8_no_zeros(char* buffer, T v)87append8_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}
100100
101char*101char*
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}
121121
122char*122char*
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" // errno10#include "cerrno" // errno
11#include "system_error" // __throw_system_error11#include "system_error" // __throw_system_error
12#include <time.h> // clock_gettime, CLOCK_MONOTONIC and CLOCK_REALTIME12#include <time.h> // clock_gettime and CLOCK_{MONOTONIC,REALTIME,MONOTONIC_RAW}
13#include "include/apple_availability.h"13#include "include/apple_availability.h"
1414
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_GETTIME20#define _LIBCPP_USE_CLOCK_GETTIME
17#endif // __APPLE__21#endif
1822
19#if defined(_LIBCPP_WIN32API)23#if defined(_LIBCPP_WIN32API)
20#define WIN32_LEAN_AND_MEAN24# define WIN32_LEAN_AND_MEAN
21#define VC_EXTRA_LEAN25# define VC_EXTRA_LEAN
22#include <windows.h>26# include <windows.h>
23#if _WIN32_WINNT >= _WIN32_WINNT_WIN827# if _WIN32_WINNT >= _WIN32_WINNT_WIN8
24#include <winapifamily.h>28# include <winapifamily.h>
25#endif29# endif
26#else30#else
27#if !defined(CLOCK_REALTIME) || !defined(_LIBCPP_USE_CLOCK_GETTIME)31# if !defined(CLOCK_REALTIME)
28#include <sys/time.h> // for gettimeofday and timeval32# 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)
3135
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#endif38#endif
4339
44_LIBCPP_BEGIN_NAMESPACE_STD40_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#else76#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_REALTIME86#endif // CLOCK_REALTIME
91#endif87#endif
92}88}
9389
...@@ -114,71 +110,24 @@ const bool steady_clock::is_steady;...@@ -114,71 +110,24 @@ const bool steady_clock::is_steady;
114110
115#if defined(__APPLE__)111#if defined(__APPLE__)
116112
117// Darwin libc versions >= 1133 provide ns precision via CLOCK_UPTIME_RAW113#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.
119steady_clock::time_point122steady_clock::time_point
120steady_clock::now() _NOEXCEPT123steady_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}
127130
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
137static
138steady_clock::rep
139steady_simplified()
140{
141 return static_cast<steady_clock::rep>(mach_absolute_time());
142}
143
144static
145double
146compute_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
153static
154steady_clock::rep
155steady_full()
156{
157 static const double factor = compute_steady_factor();
158 return static_cast<steady_clock::rep>(mach_absolute_time() * factor);
159}
160
161typedef steady_clock::rep (*FP)();
162
163static
164FP
165init_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
174steady_clock::time_point
175steady_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)
183132
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
206155
207#elif defined(CLOCK_MONOTONIC)156#elif defined(CLOCK_MONOTONIC)
208157
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
216steady_clock::time_point158steady_clock::time_point
217steady_clock::now() _NOEXCEPT159steady_clock::now() _NOEXCEPT
218{160{
...@@ -223,7 +165,7 @@ steady_clock::now() _NOEXCEPT...@@ -223,7 +165,7 @@ steady_clock::now() _NOEXCEPT
223}165}
224166
225#else167#else
226#error "Monotonic clock not implemented"168# error "Monotonic clock not implemented"
227#endif169#endif
228170
229#endif // !_LIBCPP_HAS_NO_MONOTONIC_CLOCK171#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
21extern "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_COPYFILE36#define _LIBCPP_USE_COPYFILE
37#endif37#endif
3838
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 timeval40#include <sys/time.h> // for gettimeofday and timeval
45#endif // !defined(CLOCK_REALTIME)41#endif // !defined(CLOCK_REALTIME)
4642
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;
490486
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_REALTIME501#endif // CLOCK_REALTIME
506}502}
507503
508filesystem_error::~filesystem_error() {}504filesystem_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__
3030
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__ >= 10120032#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101500
33#define _LIBCPP_USE_CLOCK_GETTIME33#define _LIBCPP_USE_ULOCK
34#endif34#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__ >= 10000036#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 130000
37#define _LIBCPP_USE_CLOCK_GETTIME37#define _LIBCPP_USE_ULOCK
38#endif38#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__ >= 10000040#if __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 130000
41#define _LIBCPP_USE_CLOCK_GETTIME41#define _LIBCPP_USE_ULOCK
42#endif42#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__ >= 3000044#if __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 60000
45#define _LIBCPP_USE_CLOCK_GETTIME45#define _LIBCPP_USE_ULOCK
46#endif46#endif
47#endif // __ENVIRONMENT_.*_VERSION_MIN_REQUIRED__47#endif // __ENVIRONMENT_.*_VERSION_MIN_REQUIRED__
4848
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
536536
537locale::locale(const char* name)537locale::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)
549549
550locale::locale(const locale& other, const char* name, category c)550locale::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
23unsigned __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
2020
21template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __basic_string_common<true>;21template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __basic_string_common<true>;
2222
23template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_string<char>;23#ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION
24template 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
2530
26template31template
27 string32 string
lib/libcxx/src/thread.cpp+3-3
...@@ -23,9 +23,9 @@...@@ -23,9 +23,9 @@
23# endif23# endif
24#endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))24#endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
2525
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
2929
30#if defined(__NetBSD__)30#if defined(__NetBSD__)
31#pragma weak pthread_create // Do not create libpthread dependency31#pragma weak pthread_create // Do not create libpthread dependency