authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2020-12-16 11:52:51+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2020-12-16 12:18:55+01:00
logf9a11fbfafa7e056c08350f740af8a96a722a235
treeb58a3c881bd097f8e52d7a18d8b2c57e9c39791b
parent1e66ac5755ebe8614b8b3a278eabcfca5f78c3c2

Update libcxx

llvm commit b2851aea80e5a8f0cfd6c3c5a56a6b00fb28c6b6

106 files changed, 5319 insertions(+), 4724 deletions(-)

lib/libcxx/include/__availability created+206
...@@ -0,0 +1,206 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___AVAILABILITY
11#define _LIBCPP___AVAILABILITY
12
13#include <__config>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19// Libc++ is shipped by various vendors. In particular, it is used as a system
20// library on macOS, iOS and other Apple platforms. In order for users to be
21// able to compile a binary that is intended to be deployed to an older version
22// of a platform, Clang provides availability attributes [1]. These attributes
23// can be placed on declarations and are used to describe the life cycle of a
24// symbol in the library.
25//
26// The main goal is to ensure a compile-time error if a symbol that hasn't been
27// introduced in a previously released library is used in a program that targets
28// that previously released library. Normally, this would be a load-time error
29// when one tries to launch the program against the older library.
30//
31// For example, the filesystem library was introduced in the dylib in macOS 10.15.
32// If a user compiles on a macOS 10.15 host but targets macOS 10.13 with their
33// program, the compiler would normally not complain (because the required
34// declarations are in the headers), but the dynamic loader would fail to find
35// the symbols when actually trying to launch the program on macOS 10.13. To
36// turn this into a compile-time issue instead, declarations are annotated with
37// when they were introduced, and the compiler can produce a diagnostic if the
38// program references something that isn't available on the deployment target.
39//
40// This mechanism is general in nature, and any vendor can add their markup to
41// the library (see below). Whenever a new feature is added that requires support
42// in the shared library, a macro should be added below to mark this feature
43// as unavailable. When vendors decide to ship the feature as part of their
44// shared library, they can update the markup appropriately.
45//
46// Note that this mechanism is disabled by default in the "upstream" libc++.
47// Availability annotations are only meaningful when shipping libc++ inside
48// a platform (i.e. as a system library), and so vendors that want them should
49// turn those annotations on at CMake configuration time.
50//
51// [1]: https://clang.llvm.org/docs/AttributeReference.html#availability
52
53
54// For backwards compatibility, allow users to define _LIBCPP_DISABLE_AVAILABILITY
55// for a while.
56#if defined(_LIBCPP_DISABLE_AVAILABILITY)
57# if !defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)
58# define _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS
59# endif
60#endif
61
62// Availability markup is disabled when building the library, or when the compiler
63// doesn't support the proper attributes.
64#if defined(_LIBCPP_BUILDING_LIBRARY) || \
65 defined(_LIBCXXABI_BUILDING_LIBRARY) || \
66 !__has_feature(attribute_availability_with_strict) || \
67 !__has_feature(attribute_availability_in_templates) || \
68 !__has_extension(pragma_clang_attribute_external_declaration)
69# if !defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)
70# define _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS
71# endif
72#endif
73
74#if defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)
75
76 // This controls the availability of std::shared_mutex and std::shared_timed_mutex,
77 // which were added to the dylib later.
78# define _LIBCPP_AVAILABILITY_SHARED_MUTEX
79
80 // These macros control the availability of std::bad_optional_access and
81 // other exception types. These were put in the shared library to prevent
82 // code bloat from every user program defining the vtable for these exception
83 // types.
84# define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
85# define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
86# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST
87
88 // This controls the availability of std::uncaught_exceptions().
89# define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS
90
91 // This controls the availability of the sized version of ::operator delete,
92 // which was added to the dylib later.
93# define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE
94
95 // This controls the availability of the std::future_error exception.
96# define _LIBCPP_AVAILABILITY_FUTURE_ERROR
97
98 // This controls the availability of std::type_info's vtable.
99 // I can't imagine how using std::type_info can work at all if
100 // this isn't supported.
101# define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE
102
103 // This controls the availability of std::locale::category members
104 // (e.g. std::locale::collate), which are defined in the dylib.
105# define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY
106
107 // This controls the availability of atomic operations on std::shared_ptr
108 // (e.g. `std::atomic_store(std::shared_ptr)`), which require a shared
109 // lock table located in the dylib.
110# define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
111
112 // These macros control the availability of all parts of <filesystem> that
113 // depend on something in the dylib.
114# define _LIBCPP_AVAILABILITY_FILESYSTEM
115# define _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH
116# define _LIBCPP_AVAILABILITY_FILESYSTEM_POP
117
118 // This controls the availability of std::to_chars.
119# define _LIBCPP_AVAILABILITY_TO_CHARS
120
121 // This controls the availability of the C++20 synchronization library,
122 // which requires shared library support for various operations
123 // (see libcxx/src/atomic.cpp).
124# define _LIBCPP_AVAILABILITY_SYNC
125
126#elif defined(__APPLE__)
127
128# define _LIBCPP_AVAILABILITY_SHARED_MUTEX \
129 __attribute__((availability(macosx,strict,introduced=10.12))) \
130 __attribute__((availability(ios,strict,introduced=10.0))) \
131 __attribute__((availability(tvos,strict,introduced=10.0))) \
132 __attribute__((availability(watchos,strict,introduced=3.0)))
133# define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS \
134 __attribute__((availability(macosx,strict,introduced=10.13))) \
135 __attribute__((availability(ios,strict,introduced=11.0))) \
136 __attribute__((availability(tvos,strict,introduced=11.0))) \
137 __attribute__((availability(watchos,strict,introduced=4.0)))
138# define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS \
139 _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
140# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST \
141 _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
142# define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS \
143 __attribute__((availability(macosx,strict,introduced=10.12))) \
144 __attribute__((availability(ios,strict,introduced=10.0))) \
145 __attribute__((availability(tvos,strict,introduced=10.0))) \
146 __attribute__((availability(watchos,strict,introduced=3.0)))
147# define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE \
148 __attribute__((availability(macosx,strict,introduced=10.12))) \
149 __attribute__((availability(ios,strict,introduced=10.0))) \
150 __attribute__((availability(tvos,strict,introduced=10.0))) \
151 __attribute__((availability(watchos,strict,introduced=3.0)))
152# define _LIBCPP_AVAILABILITY_FUTURE_ERROR \
153 __attribute__((availability(ios,strict,introduced=6.0)))
154# define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE \
155 __attribute__((availability(macosx,strict,introduced=10.9))) \
156 __attribute__((availability(ios,strict,introduced=7.0)))
157# define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY \
158 __attribute__((availability(macosx,strict,introduced=10.9))) \
159 __attribute__((availability(ios,strict,introduced=7.0)))
160# define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR \
161 __attribute__((availability(macosx,strict,introduced=10.9))) \
162 __attribute__((availability(ios,strict,introduced=7.0)))
163# define _LIBCPP_AVAILABILITY_FILESYSTEM \
164 __attribute__((availability(macosx,strict,introduced=10.15))) \
165 __attribute__((availability(ios,strict,introduced=13.0))) \
166 __attribute__((availability(tvos,strict,introduced=13.0))) \
167 __attribute__((availability(watchos,strict,introduced=6.0)))
168# define _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH \
169 _Pragma("clang attribute push(__attribute__((availability(macosx,strict,introduced=10.15))), apply_to=any(function,record))") \
170 _Pragma("clang attribute push(__attribute__((availability(ios,strict,introduced=13.0))), apply_to=any(function,record))") \
171 _Pragma("clang attribute push(__attribute__((availability(tvos,strict,introduced=13.0))), apply_to=any(function,record))") \
172 _Pragma("clang attribute push(__attribute__((availability(watchos,strict,introduced=6.0))), apply_to=any(function,record))")
173# define _LIBCPP_AVAILABILITY_FILESYSTEM_POP \
174 _Pragma("clang attribute pop") \
175 _Pragma("clang attribute pop") \
176 _Pragma("clang attribute pop") \
177 _Pragma("clang attribute pop")
178# define _LIBCPP_AVAILABILITY_TO_CHARS \
179 _LIBCPP_AVAILABILITY_FILESYSTEM
180# define _LIBCPP_AVAILABILITY_SYNC \
181 __attribute__((unavailable))
182
183#else
184
185// ...New vendors can add availability markup here...
186
187# error "It looks like you're trying to enable vendor availability markup, but you haven't defined the corresponding macros yet!"
188
189#endif
190
191// Define availability attributes that depend on _LIBCPP_NO_EXCEPTIONS.
192// Those are defined in terms of the availability attributes above, and
193// should not be vendor-specific.
194#if defined(_LIBCPP_NO_EXCEPTIONS)
195# define _LIBCPP_AVAILABILITY_FUTURE
196# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
197# define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
198# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
199#else
200# define _LIBCPP_AVAILABILITY_FUTURE _LIBCPP_AVAILABILITY_FUTURE_ERROR
201# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _LIBCPP_AVAILABILITY_BAD_ANY_CAST
202# define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
203# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
204#endif
205
206#endif // _LIBCPP___AVAILABILITY
lib/libcxx/include/__config+76-197
...@@ -32,13 +32,13 @@...@@ -32,13 +32,13 @@
32# define _GNUC_VER_NEW 032# define _GNUC_VER_NEW 0
33#endif33#endif
3434
35#define _LIBCPP_VERSION 1100035#define _LIBCPP_VERSION 12000
3636
37#ifndef _LIBCPP_ABI_VERSION37#ifndef _LIBCPP_ABI_VERSION
38# define _LIBCPP_ABI_VERSION 138# define _LIBCPP_ABI_VERSION 1
39#endif39#endif
4040
41#ifndef __STDC_HOSTED__41#if __STDC_HOSTED__ == 0
42# define _LIBCPP_FREESTANDING42# define _LIBCPP_FREESTANDING
43#endif43#endif
4444
...@@ -63,7 +63,7 @@...@@ -63,7 +63,7 @@
63#elif defined(__wasm__)63#elif defined(__wasm__)
64# define _LIBCPP_OBJECT_FORMAT_WASM 164# define _LIBCPP_OBJECT_FORMAT_WASM 1
65#else65#else
66# error Unknown object file format66 // ... add new file formats here ...
67#endif67#endif
6868
69#if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 269#if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2
...@@ -105,6 +105,10 @@...@@ -105,6 +105,10 @@
105// Re-worked external template instantiations for std::string with a focus on105// Re-worked external template instantiations for std::string with a focus on
106// performance and fast-path inlining.106// performance and fast-path inlining.
107# define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION107# define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION
108// Enable clang::trivial_abi on std::unique_ptr.
109# define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI
110// Enable clang::trivial_abi on std::shared_ptr and std::weak_ptr
111# define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI
108#elif _LIBCPP_ABI_VERSION == 1112#elif _LIBCPP_ABI_VERSION == 1
109# if !defined(_LIBCPP_OBJECT_FORMAT_COFF)113# if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
110// Enable compiling copies of now inline methods into the dylib to support114// Enable compiling copies of now inline methods into the dylib to support
...@@ -121,9 +125,11 @@...@@ -121,9 +125,11 @@
121# endif125# endif
122#endif126#endif
123127
124#ifdef _LIBCPP_TRIVIAL_PAIR_COPY_CTOR128#if defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2
125#error "_LIBCPP_TRIVIAL_PAIR_COPY_CTOR" is no longer supported. \129// Enable additional explicit instantiations of iostreams components. This
126 use _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR instead130// reduces the number of weak definitions generated in programs that use
131// iostreams by providing a single strong definition in the shared library.
132# define _LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1
127#endif133#endif
128134
129#define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y135#define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y
...@@ -344,13 +350,11 @@...@@ -344,13 +350,11 @@
344# if defined(__FreeBSD__)350# if defined(__FreeBSD__)
345# define _LIBCPP_HAS_ALIGNED_ALLOC351# define _LIBCPP_HAS_ALIGNED_ALLOC
346# define _LIBCPP_HAS_QUICK_EXIT352# define _LIBCPP_HAS_QUICK_EXIT
347# define _LIBCPP_HAS_C11_FEATURES
348# if __FreeBSD_version >= 1300064 || \353# if __FreeBSD_version >= 1300064 || \
349 (__FreeBSD_version >= 1201504 && __FreeBSD_version < 1300000)354 (__FreeBSD_version >= 1201504 && __FreeBSD_version < 1300000)
350# define _LIBCPP_HAS_TIMESPEC_GET355# define _LIBCPP_HAS_TIMESPEC_GET
351# endif356# endif
352# elif defined(__BIONIC__)357# elif defined(__BIONIC__)
353# define _LIBCPP_HAS_C11_FEATURES
354# if __ANDROID_API__ >= 21358# if __ANDROID_API__ >= 21
355# define _LIBCPP_HAS_QUICK_EXIT359# define _LIBCPP_HAS_QUICK_EXIT
356# endif360# endif
...@@ -364,7 +368,6 @@...@@ -364,7 +368,6 @@
364# define _LIBCPP_HAS_ALIGNED_ALLOC368# define _LIBCPP_HAS_ALIGNED_ALLOC
365# define _LIBCPP_HAS_QUICK_EXIT369# define _LIBCPP_HAS_QUICK_EXIT
366# define _LIBCPP_HAS_TIMESPEC_GET370# define _LIBCPP_HAS_TIMESPEC_GET
367# define _LIBCPP_HAS_C11_FEATURES
368# elif defined(__linux__)371# elif defined(__linux__)
369# if !defined(_LIBCPP_HAS_MUSL_LIBC)372# if !defined(_LIBCPP_HAS_MUSL_LIBC)
370# if _LIBCPP_GLIBC_PREREQ(2, 15) || defined(__BIONIC__)373# if _LIBCPP_GLIBC_PREREQ(2, 15) || defined(__BIONIC__)
...@@ -372,16 +375,24 @@...@@ -372,16 +375,24 @@
372# endif375# endif
373# if _LIBCPP_GLIBC_PREREQ(2, 17)376# if _LIBCPP_GLIBC_PREREQ(2, 17)
374# define _LIBCPP_HAS_ALIGNED_ALLOC377# define _LIBCPP_HAS_ALIGNED_ALLOC
375# define _LIBCPP_HAS_C11_FEATURES
376# define _LIBCPP_HAS_TIMESPEC_GET378# define _LIBCPP_HAS_TIMESPEC_GET
377# endif379# endif
378# else // defined(_LIBCPP_HAS_MUSL_LIBC)380# else // defined(_LIBCPP_HAS_MUSL_LIBC)
379# define _LIBCPP_HAS_ALIGNED_ALLOC381# define _LIBCPP_HAS_ALIGNED_ALLOC
380# define _LIBCPP_HAS_QUICK_EXIT382# define _LIBCPP_HAS_QUICK_EXIT
381# define _LIBCPP_HAS_TIMESPEC_GET383# define _LIBCPP_HAS_TIMESPEC_GET
382# define _LIBCPP_HAS_C11_FEATURES
383# endif384# endif
384# endif // __linux__385# elif defined(__APPLE__)
386 // timespec_get and aligned_alloc were introduced in macOS 10.15 and
387 // aligned releases
388# if (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101500 || \
389 __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 130000 || \
390 __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 130000 || \
391 __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 60000)
392# define _LIBCPP_HAS_ALIGNED_ALLOC
393# define _LIBCPP_HAS_TIMESPEC_GET
394# endif
395# endif // __APPLE__
385#endif396#endif
386397
387#ifndef _LIBCPP_CXX03_LANG398#ifndef _LIBCPP_CXX03_LANG
...@@ -389,9 +400,7 @@...@@ -389,9 +400,7 @@
389#elif defined(_LIBCPP_COMPILER_CLANG)400#elif defined(_LIBCPP_COMPILER_CLANG)
390# define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp)401# define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp)
391#else402#else
392// This definition is potentially buggy, but it's only taken with GCC in C++03,403# error "We don't know a correct way to implement alignof(T) in C++03 outside of Clang"
393// which we barely support anyway. See llvm.org/PR39713
394# define _LIBCPP_ALIGNOF(_Tp) __alignof(_Tp)
395#endif404#endif
396405
397#define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp)406#define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp)
...@@ -433,10 +442,6 @@ typedef __char32_t char32_t;...@@ -433,10 +442,6 @@ typedef __char32_t char32_t;
433# define _LIBCPP_NORETURN __attribute__ ((noreturn))442# define _LIBCPP_NORETURN __attribute__ ((noreturn))
434#endif443#endif
435444
436#if !(__has_feature(cxx_lambdas))
437#define _LIBCPP_HAS_NO_LAMBDAS
438#endif
439
440#if !(__has_feature(cxx_nullptr))445#if !(__has_feature(cxx_nullptr))
441# if (__has_extension(cxx_nullptr) || __has_keyword(__nullptr)) && defined(_LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR)446# if (__has_extension(cxx_nullptr) || __has_keyword(__nullptr)) && defined(_LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR)
442# define nullptr __nullptr447# define nullptr __nullptr
...@@ -445,18 +450,6 @@ typedef __char32_t char32_t;...@@ -445,18 +450,6 @@ typedef __char32_t char32_t;
445# endif450# endif
446#endif451#endif
447452
448#if !(__has_feature(cxx_rvalue_references))
449#define _LIBCPP_HAS_NO_RVALUE_REFERENCES
450#endif
451
452#if !(__has_feature(cxx_auto_type))
453#define _LIBCPP_HAS_NO_AUTO_TYPE
454#endif
455
456#if !(__has_feature(cxx_variadic_templates))
457#define _LIBCPP_HAS_NO_VARIADICS
458#endif
459
460// Objective-C++ features (opt-in)453// Objective-C++ features (opt-in)
461#if __has_feature(objc_arc)454#if __has_feature(objc_arc)
462#define _LIBCPP_HAS_OBJC_ARC455#define _LIBCPP_HAS_OBJC_ARC
...@@ -754,16 +747,6 @@ typedef __char32_t char32_t;...@@ -754,16 +747,6 @@ typedef __char32_t char32_t;
754# endif747# endif
755#endif748#endif
756749
757#ifndef _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION
758# ifdef _LIBCPP_OBJECT_FORMAT_COFF // Windows binaries can't merge typeinfos.
759# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 2
760# else
761 // TODO: This isn't strictly correct on ELF platforms due to llvm.org/PR37398
762 // And we should consider defaulting to OFF.
763# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 1
764# endif
765#endif
766
767#ifndef _LIBCPP_HIDE_FROM_ABI750#ifndef _LIBCPP_HIDE_FROM_ABI
768# if _LIBCPP_HIDE_FROM_ABI_PER_TU751# if _LIBCPP_HIDE_FROM_ABI_PER_TU
769# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE752# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE
...@@ -838,6 +821,12 @@ typedef unsigned int char32_t;...@@ -838,6 +821,12 @@ typedef unsigned int char32_t;
838# define _LIBCPP_CONSTEXPR constexpr821# define _LIBCPP_CONSTEXPR constexpr
839#endif822#endif
840823
824#ifndef __cpp_consteval
825# define _LIBCPP_CONSTEVAL _LIBCPP_CONSTEXPR
826#else
827# define _LIBCPP_CONSTEVAL consteval
828#endif
829
841#ifdef _LIBCPP_CXX03_LANG830#ifdef _LIBCPP_CXX03_LANG
842# define _LIBCPP_DEFAULT {}831# define _LIBCPP_DEFAULT {}
843#else832#else
...@@ -863,10 +852,6 @@ typedef unsigned int char32_t;...@@ -863,10 +852,6 @@ typedef unsigned int char32_t;
863# define _LIBCPP_EXPLICIT852# define _LIBCPP_EXPLICIT
864#endif853#endif
865854
866#if !__has_builtin(__builtin_operator_new) || !__has_builtin(__builtin_operator_delete)
867#define _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE
868#endif
869
870#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS855#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
871# define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx856# define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx
872# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \857# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
...@@ -880,36 +865,33 @@ typedef unsigned int char32_t;...@@ -880,36 +865,33 @@ typedef unsigned int char32_t;
880# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)865# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
881#endif // _LIBCPP_HAS_NO_STRONG_ENUMS866#endif // _LIBCPP_HAS_NO_STRONG_ENUMS
882867
883#ifdef _LIBCPP_DEBUG868// _LIBCPP_DEBUG potential values:
884# if _LIBCPP_DEBUG == 0869// - undefined: No assertions. This is the default.
885# define _LIBCPP_DEBUG_LEVEL 1870// - 0: Basic assertions
886# elif _LIBCPP_DEBUG == 1871// - 1: Basic assertions + iterator validity checks.
887# define _LIBCPP_DEBUG_LEVEL 2872#if !defined(_LIBCPP_DEBUG)
888# else873# define _LIBCPP_DEBUG_LEVEL 0
889# error Supported values for _LIBCPP_DEBUG are 0 and 1874#elif _LIBCPP_DEBUG == 0
890# endif875# define _LIBCPP_DEBUG_LEVEL 1
891# if !defined(_LIBCPP_BUILDING_LIBRARY)876#elif _LIBCPP_DEBUG == 1
892# define _LIBCPP_EXTERN_TEMPLATE(...)877# define _LIBCPP_DEBUG_LEVEL 2
893# endif878#else
879# error Supported values for _LIBCPP_DEBUG are 0 and 1
894#endif880#endif
895881
896#ifndef _LIBCPP_DEBUG_LEVEL882// _LIBCPP_DEBUG_LEVEL is always defined to one of [0, 1, 2] at this point
897# define _LIBCPP_DEBUG_LEVEL 0883#if _LIBCPP_DEBUG_LEVEL >= 1
884# define _LIBCPP_DISABLE_EXTERN_TEMPLATE
898#endif885#endif
899886
900#ifdef _LIBCPP_DISABLE_EXTERN_TEMPLATE887#ifdef _LIBCPP_DISABLE_EXTERN_TEMPLATE
901#define _LIBCPP_EXTERN_TEMPLATE(...)888#define _LIBCPP_EXTERN_TEMPLATE(...)
902#define _LIBCPP_EXTERN_TEMPLATE2(...)
903#endif889#endif
904890
905#ifndef _LIBCPP_EXTERN_TEMPLATE891#ifndef _LIBCPP_EXTERN_TEMPLATE
906#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;892#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
907#endif893#endif
908894
909#ifndef _LIBCPP_EXTERN_TEMPLATE2
910#define _LIBCPP_EXTERN_TEMPLATE2(...) extern template __VA_ARGS__;
911#endif
912
913#ifndef _LIBCPP_EXTERN_TEMPLATE_DEFINE895#ifndef _LIBCPP_EXTERN_TEMPLATE_DEFINE
914#define _LIBCPP_EXTERN_TEMPLATE_DEFINE(...) template __VA_ARGS__;896#define _LIBCPP_EXTERN_TEMPLATE_DEFINE(...) template __VA_ARGS__;
915#endif897#endif
...@@ -938,6 +920,8 @@ typedef unsigned int char32_t;...@@ -938,6 +920,8 @@ typedef unsigned int char32_t;
938 // We're deferring to Microsoft's STL to provide aligned new et al. We don't920 // We're deferring to Microsoft's STL to provide aligned new et al. We don't
939 // have it unless the language feature test macro is defined.921 // have it unless the language feature test macro is defined.
940# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION922# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
923#elif defined(__MVS__)
924# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
941#endif925#endif
942926
943#if defined(__APPLE__)927#if defined(__APPLE__)
...@@ -999,6 +983,18 @@ typedef unsigned int char32_t;...@@ -999,6 +983,18 @@ typedef unsigned int char32_t;
999# define _LIBCPP_DEPRECATED_IN_CXX17983# define _LIBCPP_DEPRECATED_IN_CXX17
1000#endif984#endif
1001985
986#if _LIBCPP_STD_VER > 17
987# define _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_DEPRECATED
988#else
989# define _LIBCPP_DEPRECATED_IN_CXX20
990#endif
991
992#if !defined(_LIBCPP_NO_HAS_CHAR8_T)
993# define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED
994#else
995# define _LIBCPP_DEPRECATED_WITH_CHAR8_T
996#endif
997
1002// Macros to enter and leave a state where deprecation warnings are suppressed.998// Macros to enter and leave a state where deprecation warnings are suppressed.
1003#if !defined(_LIBCPP_SUPPRESS_DEPRECATED_PUSH) && \999#if !defined(_LIBCPP_SUPPRESS_DEPRECATED_PUSH) && \
1004 (defined(_LIBCPP_COMPILER_CLANG) || defined(_LIBCPP_COMPILER_GCC))1000 (defined(_LIBCPP_COMPILER_CLANG) || defined(_LIBCPP_COMPILER_GCC))
...@@ -1037,14 +1033,6 @@ typedef unsigned int char32_t;...@@ -1037,14 +1033,6 @@ typedef unsigned int char32_t;
1037# define _LIBCPP_CONSTEXPR_AFTER_CXX171033# define _LIBCPP_CONSTEXPR_AFTER_CXX17
1038#endif1034#endif
10391035
1040#if _LIBCPP_STD_VER > 17 && \
1041 !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) && \
1042 !defined(_LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED)
1043# define _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED constexpr
1044#else
1045# define _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
1046#endif
1047
1048// The _LIBCPP_NODISCARD_ATTRIBUTE should only be used to define other1036// The _LIBCPP_NODISCARD_ATTRIBUTE should only be used to define other
1049// NODISCARD macros to the correct attribute.1037// NODISCARD macros to the correct attribute.
1050#if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC)1038#if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC)
...@@ -1079,12 +1067,6 @@ typedef unsigned int char32_t;...@@ -1079,12 +1067,6 @@ typedef unsigned int char32_t;
1079# define _LIBCPP_INLINE_VAR1067# define _LIBCPP_INLINE_VAR
1080#endif1068#endif
10811069
1082#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1083# define _LIBCPP_EXPLICIT_MOVE(x) _VSTD::move(x)
1084#else
1085# define _LIBCPP_EXPLICIT_MOVE(x) (x)
1086#endif
1087
1088#ifndef _LIBCPP_CONSTEXPR_IF_NODEBUG1070#ifndef _LIBCPP_CONSTEXPR_IF_NODEBUG
1089#if defined(_LIBCPP_DEBUG) || defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)1071#if defined(_LIBCPP_DEBUG) || defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
1090#define _LIBCPP_CONSTEXPR_IF_NODEBUG1072#define _LIBCPP_CONSTEXPR_IF_NODEBUG
...@@ -1125,11 +1107,13 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(...@@ -1125,11 +1107,13 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
1125# if defined(__FreeBSD__) || \1107# if defined(__FreeBSD__) || \
1126 defined(__wasi__) || \1108 defined(__wasi__) || \
1127 defined(__NetBSD__) || \1109 defined(__NetBSD__) || \
1110 defined(__NuttX__) || \
1128 defined(__linux__) || \1111 defined(__linux__) || \
1129 defined(__GNU__) || \1112 defined(__GNU__) || \
1130 defined(__APPLE__) || \1113 defined(__APPLE__) || \
1131 defined(__CloudABI__) || \1114 defined(__CloudABI__) || \
1132 defined(__sun__) || \1115 defined(__sun__) || \
1116 defined(__MVS__) || \
1133 (defined(__MINGW32__) && __has_include(<pthread.h>))1117 (defined(__MINGW32__) && __has_include(<pthread.h>))
1134# define _LIBCPP_HAS_THREAD_API_PTHREAD1118# define _LIBCPP_HAS_THREAD_API_PTHREAD
1135# elif defined(__Fuchsia__)1119# elif defined(__Fuchsia__)
...@@ -1167,10 +1151,6 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(...@@ -1167,10 +1151,6 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
1167 _LIBCPP_HAS_NO_THREADS is defined.1151 _LIBCPP_HAS_NO_THREADS is defined.
1168#endif1152#endif
11691153
1170#if defined(__STDCPP_THREADS__) && defined(_LIBCPP_HAS_NO_THREADS)
1171#error _LIBCPP_HAS_NO_THREADS cannot be set when __STDCPP_THREADS__ is set.
1172#endif
1173
1174#if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__)1154#if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__)
1175#define __STDCPP_THREADS__ 11155#define __STDCPP_THREADS__ 1
1176#endif1156#endif
...@@ -1227,8 +1207,9 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(...@@ -1227,8 +1207,9 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
1227# endif1207# endif
1228#endif1208#endif
12291209
1230#if defined(__BIONIC__) || defined(__CloudABI__) || \1210#if defined(__BIONIC__) || defined(__CloudABI__) || defined(__NuttX__) || \
1231 defined(__Fuchsia__) || defined(__wasi__) || defined(_LIBCPP_HAS_MUSL_LIBC)1211 defined(__Fuchsia__) || defined(__wasi__) || defined(_LIBCPP_HAS_MUSL_LIBC) || \
1212 defined(__MVS__)
1232#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE1213#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
1233#endif1214#endif
12341215
...@@ -1337,6 +1318,12 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(...@@ -1337,6 +1318,12 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
1337#endif1318#endif
1338#endif // !defined(_LIBCPP_NODEBUG_TYPE)1319#endif // !defined(_LIBCPP_NODEBUG_TYPE)
13391320
1321#if __has_attribute(__preferred_name__)
1322#define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x)))
1323#else
1324#define _LIBCPP_PREFERRED_NAME(x)
1325#endif
1326
1340#if defined(_LIBCPP_ABI_MICROSOFT) && \1327#if defined(_LIBCPP_ABI_MICROSOFT) && \
1341 (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases))1328 (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases))
1342# define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)1329# define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
...@@ -1367,120 +1354,6 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(...@@ -1367,120 +1354,6 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
1367#define _LIBCPP_HAS_NO_SPACESHIP_OPERATOR1354#define _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
1368#endif1355#endif
13691356
1370// Decide whether to use availability macros.
1371#if !defined(_LIBCPP_BUILDING_LIBRARY) && \
1372 !defined(_LIBCXXABI_BUILDING_LIBRARY) && \
1373 !defined(_LIBCPP_DISABLE_AVAILABILITY) && \
1374 __has_feature(attribute_availability_with_strict) && \
1375 __has_feature(attribute_availability_in_templates) && \
1376 __has_extension(pragma_clang_attribute_external_declaration)
1377# ifdef __APPLE__
1378# define _LIBCPP_USE_AVAILABILITY_APPLE
1379# endif
1380#endif
1381
1382// Define availability macros.
1383#if defined(_LIBCPP_USE_AVAILABILITY_APPLE)
1384# define _LIBCPP_AVAILABILITY_SHARED_MUTEX \
1385 __attribute__((availability(macosx,strict,introduced=10.12))) \
1386 __attribute__((availability(ios,strict,introduced=10.0))) \
1387 __attribute__((availability(tvos,strict,introduced=10.0))) \
1388 __attribute__((availability(watchos,strict,introduced=3.0)))
1389# define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS \
1390 __attribute__((availability(macosx,strict,introduced=10.13))) \
1391 __attribute__((availability(ios,strict,introduced=11.0))) \
1392 __attribute__((availability(tvos,strict,introduced=11.0))) \
1393 __attribute__((availability(watchos,strict,introduced=4.0)))
1394# define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS \
1395 _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
1396# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST \
1397 _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
1398# define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS \
1399 __attribute__((availability(macosx,strict,introduced=10.12))) \
1400 __attribute__((availability(ios,strict,introduced=10.0))) \
1401 __attribute__((availability(tvos,strict,introduced=10.0))) \
1402 __attribute__((availability(watchos,strict,introduced=3.0)))
1403# define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE \
1404 __attribute__((availability(macosx,strict,introduced=10.12))) \
1405 __attribute__((availability(ios,strict,introduced=10.0))) \
1406 __attribute__((availability(tvos,strict,introduced=10.0))) \
1407 __attribute__((availability(watchos,strict,introduced=3.0)))
1408# define _LIBCPP_AVAILABILITY_FUTURE_ERROR \
1409 __attribute__((availability(ios,strict,introduced=6.0)))
1410# define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE \
1411 __attribute__((availability(macosx,strict,introduced=10.9))) \
1412 __attribute__((availability(ios,strict,introduced=7.0)))
1413# define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY \
1414 __attribute__((availability(macosx,strict,introduced=10.9))) \
1415 __attribute__((availability(ios,strict,introduced=7.0)))
1416# define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR \
1417 __attribute__((availability(macosx,strict,introduced=10.9))) \
1418 __attribute__((availability(ios,strict,introduced=7.0)))
1419# define _LIBCPP_AVAILABILITY_FILESYSTEM \
1420 __attribute__((availability(macosx,strict,introduced=10.15))) \
1421 __attribute__((availability(ios,strict,introduced=13.0))) \
1422 __attribute__((availability(tvos,strict,introduced=13.0))) \
1423 __attribute__((availability(watchos,strict,introduced=6.0)))
1424# define _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH \
1425 _Pragma("clang attribute push(__attribute__((availability(macosx,strict,introduced=10.15))), apply_to=any(function,record))") \
1426 _Pragma("clang attribute push(__attribute__((availability(ios,strict,introduced=13.0))), apply_to=any(function,record))") \
1427 _Pragma("clang attribute push(__attribute__((availability(tvos,strict,introduced=13.0))), apply_to=any(function,record))") \
1428 _Pragma("clang attribute push(__attribute__((availability(watchos,strict,introduced=6.0))), apply_to=any(function,record))")
1429# define _LIBCPP_AVAILABILITY_FILESYSTEM_POP \
1430 _Pragma("clang attribute pop") \
1431 _Pragma("clang attribute pop") \
1432 _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))
1438#else
1439# define _LIBCPP_AVAILABILITY_SHARED_MUTEX
1440# define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
1441# define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
1442# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST
1443# define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS
1444# define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE
1445# define _LIBCPP_AVAILABILITY_FUTURE_ERROR
1446# define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE
1447# define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY
1448# define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
1449# define _LIBCPP_AVAILABILITY_FILESYSTEM
1450# define _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH
1451# define _LIBCPP_AVAILABILITY_FILESYSTEM_POP
1452# define _LIBCPP_AVAILABILITY_TO_CHARS
1453# define _LIBCPP_AVAILABILITY_SYNC
1454#endif
1455
1456// Define availability that depends on _LIBCPP_NO_EXCEPTIONS.
1457#ifdef _LIBCPP_NO_EXCEPTIONS
1458# define _LIBCPP_AVAILABILITY_FUTURE
1459# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
1460# define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
1461# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
1462#else
1463# define _LIBCPP_AVAILABILITY_FUTURE _LIBCPP_AVAILABILITY_FUTURE_ERROR
1464# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _LIBCPP_AVAILABILITY_BAD_ANY_CAST
1465# define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
1466# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
1467#endif
1468
1469// The stream API was dropped and re-added in the dylib shipped on macOS
1470// and iOS. We can only assume the dylib to provide these definitions for
1471// macosx >= 10.9 and ios >= 7.0. Otherwise, the definitions are available
1472// from the headers, but not from the dylib. Explicit instantiation
1473// declarations for streams exist conditionally to this; if we provide
1474// an explicit instantiation declaration and we try to deploy to a dylib
1475// that does not provide those symbols, we'll get a load-time error.
1476#if !defined(_LIBCPP_BUILDING_LIBRARY) && \
1477 ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
1478 __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1090) || \
1479 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \
1480 __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 70000))
1481# define _LIBCPP_DO_NOT_ASSUME_STREAMS_EXPLICIT_INSTANTIATION_IN_DYLIB
1482#endif
1483
1484#if defined(_LIBCPP_COMPILER_IBM)1357#if defined(_LIBCPP_COMPILER_IBM)
1485#define _LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO1358#define _LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO
1486#endif1359#endif
...@@ -1547,6 +1420,12 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(...@@ -1547,6 +1420,12 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
1547#define _LIBCPP_HAS_NO_FGETPOS_FSETPOS1420#define _LIBCPP_HAS_NO_FGETPOS_FSETPOS
1548#endif1421#endif
15491422
1423#if __has_attribute(init_priority)
1424# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101)))
1425#else
1426# define _LIBCPP_INIT_PRIORITY_MAX
1427#endif
1428
1550#endif // __cplusplus1429#endif // __cplusplus
15511430
1552#endif // _LIBCPP_CONFIG1431#endif // _LIBCPP_CONFIG
lib/libcxx/include/__config_site.in+3-2
...@@ -26,12 +26,13 @@...@@ -26,12 +26,13 @@
26#cmakedefine _LIBCPP_HAS_THREAD_API_WIN3226#cmakedefine _LIBCPP_HAS_THREAD_API_WIN32
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_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS
29#cmakedefine _LIBCPP_NO_VCRUNTIME30#cmakedefine _LIBCPP_NO_VCRUNTIME
30#ifndef _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION
31#cmakedefine _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION @_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION@31#cmakedefine _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION @_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION@
32#endif
33#cmakedefine _LIBCPP_ABI_NAMESPACE @_LIBCPP_ABI_NAMESPACE@32#cmakedefine _LIBCPP_ABI_NAMESPACE @_LIBCPP_ABI_NAMESPACE@
34#cmakedefine _LIBCPP_HAS_PARALLEL_ALGORITHMS33#cmakedefine _LIBCPP_HAS_PARALLEL_ALGORITHMS
34#cmakedefine _LIBCPP_HAS_NO_RANDOM_DEVICE
35#cmakedefine _LIBCPP_HAS_NO_LOCALIZATION
3536
36@_LIBCPP_ABI_DEFINES@37@_LIBCPP_ABI_DEFINES@
3738
lib/libcxx/include/__debug+17-22
...@@ -27,26 +27,21 @@...@@ -27,26 +27,21 @@
27# include <cstddef>27# include <cstddef>
28#endif28#endif
2929
30#if _LIBCPP_DEBUG_LEVEL >= 1 && !defined(_LIBCPP_ASSERT)30#if _LIBCPP_DEBUG_LEVEL == 0
31# define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : \31# define _LIBCPP_DEBUG_ASSERT(x, m) ((void)0)
32 _VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info(__FILE__, __LINE__, #x, m)))32# define _LIBCPP_ASSERT_IMPL(x, m) ((void)0)
33#endif33#elif _LIBCPP_DEBUG_LEVEL == 1
34
35#if _LIBCPP_DEBUG_LEVEL >= 2
36#ifndef _LIBCPP_DEBUG_ASSERT
37#define _LIBCPP_DEBUG_ASSERT(x, m) _LIBCPP_ASSERT(x, m)
38#endif
39#define _LIBCPP_DEBUG_MODE(...) __VA_ARGS__
40#endif
41
42#ifndef _LIBCPP_ASSERT
43# define _LIBCPP_ASSERT(x, m) ((void)0)
44#endif
45#ifndef _LIBCPP_DEBUG_ASSERT
46# define _LIBCPP_DEBUG_ASSERT(x, m) ((void)0)34# define _LIBCPP_DEBUG_ASSERT(x, m) ((void)0)
35# define _LIBCPP_ASSERT_IMPL(x, m) ((x) ? (void)0 : _VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info(__FILE__, __LINE__, #x, m)))
36#elif _LIBCPP_DEBUG_LEVEL == 2
37# define _LIBCPP_DEBUG_ASSERT(x, m) _LIBCPP_ASSERT(x, m)
38# define _LIBCPP_ASSERT_IMPL(x, m) ((x) ? (void)0 : _VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info(__FILE__, __LINE__, #x, m)))
39#else
40# error _LIBCPP_DEBUG_LEVEL must be one of 0, 1, 2
47#endif41#endif
48#ifndef _LIBCPP_DEBUG_MODE42
49#define _LIBCPP_DEBUG_MODE(...) ((void)0)43#if !defined(_LIBCPP_ASSERT)
44# define _LIBCPP_ASSERT(x, m) _LIBCPP_ASSERT_IMPL(x, m)
50#endif45#endif
5146
52_LIBCPP_BEGIN_NAMESPACE_STD47_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -59,7 +54,7 @@ struct _LIBCPP_TEMPLATE_VIS __libcpp_debug_info {...@@ -59,7 +54,7 @@ struct _LIBCPP_TEMPLATE_VIS __libcpp_debug_info {
59 __libcpp_debug_info(const char* __f, int __l, const char* __p, const char* __m)54 __libcpp_debug_info(const char* __f, int __l, const char* __p, const char* __m)
60 : __file_(__f), __line_(__l), __pred_(__p), __msg_(__m) {}55 : __file_(__f), __line_(__l), __pred_(__p), __msg_(__m) {}
6156
62 _LIBCPP_FUNC_VIS std::string what() const;57 _LIBCPP_FUNC_VIS string what() const;
6358
64 const char* __file_;59 const char* __file_;
65 int __line_;60 int __line_;
...@@ -83,7 +78,7 @@ void __libcpp_abort_debug_function(__libcpp_debug_info const&);...@@ -83,7 +78,7 @@ void __libcpp_abort_debug_function(__libcpp_debug_info const&);
83_LIBCPP_FUNC_VIS78_LIBCPP_FUNC_VIS
84bool __libcpp_set_debug_function(__libcpp_debug_function_type __func);79bool __libcpp_set_debug_function(__libcpp_debug_function_type __func);
8580
86#if _LIBCPP_DEBUG_LEVEL >= 2 || defined(_LIBCPP_BUILDING_LIBRARY)81#if _LIBCPP_DEBUG_LEVEL == 2 || defined(_LIBCPP_BUILDING_LIBRARY)
8782
88struct _LIBCPP_TYPE_VIS __c_node;83struct _LIBCPP_TYPE_VIS __c_node;
8984
...@@ -226,7 +221,7 @@ public:...@@ -226,7 +221,7 @@ public:
226221
227 template <class _Cont>222 template <class _Cont>
228 _LIBCPP_INLINE_VISIBILITY static __c_node* __create_C_node(void *__mem, void *__c, __c_node *__next) {223 _LIBCPP_INLINE_VISIBILITY static __c_node* __create_C_node(void *__mem, void *__c, __c_node *__next) {
229 return ::new(__mem) _C_node<_Cont>(__c, __next);224 return ::new (__mem) _C_node<_Cont>(__c, __next);
230 }225 }
231226
232 template <class _Cont>227 template <class _Cont>
...@@ -271,7 +266,7 @@ _LIBCPP_FUNC_VIS __libcpp_db* __get_db();...@@ -271,7 +266,7 @@ _LIBCPP_FUNC_VIS __libcpp_db* __get_db();
271_LIBCPP_FUNC_VIS const __libcpp_db* __get_const_db();266_LIBCPP_FUNC_VIS const __libcpp_db* __get_const_db();
272267
273268
274#endif // _LIBCPP_DEBUG_LEVEL >= 2 || defined(_LIBCPP_BUILDING_LIBRARY)269#endif // _LIBCPP_DEBUG_LEVEL == 2 || defined(_LIBCPP_BUILDING_LIBRARY)
275270
276_LIBCPP_END_NAMESPACE_STD271_LIBCPP_END_NAMESPACE_STD
277272
lib/libcxx/include/__functional_03+24-24
...@@ -126,7 +126,7 @@ __func<_Fp, _Alloc, _Rp()>::__clone() const...@@ -126,7 +126,7 @@ __func<_Fp, _Alloc, _Rp()>::__clone() const
126 _Ap __a(__f_.second());126 _Ap __a(__f_.second());
127 typedef __allocator_destructor<_Ap> _Dp;127 typedef __allocator_destructor<_Ap> _Dp;
128 unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));128 unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
129 ::new (__hold.get()) __func(__f_.first(), _Alloc(__a));129 ::new ((void*)__hold.get()) __func(__f_.first(), _Alloc(__a));
130 return __hold.release();130 return __hold.release();
131}131}
132132
...@@ -134,7 +134,7 @@ template<class _Fp, class _Alloc, class _Rp>...@@ -134,7 +134,7 @@ template<class _Fp, class _Alloc, class _Rp>
134void134void
135__func<_Fp, _Alloc, _Rp()>::__clone(__base<_Rp()>* __p) const135__func<_Fp, _Alloc, _Rp()>::__clone(__base<_Rp()>* __p) const
136{136{
137 ::new (__p) __func(__f_.first(), __f_.second());137 ::new ((void*)__p) __func(__f_.first(), __f_.second());
138}138}
139139
140template<class _Fp, class _Alloc, class _Rp>140template<class _Fp, class _Alloc, class _Rp>
...@@ -212,7 +212,7 @@ __func<_Fp, _Alloc, _Rp(_A0)>::__clone() const...@@ -212,7 +212,7 @@ __func<_Fp, _Alloc, _Rp(_A0)>::__clone() const
212 _Ap __a(__f_.second());212 _Ap __a(__f_.second());
213 typedef __allocator_destructor<_Ap> _Dp;213 typedef __allocator_destructor<_Ap> _Dp;
214 unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));214 unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
215 ::new (__hold.get()) __func(__f_.first(), _Alloc(__a));215 ::new ((void*)__hold.get()) __func(__f_.first(), _Alloc(__a));
216 return __hold.release();216 return __hold.release();
217}217}
218218
...@@ -220,7 +220,7 @@ template<class _Fp, class _Alloc, class _Rp, class _A0>...@@ -220,7 +220,7 @@ template<class _Fp, class _Alloc, class _Rp, class _A0>
220void220void
221__func<_Fp, _Alloc, _Rp(_A0)>::__clone(__base<_Rp(_A0)>* __p) const221__func<_Fp, _Alloc, _Rp(_A0)>::__clone(__base<_Rp(_A0)>* __p) const
222{222{
223 ::new (__p) __func(__f_.first(), __f_.second());223 ::new ((void*)__p) __func(__f_.first(), __f_.second());
224}224}
225225
226template<class _Fp, class _Alloc, class _Rp, class _A0>226template<class _Fp, class _Alloc, class _Rp, class _A0>
...@@ -298,7 +298,7 @@ __func<_Fp, _Alloc, _Rp(_A0, _A1)>::__clone() const...@@ -298,7 +298,7 @@ __func<_Fp, _Alloc, _Rp(_A0, _A1)>::__clone() const
298 _Ap __a(__f_.second());298 _Ap __a(__f_.second());
299 typedef __allocator_destructor<_Ap> _Dp;299 typedef __allocator_destructor<_Ap> _Dp;
300 unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));300 unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
301 ::new (__hold.get()) __func(__f_.first(), _Alloc(__a));301 ::new ((void*)__hold.get()) __func(__f_.first(), _Alloc(__a));
302 return __hold.release();302 return __hold.release();
303}303}
304304
...@@ -306,7 +306,7 @@ template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>...@@ -306,7 +306,7 @@ template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
306void306void
307__func<_Fp, _Alloc, _Rp(_A0, _A1)>::__clone(__base<_Rp(_A0, _A1)>* __p) const307__func<_Fp, _Alloc, _Rp(_A0, _A1)>::__clone(__base<_Rp(_A0, _A1)>* __p) const
308{308{
309 ::new (__p) __func(__f_.first(), __f_.second());309 ::new ((void*)__p) __func(__f_.first(), __f_.second());
310}310}
311311
312template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>312template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
...@@ -384,7 +384,7 @@ __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::__clone() const...@@ -384,7 +384,7 @@ __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::__clone() const
384 _Ap __a(__f_.second());384 _Ap __a(__f_.second());
385 typedef __allocator_destructor<_Ap> _Dp;385 typedef __allocator_destructor<_Ap> _Dp;
386 unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));386 unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
387 ::new (__hold.get()) __func(__f_.first(), _Alloc(__a));387 ::new ((void*)__hold.get()) __func(__f_.first(), _Alloc(__a));
388 return __hold.release();388 return __hold.release();
389}389}
390390
...@@ -392,7 +392,7 @@ template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>...@@ -392,7 +392,7 @@ template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
392void392void
393__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::__clone(__base<_Rp(_A0, _A1, _A2)>* __p) const393__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::__clone(__base<_Rp(_A0, _A1, _A2)>* __p) const
394{394{
395 ::new (__p) __func(__f_.first(), __f_.second());395 ::new ((void*)__p) __func(__f_.first(), __f_.second());
396}396}
397397
398template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>398template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
...@@ -554,7 +554,7 @@ function<_Rp()>::function(_Fp __f,...@@ -554,7 +554,7 @@ function<_Rp()>::function(_Fp __f,
554 if (sizeof(_FF) <= sizeof(__buf_))554 if (sizeof(_FF) <= sizeof(__buf_))
555 {555 {
556 __f_ = (__base*)&__buf_;556 __f_ = (__base*)&__buf_;
557 ::new (__f_) _FF(__f);557 ::new ((void*)__f_) _FF(__f);
558 }558 }
559 else559 else
560 {560 {
...@@ -562,7 +562,7 @@ function<_Rp()>::function(_Fp __f,...@@ -562,7 +562,7 @@ function<_Rp()>::function(_Fp __f,
562 _Ap __a;562 _Ap __a;
563 typedef __allocator_destructor<_Ap> _Dp;563 typedef __allocator_destructor<_Ap> _Dp;
564 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));564 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
565 ::new (__hold.get()) _FF(__f, allocator<_Fp>(__a));565 ::new ((void*)__hold.get()) _FF(__f, allocator<_Fp>(__a));
566 __f_ = __hold.release();566 __f_ = __hold.release();
567 }567 }
568 }568 }
...@@ -581,7 +581,7 @@ function<_Rp()>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,...@@ -581,7 +581,7 @@ function<_Rp()>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
581 if (sizeof(_FF) <= sizeof(__buf_))581 if (sizeof(_FF) <= sizeof(__buf_))
582 {582 {
583 __f_ = (__base*)&__buf_;583 __f_ = (__base*)&__buf_;
584 ::new (__f_) _FF(__f, __a0);584 ::new ((void*)__f_) _FF(__f, __a0);
585 }585 }
586 else586 else
587 {587 {
...@@ -589,7 +589,7 @@ function<_Rp()>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,...@@ -589,7 +589,7 @@ function<_Rp()>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
589 _Ap __a(__a0);589 _Ap __a(__a0);
590 typedef __allocator_destructor<_Ap> _Dp;590 typedef __allocator_destructor<_Ap> _Dp;
591 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));591 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
592 ::new (__hold.get()) _FF(__f, _Alloc(__a));592 ::new ((void*)__hold.get()) _FF(__f, _Alloc(__a));
593 __f_ = __hold.release();593 __f_ = __hold.release();
594 }594 }
595 }595 }
...@@ -834,7 +834,7 @@ function<_Rp(_A0)>::function(_Fp __f,...@@ -834,7 +834,7 @@ function<_Rp(_A0)>::function(_Fp __f,
834 if (sizeof(_FF) <= sizeof(__buf_))834 if (sizeof(_FF) <= sizeof(__buf_))
835 {835 {
836 __f_ = (__base*)&__buf_;836 __f_ = (__base*)&__buf_;
837 ::new (__f_) _FF(__f);837 ::new ((void*)__f_) _FF(__f);
838 }838 }
839 else839 else
840 {840 {
...@@ -842,7 +842,7 @@ function<_Rp(_A0)>::function(_Fp __f,...@@ -842,7 +842,7 @@ function<_Rp(_A0)>::function(_Fp __f,
842 _Ap __a;842 _Ap __a;
843 typedef __allocator_destructor<_Ap> _Dp;843 typedef __allocator_destructor<_Ap> _Dp;
844 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));844 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
845 ::new (__hold.get()) _FF(__f, allocator<_Fp>(__a));845 ::new ((void*)__hold.get()) _FF(__f, allocator<_Fp>(__a));
846 __f_ = __hold.release();846 __f_ = __hold.release();
847 }847 }
848 }848 }
...@@ -861,7 +861,7 @@ function<_Rp(_A0)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,...@@ -861,7 +861,7 @@ function<_Rp(_A0)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
861 if (sizeof(_FF) <= sizeof(__buf_))861 if (sizeof(_FF) <= sizeof(__buf_))
862 {862 {
863 __f_ = (__base*)&__buf_;863 __f_ = (__base*)&__buf_;
864 ::new (__f_) _FF(__f, __a0);864 ::new ((void*)__f_) _FF(__f, __a0);
865 }865 }
866 else866 else
867 {867 {
...@@ -869,7 +869,7 @@ function<_Rp(_A0)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,...@@ -869,7 +869,7 @@ function<_Rp(_A0)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
869 _Ap __a(__a0);869 _Ap __a(__a0);
870 typedef __allocator_destructor<_Ap> _Dp;870 typedef __allocator_destructor<_Ap> _Dp;
871 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));871 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
872 ::new (__hold.get()) _FF(__f, _Alloc(__a));872 ::new ((void*)__hold.get()) _FF(__f, _Alloc(__a));
873 __f_ = __hold.release();873 __f_ = __hold.release();
874 }874 }
875 }875 }
...@@ -1114,7 +1114,7 @@ function<_Rp(_A0, _A1)>::function(_Fp __f,...@@ -1114,7 +1114,7 @@ function<_Rp(_A0, _A1)>::function(_Fp __f,
1114 if (sizeof(_FF) <= sizeof(__buf_))1114 if (sizeof(_FF) <= sizeof(__buf_))
1115 {1115 {
1116 __f_ = (__base*)&__buf_;1116 __f_ = (__base*)&__buf_;
1117 ::new (__f_) _FF(__f);1117 ::new ((void*)__f_) _FF(__f);
1118 }1118 }
1119 else1119 else
1120 {1120 {
...@@ -1122,7 +1122,7 @@ function<_Rp(_A0, _A1)>::function(_Fp __f,...@@ -1122,7 +1122,7 @@ function<_Rp(_A0, _A1)>::function(_Fp __f,
1122 _Ap __a;1122 _Ap __a;
1123 typedef __allocator_destructor<_Ap> _Dp;1123 typedef __allocator_destructor<_Ap> _Dp;
1124 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));1124 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1125 ::new (__hold.get()) _FF(__f, allocator<_Fp>(__a));1125 ::new ((void*)__hold.get()) _FF(__f, allocator<_Fp>(__a));
1126 __f_ = __hold.release();1126 __f_ = __hold.release();
1127 }1127 }
1128 }1128 }
...@@ -1141,7 +1141,7 @@ function<_Rp(_A0, _A1)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,...@@ -1141,7 +1141,7 @@ function<_Rp(_A0, _A1)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
1141 if (sizeof(_FF) <= sizeof(__buf_))1141 if (sizeof(_FF) <= sizeof(__buf_))
1142 {1142 {
1143 __f_ = (__base*)&__buf_;1143 __f_ = (__base*)&__buf_;
1144 ::new (__f_) _FF(__f, __a0);1144 ::new ((void*)__f_) _FF(__f, __a0);
1145 }1145 }
1146 else1146 else
1147 {1147 {
...@@ -1149,7 +1149,7 @@ function<_Rp(_A0, _A1)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,...@@ -1149,7 +1149,7 @@ function<_Rp(_A0, _A1)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
1149 _Ap __a(__a0);1149 _Ap __a(__a0);
1150 typedef __allocator_destructor<_Ap> _Dp;1150 typedef __allocator_destructor<_Ap> _Dp;
1151 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));1151 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1152 ::new (__hold.get()) _FF(__f, _Alloc(__a));1152 ::new ((void*)__hold.get()) _FF(__f, _Alloc(__a));
1153 __f_ = __hold.release();1153 __f_ = __hold.release();
1154 }1154 }
1155 }1155 }
...@@ -1394,7 +1394,7 @@ function<_Rp(_A0, _A1, _A2)>::function(_Fp __f,...@@ -1394,7 +1394,7 @@ function<_Rp(_A0, _A1, _A2)>::function(_Fp __f,
1394 if (sizeof(_FF) <= sizeof(__buf_))1394 if (sizeof(_FF) <= sizeof(__buf_))
1395 {1395 {
1396 __f_ = (__base*)&__buf_;1396 __f_ = (__base*)&__buf_;
1397 ::new (__f_) _FF(__f);1397 ::new ((void*)__f_) _FF(__f);
1398 }1398 }
1399 else1399 else
1400 {1400 {
...@@ -1402,7 +1402,7 @@ function<_Rp(_A0, _A1, _A2)>::function(_Fp __f,...@@ -1402,7 +1402,7 @@ function<_Rp(_A0, _A1, _A2)>::function(_Fp __f,
1402 _Ap __a;1402 _Ap __a;
1403 typedef __allocator_destructor<_Ap> _Dp;1403 typedef __allocator_destructor<_Ap> _Dp;
1404 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));1404 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1405 ::new (__hold.get()) _FF(__f, allocator<_Fp>(__a));1405 ::new ((void*)__hold.get()) _FF(__f, allocator<_Fp>(__a));
1406 __f_ = __hold.release();1406 __f_ = __hold.release();
1407 }1407 }
1408 }1408 }
...@@ -1421,7 +1421,7 @@ function<_Rp(_A0, _A1, _A2)>::function(allocator_arg_t, const _Alloc& __a0, _Fp...@@ -1421,7 +1421,7 @@ function<_Rp(_A0, _A1, _A2)>::function(allocator_arg_t, const _Alloc& __a0, _Fp
1421 if (sizeof(_FF) <= sizeof(__buf_))1421 if (sizeof(_FF) <= sizeof(__buf_))
1422 {1422 {
1423 __f_ = (__base*)&__buf_;1423 __f_ = (__base*)&__buf_;
1424 ::new (__f_) _FF(__f, __a0);1424 ::new ((void*)__f_) _FF(__f, __a0);
1425 }1425 }
1426 else1426 else
1427 {1427 {
...@@ -1429,7 +1429,7 @@ function<_Rp(_A0, _A1, _A2)>::function(allocator_arg_t, const _Alloc& __a0, _Fp...@@ -1429,7 +1429,7 @@ function<_Rp(_A0, _A1, _A2)>::function(allocator_arg_t, const _Alloc& __a0, _Fp
1429 _Ap __a(__a0);1429 _Ap __a(__a0);
1430 typedef __allocator_destructor<_Ap> _Dp;1430 typedef __allocator_destructor<_Ap> _Dp;
1431 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));1431 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1432 ::new (__hold.get()) _FF(__f, _Alloc(__a));1432 ::new ((void*)__hold.get()) _FF(__f, _Alloc(__a));
1433 __f_ = __hold.release();1433 __f_ = __hold.release();
1434 }1434 }
1435 }1435 }
lib/libcxx/include/__functional_base+27-27
...@@ -298,7 +298,7 @@ struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile>...@@ -298,7 +298,7 @@ struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile>
298template <class _Tp, class ..._Args>298template <class _Tp, class ..._Args>
299struct __invoke_return299struct __invoke_return
300{300{
301 typedef decltype(__invoke(_VSTD::declval<_Tp>(), _VSTD::declval<_Args>()...)) type;301 typedef decltype(_VSTD::__invoke(declval<_Tp>(), declval<_Args>()...)) type;
302};302};
303303
304#else // defined(_LIBCPP_CXX03_LANG)304#else // defined(_LIBCPP_CXX03_LANG)
...@@ -314,27 +314,27 @@ struct __invoke_void_return_wrapper...@@ -314,27 +314,27 @@ struct __invoke_void_return_wrapper
314#ifndef _LIBCPP_CXX03_LANG314#ifndef _LIBCPP_CXX03_LANG
315 template <class ..._Args>315 template <class ..._Args>
316 static _Ret __call(_Args&&... __args) {316 static _Ret __call(_Args&&... __args) {
317 return __invoke(_VSTD::forward<_Args>(__args)...);317 return _VSTD::__invoke(_VSTD::forward<_Args>(__args)...);
318 }318 }
319#else319#else
320 template <class _Fn>320 template <class _Fn>
321 static _Ret __call(_Fn __f) {321 static _Ret __call(_Fn __f) {
322 return __invoke(__f);322 return _VSTD::__invoke(__f);
323 }323 }
324324
325 template <class _Fn, class _A0>325 template <class _Fn, class _A0>
326 static _Ret __call(_Fn __f, _A0& __a0) {326 static _Ret __call(_Fn __f, _A0& __a0) {
327 return __invoke(__f, __a0);327 return _VSTD::__invoke(__f, __a0);
328 }328 }
329329
330 template <class _Fn, class _A0, class _A1>330 template <class _Fn, class _A0, class _A1>
331 static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1) {331 static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1) {
332 return __invoke(__f, __a0, __a1);332 return _VSTD::__invoke(__f, __a0, __a1);
333 }333 }
334334
335 template <class _Fn, class _A0, class _A1, class _A2>335 template <class _Fn, class _A0, class _A1, class _A2>
336 static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2){336 static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2){
337 return __invoke(__f, __a0, __a1, __a2);337 return _VSTD::__invoke(__f, __a0, __a1, __a2);
338 }338 }
339#endif339#endif
340};340};
...@@ -345,27 +345,27 @@ struct __invoke_void_return_wrapper<void>...@@ -345,27 +345,27 @@ struct __invoke_void_return_wrapper<void>
345#ifndef _LIBCPP_CXX03_LANG345#ifndef _LIBCPP_CXX03_LANG
346 template <class ..._Args>346 template <class ..._Args>
347 static void __call(_Args&&... __args) {347 static void __call(_Args&&... __args) {
348 __invoke(_VSTD::forward<_Args>(__args)...);348 _VSTD::__invoke(_VSTD::forward<_Args>(__args)...);
349 }349 }
350#else350#else
351 template <class _Fn>351 template <class _Fn>
352 static void __call(_Fn __f) {352 static void __call(_Fn __f) {
353 __invoke(__f);353 _VSTD::__invoke(__f);
354 }354 }
355355
356 template <class _Fn, class _A0>356 template <class _Fn, class _A0>
357 static void __call(_Fn __f, _A0& __a0) {357 static void __call(_Fn __f, _A0& __a0) {
358 __invoke(__f, __a0);358 _VSTD::__invoke(__f, __a0);
359 }359 }
360360
361 template <class _Fn, class _A0, class _A1>361 template <class _Fn, class _A0, class _A1>
362 static void __call(_Fn __f, _A0& __a0, _A1& __a1) {362 static void __call(_Fn __f, _A0& __a0, _A1& __a1) {
363 __invoke(__f, __a0, __a1);363 _VSTD::__invoke(__f, __a0, __a1);
364 }364 }
365365
366 template <class _Fn, class _A0, class _A1, class _A2>366 template <class _Fn, class _A0, class _A1, class _A2>
367 static void __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2) {367 static void __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2) {
368 __invoke(__f, __a0, __a1, __a2);368 _VSTD::__invoke(__f, __a0, __a1, __a2);
369 }369 }
370#endif370#endif
371};371};
...@@ -398,112 +398,112 @@ public:...@@ -398,112 +398,112 @@ public:
398 _LIBCPP_INLINE_VISIBILITY398 _LIBCPP_INLINE_VISIBILITY
399 typename __invoke_of<type&, _ArgTypes...>::type399 typename __invoke_of<type&, _ArgTypes...>::type
400 operator() (_ArgTypes&&... __args) const {400 operator() (_ArgTypes&&... __args) const {
401 return __invoke(get(), _VSTD::forward<_ArgTypes>(__args)...);401 return _VSTD::__invoke(get(), _VSTD::forward<_ArgTypes>(__args)...);
402 }402 }
403#else403#else
404404
405 _LIBCPP_INLINE_VISIBILITY405 _LIBCPP_INLINE_VISIBILITY
406 typename __invoke_return<type>::type406 typename __invoke_return<type>::type
407 operator() () const {407 operator() () const {
408 return __invoke(get());408 return _VSTD::__invoke(get());
409 }409 }
410410
411 template <class _A0>411 template <class _A0>
412 _LIBCPP_INLINE_VISIBILITY412 _LIBCPP_INLINE_VISIBILITY
413 typename __invoke_return0<type, _A0>::type413 typename __invoke_return0<type, _A0>::type
414 operator() (_A0& __a0) const {414 operator() (_A0& __a0) const {
415 return __invoke(get(), __a0);415 return _VSTD::__invoke(get(), __a0);
416 }416 }
417417
418 template <class _A0>418 template <class _A0>
419 _LIBCPP_INLINE_VISIBILITY419 _LIBCPP_INLINE_VISIBILITY
420 typename __invoke_return0<type, _A0 const>::type420 typename __invoke_return0<type, _A0 const>::type
421 operator() (_A0 const& __a0) const {421 operator() (_A0 const& __a0) const {
422 return __invoke(get(), __a0);422 return _VSTD::__invoke(get(), __a0);
423 }423 }
424424
425 template <class _A0, class _A1>425 template <class _A0, class _A1>
426 _LIBCPP_INLINE_VISIBILITY426 _LIBCPP_INLINE_VISIBILITY
427 typename __invoke_return1<type, _A0, _A1>::type427 typename __invoke_return1<type, _A0, _A1>::type
428 operator() (_A0& __a0, _A1& __a1) const {428 operator() (_A0& __a0, _A1& __a1) const {
429 return __invoke(get(), __a0, __a1);429 return _VSTD::__invoke(get(), __a0, __a1);
430 }430 }
431431
432 template <class _A0, class _A1>432 template <class _A0, class _A1>
433 _LIBCPP_INLINE_VISIBILITY433 _LIBCPP_INLINE_VISIBILITY
434 typename __invoke_return1<type, _A0 const, _A1>::type434 typename __invoke_return1<type, _A0 const, _A1>::type
435 operator() (_A0 const& __a0, _A1& __a1) const {435 operator() (_A0 const& __a0, _A1& __a1) const {
436 return __invoke(get(), __a0, __a1);436 return _VSTD::__invoke(get(), __a0, __a1);
437 }437 }
438438
439 template <class _A0, class _A1>439 template <class _A0, class _A1>
440 _LIBCPP_INLINE_VISIBILITY440 _LIBCPP_INLINE_VISIBILITY
441 typename __invoke_return1<type, _A0, _A1 const>::type441 typename __invoke_return1<type, _A0, _A1 const>::type
442 operator() (_A0& __a0, _A1 const& __a1) const {442 operator() (_A0& __a0, _A1 const& __a1) const {
443 return __invoke(get(), __a0, __a1);443 return _VSTD::__invoke(get(), __a0, __a1);
444 }444 }
445445
446 template <class _A0, class _A1>446 template <class _A0, class _A1>
447 _LIBCPP_INLINE_VISIBILITY447 _LIBCPP_INLINE_VISIBILITY
448 typename __invoke_return1<type, _A0 const, _A1 const>::type448 typename __invoke_return1<type, _A0 const, _A1 const>::type
449 operator() (_A0 const& __a0, _A1 const& __a1) const {449 operator() (_A0 const& __a0, _A1 const& __a1) const {
450 return __invoke(get(), __a0, __a1);450 return _VSTD::__invoke(get(), __a0, __a1);
451 }451 }
452452
453 template <class _A0, class _A1, class _A2>453 template <class _A0, class _A1, class _A2>
454 _LIBCPP_INLINE_VISIBILITY454 _LIBCPP_INLINE_VISIBILITY
455 typename __invoke_return2<type, _A0, _A1, _A2>::type455 typename __invoke_return2<type, _A0, _A1, _A2>::type
456 operator() (_A0& __a0, _A1& __a1, _A2& __a2) const {456 operator() (_A0& __a0, _A1& __a1, _A2& __a2) const {
457 return __invoke(get(), __a0, __a1, __a2);457 return _VSTD::__invoke(get(), __a0, __a1, __a2);
458 }458 }
459459
460 template <class _A0, class _A1, class _A2>460 template <class _A0, class _A1, class _A2>
461 _LIBCPP_INLINE_VISIBILITY461 _LIBCPP_INLINE_VISIBILITY
462 typename __invoke_return2<type, _A0 const, _A1, _A2>::type462 typename __invoke_return2<type, _A0 const, _A1, _A2>::type
463 operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const {463 operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const {
464 return __invoke(get(), __a0, __a1, __a2);464 return _VSTD::__invoke(get(), __a0, __a1, __a2);
465 }465 }
466466
467 template <class _A0, class _A1, class _A2>467 template <class _A0, class _A1, class _A2>
468 _LIBCPP_INLINE_VISIBILITY468 _LIBCPP_INLINE_VISIBILITY
469 typename __invoke_return2<type, _A0, _A1 const, _A2>::type469 typename __invoke_return2<type, _A0, _A1 const, _A2>::type
470 operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const {470 operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const {
471 return __invoke(get(), __a0, __a1, __a2);471 return _VSTD::__invoke(get(), __a0, __a1, __a2);
472 }472 }
473473
474 template <class _A0, class _A1, class _A2>474 template <class _A0, class _A1, class _A2>
475 _LIBCPP_INLINE_VISIBILITY475 _LIBCPP_INLINE_VISIBILITY
476 typename __invoke_return2<type, _A0, _A1, _A2 const>::type476 typename __invoke_return2<type, _A0, _A1, _A2 const>::type
477 operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const {477 operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const {
478 return __invoke(get(), __a0, __a1, __a2);478 return _VSTD::__invoke(get(), __a0, __a1, __a2);
479 }479 }
480480
481 template <class _A0, class _A1, class _A2>481 template <class _A0, class _A1, class _A2>
482 _LIBCPP_INLINE_VISIBILITY482 _LIBCPP_INLINE_VISIBILITY
483 typename __invoke_return2<type, _A0 const, _A1 const, _A2>::type483 typename __invoke_return2<type, _A0 const, _A1 const, _A2>::type
484 operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const {484 operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const {
485 return __invoke(get(), __a0, __a1, __a2);485 return _VSTD::__invoke(get(), __a0, __a1, __a2);
486 }486 }
487487
488 template <class _A0, class _A1, class _A2>488 template <class _A0, class _A1, class _A2>
489 _LIBCPP_INLINE_VISIBILITY489 _LIBCPP_INLINE_VISIBILITY
490 typename __invoke_return2<type, _A0 const, _A1, _A2 const>::type490 typename __invoke_return2<type, _A0 const, _A1, _A2 const>::type
491 operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const {491 operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const {
492 return __invoke(get(), __a0, __a1, __a2);492 return _VSTD::__invoke(get(), __a0, __a1, __a2);
493 }493 }
494494
495 template <class _A0, class _A1, class _A2>495 template <class _A0, class _A1, class _A2>
496 _LIBCPP_INLINE_VISIBILITY496 _LIBCPP_INLINE_VISIBILITY
497 typename __invoke_return2<type, _A0, _A1 const, _A2 const>::type497 typename __invoke_return2<type, _A0, _A1 const, _A2 const>::type
498 operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const {498 operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const {
499 return __invoke(get(), __a0, __a1, __a2);499 return _VSTD::__invoke(get(), __a0, __a1, __a2);
500 }500 }
501501
502 template <class _A0, class _A1, class _A2>502 template <class _A0, class _A1, class _A2>
503 _LIBCPP_INLINE_VISIBILITY503 _LIBCPP_INLINE_VISIBILITY
504 typename __invoke_return2<type, _A0 const, _A1 const, _A2 const>::type504 typename __invoke_return2<type, _A0 const, _A1 const, _A2 const>::type
505 operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const {505 operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const {
506 return __invoke(get(), __a0, __a1, __a2);506 return _VSTD::__invoke(get(), __a0, __a1, __a2);
507 }507 }
508#endif // _LIBCPP_CXX03_LANG508#endif // _LIBCPP_CXX03_LANG
509};509};
lib/libcxx/include/__functional_base_03+12-12
...@@ -40,7 +40,7 @@ struct __enable_invoke_imp<_Ret, _T1, false, true> {...@@ -40,7 +40,7 @@ struct __enable_invoke_imp<_Ret, _T1, false, true> {
40template <class _Ret, class _T1>40template <class _Ret, class _T1>
41struct __enable_invoke_imp<_Ret, _T1, false, false> {41struct __enable_invoke_imp<_Ret, _T1, false, false> {
42 typedef typename add_lvalue_reference<42 typedef typename add_lvalue_reference<
43 typename __apply_cv<decltype(*_VSTD::declval<_T1>()), _Ret>::type43 typename __apply_cv<decltype(*declval<_T1>()), _Ret>::type
44 >::type _Bullet4;44 >::type _Bullet4;
45 typedef _Bullet4 type;45 typedef _Bullet4 type;
46};46};
...@@ -142,7 +142,7 @@ __invoke(_Fn __f, _T1& __t1) {...@@ -142,7 +142,7 @@ __invoke(_Fn __f, _T1& __t1) {
142142
143template <class _Fp>143template <class _Fp>
144inline _LIBCPP_INLINE_VISIBILITY144inline _LIBCPP_INLINE_VISIBILITY
145decltype(_VSTD::declval<_Fp&>()())145decltype(declval<_Fp&>()())
146__invoke(_Fp& __f)146__invoke(_Fp& __f)
147{147{
148 return __f();148 return __f();
...@@ -150,7 +150,7 @@ __invoke(_Fp& __f)...@@ -150,7 +150,7 @@ __invoke(_Fp& __f)
150150
151template <class _Fp, class _A0>151template <class _Fp, class _A0>
152inline _LIBCPP_INLINE_VISIBILITY152inline _LIBCPP_INLINE_VISIBILITY
153decltype(_VSTD::declval<_Fp&>()(_VSTD::declval<_A0&>()))153decltype(declval<_Fp&>()(declval<_A0&>()))
154__invoke(_Fp& __f, _A0& __a0)154__invoke(_Fp& __f, _A0& __a0)
155{155{
156 return __f(__a0);156 return __f(__a0);
...@@ -158,7 +158,7 @@ __invoke(_Fp& __f, _A0& __a0)...@@ -158,7 +158,7 @@ __invoke(_Fp& __f, _A0& __a0)
158158
159template <class _Fp, class _A0, class _A1>159template <class _Fp, class _A0, class _A1>
160inline _LIBCPP_INLINE_VISIBILITY160inline _LIBCPP_INLINE_VISIBILITY
161decltype(_VSTD::declval<_Fp&>()(_VSTD::declval<_A0&>(), _VSTD::declval<_A1&>()))161decltype(declval<_Fp&>()(declval<_A0&>(), declval<_A1&>()))
162__invoke(_Fp& __f, _A0& __a0, _A1& __a1)162__invoke(_Fp& __f, _A0& __a0, _A1& __a1)
163{163{
164 return __f(__a0, __a1);164 return __f(__a0, __a1);
...@@ -166,7 +166,7 @@ __invoke(_Fp& __f, _A0& __a0, _A1& __a1)...@@ -166,7 +166,7 @@ __invoke(_Fp& __f, _A0& __a0, _A1& __a1)
166166
167template <class _Fp, class _A0, class _A1, class _A2>167template <class _Fp, class _A0, class _A1, class _A2>
168inline _LIBCPP_INLINE_VISIBILITY168inline _LIBCPP_INLINE_VISIBILITY
169decltype(_VSTD::declval<_Fp&>()(_VSTD::declval<_A0&>(), _VSTD::declval<_A1&>(), _VSTD::declval<_A2&>()))169decltype(declval<_Fp&>()(declval<_A0&>(), declval<_A1&>(), declval<_A2&>()))
170__invoke(_Fp& __f, _A0& __a0, _A1& __a1, _A2& __a2)170__invoke(_Fp& __f, _A0& __a0, _A1& __a1, _A2& __a2)
171{171{
172 return __f(__a0, __a1, __a2);172 return __f(__a0, __a1, __a2);
...@@ -181,13 +181,13 @@ struct __invoke_return...@@ -181,13 +181,13 @@ struct __invoke_return
181template <class _Fp>181template <class _Fp>
182struct __invoke_return<_Fp, false>182struct __invoke_return<_Fp, false>
183{183{
184 typedef decltype(__invoke(_VSTD::declval<_Fp&>())) type;184 typedef decltype(_VSTD::__invoke(declval<_Fp&>())) type;
185};185};
186186
187template <class _Tp, class _A0>187template <class _Tp, class _A0>
188struct __invoke_return0188struct __invoke_return0
189{189{
190 typedef decltype(__invoke(_VSTD::declval<_Tp&>(), _VSTD::declval<_A0&>())) type;190 typedef decltype(_VSTD::__invoke(declval<_Tp&>(), declval<_A0&>())) type;
191};191};
192192
193template <class _Rp, class _Tp, class _A0>193template <class _Rp, class _Tp, class _A0>
...@@ -199,8 +199,8 @@ struct __invoke_return0<_Rp _Tp::*, _A0>...@@ -199,8 +199,8 @@ struct __invoke_return0<_Rp _Tp::*, _A0>
199template <class _Tp, class _A0, class _A1>199template <class _Tp, class _A0, class _A1>
200struct __invoke_return1200struct __invoke_return1
201{201{
202 typedef decltype(__invoke(_VSTD::declval<_Tp&>(), _VSTD::declval<_A0&>(),202 typedef decltype(_VSTD::__invoke(declval<_Tp&>(), declval<_A0&>(),
203 _VSTD::declval<_A1&>())) type;203 declval<_A1&>())) type;
204};204};
205205
206template <class _Rp, class _Class, class _A0, class _A1>206template <class _Rp, class _Class, class _A0, class _A1>
...@@ -211,9 +211,9 @@ struct __invoke_return1<_Rp _Class::*, _A0, _A1> {...@@ -211,9 +211,9 @@ struct __invoke_return1<_Rp _Class::*, _A0, _A1> {
211template <class _Tp, class _A0, class _A1, class _A2>211template <class _Tp, class _A0, class _A1, class _A2>
212struct __invoke_return2212struct __invoke_return2
213{213{
214 typedef decltype(__invoke(_VSTD::declval<_Tp&>(), _VSTD::declval<_A0&>(),214 typedef decltype(_VSTD::__invoke(declval<_Tp&>(), declval<_A0&>(),
215 _VSTD::declval<_A1&>(),215 declval<_A1&>(),
216 _VSTD::declval<_A2&>())) type;216 declval<_A2&>())) type;
217};217};
218218
219template <class _Ret, class _Class, class _A0, class _A1, class _A2>219template <class _Ret, class _Class, class _A0, class _A1, class _A2>
lib/libcxx/include/__hash_table+68-170
...@@ -34,19 +34,17 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -34,19 +34,17 @@ _LIBCPP_BEGIN_NAMESPACE_STD
34template <class _Key, class _Tp>34template <class _Key, class _Tp>
35struct __hash_value_type;35struct __hash_value_type;
3636
37#ifndef _LIBCPP_CXX03_LANG
38template <class _Tp>37template <class _Tp>
39struct __is_hash_value_type_imp : false_type {};38struct __is_hash_value_type_imp : false_type {};
4039
41template <class _Key, class _Value>40template <class _Key, class _Value>
42struct __is_hash_value_type_imp<__hash_value_type<_Key, _Value>> : true_type {};41struct __is_hash_value_type_imp<__hash_value_type<_Key, _Value> > : true_type {};
4342
44template <class ..._Args>43template <class ..._Args>
45struct __is_hash_value_type : false_type {};44struct __is_hash_value_type : false_type {};
4645
47template <class _One>46template <class _One>
48struct __is_hash_value_type<_One> : __is_hash_value_type_imp<typename __uncvref<_One>::type> {};47struct __is_hash_value_type<_One> : __is_hash_value_type_imp<typename __uncvref<_One>::type> {};
49#endif
5048
51_LIBCPP_FUNC_VIS49_LIBCPP_FUNC_VIS
52size_t __next_prime(size_t __n);50size_t __next_prime(size_t __n);
...@@ -122,7 +120,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -122,7 +120,7 @@ inline _LIBCPP_INLINE_VISIBILITY
122size_t120size_t
123__next_hash_pow2(size_t __n)121__next_hash_pow2(size_t __n)
124{122{
125 return __n < 2 ? __n : (size_t(1) << (std::numeric_limits<size_t>::digits - __libcpp_clz(__n-1)));123 return __n < 2 ? __n : (size_t(1) << (numeric_limits<size_t>::digits - __libcpp_clz(__n-1)));
126}124}
127125
128126
...@@ -155,12 +153,10 @@ struct __hash_key_value_types {...@@ -155,12 +153,10 @@ struct __hash_key_value_types {
155 static __container_value_type* __get_ptr(__node_value_type& __n) {153 static __container_value_type* __get_ptr(__node_value_type& __n) {
156 return _VSTD::addressof(__n);154 return _VSTD::addressof(__n);
157 }155 }
158#ifndef _LIBCPP_CXX03_LANG
159 _LIBCPP_INLINE_VISIBILITY156 _LIBCPP_INLINE_VISIBILITY
160 static __container_value_type&& __move(__node_value_type& __v) {157 static __container_value_type&& __move(__node_value_type& __v) {
161 return _VSTD::move(__v);158 return _VSTD::move(__v);
162 }159 }
163#endif
164};160};
165161
166template <class _Key, class _Tp>162template <class _Key, class _Tp>
...@@ -197,13 +193,10 @@ struct __hash_key_value_types<__hash_value_type<_Key, _Tp> > {...@@ -197,13 +193,10 @@ struct __hash_key_value_types<__hash_value_type<_Key, _Tp> > {
197 static __container_value_type* __get_ptr(__node_value_type& __n) {193 static __container_value_type* __get_ptr(__node_value_type& __n) {
198 return _VSTD::addressof(__n.__get_value());194 return _VSTD::addressof(__n.__get_value());
199 }195 }
200#ifndef _LIBCPP_CXX03_LANG
201 _LIBCPP_INLINE_VISIBILITY196 _LIBCPP_INLINE_VISIBILITY
202 static pair<key_type&&, mapped_type&&> __move(__node_value_type& __v) {197 static pair<key_type&&, mapped_type&&> __move(__node_value_type& __v) {
203 return __v.__move();198 return __v.__move();
204 }199 }
205#endif
206
207};200};
208201
209template <class _Tp, class _AllocPtr, class _KVTypes = __hash_key_value_types<_Tp>,202template <class _Tp, class _AllocPtr, class _KVTypes = __hash_key_value_types<_Tp>,
...@@ -295,10 +288,12 @@ public:...@@ -295,10 +288,12 @@ public:
295 typedef typename _NodeTypes::__node_value_type_pointer pointer;288 typedef typename _NodeTypes::__node_value_type_pointer pointer;
296289
297 _LIBCPP_INLINE_VISIBILITY __hash_iterator() _NOEXCEPT : __node_(nullptr) {290 _LIBCPP_INLINE_VISIBILITY __hash_iterator() _NOEXCEPT : __node_(nullptr) {
298 _LIBCPP_DEBUG_MODE(__get_db()->__insert_i(this));291#if _LIBCPP_DEBUG_LEVEL == 2
292 __get_db()->__insert_i(this);
293#endif
299 }294 }
300295
301#if _LIBCPP_DEBUG_LEVEL >= 2296#if _LIBCPP_DEBUG_LEVEL == 2
302 _LIBCPP_INLINE_VISIBILITY297 _LIBCPP_INLINE_VISIBILITY
303 __hash_iterator(const __hash_iterator& __i)298 __hash_iterator(const __hash_iterator& __i)
304 : __node_(__i.__node_)299 : __node_(__i.__node_)
...@@ -322,7 +317,7 @@ public:...@@ -322,7 +317,7 @@ public:
322 }317 }
323 return *this;318 return *this;
324 }319 }
325#endif // _LIBCPP_DEBUG_LEVEL >= 2320#endif // _LIBCPP_DEBUG_LEVEL == 2
326321
327 _LIBCPP_INLINE_VISIBILITY322 _LIBCPP_INLINE_VISIBILITY
328 reference operator*() const {323 reference operator*() const {
...@@ -364,7 +359,7 @@ public:...@@ -364,7 +359,7 @@ public:
364 {return !(__x == __y);}359 {return !(__x == __y);}
365360
366private:361private:
367#if _LIBCPP_DEBUG_LEVEL >= 2362#if _LIBCPP_DEBUG_LEVEL == 2
368 _LIBCPP_INLINE_VISIBILITY363 _LIBCPP_INLINE_VISIBILITY
369 __hash_iterator(__next_pointer __node, const void* __c) _NOEXCEPT364 __hash_iterator(__next_pointer __node, const void* __c) _NOEXCEPT
370 : __node_(__node)365 : __node_(__node)
...@@ -405,17 +400,21 @@ public:...@@ -405,17 +400,21 @@ public:
405400
406401
407 _LIBCPP_INLINE_VISIBILITY __hash_const_iterator() _NOEXCEPT : __node_(nullptr) {402 _LIBCPP_INLINE_VISIBILITY __hash_const_iterator() _NOEXCEPT : __node_(nullptr) {
408 _LIBCPP_DEBUG_MODE(__get_db()->__insert_i(this));403#if _LIBCPP_DEBUG_LEVEL == 2
404 __get_db()->__insert_i(this);
405#endif
409 }406 }
410407
411 _LIBCPP_INLINE_VISIBILITY408 _LIBCPP_INLINE_VISIBILITY
412 __hash_const_iterator(const __non_const_iterator& __x) _NOEXCEPT409 __hash_const_iterator(const __non_const_iterator& __x) _NOEXCEPT
413 : __node_(__x.__node_)410 : __node_(__x.__node_)
414 {411 {
415 _LIBCPP_DEBUG_MODE(__get_db()->__iterator_copy(this, &__x));412#if _LIBCPP_DEBUG_LEVEL == 2
413 __get_db()->__iterator_copy(this, &__x);
414#endif
416 }415 }
417416
418#if _LIBCPP_DEBUG_LEVEL >= 2417#if _LIBCPP_DEBUG_LEVEL == 2
419 _LIBCPP_INLINE_VISIBILITY418 _LIBCPP_INLINE_VISIBILITY
420 __hash_const_iterator(const __hash_const_iterator& __i)419 __hash_const_iterator(const __hash_const_iterator& __i)
421 : __node_(__i.__node_)420 : __node_(__i.__node_)
...@@ -439,7 +438,7 @@ public:...@@ -439,7 +438,7 @@ public:
439 }438 }
440 return *this;439 return *this;
441 }440 }
442#endif // _LIBCPP_DEBUG_LEVEL >= 2441#endif // _LIBCPP_DEBUG_LEVEL == 2
443442
444 _LIBCPP_INLINE_VISIBILITY443 _LIBCPP_INLINE_VISIBILITY
445 reference operator*() const {444 reference operator*() const {
...@@ -480,7 +479,7 @@ public:...@@ -480,7 +479,7 @@ public:
480 {return !(__x == __y);}479 {return !(__x == __y);}
481480
482private:481private:
483#if _LIBCPP_DEBUG_LEVEL >= 2482#if _LIBCPP_DEBUG_LEVEL == 2
484 _LIBCPP_INLINE_VISIBILITY483 _LIBCPP_INLINE_VISIBILITY
485 __hash_const_iterator(__next_pointer __node, const void* __c) _NOEXCEPT484 __hash_const_iterator(__next_pointer __node, const void* __c) _NOEXCEPT
486 : __node_(__node)485 : __node_(__node)
...@@ -518,10 +517,12 @@ public:...@@ -518,10 +517,12 @@ public:
518 typedef typename _NodeTypes::__node_value_type_pointer pointer;517 typedef typename _NodeTypes::__node_value_type_pointer pointer;
519518
520 _LIBCPP_INLINE_VISIBILITY __hash_local_iterator() _NOEXCEPT : __node_(nullptr) {519 _LIBCPP_INLINE_VISIBILITY __hash_local_iterator() _NOEXCEPT : __node_(nullptr) {
521 _LIBCPP_DEBUG_MODE(__get_db()->__insert_i(this));520#if _LIBCPP_DEBUG_LEVEL == 2
521 __get_db()->__insert_i(this);
522#endif
522 }523 }
523524
524#if _LIBCPP_DEBUG_LEVEL >= 2525#if _LIBCPP_DEBUG_LEVEL == 2
525 _LIBCPP_INLINE_VISIBILITY526 _LIBCPP_INLINE_VISIBILITY
526 __hash_local_iterator(const __hash_local_iterator& __i)527 __hash_local_iterator(const __hash_local_iterator& __i)
527 : __node_(__i.__node_),528 : __node_(__i.__node_),
...@@ -549,7 +550,7 @@ public:...@@ -549,7 +550,7 @@ public:
549 }550 }
550 return *this;551 return *this;
551 }552 }
552#endif // _LIBCPP_DEBUG_LEVEL >= 2553#endif // _LIBCPP_DEBUG_LEVEL == 2
553554
554 _LIBCPP_INLINE_VISIBILITY555 _LIBCPP_INLINE_VISIBILITY
555 reference operator*() const {556 reference operator*() const {
...@@ -593,7 +594,7 @@ public:...@@ -593,7 +594,7 @@ public:
593 {return !(__x == __y);}594 {return !(__x == __y);}
594595
595private:596private:
596#if _LIBCPP_DEBUG_LEVEL >= 2597#if _LIBCPP_DEBUG_LEVEL == 2
597 _LIBCPP_INLINE_VISIBILITY598 _LIBCPP_INLINE_VISIBILITY
598 __hash_local_iterator(__next_pointer __node, size_t __bucket,599 __hash_local_iterator(__next_pointer __node, size_t __bucket,
599 size_t __bucket_count, const void* __c) _NOEXCEPT600 size_t __bucket_count, const void* __c) _NOEXCEPT
...@@ -650,7 +651,9 @@ public:...@@ -650,7 +651,9 @@ public:
650651
651652
652 _LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator() _NOEXCEPT : __node_(nullptr) {653 _LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator() _NOEXCEPT : __node_(nullptr) {
653 _LIBCPP_DEBUG_MODE(__get_db()->__insert_i(this));654#if _LIBCPP_DEBUG_LEVEL == 2
655 __get_db()->__insert_i(this);
656#endif
654 }657 }
655658
656 _LIBCPP_INLINE_VISIBILITY659 _LIBCPP_INLINE_VISIBILITY
...@@ -659,10 +662,12 @@ public:...@@ -659,10 +662,12 @@ public:
659 __bucket_(__x.__bucket_),662 __bucket_(__x.__bucket_),
660 __bucket_count_(__x.__bucket_count_)663 __bucket_count_(__x.__bucket_count_)
661 {664 {
662 _LIBCPP_DEBUG_MODE(__get_db()->__iterator_copy(this, &__x));665#if _LIBCPP_DEBUG_LEVEL == 2
666 __get_db()->__iterator_copy(this, &__x);
667#endif
663 }668 }
664669
665#if _LIBCPP_DEBUG_LEVEL >= 2670#if _LIBCPP_DEBUG_LEVEL == 2
666 _LIBCPP_INLINE_VISIBILITY671 _LIBCPP_INLINE_VISIBILITY
667 __hash_const_local_iterator(const __hash_const_local_iterator& __i)672 __hash_const_local_iterator(const __hash_const_local_iterator& __i)
668 : __node_(__i.__node_),673 : __node_(__i.__node_),
...@@ -690,7 +695,7 @@ public:...@@ -690,7 +695,7 @@ public:
690 }695 }
691 return *this;696 return *this;
692 }697 }
693#endif // _LIBCPP_DEBUG_LEVEL >= 2698#endif // _LIBCPP_DEBUG_LEVEL == 2
694699
695 _LIBCPP_INLINE_VISIBILITY700 _LIBCPP_INLINE_VISIBILITY
696 reference operator*() const {701 reference operator*() const {
...@@ -734,7 +739,7 @@ public:...@@ -734,7 +739,7 @@ public:
734 {return !(__x == __y);}739 {return !(__x == __y);}
735740
736private:741private:
737#if _LIBCPP_DEBUG_LEVEL >= 2742#if _LIBCPP_DEBUG_LEVEL == 2
738 _LIBCPP_INLINE_VISIBILITY743 _LIBCPP_INLINE_VISIBILITY
739 __hash_const_local_iterator(__next_pointer __node, size_t __bucket,744 __hash_const_local_iterator(__next_pointer __node, size_t __bucket,
740 size_t __bucket_count, const void* __c) _NOEXCEPT745 size_t __bucket_count, const void* __c) _NOEXCEPT
...@@ -783,7 +788,6 @@ public:...@@ -783,7 +788,6 @@ public:
783 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)788 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
784 : __data_(__size, __a) {}789 : __data_(__size, __a) {}
785790
786#ifndef _LIBCPP_CXX03_LANG
787 _LIBCPP_INLINE_VISIBILITY791 _LIBCPP_INLINE_VISIBILITY
788 __bucket_list_deallocator(__bucket_list_deallocator&& __x)792 __bucket_list_deallocator(__bucket_list_deallocator&& __x)
789 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)793 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
...@@ -791,7 +795,6 @@ public:...@@ -791,7 +795,6 @@ public:
791 {795 {
792 __x.size() = 0;796 __x.size() = 0;
793 }797 }
794#endif
795798
796 _LIBCPP_INLINE_VISIBILITY799 _LIBCPP_INLINE_VISIBILITY
797 size_type& size() _NOEXCEPT {return __data_.first();}800 size_type& size() _NOEXCEPT {return __data_.first();}
...@@ -1007,7 +1010,6 @@ public:...@@ -1007,7 +1010,6 @@ public:
1007 explicit __hash_table(const allocator_type& __a);1010 explicit __hash_table(const allocator_type& __a);
1008 __hash_table(const __hash_table& __u);1011 __hash_table(const __hash_table& __u);
1009 __hash_table(const __hash_table& __u, const allocator_type& __a);1012 __hash_table(const __hash_table& __u, const allocator_type& __a);
1010#ifndef _LIBCPP_CXX03_LANG
1011 __hash_table(__hash_table&& __u)1013 __hash_table(__hash_table&& __u)
1012 _NOEXCEPT_(1014 _NOEXCEPT_(
1013 is_nothrow_move_constructible<__bucket_list>::value &&1015 is_nothrow_move_constructible<__bucket_list>::value &&
...@@ -1016,11 +1018,9 @@ public:...@@ -1016,11 +1018,9 @@ public:
1016 is_nothrow_move_constructible<hasher>::value &&1018 is_nothrow_move_constructible<hasher>::value &&
1017 is_nothrow_move_constructible<key_equal>::value);1019 is_nothrow_move_constructible<key_equal>::value);
1018 __hash_table(__hash_table&& __u, const allocator_type& __a);1020 __hash_table(__hash_table&& __u, const allocator_type& __a);
1019#endif // _LIBCPP_CXX03_LANG
1020 ~__hash_table();1021 ~__hash_table();
10211022
1022 __hash_table& operator=(const __hash_table& __u);1023 __hash_table& operator=(const __hash_table& __u);
1023#ifndef _LIBCPP_CXX03_LANG
1024 _LIBCPP_INLINE_VISIBILITY1024 _LIBCPP_INLINE_VISIBILITY
1025 __hash_table& operator=(__hash_table&& __u)1025 __hash_table& operator=(__hash_table&& __u)
1026 _NOEXCEPT_(1026 _NOEXCEPT_(
...@@ -1028,7 +1028,6 @@ public:...@@ -1028,7 +1028,6 @@ public:
1028 is_nothrow_move_assignable<__node_allocator>::value &&1028 is_nothrow_move_assignable<__node_allocator>::value &&
1029 is_nothrow_move_assignable<hasher>::value &&1029 is_nothrow_move_assignable<hasher>::value &&
1030 is_nothrow_move_assignable<key_equal>::value);1030 is_nothrow_move_assignable<key_equal>::value);
1031#endif
1032 template <class _InputIterator>1031 template <class _InputIterator>
1033 void __assign_unique(_InputIterator __first, _InputIterator __last);1032 void __assign_unique(_InputIterator __first, _InputIterator __last);
1034 template <class _InputIterator>1033 template <class _InputIterator>
...@@ -1037,7 +1036,7 @@ public:...@@ -1037,7 +1036,7 @@ public:
1037 _LIBCPP_INLINE_VISIBILITY1036 _LIBCPP_INLINE_VISIBILITY
1038 size_type max_size() const _NOEXCEPT1037 size_type max_size() const _NOEXCEPT
1039 {1038 {
1040 return std::min<size_type>(1039 return _VSTD::min<size_type>(
1041 __node_traits::max_size(__node_alloc()),1040 __node_traits::max_size(__node_alloc()),
1042 numeric_limits<difference_type >::max()1041 numeric_limits<difference_type >::max()
1043 );1042 );
...@@ -1066,7 +1065,6 @@ public:...@@ -1066,7 +1065,6 @@ public:
1066 iterator __node_insert_multi(const_iterator __p,1065 iterator __node_insert_multi(const_iterator __p,
1067 __node_pointer __nd);1066 __node_pointer __nd);
10681067
1069#ifndef _LIBCPP_CXX03_LANG
1070 template <class _Key, class ..._Args>1068 template <class _Key, class ..._Args>
1071 _LIBCPP_INLINE_VISIBILITY1069 _LIBCPP_INLINE_VISIBILITY
1072 pair<iterator, bool> __emplace_unique_key_args(_Key const& __k, _Args&&... __args);1070 pair<iterator, bool> __emplace_unique_key_args(_Key const& __k, _Args&&... __args);
...@@ -1151,15 +1149,6 @@ public:...@@ -1151,15 +1149,6 @@ public:
1151 return __emplace_hint_multi(__p, _VSTD::forward<_Pp>(__x));1149 return __emplace_hint_multi(__p, _VSTD::forward<_Pp>(__x));
1152 }1150 }
11531151
1154#else // !defined(_LIBCPP_CXX03_LANG)
1155 template <class _Key, class _Args>
1156 _LIBCPP_INLINE_VISIBILITY
1157 pair<iterator, bool> __emplace_unique_key_args(_Key const&, _Args& __args);
1158
1159 iterator __insert_multi(const __container_value_type& __x);
1160 iterator __insert_multi(const_iterator __p, const __container_value_type& __x);
1161#endif
1162
1163 _LIBCPP_INLINE_VISIBILITY1152 _LIBCPP_INLINE_VISIBILITY
1164 pair<iterator, bool> __insert_unique(const __container_value_type& __x) {1153 pair<iterator, bool> __insert_unique(const __container_value_type& __x) {
1165 return __emplace_unique_key_args(_NodeTypes::__get_key(__x), __x);1154 return __emplace_unique_key_args(_NodeTypes::__get_key(__x), __x);
...@@ -1295,7 +1284,7 @@ public:...@@ -1295,7 +1284,7 @@ public:
1295 {1284 {
1296 _LIBCPP_ASSERT(__n < bucket_count(),1285 _LIBCPP_ASSERT(__n < bucket_count(),
1297 "unordered container::begin(n) called with n >= bucket_count()");1286 "unordered container::begin(n) called with n >= bucket_count()");
1298#if _LIBCPP_DEBUG_LEVEL >= 21287#if _LIBCPP_DEBUG_LEVEL == 2
1299 return local_iterator(__bucket_list_[__n], __n, bucket_count(), this);1288 return local_iterator(__bucket_list_[__n], __n, bucket_count(), this);
1300#else1289#else
1301 return local_iterator(__bucket_list_[__n], __n, bucket_count());1290 return local_iterator(__bucket_list_[__n], __n, bucket_count());
...@@ -1308,7 +1297,7 @@ public:...@@ -1308,7 +1297,7 @@ public:
1308 {1297 {
1309 _LIBCPP_ASSERT(__n < bucket_count(),1298 _LIBCPP_ASSERT(__n < bucket_count(),
1310 "unordered container::end(n) called with n >= bucket_count()");1299 "unordered container::end(n) called with n >= bucket_count()");
1311#if _LIBCPP_DEBUG_LEVEL >= 21300#if _LIBCPP_DEBUG_LEVEL == 2
1312 return local_iterator(nullptr, __n, bucket_count(), this);1301 return local_iterator(nullptr, __n, bucket_count(), this);
1313#else1302#else
1314 return local_iterator(nullptr, __n, bucket_count());1303 return local_iterator(nullptr, __n, bucket_count());
...@@ -1321,7 +1310,7 @@ public:...@@ -1321,7 +1310,7 @@ public:
1321 {1310 {
1322 _LIBCPP_ASSERT(__n < bucket_count(),1311 _LIBCPP_ASSERT(__n < bucket_count(),
1323 "unordered container::cbegin(n) called with n >= bucket_count()");1312 "unordered container::cbegin(n) called with n >= bucket_count()");
1324#if _LIBCPP_DEBUG_LEVEL >= 21313#if _LIBCPP_DEBUG_LEVEL == 2
1325 return const_local_iterator(__bucket_list_[__n], __n, bucket_count(), this);1314 return const_local_iterator(__bucket_list_[__n], __n, bucket_count(), this);
1326#else1315#else
1327 return const_local_iterator(__bucket_list_[__n], __n, bucket_count());1316 return const_local_iterator(__bucket_list_[__n], __n, bucket_count());
...@@ -1334,35 +1323,30 @@ public:...@@ -1334,35 +1323,30 @@ public:
1334 {1323 {
1335 _LIBCPP_ASSERT(__n < bucket_count(),1324 _LIBCPP_ASSERT(__n < bucket_count(),
1336 "unordered container::cend(n) called with n >= bucket_count()");1325 "unordered container::cend(n) called with n >= bucket_count()");
1337#if _LIBCPP_DEBUG_LEVEL >= 21326#if _LIBCPP_DEBUG_LEVEL == 2
1338 return const_local_iterator(nullptr, __n, bucket_count(), this);1327 return const_local_iterator(nullptr, __n, bucket_count(), this);
1339#else1328#else
1340 return const_local_iterator(nullptr, __n, bucket_count());1329 return const_local_iterator(nullptr, __n, bucket_count());
1341#endif1330#endif
1342 }1331 }
13431332
1344#if _LIBCPP_DEBUG_LEVEL >= 21333#if _LIBCPP_DEBUG_LEVEL == 2
13451334
1346 bool __dereferenceable(const const_iterator* __i) const;1335 bool __dereferenceable(const const_iterator* __i) const;
1347 bool __decrementable(const const_iterator* __i) const;1336 bool __decrementable(const const_iterator* __i) const;
1348 bool __addable(const const_iterator* __i, ptrdiff_t __n) const;1337 bool __addable(const const_iterator* __i, ptrdiff_t __n) const;
1349 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;1338 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;
13501339
1351#endif // _LIBCPP_DEBUG_LEVEL >= 21340#endif // _LIBCPP_DEBUG_LEVEL == 2
13521341
1353private:1342private:
1354 void __rehash(size_type __n);1343 void __rehash(size_type __n);
13551344
1356#ifndef _LIBCPP_CXX03_LANG
1357 template <class ..._Args>1345 template <class ..._Args>
1358 __node_holder __construct_node(_Args&& ...__args);1346 __node_holder __construct_node(_Args&& ...__args);
13591347
1360 template <class _First, class ..._Rest>1348 template <class _First, class ..._Rest>
1361 __node_holder __construct_node_hash(size_t __hash, _First&& __f, _Rest&&... __rest);1349 __node_holder __construct_node_hash(size_t __hash, _First&& __f, _Rest&&... __rest);
1362#else // _LIBCPP_CXX03_LANG
1363 __node_holder __construct_node(const __container_value_type& __v);
1364 __node_holder __construct_node_hash(size_t __hash, const __container_value_type& __v);
1365#endif
13661350
13671351
1368 _LIBCPP_INLINE_VISIBILITY1352 _LIBCPP_INLINE_VISIBILITY
...@@ -1373,7 +1357,6 @@ private:...@@ -1373,7 +1357,6 @@ private:
1373 _LIBCPP_INLINE_VISIBILITY1357 _LIBCPP_INLINE_VISIBILITY
1374 void __copy_assign_alloc(const __hash_table&, false_type) {}1358 void __copy_assign_alloc(const __hash_table&, false_type) {}
13751359
1376#ifndef _LIBCPP_CXX03_LANG
1377 void __move_assign(__hash_table& __u, false_type);1360 void __move_assign(__hash_table& __u, false_type);
1378 void __move_assign(__hash_table& __u, true_type)1361 void __move_assign(__hash_table& __u, true_type)
1379 _NOEXCEPT_(1362 _NOEXCEPT_(
...@@ -1400,7 +1383,6 @@ private:...@@ -1400,7 +1383,6 @@ private:
1400 }1383 }
1401 _LIBCPP_INLINE_VISIBILITY1384 _LIBCPP_INLINE_VISIBILITY
1402 void __move_assign_alloc(__hash_table&, false_type) _NOEXCEPT {}1385 void __move_assign_alloc(__hash_table&, false_type) _NOEXCEPT {}
1403#endif // _LIBCPP_CXX03_LANG
14041386
1405 void __deallocate_node(__next_pointer __np) _NOEXCEPT;1387 void __deallocate_node(__next_pointer __np) _NOEXCEPT;
1406 __next_pointer __detach() _NOEXCEPT;1388 __next_pointer __detach() _NOEXCEPT;
...@@ -1477,8 +1459,6 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u,...@@ -1477,8 +1459,6 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u,
1477{1459{
1478}1460}
14791461
1480#ifndef _LIBCPP_CXX03_LANG
1481
1482template <class _Tp, class _Hash, class _Equal, class _Alloc>1462template <class _Tp, class _Hash, class _Equal, class _Alloc>
1483__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u)1463__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u)
1484 _NOEXCEPT_(1464 _NOEXCEPT_(
...@@ -1526,8 +1506,6 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u,...@@ -1526,8 +1506,6 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u,
1526 }1506 }
1527}1507}
15281508
1529#endif // _LIBCPP_CXX03_LANG
1530
1531template <class _Tp, class _Hash, class _Equal, class _Alloc>1509template <class _Tp, class _Hash, class _Equal, class _Alloc>
1532__hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table()1510__hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table()
1533{1511{
...@@ -1539,7 +1517,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table()...@@ -1539,7 +1517,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table()
1539#endif1517#endif
15401518
1541 __deallocate_node(__p1_.first().__next_);1519 __deallocate_node(__p1_.first().__next_);
1542#if _LIBCPP_DEBUG_LEVEL >= 21520#if _LIBCPP_DEBUG_LEVEL == 2
1543 __get_db()->__erase_c(this);1521 __get_db()->__erase_c(this);
1544#endif1522#endif
1545}1523}
...@@ -1583,7 +1561,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__deallocate_node(__next_pointer __np)...@@ -1583,7 +1561,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__deallocate_node(__next_pointer __np)
1583 while (__np != nullptr)1561 while (__np != nullptr)
1584 {1562 {
1585 __next_pointer __next = __np->__next_;1563 __next_pointer __next = __np->__next_;
1586#if _LIBCPP_DEBUG_LEVEL >= 21564#if _LIBCPP_DEBUG_LEVEL == 2
1587 __c_node* __c = __get_db()->__find_c_and_lock(this);1565 __c_node* __c = __get_db()->__find_c_and_lock(this);
1588 for (__i_node** __p = __c->end_; __p != __c->beg_; )1566 for (__i_node** __p = __c->end_; __p != __c->beg_; )
1589 {1567 {
...@@ -1593,7 +1571,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__deallocate_node(__next_pointer __np)...@@ -1593,7 +1571,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__deallocate_node(__next_pointer __np)
1593 {1571 {
1594 (*__p)->__c_ = nullptr;1572 (*__p)->__c_ = nullptr;
1595 if (--__c->end_ != __p)1573 if (--__c->end_ != __p)
1596 memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));1574 _VSTD::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
1597 }1575 }
1598 }1576 }
1599 __get_db()->unlock();1577 __get_db()->unlock();
...@@ -1618,8 +1596,6 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__detach() _NOEXCEPT...@@ -1618,8 +1596,6 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__detach() _NOEXCEPT
1618 return __cache;1596 return __cache;
1619}1597}
16201598
1621#ifndef _LIBCPP_CXX03_LANG
1622
1623template <class _Tp, class _Hash, class _Equal, class _Alloc>1599template <class _Tp, class _Hash, class _Equal, class _Alloc>
1624void1600void
1625__hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(1601__hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(
...@@ -1646,7 +1622,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(...@@ -1646,7 +1622,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(
1646 __u.__p1_.first().__next_ = nullptr;1622 __u.__p1_.first().__next_ = nullptr;
1647 __u.size() = 0;1623 __u.size() = 0;
1648 }1624 }
1649#if _LIBCPP_DEBUG_LEVEL >= 21625#if _LIBCPP_DEBUG_LEVEL == 2
1650 __get_db()->swap(this, &__u);1626 __get_db()->swap(this, &__u);
1651#endif1627#endif
1652}1628}
...@@ -1714,8 +1690,6 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::operator=(__hash_table&& __u)...@@ -1714,8 +1690,6 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::operator=(__hash_table&& __u)
1714 return *this;1690 return *this;
1715}1691}
17161692
1717#endif // _LIBCPP_CXX03_LANG
1718
1719template <class _Tp, class _Hash, class _Equal, class _Alloc>1693template <class _Tp, class _Hash, class _Equal, class _Alloc>
1720template <class _InputIterator>1694template <class _InputIterator>
1721void1695void
...@@ -1800,7 +1774,7 @@ inline...@@ -1800,7 +1774,7 @@ inline
1800typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator1774typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
1801__hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() _NOEXCEPT1775__hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() _NOEXCEPT
1802{1776{
1803#if _LIBCPP_DEBUG_LEVEL >= 21777#if _LIBCPP_DEBUG_LEVEL == 2
1804 return iterator(__p1_.first().__next_, this);1778 return iterator(__p1_.first().__next_, this);
1805#else1779#else
1806 return iterator(__p1_.first().__next_);1780 return iterator(__p1_.first().__next_);
...@@ -1812,7 +1786,7 @@ inline...@@ -1812,7 +1786,7 @@ inline
1812typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator1786typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
1813__hash_table<_Tp, _Hash, _Equal, _Alloc>::end() _NOEXCEPT1787__hash_table<_Tp, _Hash, _Equal, _Alloc>::end() _NOEXCEPT
1814{1788{
1815#if _LIBCPP_DEBUG_LEVEL >= 21789#if _LIBCPP_DEBUG_LEVEL == 2
1816 return iterator(nullptr, this);1790 return iterator(nullptr, this);
1817#else1791#else
1818 return iterator(nullptr);1792 return iterator(nullptr);
...@@ -1824,7 +1798,7 @@ inline...@@ -1824,7 +1798,7 @@ inline
1824typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator1798typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator
1825__hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() const _NOEXCEPT1799__hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() const _NOEXCEPT
1826{1800{
1827#if _LIBCPP_DEBUG_LEVEL >= 21801#if _LIBCPP_DEBUG_LEVEL == 2
1828 return const_iterator(__p1_.first().__next_, this);1802 return const_iterator(__p1_.first().__next_, this);
1829#else1803#else
1830 return const_iterator(__p1_.first().__next_);1804 return const_iterator(__p1_.first().__next_);
...@@ -1836,7 +1810,7 @@ inline...@@ -1836,7 +1810,7 @@ inline
1836typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator1810typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator
1837__hash_table<_Tp, _Hash, _Equal, _Alloc>::end() const _NOEXCEPT1811__hash_table<_Tp, _Hash, _Equal, _Alloc>::end() const _NOEXCEPT
1838{1812{
1839#if _LIBCPP_DEBUG_LEVEL >= 21813#if _LIBCPP_DEBUG_LEVEL == 2
1840 return const_iterator(nullptr, this);1814 return const_iterator(nullptr, this);
1841#else1815#else
1842 return const_iterator(nullptr);1816 return const_iterator(nullptr);
...@@ -1945,7 +1919,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique(__node_pointer __...@@ -1945,7 +1919,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique(__node_pointer __
1945 __existing_node = __nd->__ptr();1919 __existing_node = __nd->__ptr();
1946 __inserted = true;1920 __inserted = true;
1947 }1921 }
1948#if _LIBCPP_DEBUG_LEVEL >= 21922#if _LIBCPP_DEBUG_LEVEL == 2
1949 return pair<iterator, bool>(iterator(__existing_node, this), __inserted);1923 return pair<iterator, bool>(iterator(__existing_node, this), __inserted);
1950#else1924#else
1951 return pair<iterator, bool>(iterator(__existing_node), __inserted);1925 return pair<iterator, bool>(iterator(__existing_node), __inserted);
...@@ -1955,7 +1929,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique(__node_pointer __...@@ -1955,7 +1929,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique(__node_pointer __
1955// Prepare the container for an insertion of the value __cp_val with the hash1929// Prepare the container for an insertion of the value __cp_val with the hash
1956// __cp_hash. This does a lookup into the container to see if __cp_value is1930// __cp_hash. This does a lookup into the container to see if __cp_value is
1957// already present, and performs a rehash if necessary. Returns a pointer to the1931// already present, and performs a rehash if necessary. Returns a pointer to the
1958// last occurance of __cp_val in the map.1932// last occurrence of __cp_val in the map.
1959//1933//
1960// Note that this function does forward exceptions if key_eq() throws, and never1934// Note that this function does forward exceptions if key_eq() throws, and never
1961// mutates __value or actually inserts into the map.1935// mutates __value or actually inserts into the map.
...@@ -2043,7 +2017,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(__node_pointer __c...@@ -2043,7 +2017,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(__node_pointer __c
2043 __next_pointer __pn = __node_insert_multi_prepare(__cp->__hash(), __cp->__value_);2017 __next_pointer __pn = __node_insert_multi_prepare(__cp->__hash(), __cp->__value_);
2044 __node_insert_multi_perform(__cp, __pn);2018 __node_insert_multi_perform(__cp, __pn);
20452019
2046#if _LIBCPP_DEBUG_LEVEL >= 22020#if _LIBCPP_DEBUG_LEVEL == 2
2047 return iterator(__cp->__ptr(), this);2021 return iterator(__cp->__ptr(), this);
2048#else2022#else
2049 return iterator(__cp->__ptr());2023 return iterator(__cp->__ptr());
...@@ -2055,7 +2029,7 @@ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator...@@ -2055,7 +2029,7 @@ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
2055__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(2029__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(
2056 const_iterator __p, __node_pointer __cp)2030 const_iterator __p, __node_pointer __cp)
2057{2031{
2058#if _LIBCPP_DEBUG_LEVEL >= 22032#if _LIBCPP_DEBUG_LEVEL == 2
2059 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,2033 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
2060 "unordered container::emplace_hint(const_iterator, args...) called with an iterator not"2034 "unordered container::emplace_hint(const_iterator, args...) called with an iterator not"
2061 " referring to this unordered container");2035 " referring to this unordered container");
...@@ -2078,7 +2052,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(...@@ -2078,7 +2052,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(
2078 __cp->__next_ = __np;2052 __cp->__next_ = __np;
2079 __pp->__next_ = static_cast<__next_pointer>(__cp);2053 __pp->__next_ = static_cast<__next_pointer>(__cp);
2080 ++size();2054 ++size();
2081#if _LIBCPP_DEBUG_LEVEL >= 22055#if _LIBCPP_DEBUG_LEVEL == 2
2082 return iterator(static_cast<__next_pointer>(__cp), this);2056 return iterator(static_cast<__next_pointer>(__cp), this);
2083#else2057#else
2084 return iterator(static_cast<__next_pointer>(__cp));2058 return iterator(static_cast<__next_pointer>(__cp));
...@@ -2089,17 +2063,10 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(...@@ -2089,17 +2063,10 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(
20892063
20902064
20912065
2092#ifndef _LIBCPP_CXX03_LANG
2093template <class _Tp, class _Hash, class _Equal, class _Alloc>2066template <class _Tp, class _Hash, class _Equal, class _Alloc>
2094template <class _Key, class ..._Args>2067template <class _Key, class ..._Args>
2095pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator, bool>2068pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator, bool>
2096__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const& __k, _Args&&... __args)2069__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const& __k, _Args&&... __args)
2097#else
2098template <class _Tp, class _Hash, class _Equal, class _Alloc>
2099template <class _Key, class _Args>
2100pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator, bool>
2101__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const& __k, _Args& __args)
2102#endif
2103{2070{
21042071
2105 size_t __hash = hash_function()(__k);2072 size_t __hash = hash_function()(__k);
...@@ -2123,11 +2090,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const&...@@ -2123,11 +2090,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const&
2123 }2090 }
2124 }2091 }
2125 {2092 {
2126#ifndef _LIBCPP_CXX03_LANG
2127 __node_holder __h = __construct_node_hash(__hash, _VSTD::forward<_Args>(__args)...);2093 __node_holder __h = __construct_node_hash(__hash, _VSTD::forward<_Args>(__args)...);
2128#else
2129 __node_holder __h = __construct_node_hash(__hash, __args);
2130#endif
2131 if (size()+1 > __bc * max_load_factor() || __bc == 0)2094 if (size()+1 > __bc * max_load_factor() || __bc == 0)
2132 {2095 {
2133 rehash(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),2096 rehash(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
...@@ -2159,15 +2122,13 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const&...@@ -2159,15 +2122,13 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const&
2159 __inserted = true;2122 __inserted = true;
2160 }2123 }
2161__done:2124__done:
2162#if _LIBCPP_DEBUG_LEVEL >= 22125#if _LIBCPP_DEBUG_LEVEL == 2
2163 return pair<iterator, bool>(iterator(__nd, this), __inserted);2126 return pair<iterator, bool>(iterator(__nd, this), __inserted);
2164#else2127#else
2165 return pair<iterator, bool>(iterator(__nd), __inserted);2128 return pair<iterator, bool>(iterator(__nd), __inserted);
2166#endif2129#endif
2167}2130}
21682131
2169#ifndef _LIBCPP_CXX03_LANG
2170
2171template <class _Tp, class _Hash, class _Equal, class _Alloc>2132template <class _Tp, class _Hash, class _Equal, class _Alloc>
2172template <class... _Args>2133template <class... _Args>
2173pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator, bool>2134pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator, bool>
...@@ -2197,7 +2158,7 @@ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator...@@ -2197,7 +2158,7 @@ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
2197__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_hint_multi(2158__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_hint_multi(
2198 const_iterator __p, _Args&&... __args)2159 const_iterator __p, _Args&&... __args)
2199{2160{
2200#if _LIBCPP_DEBUG_LEVEL >= 22161#if _LIBCPP_DEBUG_LEVEL == 2
2201 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,2162 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
2202 "unordered container::emplace_hint(const_iterator, args...) called with an iterator not"2163 "unordered container::emplace_hint(const_iterator, args...) called with an iterator not"
2203 " referring to this unordered container");2164 " referring to this unordered container");
...@@ -2208,36 +2169,6 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_hint_multi(...@@ -2208,36 +2169,6 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_hint_multi(
2208 return __r;2169 return __r;
2209}2170}
22102171
2211#else // _LIBCPP_CXX03_LANG
2212
2213template <class _Tp, class _Hash, class _Equal, class _Alloc>
2214typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
2215__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_multi(const __container_value_type& __x)
2216{
2217 __node_holder __h = __construct_node(__x);
2218 iterator __r = __node_insert_multi(__h.get());
2219 __h.release();
2220 return __r;
2221}
2222
2223template <class _Tp, class _Hash, class _Equal, class _Alloc>
2224typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
2225__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_multi(const_iterator __p,
2226 const __container_value_type& __x)
2227{
2228#if _LIBCPP_DEBUG_LEVEL >= 2
2229 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
2230 "unordered container::insert(const_iterator, lvalue) called with an iterator not"
2231 " referring to this unordered container");
2232#endif
2233 __node_holder __h = __construct_node(__x);
2234 iterator __r = __node_insert_multi(__p, __h.get());
2235 __h.release();
2236 return __r;
2237}
2238
2239#endif // _LIBCPP_CXX03_LANG
2240
2241#if _LIBCPP_STD_VER > 142172#if _LIBCPP_STD_VER > 14
2242template <class _Tp, class _Hash, class _Equal, class _Alloc>2173template <class _Tp, class _Hash, class _Equal, class _Alloc>
2243template <class _NodeHandle, class _InsertReturnType>2174template <class _NodeHandle, class _InsertReturnType>
...@@ -2399,9 +2330,9 @@ template <class _Tp, class _Hash, class _Equal, class _Alloc>...@@ -2399,9 +2330,9 @@ template <class _Tp, class _Hash, class _Equal, class _Alloc>
2399void2330void
2400__hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __nbc)2331__hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __nbc)
2401{2332{
2402#if _LIBCPP_DEBUG_LEVEL >= 22333#if _LIBCPP_DEBUG_LEVEL == 2
2403 __get_db()->__invalidate_all(this);2334 __get_db()->__invalidate_all(this);
2404#endif // _LIBCPP_DEBUG_LEVEL >= 22335#endif
2405 __pointer_allocator& __npa = __bucket_list_.get_deleter().__alloc();2336 __pointer_allocator& __npa = __bucket_list_.get_deleter().__alloc();
2406 __bucket_list_.reset(__nbc > 0 ?2337 __bucket_list_.reset(__nbc > 0 ?
2407 __pointer_alloc_traits::allocate(__npa, __nbc) : nullptr);2338 __pointer_alloc_traits::allocate(__npa, __nbc) : nullptr);
...@@ -2470,7 +2401,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k)...@@ -2470,7 +2401,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k)
2470 {2401 {
2471 if ((__nd->__hash() == __hash)2402 if ((__nd->__hash() == __hash)
2472 && key_eq()(__nd->__upcast()->__value_, __k))2403 && key_eq()(__nd->__upcast()->__value_, __k))
2473#if _LIBCPP_DEBUG_LEVEL >= 22404#if _LIBCPP_DEBUG_LEVEL == 2
2474 return iterator(__nd, this);2405 return iterator(__nd, this);
2475#else2406#else
2476 return iterator(__nd);2407 return iterator(__nd);
...@@ -2501,7 +2432,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) const...@@ -2501,7 +2432,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) const
2501 {2432 {
2502 if ((__nd->__hash() == __hash)2433 if ((__nd->__hash() == __hash)
2503 && key_eq()(__nd->__upcast()->__value_, __k))2434 && key_eq()(__nd->__upcast()->__value_, __k))
2504#if _LIBCPP_DEBUG_LEVEL >= 22435#if _LIBCPP_DEBUG_LEVEL == 2
2505 return const_iterator(__nd, this);2436 return const_iterator(__nd, this);
2506#else2437#else
2507 return const_iterator(__nd);2438 return const_iterator(__nd);
...@@ -2513,8 +2444,6 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) const...@@ -2513,8 +2444,6 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) const
2513 return end();2444 return end();
2514}2445}
25152446
2516#ifndef _LIBCPP_CXX03_LANG
2517
2518template <class _Tp, class _Hash, class _Equal, class _Alloc>2447template <class _Tp, class _Hash, class _Equal, class _Alloc>
2519template <class ..._Args>2448template <class ..._Args>
2520typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder2449typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder
...@@ -2550,43 +2479,12 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node_hash(...@@ -2550,43 +2479,12 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node_hash(
2550 return __h;2479 return __h;
2551}2480}
25522481
2553#else // _LIBCPP_CXX03_LANG
2554
2555template <class _Tp, class _Hash, class _Equal, class _Alloc>
2556typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder
2557__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(const __container_value_type& __v)
2558{
2559 __node_allocator& __na = __node_alloc();
2560 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
2561 __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), __v);
2562 __h.get_deleter().__value_constructed = true;
2563 __h->__hash_ = hash_function()(__h->__value_);
2564 __h->__next_ = nullptr;
2565 return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03
2566}
2567
2568template <class _Tp, class _Hash, class _Equal, class _Alloc>
2569typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder
2570__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node_hash(size_t __hash,
2571 const __container_value_type& __v)
2572{
2573 __node_allocator& __na = __node_alloc();
2574 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
2575 __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), __v);
2576 __h.get_deleter().__value_constructed = true;
2577 __h->__hash_ = __hash;
2578 __h->__next_ = nullptr;
2579 return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03
2580}
2581
2582#endif // _LIBCPP_CXX03_LANG
2583
2584template <class _Tp, class _Hash, class _Equal, class _Alloc>2482template <class _Tp, class _Hash, class _Equal, class _Alloc>
2585typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator2483typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
2586__hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __p)2484__hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __p)
2587{2485{
2588 __next_pointer __np = __p.__node_;2486 __next_pointer __np = __p.__node_;
2589#if _LIBCPP_DEBUG_LEVEL >= 22487#if _LIBCPP_DEBUG_LEVEL == 2
2590 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,2488 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
2591 "unordered container erase(iterator) called with an iterator not"2489 "unordered container erase(iterator) called with an iterator not"
2592 " referring to this container");2490 " referring to this container");
...@@ -2606,7 +2504,7 @@ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator...@@ -2606,7 +2504,7 @@ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
2606__hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __first,2504__hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __first,
2607 const_iterator __last)2505 const_iterator __last)
2608{2506{
2609#if _LIBCPP_DEBUG_LEVEL >= 22507#if _LIBCPP_DEBUG_LEVEL == 2
2610 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this,2508 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this,
2611 "unodered container::erase(iterator, iterator) called with an iterator not"2509 "unodered container::erase(iterator, iterator) called with an iterator not"
2612 " referring to this unodered container");2510 " referring to this unodered container");
...@@ -2620,7 +2518,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __first,...@@ -2620,7 +2518,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __first,
2620 erase(__p);2518 erase(__p);
2621 }2519 }
2622 __next_pointer __np = __last.__node_;2520 __next_pointer __np = __last.__node_;
2623#if _LIBCPP_DEBUG_LEVEL >= 22521#if _LIBCPP_DEBUG_LEVEL == 2
2624 return iterator (__np, this);2522 return iterator (__np, this);
2625#else2523#else
2626 return iterator (__np);2524 return iterator (__np);
...@@ -2691,7 +2589,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT...@@ -2691,7 +2589,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT
2691 __pn->__next_ = __cn->__next_;2589 __pn->__next_ = __cn->__next_;
2692 __cn->__next_ = nullptr;2590 __cn->__next_ = nullptr;
2693 --size();2591 --size();
2694#if _LIBCPP_DEBUG_LEVEL >= 22592#if _LIBCPP_DEBUG_LEVEL == 2
2695 __c_node* __c = __get_db()->__find_c_and_lock(this);2593 __c_node* __c = __get_db()->__find_c_and_lock(this);
2696 for (__i_node** __dp = __c->end_; __dp != __c->beg_; )2594 for (__i_node** __dp = __c->end_; __dp != __c->beg_; )
2697 {2595 {
...@@ -2701,7 +2599,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT...@@ -2701,7 +2599,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT
2701 {2599 {
2702 (*__dp)->__c_ = nullptr;2600 (*__dp)->__c_ = nullptr;
2703 if (--__c->end_ != __dp)2601 if (--__c->end_ != __dp)
2704 memmove(__dp, __dp+1, (__c->end_ - __dp)*sizeof(__i_node*));2602 _VSTD::memmove(__dp, __dp+1, (__c->end_ - __dp)*sizeof(__i_node*));
2705 }2603 }
2706 }2604 }
2707 __get_db()->unlock();2605 __get_db()->unlock();
...@@ -2830,9 +2728,9 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u)...@@ -2830,9 +2728,9 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u)
2830 __u.__bucket_list_.reset(__npp);2728 __u.__bucket_list_.reset(__npp);
2831 }2729 }
2832 _VSTD::swap(__bucket_list_.get_deleter().size(), __u.__bucket_list_.get_deleter().size());2730 _VSTD::swap(__bucket_list_.get_deleter().size(), __u.__bucket_list_.get_deleter().size());
2833 __swap_allocator(__bucket_list_.get_deleter().__alloc(),2731 _VSTD::__swap_allocator(__bucket_list_.get_deleter().__alloc(),
2834 __u.__bucket_list_.get_deleter().__alloc());2732 __u.__bucket_list_.get_deleter().__alloc());
2835 __swap_allocator(__node_alloc(), __u.__node_alloc());2733 _VSTD::__swap_allocator(__node_alloc(), __u.__node_alloc());
2836 _VSTD::swap(__p1_.first().__next_, __u.__p1_.first().__next_);2734 _VSTD::swap(__p1_.first().__next_, __u.__p1_.first().__next_);
2837 __p2_.swap(__u.__p2_);2735 __p2_.swap(__u.__p2_);
2838 __p3_.swap(__u.__p3_);2736 __p3_.swap(__u.__p3_);
...@@ -2842,7 +2740,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u)...@@ -2842,7 +2740,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u)
2842 if (__u.size() > 0)2740 if (__u.size() > 0)
2843 __u.__bucket_list_[__constrain_hash(__u.__p1_.first().__next_->__hash(), __u.bucket_count())] =2741 __u.__bucket_list_[__constrain_hash(__u.__p1_.first().__next_->__hash(), __u.bucket_count())] =
2844 __u.__p1_.first().__ptr();2742 __u.__p1_.first().__ptr();
2845#if _LIBCPP_DEBUG_LEVEL >= 22743#if _LIBCPP_DEBUG_LEVEL == 2
2846 __get_db()->swap(this, &__u);2744 __get_db()->swap(this, &__u);
2847#endif2745#endif
2848}2746}
...@@ -2876,7 +2774,7 @@ swap(__hash_table<_Tp, _Hash, _Equal, _Alloc>& __x,...@@ -2876,7 +2774,7 @@ swap(__hash_table<_Tp, _Hash, _Equal, _Alloc>& __x,
2876 __x.swap(__y);2774 __x.swap(__y);
2877}2775}
28782776
2879#if _LIBCPP_DEBUG_LEVEL >= 22777#if _LIBCPP_DEBUG_LEVEL == 2
28802778
2881template <class _Tp, class _Hash, class _Equal, class _Alloc>2779template <class _Tp, class _Hash, class _Equal, class _Alloc>
2882bool2780bool
...@@ -2906,7 +2804,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__subscriptable(const const_iterator*,...@@ -2906,7 +2804,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__subscriptable(const const_iterator*,
2906 return false;2804 return false;
2907}2805}
29082806
2909#endif // _LIBCPP_DEBUG_LEVEL >= 22807#endif // _LIBCPP_DEBUG_LEVEL == 2
29102808
2911_LIBCPP_END_NAMESPACE_STD2809_LIBCPP_END_NAMESPACE_STD
29122810
lib/libcxx/include/__libcpp_version+1-1
...@@ -1 +1 @@...@@ -1 +1 @@
111000112000
lib/libcxx/include/__locale+234-36
...@@ -11,6 +11,7 @@...@@ -11,6 +11,7 @@
11#define _LIBCPP___LOCALE11#define _LIBCPP___LOCALE
1212
13#include <__config>13#include <__config>
14#include <__availability>
14#include <string>15#include <string>
15#include <memory>16#include <memory>
16#include <utility>17#include <utility>
...@@ -21,7 +22,9 @@...@@ -21,7 +22,9 @@
21#if defined(_LIBCPP_MSVCRT_LIKE)22#if defined(_LIBCPP_MSVCRT_LIKE)
22# include <cstring>23# include <cstring>
23# include <support/win32/locale_win32.h>24# include <support/win32/locale_win32.h>
24#elif defined(_AIX)25#elif defined(__NuttX__)
26# include <support/nuttx/xlocale.h>
27#elif defined(_AIX) || defined(__MVS__)
25# include <support/ibm/xlocale.h>28# include <support/ibm/xlocale.h>
26#elif defined(__ANDROID__)29#elif defined(__ANDROID__)
27# include <support/android/locale_bionic.h>30# include <support/android/locale_bionic.h>
...@@ -76,7 +79,7 @@ struct __libcpp_locale_guard {...@@ -76,7 +79,7 @@ struct __libcpp_locale_guard {
76 // locale name, otherwise it will be a semicolon-separated string listing79 // locale name, otherwise it will be a semicolon-separated string listing
77 // each category. In the second case, we know at least one category won't80 // each category. In the second case, we know at least one category won't
78 // be what we want, so we only have to check the first case.81 // be what we want, so we only have to check the first case.
79 if (strcmp(__l.__get_locale(), __lc) != 0) {82 if (_VSTD::strcmp(__l.__get_locale(), __lc) != 0) {
80 __locale_all = _strdup(__lc);83 __locale_all = _strdup(__lc);
81 if (__locale_all == nullptr)84 if (__locale_all == nullptr)
82 __throw_bad_alloc();85 __throw_bad_alloc();
...@@ -105,7 +108,6 @@ struct __libcpp_locale_guard {...@@ -105,7 +108,6 @@ struct __libcpp_locale_guard {
105};108};
106#endif109#endif
107110
108
109class _LIBCPP_TYPE_VIS locale;111class _LIBCPP_TYPE_VIS locale;
110112
111template <class _Facet>113template <class _Facet>
...@@ -335,8 +337,8 @@ collate<_CharT>::do_hash(const char_type* __lo, const char_type* __hi) const...@@ -335,8 +337,8 @@ collate<_CharT>::do_hash(const char_type* __lo, const char_type* __hi) const
335 return static_cast<long>(__h);337 return static_cast<long>(__h);
336}338}
337339
338_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<char>)340_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<char>)
339_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<wchar_t>)341_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<wchar_t>)
340342
341// template <class CharT> class collate_byname;343// template <class CharT> class collate_byname;
342344
...@@ -396,7 +398,26 @@ locale::operator()(const basic_string<_CharT, _Traits, _Allocator>& __x,...@@ -396,7 +398,26 @@ locale::operator()(const basic_string<_CharT, _Traits, _Allocator>& __x,
396class _LIBCPP_TYPE_VIS ctype_base398class _LIBCPP_TYPE_VIS ctype_base
397{399{
398public:400public:
399#if defined(__GLIBC__)401#if defined(_LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE)
402 typedef unsigned long mask;
403 static const mask space = 1<<0;
404 static const mask print = 1<<1;
405 static const mask cntrl = 1<<2;
406 static const mask upper = 1<<3;
407 static const mask lower = 1<<4;
408 static const mask alpha = 1<<5;
409 static const mask digit = 1<<6;
410 static const mask punct = 1<<7;
411 static const mask xdigit = 1<<8;
412 static const mask blank = 1<<9;
413#if defined(__BIONIC__)
414 // Historically this was a part of regex_traits rather than ctype_base. The
415 // historical value of the constant is preserved for ABI compatibility.
416 static const mask __regex_word = 0x8000;
417#else
418 static const mask __regex_word = 1<<10;
419#endif // defined(__BIONIC__)
420#elif defined(__GLIBC__)
400 typedef unsigned short mask;421 typedef unsigned short mask;
401 static const mask space = _ISspace;422 static const mask space = _ISspace;
402 static const mask print = _ISprint;423 static const mask print = _ISprint;
...@@ -485,24 +506,7 @@ public:...@@ -485,24 +506,7 @@ public:
485# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA506# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA
486# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT507# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT
487#else508#else
488 typedef unsigned long mask;509# error unknown rune table for this platform -- do you mean to define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE?
489 static const mask space = 1<<0;
490 static const mask print = 1<<1;
491 static const mask cntrl = 1<<2;
492 static const mask upper = 1<<3;
493 static const mask lower = 1<<4;
494 static const mask alpha = 1<<5;
495 static const mask digit = 1<<6;
496 static const mask punct = 1<<7;
497 static const mask xdigit = 1<<8;
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
504 static const mask __regex_word = 1<<10;
505#endif // defined(__BIONIC__)
506#endif510#endif
507 static const mask alnum = alpha | digit;511 static const mask alnum = alpha | digit;
508 static const mask graph = alnum | punct;512 static const mask graph = alnum | punct;
...@@ -623,7 +627,7 @@ class _LIBCPP_TYPE_VIS ctype<char>...@@ -623,7 +627,7 @@ class _LIBCPP_TYPE_VIS ctype<char>
623public:627public:
624 typedef char char_type;628 typedef char char_type;
625629
626 explicit ctype(const mask* __tab = 0, bool __del = false, size_t __refs = 0);630 explicit ctype(const mask* __tab = nullptr, bool __del = false, size_t __refs = 0);
627631
628 _LIBCPP_INLINE_VISIBILITY632 _LIBCPP_INLINE_VISIBILITY
629 bool is(mask __m, char_type __c) const633 bool is(mask __m, char_type __c) const
...@@ -1069,10 +1073,10 @@ protected:...@@ -1069,10 +1073,10 @@ protected:
1069 virtual int do_max_length() const _NOEXCEPT;1073 virtual int do_max_length() const _NOEXCEPT;
1070};1074};
10711075
1072// template <> class codecvt<char16_t, char, mbstate_t>1076// template <> class codecvt<char16_t, char, mbstate_t> // deprecated in C++20
10731077
1074template <>1078template <>
1075class _LIBCPP_TYPE_VIS codecvt<char16_t, char, mbstate_t>1079class _LIBCPP_TYPE_VIS _LIBCPP_DEPRECATED_IN_CXX20 codecvt<char16_t, char, mbstate_t>
1076 : public locale::facet,1080 : public locale::facet,
1077 public codecvt_base1081 public codecvt_base
1078{1082{
...@@ -1155,10 +1159,100 @@ protected:...@@ -1155,10 +1159,100 @@ protected:
1155 virtual int do_max_length() const _NOEXCEPT;1159 virtual int do_max_length() const _NOEXCEPT;
1156};1160};
11571161
1158// template <> class codecvt<char32_t, char, mbstate_t>1162#ifndef _LIBCPP_NO_HAS_CHAR8_T
1163
1164// template <> class codecvt<char16_t, char8_t, mbstate_t> // C++20
11591165
1160template <>1166template <>
1161class _LIBCPP_TYPE_VIS codecvt<char32_t, char, mbstate_t>1167class _LIBCPP_TYPE_VIS codecvt<char16_t, char8_t, mbstate_t>
1168 : public locale::facet,
1169 public codecvt_base
1170{
1171public:
1172 typedef char16_t intern_type;
1173 typedef char8_t extern_type;
1174 typedef mbstate_t state_type;
1175
1176 _LIBCPP_INLINE_VISIBILITY
1177 explicit codecvt(size_t __refs = 0)
1178 : locale::facet(__refs) {}
1179
1180 _LIBCPP_INLINE_VISIBILITY
1181 result out(state_type& __st,
1182 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
1183 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
1184 {
1185 return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
1186 }
1187
1188 _LIBCPP_INLINE_VISIBILITY
1189 result unshift(state_type& __st,
1190 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
1191 {
1192 return do_unshift(__st, __to, __to_end, __to_nxt);
1193 }
1194
1195 _LIBCPP_INLINE_VISIBILITY
1196 result in(state_type& __st,
1197 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
1198 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
1199 {
1200 return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
1201 }
1202
1203 _LIBCPP_INLINE_VISIBILITY
1204 int encoding() const _NOEXCEPT
1205 {
1206 return do_encoding();
1207 }
1208
1209 _LIBCPP_INLINE_VISIBILITY
1210 bool always_noconv() const _NOEXCEPT
1211 {
1212 return do_always_noconv();
1213 }
1214
1215 _LIBCPP_INLINE_VISIBILITY
1216 int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
1217 {
1218 return do_length(__st, __frm, __end, __mx);
1219 }
1220
1221 _LIBCPP_INLINE_VISIBILITY
1222 int max_length() const _NOEXCEPT
1223 {
1224 return do_max_length();
1225 }
1226
1227 static locale::id id;
1228
1229protected:
1230 _LIBCPP_INLINE_VISIBILITY
1231 explicit codecvt(const char*, size_t __refs = 0)
1232 : locale::facet(__refs) {}
1233
1234 ~codecvt();
1235
1236 virtual result do_out(state_type& __st,
1237 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
1238 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
1239 virtual result do_in(state_type& __st,
1240 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
1241 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
1242 virtual result do_unshift(state_type& __st,
1243 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
1244 virtual int do_encoding() const _NOEXCEPT;
1245 virtual bool do_always_noconv() const _NOEXCEPT;
1246 virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
1247 virtual int do_max_length() const _NOEXCEPT;
1248};
1249
1250#endif
1251
1252// template <> class codecvt<char32_t, char, mbstate_t> // deprecated in C++20
1253
1254template <>
1255class _LIBCPP_TYPE_VIS _LIBCPP_DEPRECATED_IN_CXX20 codecvt<char32_t, char, mbstate_t>
1162 : public locale::facet,1256 : public locale::facet,
1163 public codecvt_base1257 public codecvt_base
1164{1258{
...@@ -1241,6 +1335,96 @@ protected:...@@ -1241,6 +1335,96 @@ protected:
1241 virtual int do_max_length() const _NOEXCEPT;1335 virtual int do_max_length() const _NOEXCEPT;
1242};1336};
12431337
1338#ifndef _LIBCPP_NO_HAS_CHAR8_T
1339
1340// template <> class codecvt<char32_t, char8_t, mbstate_t> // C++20
1341
1342template <>
1343class _LIBCPP_TYPE_VIS codecvt<char32_t, char8_t, mbstate_t>
1344 : public locale::facet,
1345 public codecvt_base
1346{
1347public:
1348 typedef char32_t intern_type;
1349 typedef char8_t extern_type;
1350 typedef mbstate_t state_type;
1351
1352 _LIBCPP_INLINE_VISIBILITY
1353 explicit codecvt(size_t __refs = 0)
1354 : locale::facet(__refs) {}
1355
1356 _LIBCPP_INLINE_VISIBILITY
1357 result out(state_type& __st,
1358 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
1359 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
1360 {
1361 return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
1362 }
1363
1364 _LIBCPP_INLINE_VISIBILITY
1365 result unshift(state_type& __st,
1366 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
1367 {
1368 return do_unshift(__st, __to, __to_end, __to_nxt);
1369 }
1370
1371 _LIBCPP_INLINE_VISIBILITY
1372 result in(state_type& __st,
1373 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
1374 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
1375 {
1376 return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
1377 }
1378
1379 _LIBCPP_INLINE_VISIBILITY
1380 int encoding() const _NOEXCEPT
1381 {
1382 return do_encoding();
1383 }
1384
1385 _LIBCPP_INLINE_VISIBILITY
1386 bool always_noconv() const _NOEXCEPT
1387 {
1388 return do_always_noconv();
1389 }
1390
1391 _LIBCPP_INLINE_VISIBILITY
1392 int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
1393 {
1394 return do_length(__st, __frm, __end, __mx);
1395 }
1396
1397 _LIBCPP_INLINE_VISIBILITY
1398 int max_length() const _NOEXCEPT
1399 {
1400 return do_max_length();
1401 }
1402
1403 static locale::id id;
1404
1405protected:
1406 _LIBCPP_INLINE_VISIBILITY
1407 explicit codecvt(const char*, size_t __refs = 0)
1408 : locale::facet(__refs) {}
1409
1410 ~codecvt();
1411
1412 virtual result do_out(state_type& __st,
1413 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
1414 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
1415 virtual result do_in(state_type& __st,
1416 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
1417 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
1418 virtual result do_unshift(state_type& __st,
1419 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
1420 virtual int do_encoding() const _NOEXCEPT;
1421 virtual bool do_always_noconv() const _NOEXCEPT;
1422 virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
1423 virtual int do_max_length() const _NOEXCEPT;
1424};
1425
1426#endif
1427
1244// template <class _InternT, class _ExternT, class _StateT> class codecvt_byname1428// template <class _InternT, class _ExternT, class _StateT> class codecvt_byname
12451429
1246template <class _InternT, class _ExternT, class _StateT>1430template <class _InternT, class _ExternT, class _StateT>
...@@ -1258,15 +1442,21 @@ protected:...@@ -1258,15 +1442,21 @@ protected:
1258 ~codecvt_byname();1442 ~codecvt_byname();
1259};1443};
12601444
1445_LIBCPP_SUPPRESS_DEPRECATED_PUSH
1261template <class _InternT, class _ExternT, class _StateT>1446template <class _InternT, class _ExternT, class _StateT>
1262codecvt_byname<_InternT, _ExternT, _StateT>::~codecvt_byname()1447codecvt_byname<_InternT, _ExternT, _StateT>::~codecvt_byname()
1263{1448{
1264}1449}
12651450_LIBCPP_SUPPRESS_DEPRECATED_POP
1266_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char, char, mbstate_t>)1451
1267_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>)1452_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char, char, mbstate_t>)
1268_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>)1453_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>)
1269_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>)1454_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DEPRECATED_IN_CXX20 codecvt_byname<char16_t, char, mbstate_t>) // deprecated in C++20
1455_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DEPRECATED_IN_CXX20 codecvt_byname<char32_t, char, mbstate_t>) // deprecated in C++20
1456#ifndef _LIBCPP_NO_HAS_CHAR8_T
1457_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char8_t, mbstate_t>) // C++20
1458_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char8_t, mbstate_t>) // C++20
1459#endif
12701460
1271template <size_t _Np>1461template <size_t _Np>
1272struct __narrow_to_utf81462struct __narrow_to_utf8
...@@ -1290,12 +1480,14 @@ struct __narrow_to_utf8<8>...@@ -1290,12 +1480,14 @@ struct __narrow_to_utf8<8>
1290 }1480 }
1291};1481};
12921482
1483_LIBCPP_SUPPRESS_DEPRECATED_PUSH
1293template <>1484template <>
1294struct _LIBCPP_TEMPLATE_VIS __narrow_to_utf8<16>1485struct _LIBCPP_TEMPLATE_VIS __narrow_to_utf8<16>
1295 : public codecvt<char16_t, char, mbstate_t>1486 : public codecvt<char16_t, char, mbstate_t>
1296{1487{
1297 _LIBCPP_INLINE_VISIBILITY1488 _LIBCPP_INLINE_VISIBILITY
1298 __narrow_to_utf8() : codecvt<char16_t, char, mbstate_t>(1) {}1489 __narrow_to_utf8() : codecvt<char16_t, char, mbstate_t>(1) {}
1490_LIBCPP_SUPPRESS_DEPRECATED_POP
12991491
1300 _LIBCPP_EXPORTED_FROM_ABI ~__narrow_to_utf8();1492 _LIBCPP_EXPORTED_FROM_ABI ~__narrow_to_utf8();
13011493
...@@ -1324,12 +1516,14 @@ struct _LIBCPP_TEMPLATE_VIS __narrow_to_utf8<16>...@@ -1324,12 +1516,14 @@ struct _LIBCPP_TEMPLATE_VIS __narrow_to_utf8<16>
1324 }1516 }
1325};1517};
13261518
1519_LIBCPP_SUPPRESS_DEPRECATED_PUSH
1327template <>1520template <>
1328struct _LIBCPP_TEMPLATE_VIS __narrow_to_utf8<32>1521struct _LIBCPP_TEMPLATE_VIS __narrow_to_utf8<32>
1329 : public codecvt<char32_t, char, mbstate_t>1522 : public codecvt<char32_t, char, mbstate_t>
1330{1523{
1331 _LIBCPP_INLINE_VISIBILITY1524 _LIBCPP_INLINE_VISIBILITY
1332 __narrow_to_utf8() : codecvt<char32_t, char, mbstate_t>(1) {}1525 __narrow_to_utf8() : codecvt<char32_t, char, mbstate_t>(1) {}
1526_LIBCPP_SUPPRESS_DEPRECATED_POP
13331527
1334 _LIBCPP_EXPORTED_FROM_ABI ~__narrow_to_utf8();1528 _LIBCPP_EXPORTED_FROM_ABI ~__narrow_to_utf8();
13351529
...@@ -1380,12 +1574,14 @@ struct __widen_from_utf8<8>...@@ -1380,12 +1574,14 @@ struct __widen_from_utf8<8>
1380 }1574 }
1381};1575};
13821576
1577_LIBCPP_SUPPRESS_DEPRECATED_PUSH
1383template <>1578template <>
1384struct _LIBCPP_TEMPLATE_VIS __widen_from_utf8<16>1579struct _LIBCPP_TEMPLATE_VIS __widen_from_utf8<16>
1385 : public codecvt<char16_t, char, mbstate_t>1580 : public codecvt<char16_t, char, mbstate_t>
1386{1581{
1387 _LIBCPP_INLINE_VISIBILITY1582 _LIBCPP_INLINE_VISIBILITY
1388 __widen_from_utf8() : codecvt<char16_t, char, mbstate_t>(1) {}1583 __widen_from_utf8() : codecvt<char16_t, char, mbstate_t>(1) {}
1584_LIBCPP_SUPPRESS_DEPRECATED_POP
13891585
1390 _LIBCPP_EXPORTED_FROM_ABI ~__widen_from_utf8();1586 _LIBCPP_EXPORTED_FROM_ABI ~__widen_from_utf8();
13911587
...@@ -1407,19 +1603,21 @@ struct _LIBCPP_TEMPLATE_VIS __widen_from_utf8<16>...@@ -1407,19 +1603,21 @@ struct _LIBCPP_TEMPLATE_VIS __widen_from_utf8<16>
1407 if (__r == codecvt_base::error || __nn == __nb)1603 if (__r == codecvt_base::error || __nn == __nb)
1408 __throw_runtime_error("locale not supported");1604 __throw_runtime_error("locale not supported");
1409 for (const char16_t* __p = __buf; __p < __bn; ++__p, ++__s)1605 for (const char16_t* __p = __buf; __p < __bn; ++__p, ++__s)
1410 *__s = (wchar_t)*__p;1606 *__s = *__p;
1411 __nb = __nn;1607 __nb = __nn;
1412 }1608 }
1413 return __s;1609 return __s;
1414 }1610 }
1415};1611};
14161612
1613_LIBCPP_SUPPRESS_DEPRECATED_PUSH
1417template <>1614template <>
1418struct _LIBCPP_TEMPLATE_VIS __widen_from_utf8<32>1615struct _LIBCPP_TEMPLATE_VIS __widen_from_utf8<32>
1419 : public codecvt<char32_t, char, mbstate_t>1616 : public codecvt<char32_t, char, mbstate_t>
1420{1617{
1421 _LIBCPP_INLINE_VISIBILITY1618 _LIBCPP_INLINE_VISIBILITY
1422 __widen_from_utf8() : codecvt<char32_t, char, mbstate_t>(1) {}1619 __widen_from_utf8() : codecvt<char32_t, char, mbstate_t>(1) {}
1620_LIBCPP_SUPPRESS_DEPRECATED_POP
14231621
1424 _LIBCPP_EXPORTED_FROM_ABI ~__widen_from_utf8();1622 _LIBCPP_EXPORTED_FROM_ABI ~__widen_from_utf8();
14251623
...@@ -1441,7 +1639,7 @@ struct _LIBCPP_TEMPLATE_VIS __widen_from_utf8<32>...@@ -1441,7 +1639,7 @@ struct _LIBCPP_TEMPLATE_VIS __widen_from_utf8<32>
1441 if (__r == codecvt_base::error || __nn == __nb)1639 if (__r == codecvt_base::error || __nn == __nb)
1442 __throw_runtime_error("locale not supported");1640 __throw_runtime_error("locale not supported");
1443 for (const char32_t* __p = __buf; __p < __bn; ++__p, ++__s)1641 for (const char32_t* __p = __buf; __p < __bn; ++__p, ++__s)
1444 *__s = (wchar_t)*__p;1642 *__s = *__p;
1445 __nb = __nn;1643 __nb = __nn;
1446 }1644 }
1447 return __s;1645 return __s;
lib/libcxx/include/__memory/allocator_traits.h created+589
...@@ -0,0 +1,589 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___MEMORY_ALLOCATOR_TRAITS_H
11#define _LIBCPP___MEMORY_ALLOCATOR_TRAITS_H
12
13#include <__config>
14#include <__memory/base.h>
15#include <__memory/pointer_traits.h>
16#include <type_traits>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#pragma GCC system_header
20#endif
21
22_LIBCPP_PUSH_MACROS
23#include <__undef_macros>
24
25_LIBCPP_BEGIN_NAMESPACE_STD
26
27template <class _Tp, class = void>
28struct __has_pointer_type : false_type {};
29
30template <class _Tp>
31struct __has_pointer_type<_Tp,
32 typename __void_t<typename _Tp::pointer>::type> : true_type {};
33
34namespace __pointer_type_imp
35{
36
37template <class _Tp, class _Dp, bool = __has_pointer_type<_Dp>::value>
38struct __pointer_type
39{
40 typedef _LIBCPP_NODEBUG_TYPE typename _Dp::pointer type;
41};
42
43template <class _Tp, class _Dp>
44struct __pointer_type<_Tp, _Dp, false>
45{
46 typedef _LIBCPP_NODEBUG_TYPE _Tp* type;
47};
48
49} // __pointer_type_imp
50
51template <class _Tp, class _Dp>
52struct __pointer_type
53{
54 typedef _LIBCPP_NODEBUG_TYPE typename __pointer_type_imp::__pointer_type<_Tp, typename remove_reference<_Dp>::type>::type type;
55};
56
57template <class _Tp, class = void>
58struct __has_const_pointer : false_type {};
59
60template <class _Tp>
61struct __has_const_pointer<_Tp,
62 typename __void_t<typename _Tp::const_pointer>::type> : true_type {};
63
64template <class _Tp, class _Ptr, class _Alloc, bool = __has_const_pointer<_Alloc>::value>
65struct __const_pointer
66{
67 typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::const_pointer type;
68};
69
70template <class _Tp, class _Ptr, class _Alloc>
71struct __const_pointer<_Tp, _Ptr, _Alloc, false>
72{
73#ifndef _LIBCPP_CXX03_LANG
74 typedef _LIBCPP_NODEBUG_TYPE typename pointer_traits<_Ptr>::template rebind<const _Tp> type;
75#else
76 typedef typename pointer_traits<_Ptr>::template rebind<const _Tp>::other type;
77#endif
78};
79
80template <class _Tp, class = void>
81struct __has_void_pointer : false_type {};
82
83template <class _Tp>
84struct __has_void_pointer<_Tp,
85 typename __void_t<typename _Tp::void_pointer>::type> : true_type {};
86
87template <class _Ptr, class _Alloc, bool = __has_void_pointer<_Alloc>::value>
88struct __void_pointer
89{
90 typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::void_pointer type;
91};
92
93template <class _Ptr, class _Alloc>
94struct __void_pointer<_Ptr, _Alloc, false>
95{
96#ifndef _LIBCPP_CXX03_LANG
97 typedef _LIBCPP_NODEBUG_TYPE typename pointer_traits<_Ptr>::template rebind<void> type;
98#else
99 typedef _LIBCPP_NODEBUG_TYPE typename pointer_traits<_Ptr>::template rebind<void>::other type;
100#endif
101};
102
103template <class _Tp, class = void>
104struct __has_const_void_pointer : false_type {};
105
106template <class _Tp>
107struct __has_const_void_pointer<_Tp,
108 typename __void_t<typename _Tp::const_void_pointer>::type> : true_type {};
109
110template <class _Ptr, class _Alloc, bool = __has_const_void_pointer<_Alloc>::value>
111struct __const_void_pointer
112{
113 typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::const_void_pointer type;
114};
115
116template <class _Ptr, class _Alloc>
117struct __const_void_pointer<_Ptr, _Alloc, false>
118{
119#ifndef _LIBCPP_CXX03_LANG
120 typedef _LIBCPP_NODEBUG_TYPE typename pointer_traits<_Ptr>::template rebind<const void> type;
121#else
122 typedef _LIBCPP_NODEBUG_TYPE typename pointer_traits<_Ptr>::template rebind<const void>::other type;
123#endif
124};
125
126template <class _Tp, class = void>
127struct __has_size_type : false_type {};
128
129template <class _Tp>
130struct __has_size_type<_Tp,
131 typename __void_t<typename _Tp::size_type>::type> : true_type {};
132
133template <class _Alloc, class _DiffType, bool = __has_size_type<_Alloc>::value>
134struct __size_type
135{
136 typedef _LIBCPP_NODEBUG_TYPE typename make_unsigned<_DiffType>::type type;
137};
138
139template <class _Alloc, class _DiffType>
140struct __size_type<_Alloc, _DiffType, true>
141{
142 typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::size_type type;
143};
144
145template <class _Tp, class = void>
146struct __has_propagate_on_container_copy_assignment : false_type {};
147
148template <class _Tp>
149struct __has_propagate_on_container_copy_assignment<_Tp,
150 typename __void_t<typename _Tp::propagate_on_container_copy_assignment>::type>
151 : true_type {};
152
153template <class _Alloc, bool = __has_propagate_on_container_copy_assignment<_Alloc>::value>
154struct __propagate_on_container_copy_assignment
155{
156 typedef _LIBCPP_NODEBUG_TYPE false_type type;
157};
158
159template <class _Alloc>
160struct __propagate_on_container_copy_assignment<_Alloc, true>
161{
162 typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::propagate_on_container_copy_assignment type;
163};
164
165template <class _Tp, class = void>
166struct __has_propagate_on_container_move_assignment : false_type {};
167
168template <class _Tp>
169struct __has_propagate_on_container_move_assignment<_Tp,
170 typename __void_t<typename _Tp::propagate_on_container_move_assignment>::type>
171 : true_type {};
172
173template <class _Alloc, bool = __has_propagate_on_container_move_assignment<_Alloc>::value>
174struct __propagate_on_container_move_assignment
175{
176 typedef false_type type;
177};
178
179template <class _Alloc>
180struct __propagate_on_container_move_assignment<_Alloc, true>
181{
182 typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::propagate_on_container_move_assignment type;
183};
184
185template <class _Tp, class = void>
186struct __has_propagate_on_container_swap : false_type {};
187
188template <class _Tp>
189struct __has_propagate_on_container_swap<_Tp,
190 typename __void_t<typename _Tp::propagate_on_container_swap>::type>
191 : true_type {};
192
193template <class _Alloc, bool = __has_propagate_on_container_swap<_Alloc>::value>
194struct __propagate_on_container_swap
195{
196 typedef false_type type;
197};
198
199template <class _Alloc>
200struct __propagate_on_container_swap<_Alloc, true>
201{
202 typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::propagate_on_container_swap type;
203};
204
205template <class _Tp, class = void>
206struct __has_is_always_equal : false_type {};
207
208template <class _Tp>
209struct __has_is_always_equal<_Tp,
210 typename __void_t<typename _Tp::is_always_equal>::type>
211 : true_type {};
212
213template <class _Alloc, bool = __has_is_always_equal<_Alloc>::value>
214struct __is_always_equal
215{
216 typedef _LIBCPP_NODEBUG_TYPE typename _VSTD::is_empty<_Alloc>::type type;
217};
218
219template <class _Alloc>
220struct __is_always_equal<_Alloc, true>
221{
222 typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::is_always_equal type;
223};
224
225template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value>
226struct __has_rebind_other
227{
228private:
229 struct __two {char __lx; char __lxx;};
230 template <class _Xp> static __two __test(...);
231 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
232 template <class _Xp> static char __test(typename _Xp::template rebind<_Up>::other* = 0);
233 _LIBCPP_SUPPRESS_DEPRECATED_POP
234public:
235 static const bool value = sizeof(__test<_Tp>(0)) == 1;
236};
237
238template <class _Tp, class _Up>
239struct __has_rebind_other<_Tp, _Up, false>
240{
241 static const bool value = false;
242};
243
244template <class _Tp, class _Up, bool = __has_rebind_other<_Tp, _Up>::value>
245struct __allocator_traits_rebind
246{
247 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
248 typedef _LIBCPP_NODEBUG_TYPE typename _Tp::template rebind<_Up>::other type;
249 _LIBCPP_SUPPRESS_DEPRECATED_POP
250};
251
252template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up>
253struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, true>
254{
255 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
256 typedef _LIBCPP_NODEBUG_TYPE typename _Alloc<_Tp, _Args...>::template rebind<_Up>::other type;
257 _LIBCPP_SUPPRESS_DEPRECATED_POP
258};
259
260template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up>
261struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, false>
262{
263 typedef _LIBCPP_NODEBUG_TYPE _Alloc<_Up, _Args...> type;
264};
265
266#ifndef _LIBCPP_CXX03_LANG
267
268_LIBCPP_SUPPRESS_DEPRECATED_PUSH
269template <class _Alloc, class _SizeType, class _ConstVoidPtr>
270auto
271__has_allocate_hint_test(_Alloc&& __a, _SizeType&& __sz, _ConstVoidPtr&& __p)
272 -> decltype((void)__a.allocate(__sz, __p), true_type());
273_LIBCPP_SUPPRESS_DEPRECATED_POP
274
275template <class _Alloc, class _SizeType, class _ConstVoidPtr>
276auto
277__has_allocate_hint_test(const _Alloc& __a, _SizeType&& __sz, _ConstVoidPtr&& __p)
278 -> false_type;
279
280template <class _Alloc, class _SizeType, class _ConstVoidPtr>
281struct __has_allocate_hint
282 : decltype(_VSTD::__has_allocate_hint_test(declval<_Alloc>(),
283 declval<_SizeType>(),
284 declval<_ConstVoidPtr>()))
285{
286};
287
288#else // _LIBCPP_CXX03_LANG
289
290template <class _Alloc, class _SizeType, class _ConstVoidPtr>
291struct __has_allocate_hint
292 : true_type
293{
294};
295
296#endif // _LIBCPP_CXX03_LANG
297
298_LIBCPP_SUPPRESS_DEPRECATED_PUSH
299template <class _Alloc, class ..._Args,
300 class = decltype(_VSTD::declval<_Alloc>().construct(_VSTD::declval<_Args>()...))>
301static true_type __test_has_construct(int);
302_LIBCPP_SUPPRESS_DEPRECATED_POP
303
304template <class _Alloc, class...>
305static false_type __test_has_construct(...);
306
307template <class _Alloc, class ..._Args>
308struct __has_construct : decltype(__test_has_construct<_Alloc, _Args...>(0)) {};
309
310#if !defined(_LIBCPP_CXX03_LANG)
311
312_LIBCPP_SUPPRESS_DEPRECATED_PUSH
313template <class _Alloc, class _Pointer>
314auto
315__has_destroy_test(_Alloc&& __a, _Pointer&& __p)
316 -> decltype(__a.destroy(__p), true_type());
317_LIBCPP_SUPPRESS_DEPRECATED_POP
318
319template <class _Alloc, class _Pointer>
320auto
321__has_destroy_test(const _Alloc& __a, _Pointer&& __p)
322 -> false_type;
323
324template <class _Alloc, class _Pointer>
325struct __has_destroy
326 : decltype(_VSTD::__has_destroy_test(declval<_Alloc>(),
327 declval<_Pointer>()))
328{
329};
330
331_LIBCPP_SUPPRESS_DEPRECATED_PUSH
332template <class _Alloc>
333auto
334__has_max_size_test(_Alloc&& __a)
335 -> decltype(__a.max_size(), true_type());
336_LIBCPP_SUPPRESS_DEPRECATED_POP
337
338template <class _Alloc>
339auto
340__has_max_size_test(const volatile _Alloc& __a)
341 -> false_type;
342
343template <class _Alloc>
344struct __has_max_size
345 : decltype(_VSTD::__has_max_size_test(declval<_Alloc&>()))
346{
347};
348
349template <class _Alloc>
350auto
351__has_select_on_container_copy_construction_test(_Alloc&& __a)
352 -> decltype(__a.select_on_container_copy_construction(), true_type());
353
354template <class _Alloc>
355auto
356__has_select_on_container_copy_construction_test(const volatile _Alloc& __a)
357 -> false_type;
358
359template <class _Alloc>
360struct __has_select_on_container_copy_construction
361 : decltype(_VSTD::__has_select_on_container_copy_construction_test(declval<_Alloc&>()))
362{
363};
364
365#else // _LIBCPP_CXX03_LANG
366
367template <class _Alloc, class _Pointer, class = void>
368struct __has_destroy : false_type {};
369
370template <class _Alloc, class _Pointer>
371struct __has_destroy<_Alloc, _Pointer, typename __void_t<
372 decltype(_VSTD::declval<_Alloc>().destroy(_VSTD::declval<_Pointer>()))
373>::type> : true_type {};
374
375template <class _Alloc>
376struct __has_max_size
377 : true_type
378{
379};
380
381template <class _Alloc>
382struct __has_select_on_container_copy_construction
383 : false_type
384{
385};
386
387#endif // _LIBCPP_CXX03_LANG
388
389template <class _Alloc, class _Ptr, bool = __has_difference_type<_Alloc>::value>
390struct __alloc_traits_difference_type
391{
392 typedef _LIBCPP_NODEBUG_TYPE typename pointer_traits<_Ptr>::difference_type type;
393};
394
395template <class _Alloc, class _Ptr>
396struct __alloc_traits_difference_type<_Alloc, _Ptr, true>
397{
398 typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::difference_type type;
399};
400
401template <class _Tp>
402struct __is_default_allocator : false_type {};
403
404template <class _Tp>
405struct __is_default_allocator<_VSTD::allocator<_Tp> > : true_type {};
406
407
408
409template <class _Alloc,
410 bool = __has_construct<_Alloc, typename _Alloc::value_type*, typename _Alloc::value_type&&>::value && !__is_default_allocator<_Alloc>::value
411 >
412struct __is_cpp17_move_insertable;
413template <class _Alloc>
414struct __is_cpp17_move_insertable<_Alloc, true> : true_type {};
415template <class _Alloc>
416struct __is_cpp17_move_insertable<_Alloc, false> : is_move_constructible<typename _Alloc::value_type> {};
417
418template <class _Alloc,
419 bool = __has_construct<_Alloc, typename _Alloc::value_type*, const typename _Alloc::value_type&>::value && !__is_default_allocator<_Alloc>::value
420 >
421struct __is_cpp17_copy_insertable;
422template <class _Alloc>
423struct __is_cpp17_copy_insertable<_Alloc, true> : __is_cpp17_move_insertable<_Alloc> {};
424template <class _Alloc>
425struct __is_cpp17_copy_insertable<_Alloc, false> : integral_constant<bool,
426 is_copy_constructible<typename _Alloc::value_type>::value &&
427 __is_cpp17_move_insertable<_Alloc>::value>
428 {};
429
430
431
432template <class _Alloc>
433struct _LIBCPP_TEMPLATE_VIS allocator_traits
434{
435 typedef _Alloc allocator_type;
436 typedef typename allocator_type::value_type value_type;
437
438 typedef typename __pointer_type<value_type, allocator_type>::type pointer;
439 typedef typename __const_pointer<value_type, pointer, allocator_type>::type const_pointer;
440 typedef typename __void_pointer<pointer, allocator_type>::type void_pointer;
441 typedef typename __const_void_pointer<pointer, allocator_type>::type const_void_pointer;
442
443 typedef typename __alloc_traits_difference_type<allocator_type, pointer>::type difference_type;
444 typedef typename __size_type<allocator_type, difference_type>::type size_type;
445
446 typedef typename __propagate_on_container_copy_assignment<allocator_type>::type
447 propagate_on_container_copy_assignment;
448 typedef typename __propagate_on_container_move_assignment<allocator_type>::type
449 propagate_on_container_move_assignment;
450 typedef typename __propagate_on_container_swap<allocator_type>::type
451 propagate_on_container_swap;
452 typedef typename __is_always_equal<allocator_type>::type
453 is_always_equal;
454
455#ifndef _LIBCPP_CXX03_LANG
456 template <class _Tp> using rebind_alloc =
457 typename __allocator_traits_rebind<allocator_type, _Tp>::type;
458 template <class _Tp> using rebind_traits = allocator_traits<rebind_alloc<_Tp> >;
459#else // _LIBCPP_CXX03_LANG
460 template <class _Tp> struct rebind_alloc
461 {typedef typename __allocator_traits_rebind<allocator_type, _Tp>::type other;};
462 template <class _Tp> struct rebind_traits
463 {typedef allocator_traits<typename rebind_alloc<_Tp>::other> other;};
464#endif // _LIBCPP_CXX03_LANG
465
466 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
467 static pointer allocate(allocator_type& __a, size_type __n)
468 {return __a.allocate(__n);}
469 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
470 static pointer allocate(allocator_type& __a, size_type __n, const_void_pointer __hint)
471 {return __allocate(__a, __n, __hint,
472 __has_allocate_hint<allocator_type, size_type, const_void_pointer>());}
473
474 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
475 static void deallocate(allocator_type& __a, pointer __p, size_type __n) _NOEXCEPT
476 {__a.deallocate(__p, __n);}
477
478 template <class _Tp, class... _Args>
479 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
480 static void construct(allocator_type& __a, _Tp* __p, _Args&&... __args)
481 {__construct(__has_construct<allocator_type, _Tp*, _Args...>(),
482 __a, __p, _VSTD::forward<_Args>(__args)...);}
483
484 template <class _Tp>
485 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
486 static void destroy(allocator_type& __a, _Tp* __p)
487 {__destroy(__has_destroy<allocator_type, _Tp*>(), __a, __p);}
488
489 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
490 static size_type max_size(const allocator_type& __a) _NOEXCEPT
491 {return __max_size(__has_max_size<const allocator_type>(), __a);}
492
493 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
494 static allocator_type
495 select_on_container_copy_construction(const allocator_type& __a)
496 {return __select_on_container_copy_construction(
497 __has_select_on_container_copy_construction<const allocator_type>(),
498 __a);}
499
500private:
501 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
502 static pointer __allocate(allocator_type& __a, size_type __n,
503 const_void_pointer __hint, true_type)
504 {
505 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
506 return __a.allocate(__n, __hint);
507 _LIBCPP_SUPPRESS_DEPRECATED_POP
508 }
509 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
510 static pointer __allocate(allocator_type& __a, size_type __n,
511 const_void_pointer, false_type)
512 {return __a.allocate(__n);}
513
514 template <class _Tp, class... _Args>
515 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
516 static void __construct(true_type, allocator_type& __a, _Tp* __p, _Args&&... __args)
517 {
518 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
519 __a.construct(__p, _VSTD::forward<_Args>(__args)...);
520 _LIBCPP_SUPPRESS_DEPRECATED_POP
521 }
522
523 template <class _Tp, class... _Args>
524 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
525 static void __construct(false_type, allocator_type&, _Tp* __p, _Args&&... __args)
526 {
527#if _LIBCPP_STD_VER > 17
528 _VSTD::construct_at(__p, _VSTD::forward<_Args>(__args)...);
529#else
530 ::new ((void*)__p) _Tp(_VSTD::forward<_Args>(__args)...);
531#endif
532 }
533
534 template <class _Tp>
535 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
536 static void __destroy(true_type, allocator_type& __a, _Tp* __p)
537 {
538 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
539 __a.destroy(__p);
540 _LIBCPP_SUPPRESS_DEPRECATED_POP
541 }
542 template <class _Tp>
543 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
544 static void __destroy(false_type, allocator_type&, _Tp* __p)
545 {
546#if _LIBCPP_STD_VER > 17
547 _VSTD::destroy_at(__p);
548#else
549 __p->~_Tp();
550#endif
551 }
552
553 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
554 static size_type __max_size(true_type, const allocator_type& __a) _NOEXCEPT
555 {
556 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
557 return __a.max_size();
558 _LIBCPP_SUPPRESS_DEPRECATED_POP
559 }
560
561 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
562 static size_type __max_size(false_type, const allocator_type&) _NOEXCEPT
563 {return numeric_limits<size_type>::max() / sizeof(value_type);}
564
565 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
566 static allocator_type
567 __select_on_container_copy_construction(true_type, const allocator_type& __a)
568 {return __a.select_on_container_copy_construction();}
569 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
570 static allocator_type
571 __select_on_container_copy_construction(false_type, const allocator_type& __a)
572 {return __a;}
573};
574
575template <class _Traits, class _Tp>
576struct __rebind_alloc_helper
577{
578#ifndef _LIBCPP_CXX03_LANG
579 typedef _LIBCPP_NODEBUG_TYPE typename _Traits::template rebind_alloc<_Tp> type;
580#else
581 typedef typename _Traits::template rebind_alloc<_Tp>::other type;
582#endif
583};
584
585_LIBCPP_END_NAMESPACE_STD
586
587_LIBCPP_POP_MACROS
588
589#endif // _LIBCPP___MEMORY_ALLOCATOR_TRAITS_H
lib/libcxx/include/__memory/base.h created+127
...@@ -0,0 +1,127 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___MEMORY_BASE_H
11#define _LIBCPP___MEMORY_BASE_H
12
13#include <__config>
14#include <__debug>
15#include <type_traits>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header
19#endif
20
21_LIBCPP_PUSH_MACROS
22#include <__undef_macros>
23
24_LIBCPP_BEGIN_NAMESPACE_STD
25
26// addressof
27#ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
28
29template <class _Tp>
30inline _LIBCPP_CONSTEXPR_AFTER_CXX14
31_LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
32_Tp*
33addressof(_Tp& __x) _NOEXCEPT
34{
35 return __builtin_addressof(__x);
36}
37
38#else
39
40template <class _Tp>
41inline _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
42_Tp*
43addressof(_Tp& __x) _NOEXCEPT
44{
45 return reinterpret_cast<_Tp *>(
46 const_cast<char *>(&reinterpret_cast<const volatile char &>(__x)));
47}
48
49#endif // _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
50
51#if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF)
52// Objective-C++ Automatic Reference Counting uses qualified pointers
53// that require special addressof() signatures. When
54// _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler
55// itself is providing these definitions. Otherwise, we provide them.
56template <class _Tp>
57inline _LIBCPP_INLINE_VISIBILITY
58__strong _Tp*
59addressof(__strong _Tp& __x) _NOEXCEPT
60{
61 return &__x;
62}
63
64#ifdef _LIBCPP_HAS_OBJC_ARC_WEAK
65template <class _Tp>
66inline _LIBCPP_INLINE_VISIBILITY
67__weak _Tp*
68addressof(__weak _Tp& __x) _NOEXCEPT
69{
70 return &__x;
71}
72#endif
73
74template <class _Tp>
75inline _LIBCPP_INLINE_VISIBILITY
76__autoreleasing _Tp*
77addressof(__autoreleasing _Tp& __x) _NOEXCEPT
78{
79 return &__x;
80}
81
82template <class _Tp>
83inline _LIBCPP_INLINE_VISIBILITY
84__unsafe_unretained _Tp*
85addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT
86{
87 return &__x;
88}
89#endif
90
91#if !defined(_LIBCPP_CXX03_LANG)
92template <class _Tp> _Tp* addressof(const _Tp&&) noexcept = delete;
93#endif
94
95// construct_at
96
97#if _LIBCPP_STD_VER > 17
98
99template<class _Tp, class ..._Args, class = decltype(
100 ::new (_VSTD::declval<void*>()) _Tp(_VSTD::declval<_Args>()...)
101)>
102_LIBCPP_INLINE_VISIBILITY
103constexpr _Tp* construct_at(_Tp* __location, _Args&& ...__args) {
104 _LIBCPP_ASSERT(__location, "null pointer given to construct_at");
105 return ::new ((void*)__location) _Tp(_VSTD::forward<_Args>(__args)...);
106}
107
108#endif
109
110// destroy_at
111
112#if _LIBCPP_STD_VER > 14
113
114template <class _Tp>
115inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
116void destroy_at(_Tp* __loc) {
117 _LIBCPP_ASSERT(__loc, "null pointer given to destroy_at");
118 __loc->~_Tp();
119}
120
121#endif
122
123_LIBCPP_END_NAMESPACE_STD
124
125_LIBCPP_POP_MACROS
126
127#endif // _LIBCPP___MEMORY_BASE_H
lib/libcxx/include/__memory/pointer_traits.h created+169
...@@ -0,0 +1,169 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___MEMORY_POINTER_TRAITS_H
11#define _LIBCPP___MEMORY_POINTER_TRAITS_H
12
13#include <__config>
14#include <type_traits>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17#pragma GCC system_header
18#endif
19
20_LIBCPP_PUSH_MACROS
21#include <__undef_macros>
22
23_LIBCPP_BEGIN_NAMESPACE_STD
24
25template <class _Tp, class = void>
26struct __has_element_type : false_type {};
27
28template <class _Tp>
29struct __has_element_type<_Tp,
30 typename __void_t<typename _Tp::element_type>::type> : true_type {};
31
32template <class _Ptr, bool = __has_element_type<_Ptr>::value>
33struct __pointer_traits_element_type;
34
35template <class _Ptr>
36struct __pointer_traits_element_type<_Ptr, true>
37{
38 typedef _LIBCPP_NODEBUG_TYPE typename _Ptr::element_type type;
39};
40
41template <template <class, class...> class _Sp, class _Tp, class ..._Args>
42struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, true>
43{
44 typedef _LIBCPP_NODEBUG_TYPE typename _Sp<_Tp, _Args...>::element_type type;
45};
46
47template <template <class, class...> class _Sp, class _Tp, class ..._Args>
48struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, false>
49{
50 typedef _LIBCPP_NODEBUG_TYPE _Tp type;
51};
52
53template <class _Tp, class = void>
54struct __has_difference_type : false_type {};
55
56template <class _Tp>
57struct __has_difference_type<_Tp,
58 typename __void_t<typename _Tp::difference_type>::type> : true_type {};
59
60template <class _Ptr, bool = __has_difference_type<_Ptr>::value>
61struct __pointer_traits_difference_type
62{
63 typedef _LIBCPP_NODEBUG_TYPE ptrdiff_t type;
64};
65
66template <class _Ptr>
67struct __pointer_traits_difference_type<_Ptr, true>
68{
69 typedef _LIBCPP_NODEBUG_TYPE typename _Ptr::difference_type type;
70};
71
72template <class _Tp, class _Up>
73struct __has_rebind
74{
75private:
76 struct __two {char __lx; char __lxx;};
77 template <class _Xp> static __two __test(...);
78 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
79 template <class _Xp> static char __test(typename _Xp::template rebind<_Up>* = 0);
80 _LIBCPP_SUPPRESS_DEPRECATED_POP
81public:
82 static const bool value = sizeof(__test<_Tp>(0)) == 1;
83};
84
85template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value>
86struct __pointer_traits_rebind
87{
88#ifndef _LIBCPP_CXX03_LANG
89 typedef _LIBCPP_NODEBUG_TYPE typename _Tp::template rebind<_Up> type;
90#else
91 typedef _LIBCPP_NODEBUG_TYPE typename _Tp::template rebind<_Up>::other type;
92#endif
93};
94
95template <template <class, class...> class _Sp, class _Tp, class ..._Args, class _Up>
96struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, true>
97{
98#ifndef _LIBCPP_CXX03_LANG
99 typedef _LIBCPP_NODEBUG_TYPE typename _Sp<_Tp, _Args...>::template rebind<_Up> type;
100#else
101 typedef _LIBCPP_NODEBUG_TYPE typename _Sp<_Tp, _Args...>::template rebind<_Up>::other type;
102#endif
103};
104
105template <template <class, class...> class _Sp, class _Tp, class ..._Args, class _Up>
106struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, false>
107{
108 typedef _Sp<_Up, _Args...> type;
109};
110
111template <class _Ptr>
112struct _LIBCPP_TEMPLATE_VIS pointer_traits
113{
114 typedef _Ptr pointer;
115 typedef typename __pointer_traits_element_type<pointer>::type element_type;
116 typedef typename __pointer_traits_difference_type<pointer>::type difference_type;
117
118#ifndef _LIBCPP_CXX03_LANG
119 template <class _Up> using rebind = typename __pointer_traits_rebind<pointer, _Up>::type;
120#else
121 template <class _Up> struct rebind
122 {typedef typename __pointer_traits_rebind<pointer, _Up>::type other;};
123#endif // _LIBCPP_CXX03_LANG
124
125private:
126 struct __nat {};
127public:
128 _LIBCPP_INLINE_VISIBILITY
129 static pointer pointer_to(typename conditional<is_void<element_type>::value,
130 __nat, element_type>::type& __r)
131 {return pointer::pointer_to(__r);}
132};
133
134template <class _Tp>
135struct _LIBCPP_TEMPLATE_VIS pointer_traits<_Tp*>
136{
137 typedef _Tp* pointer;
138 typedef _Tp element_type;
139 typedef ptrdiff_t difference_type;
140
141#ifndef _LIBCPP_CXX03_LANG
142 template <class _Up> using rebind = _Up*;
143#else
144 template <class _Up> struct rebind {typedef _Up* other;};
145#endif
146
147private:
148 struct __nat {};
149public:
150 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
151 static pointer pointer_to(typename conditional<is_void<element_type>::value,
152 __nat, element_type>::type& __r) _NOEXCEPT
153 {return _VSTD::addressof(__r);}
154};
155
156template <class _From, class _To>
157struct __rebind_pointer {
158#ifndef _LIBCPP_CXX03_LANG
159 typedef typename pointer_traits<_From>::template rebind<_To> type;
160#else
161 typedef typename pointer_traits<_From>::template rebind<_To>::other type;
162#endif
163};
164
165_LIBCPP_END_NAMESPACE_STD
166
167_LIBCPP_POP_MACROS
168
169#endif // _LIBCPP___MEMORY_POINTER_TRAITS_H
lib/libcxx/include/__memory/utilities.h created+88
...@@ -0,0 +1,88 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___MEMORY_UTILITIES_H
11#define _LIBCPP___MEMORY_UTILITIES_H
12
13#include <__config>
14#include <__memory/allocator_traits.h>
15#include <cstddef>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header
19#endif
20
21_LIBCPP_PUSH_MACROS
22#include <__undef_macros>
23
24
25_LIBCPP_BEGIN_NAMESPACE_STD
26
27// Helper class to allocate memory using an Allocator in an exception safe
28// manner.
29//
30// The intended usage of this class is as follows:
31//
32// 0
33// 1 __allocation_guard<SomeAllocator> guard(alloc, 10);
34// 2 do_some_initialization_that_may_throw(guard.__get());
35// 3 save_allocated_pointer_in_a_noexcept_operation(guard.__release_ptr());
36// 4
37//
38// If line (2) throws an exception during initialization of the memory, the
39// guard's destructor will be called, and the memory will be released using
40// Allocator deallocation. Otherwise, we release the memory from the guard on
41// line (3) in an operation that can't throw -- after that, the guard is not
42// responsible for the memory anymore.
43//
44// This is similar to a unique_ptr, except it's easier to use with a
45// custom allocator.
46template<class _Alloc>
47struct __allocation_guard {
48 using _Pointer = typename allocator_traits<_Alloc>::pointer;
49 using _Size = typename allocator_traits<_Alloc>::size_type;
50
51 template<class _AllocT> // we perform the allocator conversion inside the constructor
52 _LIBCPP_HIDE_FROM_ABI
53 explicit __allocation_guard(_AllocT __alloc, _Size __n)
54 : __alloc_(_VSTD::move(__alloc))
55 , __n_(__n)
56 , __ptr_(allocator_traits<_Alloc>::allocate(__alloc_, __n_)) // initialization order is important
57 { }
58
59 _LIBCPP_HIDE_FROM_ABI
60 ~__allocation_guard() _NOEXCEPT {
61 if (__ptr_ != nullptr) {
62 allocator_traits<_Alloc>::deallocate(__alloc_, __ptr_, __n_);
63 }
64 }
65
66 _LIBCPP_HIDE_FROM_ABI
67 _Pointer __release_ptr() _NOEXCEPT { // not called __release() because it's a keyword in objective-c++
68 _Pointer __tmp = __ptr_;
69 __ptr_ = nullptr;
70 return __tmp;
71 }
72
73 _LIBCPP_HIDE_FROM_ABI
74 _Pointer __get() const _NOEXCEPT {
75 return __ptr_;
76 }
77
78private:
79 _Alloc __alloc_;
80 _Size __n_;
81 _Pointer __ptr_;
82};
83
84_LIBCPP_END_NAMESPACE_STD
85
86_LIBCPP_POP_MACROS
87
88#endif // _LIBCPP___MEMORY_UTILITIES_H
lib/libcxx/include/__mutex_base+2-5
...@@ -146,7 +146,6 @@ private:...@@ -146,7 +146,6 @@ private:
146 unique_lock& operator=(unique_lock const&); // = delete;146 unique_lock& operator=(unique_lock const&); // = delete;
147147
148public:148public:
149#ifndef _LIBCPP_CXX03_LANG
150 _LIBCPP_INLINE_VISIBILITY149 _LIBCPP_INLINE_VISIBILITY
151 unique_lock(unique_lock&& __u) _NOEXCEPT150 unique_lock(unique_lock&& __u) _NOEXCEPT
152 : __m_(__u.__m_), __owns_(__u.__owns_)151 : __m_(__u.__m_), __owns_(__u.__owns_)
...@@ -163,8 +162,6 @@ public:...@@ -163,8 +162,6 @@ public:
163 return *this;162 return *this;
164 }163 }
165164
166#endif // _LIBCPP_CXX03_LANG
167
168 void lock();165 void lock();
169 bool try_lock();166 bool try_lock();
170167
...@@ -382,12 +379,12 @@ __safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d)...@@ -382,12 +379,12 @@ __safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d)
382379
383 using __ratio = ratio_divide<_Period, nano>;380 using __ratio = ratio_divide<_Period, nano>;
384 using __ns_rep = nanoseconds::rep;381 using __ns_rep = nanoseconds::rep;
385 __ns_rep __result_max = std::numeric_limits<__ns_rep>::max();382 __ns_rep __result_max = numeric_limits<__ns_rep>::max();
386 if (__d.count() > 0 && __d.count() > __result_max / __ratio::num) {383 if (__d.count() > 0 && __d.count() > __result_max / __ratio::num) {
387 return nanoseconds::max();384 return nanoseconds::max();
388 }385 }
389386
390 __ns_rep __result_min = std::numeric_limits<__ns_rep>::min();387 __ns_rep __result_min = numeric_limits<__ns_rep>::min();
391 if (__d.count() < 0 && __d.count() < __result_min / __ratio::num) {388 if (__d.count() < 0 && __d.count() < __result_min / __ratio::num) {
392 return nanoseconds::min();389 return nanoseconds::min();
393 }390 }
lib/libcxx/include/__split_buffer+4-20
...@@ -68,7 +68,6 @@ public:...@@ -68,7 +68,6 @@ public:
68 __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a);68 __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a);
69 ~__split_buffer();69 ~__split_buffer();
7070
71#ifndef _LIBCPP_CXX03_LANG
72 __split_buffer(__split_buffer&& __c)71 __split_buffer(__split_buffer&& __c)
73 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);72 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
74 __split_buffer(__split_buffer&& __c, const __alloc_rr& __a);73 __split_buffer(__split_buffer&& __c, const __alloc_rr& __a);
...@@ -76,7 +75,6 @@ public:...@@ -76,7 +75,6 @@ public:
76 _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&75 _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&
77 is_nothrow_move_assignable<allocator_type>::value) ||76 is_nothrow_move_assignable<allocator_type>::value) ||
78 !__alloc_traits::propagate_on_container_move_assignment::value);77 !__alloc_traits::propagate_on_container_move_assignment::value);
79#endif // _LIBCPP_CXX03_LANG
8078
81 _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT {return __begin_;}79 _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT {return __begin_;}
82 _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT {return __begin_;}80 _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT {return __begin_;}
...@@ -101,12 +99,10 @@ public:...@@ -101,12 +99,10 @@ public:
101 void shrink_to_fit() _NOEXCEPT;99 void shrink_to_fit() _NOEXCEPT;
102 void push_front(const_reference __x);100 void push_front(const_reference __x);
103 _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);101 _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
104#ifndef _LIBCPP_CXX03_LANG
105 void push_front(value_type&& __x);102 void push_front(value_type&& __x);
106 void push_back(value_type&& __x);103 void push_back(value_type&& __x);
107 template <class... _Args>104 template <class... _Args>
108 void emplace_back(_Args&&... __args);105 void emplace_back(_Args&&... __args);
109#endif // !defined(_LIBCPP_CXX03_LANG)
110106
111 _LIBCPP_INLINE_VISIBILITY void pop_front() {__destruct_at_begin(__begin_+1);}107 _LIBCPP_INLINE_VISIBILITY void pop_front() {__destruct_at_begin(__begin_+1);}
112 _LIBCPP_INLINE_VISIBILITY void pop_back() {__destruct_at_end(__end_-1);}108 _LIBCPP_INLINE_VISIBILITY void pop_back() {__destruct_at_end(__end_-1);}
...@@ -270,7 +266,7 @@ typename enable_if...@@ -270,7 +266,7 @@ typename enable_if
270>::type266>::type
271__split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last)267__split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last)
272{268{
273 _ConstructTransaction __tx(&this->__end_, std::distance(__first, __last));269 _ConstructTransaction __tx(&this->__end_, _VSTD::distance(__first, __last));
274 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_, ++__first) {270 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_, ++__first) {
275 __alloc_traits::construct(this->__alloc(),271 __alloc_traits::construct(this->__alloc(),
276 _VSTD::__to_address(__tx.__pos_), *__first);272 _VSTD::__to_address(__tx.__pos_), *__first);
...@@ -283,7 +279,7 @@ void...@@ -283,7 +279,7 @@ void
283__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type)279__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type)
284{280{
285 while (__begin_ != __new_begin)281 while (__begin_ != __new_begin)
286 __alloc_traits::destroy(__alloc(), __to_address(__begin_++));282 __alloc_traits::destroy(__alloc(), _VSTD::__to_address(__begin_++));
287}283}
288284
289template <class _Tp, class _Allocator>285template <class _Tp, class _Allocator>
...@@ -300,7 +296,7 @@ void...@@ -300,7 +296,7 @@ void
300__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT296__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT
301{297{
302 while (__new_last != __end_)298 while (__new_last != __end_)
303 __alloc_traits::destroy(__alloc(), __to_address(--__end_));299 __alloc_traits::destroy(__alloc(), _VSTD::__to_address(--__end_));
304}300}
305301
306template <class _Tp, class _Allocator>302template <class _Tp, class _Allocator>
...@@ -350,8 +346,6 @@ __split_buffer<_Tp, _Allocator>::~__split_buffer()...@@ -350,8 +346,6 @@ __split_buffer<_Tp, _Allocator>::~__split_buffer()
350 __alloc_traits::deallocate(__alloc(), __first_, capacity());346 __alloc_traits::deallocate(__alloc(), __first_, capacity());
351}347}
352348
353#ifndef _LIBCPP_CXX03_LANG
354
355template <class _Tp, class _Allocator>349template <class _Tp, class _Allocator>
356__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c)350__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c)
357 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)351 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
...@@ -412,8 +406,6 @@ __split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c)...@@ -412,8 +406,6 @@ __split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c)
412 return *this;406 return *this;
413}407}
414408
415#endif // _LIBCPP_CXX03_LANG
416
417template <class _Tp, class _Allocator>409template <class _Tp, class _Allocator>
418void410void
419__split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)411__split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)
...@@ -424,7 +416,7 @@ __split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)...@@ -424,7 +416,7 @@ __split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)
424 _VSTD::swap(__begin_, __x.__begin_);416 _VSTD::swap(__begin_, __x.__begin_);
425 _VSTD::swap(__end_, __x.__end_);417 _VSTD::swap(__end_, __x.__end_);
426 _VSTD::swap(__end_cap(), __x.__end_cap());418 _VSTD::swap(__end_cap(), __x.__end_cap());
427 __swap_allocator(__alloc(), __x.__alloc());419 _VSTD::__swap_allocator(__alloc(), __x.__alloc());
428}420}
429421
430template <class _Tp, class _Allocator>422template <class _Tp, class _Allocator>
...@@ -499,8 +491,6 @@ __split_buffer<_Tp, _Allocator>::push_front(const_reference __x)...@@ -499,8 +491,6 @@ __split_buffer<_Tp, _Allocator>::push_front(const_reference __x)
499 --__begin_;491 --__begin_;
500}492}
501493
502#ifndef _LIBCPP_CXX03_LANG
503
504template <class _Tp, class _Allocator>494template <class _Tp, class _Allocator>
505void495void
506__split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)496__split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)
...@@ -531,8 +521,6 @@ __split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)...@@ -531,8 +521,6 @@ __split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)
531 --__begin_;521 --__begin_;
532}522}
533523
534#endif // _LIBCPP_CXX03_LANG
535
536template <class _Tp, class _Allocator>524template <class _Tp, class _Allocator>
537inline _LIBCPP_INLINE_VISIBILITY525inline _LIBCPP_INLINE_VISIBILITY
538void526void
...@@ -563,8 +551,6 @@ __split_buffer<_Tp, _Allocator>::push_back(const_reference __x)...@@ -563,8 +551,6 @@ __split_buffer<_Tp, _Allocator>::push_back(const_reference __x)
563 ++__end_;551 ++__end_;
564}552}
565553
566#ifndef _LIBCPP_CXX03_LANG
567
568template <class _Tp, class _Allocator>554template <class _Tp, class _Allocator>
569void555void
570__split_buffer<_Tp, _Allocator>::push_back(value_type&& __x)556__split_buffer<_Tp, _Allocator>::push_back(value_type&& __x)
...@@ -626,8 +612,6 @@ __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args)...@@ -626,8 +612,6 @@ __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args)
626 ++__end_;612 ++__end_;
627}613}
628614
629#endif // _LIBCPP_CXX03_LANG
630
631template <class _Tp, class _Allocator>615template <class _Tp, class _Allocator>
632inline _LIBCPP_INLINE_VISIBILITY616inline _LIBCPP_INLINE_VISIBILITY
633void617void
lib/libcxx/include/__sso_allocator+5-4
...@@ -11,8 +11,9 @@...@@ -11,8 +11,9 @@
11#define _LIBCPP___SSO_ALLOCATOR11#define _LIBCPP___SSO_ALLOCATOR
1212
13#include <__config>13#include <__config>
14#include <type_traits>14#include <memory>
15#include <new>15#include <new>
16#include <type_traits>
1617
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header19#pragma GCC system_header
...@@ -47,21 +48,21 @@ public:...@@ -47,21 +48,21 @@ public:
47private:48private:
48 __sso_allocator& operator=(const __sso_allocator&);49 __sso_allocator& operator=(const __sso_allocator&);
49public:50public:
50 _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, typename __sso_allocator<void, _Np>::const_pointer = 0)51 _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, typename __sso_allocator<void, _Np>::const_pointer = nullptr)
51 {52 {
52 if (!__allocated_ && __n <= _Np)53 if (!__allocated_ && __n <= _Np)
53 {54 {
54 __allocated_ = true;55 __allocated_ = true;
55 return (pointer)&buf_;56 return (pointer)&buf_;
56 }57 }
57 return static_cast<pointer>(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)));58 return allocator<_Tp>().allocate(__n);
58 }59 }
59 _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type __n)60 _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type __n)
60 {61 {
61 if (__p == (pointer)&buf_)62 if (__p == (pointer)&buf_)
62 __allocated_ = false;63 __allocated_ = false;
63 else64 else
64 _VSTD::__libcpp_deallocate(__p, __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));65 allocator<_Tp>().deallocate(__p, __n);
65 }66 }
66 _LIBCPP_INLINE_VISIBILITY size_type max_size() const throw() {return size_type(~0) / sizeof(_Tp);}67 _LIBCPP_INLINE_VISIBILITY size_type max_size() const throw() {return size_type(~0) / sizeof(_Tp);}
6768
lib/libcxx/include/__string+49-47
...@@ -55,7 +55,9 @@ template <> struct char_traits<char8_t>; // c++20...@@ -55,7 +55,9 @@ template <> struct char_traits<char8_t>; // c++20
5555
56#include <__config>56#include <__config>
57#include <algorithm> // for search and min57#include <algorithm> // for search and min
58#include <cstdio> // For EOF.58#include <cstdio> // for EOF
59#include <cstring> // for memcpy
60#include <cwchar> // for wmemcpy
59#include <memory> // for __murmur2_or_cityhash61#include <memory> // for __murmur2_or_cityhash
6062
61#include <__debug>63#include <__debug>
...@@ -92,7 +94,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -92,7 +94,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
92 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type, size_type)) \94 _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&)) \95 _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*)) \96 _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&)) \97 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, 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) \98 _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()) \99 _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) \100 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_not_of(value_type const*, size_type, size_type) const) \
...@@ -108,7 +110,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -108,7 +110,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
108 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*, size_type)) \110 _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)) \111 _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) \112 _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&)) \113 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, size_type, size_type, allocator<_CharType> const&)) \
112 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type, size_type) const) \114 _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)) \115 _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*)) \116 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*)) \
...@@ -158,7 +160,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -158,7 +160,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
158 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*, size_type)) \160 _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)) \161 _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) \162 _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&)) \163 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, size_type, size_type, allocator<_CharType> const&)) \
162 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type, size_type) const) \164 _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)) \165 _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*)) \166 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*)) \
...@@ -268,7 +270,7 @@ char_traits<_CharT>::find(const char_type* __s, size_t __n, const char_type& __a...@@ -268,7 +270,7 @@ char_traits<_CharT>::find(const char_type* __s, size_t __n, const char_type& __a
268 return __s;270 return __s;
269 ++__s;271 ++__s;
270 }272 }
271 return 0;273 return nullptr;
272}274}
273275
274template <class _CharT>276template <class _CharT>
...@@ -318,7 +320,7 @@ char_traits<_CharT>::assign(char_type* __s, size_t __n, char_type __a)...@@ -318,7 +320,7 @@ char_traits<_CharT>::assign(char_type* __s, size_t __n, char_type __a)
318// constexpr versions of move/copy/assign.320// constexpr versions of move/copy/assign.
319321
320template <class _CharT>322template <class _CharT>
321static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED323static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
322_CharT* __move_constexpr(_CharT* __s1, const _CharT* __s2, size_t __n) _NOEXCEPT324_CharT* __move_constexpr(_CharT* __s1, const _CharT* __s2, size_t __n) _NOEXCEPT
323{325{
324 if (__n == 0) return __s1;326 if (__n == 0) return __s1;
...@@ -331,7 +333,7 @@ _CharT* __move_constexpr(_CharT* __s1, const _CharT* __s2, size_t __n) _NOEXCEPT...@@ -331,7 +333,7 @@ _CharT* __move_constexpr(_CharT* __s1, const _CharT* __s2, size_t __n) _NOEXCEPT
331}333}
332334
333template <class _CharT>335template <class _CharT>
334static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED336static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
335_CharT* __copy_constexpr(_CharT* __s1, const _CharT* __s2, size_t __n) _NOEXCEPT337_CharT* __copy_constexpr(_CharT* __s1, const _CharT* __s2, size_t __n) _NOEXCEPT
336{338{
337 _VSTD::copy_n(__s2, __n, __s1);339 _VSTD::copy_n(__s2, __n, __s1);
...@@ -339,7 +341,7 @@ _CharT* __copy_constexpr(_CharT* __s1, const _CharT* __s2, size_t __n) _NOEXCEPT...@@ -339,7 +341,7 @@ _CharT* __copy_constexpr(_CharT* __s1, const _CharT* __s2, size_t __n) _NOEXCEPT
339}341}
340342
341template <class _CharT>343template <class _CharT>
342static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED344static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
343_CharT* __assign_constexpr(_CharT* __s, size_t __n, _CharT __a) _NOEXCEPT345_CharT* __assign_constexpr(_CharT* __s, size_t __n, _CharT __a) _NOEXCEPT
344{346{
345 _VSTD::fill_n(__s, __n, __a);347 _VSTD::fill_n(__s, __n, __a);
...@@ -370,27 +372,27 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char>...@@ -370,27 +372,27 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char>
370 length(const char_type* __s) _NOEXCEPT {return __builtin_strlen(__s);}372 length(const char_type* __s) _NOEXCEPT {return __builtin_strlen(__s);}
371 static _LIBCPP_CONSTEXPR_AFTER_CXX14373 static _LIBCPP_CONSTEXPR_AFTER_CXX14
372 const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;374 const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
373 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED375 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
374 char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT376 char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
375 {377 {
376 return __libcpp_is_constant_evaluated()378 return __libcpp_is_constant_evaluated()
377 ? __move_constexpr(__s1, __s2, __n)379 ? _VSTD::__move_constexpr(__s1, __s2, __n)
378 : __n == 0 ? __s1 : (char_type*)memmove(__s1, __s2, __n);380 : __n == 0 ? __s1 : (char_type*)_VSTD::memmove(__s1, __s2, __n);
379 }381 }
380 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED382 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
381 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT383 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
382 {384 {
383 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");385 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
384 return __libcpp_is_constant_evaluated()386 return __libcpp_is_constant_evaluated()
385 ? __copy_constexpr(__s1, __s2, __n)387 ? _VSTD::__copy_constexpr(__s1, __s2, __n)
386 : __n == 0 ? __s1 : (char_type*)memcpy(__s1, __s2, __n);388 : __n == 0 ? __s1 : (char_type*)_VSTD::memcpy(__s1, __s2, __n);
387 }389 }
388 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED390 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
389 char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT391 char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
390 {392 {
391 return __libcpp_is_constant_evaluated()393 return __libcpp_is_constant_evaluated()
392 ? __assign_constexpr(__s, __n, __a)394 ? _VSTD::__assign_constexpr(__s, __n, __a)
393 : __n == 0 ? __s : (char_type*)memset(__s, to_int_type(__a), __n);395 : __n == 0 ? __s : (char_type*)_VSTD::memset(__s, to_int_type(__a), __n);
394 }396 }
395397
396 static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT398 static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
...@@ -414,7 +416,7 @@ char_traits<char>::compare(const char_type* __s1, const char_type* __s2, size_t...@@ -414,7 +416,7 @@ char_traits<char>::compare(const char_type* __s1, const char_type* __s2, size_t
414#if __has_feature(cxx_constexpr_string_builtins)416#if __has_feature(cxx_constexpr_string_builtins)
415 return __builtin_memcmp(__s1, __s2, __n);417 return __builtin_memcmp(__s1, __s2, __n);
416#elif _LIBCPP_STD_VER <= 14418#elif _LIBCPP_STD_VER <= 14
417 return memcmp(__s1, __s2, __n);419 return _VSTD::memcmp(__s1, __s2, __n);
418#else420#else
419 for (; __n; --__n, ++__s1, ++__s2)421 for (; __n; --__n, ++__s1, ++__s2)
420 {422 {
...@@ -436,7 +438,7 @@ char_traits<char>::find(const char_type* __s, size_t __n, const char_type& __a)...@@ -436,7 +438,7 @@ char_traits<char>::find(const char_type* __s, size_t __n, const char_type& __a)
436#if __has_feature(cxx_constexpr_string_builtins)438#if __has_feature(cxx_constexpr_string_builtins)
437 return __builtin_char_memchr(__s, to_int_type(__a), __n);439 return __builtin_char_memchr(__s, to_int_type(__a), __n);
438#elif _LIBCPP_STD_VER <= 14440#elif _LIBCPP_STD_VER <= 14
439 return (const char_type*) memchr(__s, to_int_type(__a), __n);441 return (const char_type*) _VSTD::memchr(__s, to_int_type(__a), __n);
440#else442#else
441 for (; __n; --__n)443 for (; __n; --__n)
442 {444 {
...@@ -473,27 +475,27 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t>...@@ -473,27 +475,27 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t>
473 size_t length(const char_type* __s) _NOEXCEPT;475 size_t length(const char_type* __s) _NOEXCEPT;
474 static _LIBCPP_CONSTEXPR_AFTER_CXX14476 static _LIBCPP_CONSTEXPR_AFTER_CXX14
475 const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;477 const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
476 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED478 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
477 char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT479 char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
478 {480 {
479 return __libcpp_is_constant_evaluated()481 return __libcpp_is_constant_evaluated()
480 ? __move_constexpr(__s1, __s2, __n)482 ? _VSTD::__move_constexpr(__s1, __s2, __n)
481 : __n == 0 ? __s1 : wmemmove(__s1, __s2, __n);483 : __n == 0 ? __s1 : _VSTD::wmemmove(__s1, __s2, __n);
482 }484 }
483 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED485 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
484 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT486 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
485 {487 {
486 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");488 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
487 return __libcpp_is_constant_evaluated()489 return __libcpp_is_constant_evaluated()
488 ? __copy_constexpr(__s1, __s2, __n)490 ? _VSTD::__copy_constexpr(__s1, __s2, __n)
489 : __n == 0 ? __s1 : wmemcpy(__s1, __s2, __n);491 : __n == 0 ? __s1 : _VSTD::wmemcpy(__s1, __s2, __n);
490 }492 }
491 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED493 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
492 char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT494 char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
493 {495 {
494 return __libcpp_is_constant_evaluated()496 return __libcpp_is_constant_evaluated()
495 ? __assign_constexpr(__s, __n, __a)497 ? _VSTD::__assign_constexpr(__s, __n, __a)
496 : __n == 0 ? __s : wmemset(__s, __a, __n);498 : __n == 0 ? __s : _VSTD::wmemset(__s, __a, __n);
497 }499 }
498 static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT500 static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
499 {return eq_int_type(__c, eof()) ? ~eof() : __c;}501 {return eq_int_type(__c, eof()) ? ~eof() : __c;}
...@@ -516,7 +518,7 @@ char_traits<wchar_t>::compare(const char_type* __s1, const char_type* __s2, size...@@ -516,7 +518,7 @@ char_traits<wchar_t>::compare(const char_type* __s1, const char_type* __s2, size
516#if __has_feature(cxx_constexpr_string_builtins)518#if __has_feature(cxx_constexpr_string_builtins)
517 return __builtin_wmemcmp(__s1, __s2, __n);519 return __builtin_wmemcmp(__s1, __s2, __n);
518#elif _LIBCPP_STD_VER <= 14520#elif _LIBCPP_STD_VER <= 14
519 return wmemcmp(__s1, __s2, __n);521 return _VSTD::wmemcmp(__s1, __s2, __n);
520#else522#else
521 for (; __n; --__n, ++__s1, ++__s2)523 for (; __n; --__n, ++__s1, ++__s2)
522 {524 {
...@@ -548,7 +550,7 @@ char_traits<wchar_t>::length(const char_type* __s) _NOEXCEPT...@@ -548,7 +550,7 @@ char_traits<wchar_t>::length(const char_type* __s) _NOEXCEPT
548#if __has_feature(cxx_constexpr_string_builtins)550#if __has_feature(cxx_constexpr_string_builtins)
549 return __builtin_wcslen(__s);551 return __builtin_wcslen(__s);
550#elif _LIBCPP_STD_VER <= 14552#elif _LIBCPP_STD_VER <= 14
551 return wcslen(__s);553 return _VSTD::wcslen(__s);
552#else554#else
553 size_t __len = 0;555 size_t __len = 0;
554 for (; !eq(*__s, char_type(0)); ++__s)556 for (; !eq(*__s, char_type(0)); ++__s)
...@@ -566,7 +568,7 @@ char_traits<wchar_t>::find(const char_type* __s, size_t __n, const char_type& __...@@ -566,7 +568,7 @@ char_traits<wchar_t>::find(const char_type* __s, size_t __n, const char_type& __
566#if __has_feature(cxx_constexpr_string_builtins)568#if __has_feature(cxx_constexpr_string_builtins)
567 return __builtin_wmemchr(__s, __a, __n);569 return __builtin_wmemchr(__s, __a, __n);
568#elif _LIBCPP_STD_VER <= 14570#elif _LIBCPP_STD_VER <= 14
569 return wmemchr(__s, __a, __n);571 return _VSTD::wmemchr(__s, __a, __n);
570#else572#else
571 for (; __n; --__n)573 for (; __n; --__n)
572 {574 {
...@@ -606,29 +608,29 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>...@@ -606,29 +608,29 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>
606 _LIBCPP_INLINE_VISIBILITY static constexpr608 _LIBCPP_INLINE_VISIBILITY static constexpr
607 const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;609 const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
608610
609 static _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED611 static _LIBCPP_CONSTEXPR_AFTER_CXX17
610 char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT612 char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
611 {613 {
612 return __libcpp_is_constant_evaluated()614 return __libcpp_is_constant_evaluated()
613 ? __move_constexpr(__s1, __s2, __n)615 ? _VSTD::__move_constexpr(__s1, __s2, __n)
614 : __n == 0 ? __s1 : (char_type*)memmove(__s1, __s2, __n);616 : __n == 0 ? __s1 : (char_type*)_VSTD::memmove(__s1, __s2, __n);
615 }617 }
616618
617 static _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED619 static _LIBCPP_CONSTEXPR_AFTER_CXX17
618 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT620 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
619 {621 {
620 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");622 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
621 return __libcpp_is_constant_evaluated()623 return __libcpp_is_constant_evaluated()
622 ? __copy_constexpr(__s1, __s2, __n)624 ? _VSTD::__copy_constexpr(__s1, __s2, __n)
623 : __n == 0 ? __s1 : (char_type*)memcpy(__s1, __s2, __n);625 : __n == 0 ? __s1 : (char_type*)_VSTD::memcpy(__s1, __s2, __n);
624 }626 }
625627
626 static _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED628 static _LIBCPP_CONSTEXPR_AFTER_CXX17
627 char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT629 char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
628 {630 {
629 return __libcpp_is_constant_evaluated()631 return __libcpp_is_constant_evaluated()
630 ? __assign_constexpr(__s, __n, __a)632 ? _VSTD::__assign_constexpr(__s, __n, __a)
631 : __n == 0 ? __s : (char_type*)memset(__s, to_int_type(__a), __n);633 : __n == 0 ? __s : (char_type*)_VSTD::memset(__s, to_int_type(__a), __n);
632 }634 }
633635
634 static inline constexpr int_type not_eof(int_type __c) noexcept636 static inline constexpr int_type not_eof(int_type __c) noexcept
...@@ -683,7 +685,7 @@ char_traits<char8_t>::find(const char_type* __s, size_t __n, const char_type& __...@@ -683,7 +685,7 @@ char_traits<char8_t>::find(const char_type* __s, size_t __n, const char_type& __
683 return __s;685 return __s;
684 ++__s;686 ++__s;
685 }687 }
686 return 0;688 return nullptr;
687}689}
688690
689#endif // #_LIBCPP_NO_HAS_CHAR8_T691#endif // #_LIBCPP_NO_HAS_CHAR8_T
...@@ -765,7 +767,7 @@ char_traits<char16_t>::find(const char_type* __s, size_t __n, const char_type& _...@@ -765,7 +767,7 @@ char_traits<char16_t>::find(const char_type* __s, size_t __n, const char_type& _
765 return __s;767 return __s;
766 ++__s;768 ++__s;
767 }769 }
768 return 0;770 return nullptr;
769}771}
770772
771inline _LIBCPP_CONSTEXPR_AFTER_CXX17773inline _LIBCPP_CONSTEXPR_AFTER_CXX17
...@@ -885,7 +887,7 @@ char_traits<char32_t>::find(const char_type* __s, size_t __n, const char_type& _...@@ -885,7 +887,7 @@ char_traits<char32_t>::find(const char_type* __s, size_t __n, const char_type& _
885 return __s;887 return __s;
886 ++__s;888 ++__s;
887 }889 }
888 return 0;890 return nullptr;
889}891}
890892
891inline _LIBCPP_CONSTEXPR_AFTER_CXX17893inline _LIBCPP_CONSTEXPR_AFTER_CXX17
...@@ -943,7 +945,7 @@ __str_find(const _CharT *__p, _SizeT __sz,...@@ -943,7 +945,7 @@ __str_find(const _CharT *__p, _SizeT __sz,
943 if (__pos >= __sz)945 if (__pos >= __sz)
944 return __npos;946 return __npos;
945 const _CharT* __r = _Traits::find(__p + __pos, __sz - __pos, __c);947 const _CharT* __r = _Traits::find(__p + __pos, __sz - __pos, __c);
946 if (__r == 0)948 if (__r == nullptr)
947 return __npos;949 return __npos;
948 return static_cast<_SizeT>(__r - __p);950 return static_cast<_SizeT>(__r - __p);
949}951}
...@@ -972,7 +974,7 @@ __search_substring(const _CharT *__first1, const _CharT *__last1,...@@ -972,7 +974,7 @@ __search_substring(const _CharT *__first1, const _CharT *__last1,
972974
973 // Find __f2 the first byte matching in __first1.975 // Find __f2 the first byte matching in __first1.
974 __first1 = _Traits::find(__first1, __len1 - __len2 + 1, __f2);976 __first1 = _Traits::find(__first1, __len1 - __len2 + 1, __f2);
975 if (__first1 == 0)977 if (__first1 == nullptr)
976 return __last1;978 return __last1;
977979
978 // It is faster to compare from the first byte of __first1 even if we980 // It is faster to compare from the first byte of __first1 even if we
...@@ -1095,7 +1097,7 @@ __str_find_first_not_of(const _CharT *__p, _SizeT __sz,...@@ -1095,7 +1097,7 @@ __str_find_first_not_of(const _CharT *__p, _SizeT __sz,
1095 {1097 {
1096 const _CharT* __pe = __p + __sz;1098 const _CharT* __pe = __p + __sz;
1097 for (const _CharT* __ps = __p + __pos; __ps != __pe; ++__ps)1099 for (const _CharT* __ps = __p + __pos; __ps != __pe; ++__ps)
1098 if (_Traits::find(__s, __n, *__ps) == 0)1100 if (_Traits::find(__s, __n, *__ps) == nullptr)
1099 return static_cast<_SizeT>(__ps - __p);1101 return static_cast<_SizeT>(__ps - __p);
1100 }1102 }
1101 return __npos;1103 return __npos;
...@@ -1129,7 +1131,7 @@ __str_find_last_not_of(const _CharT *__p, _SizeT __sz,...@@ -1129,7 +1131,7 @@ __str_find_last_not_of(const _CharT *__p, _SizeT __sz,
1129 else1131 else
1130 __pos = __sz;1132 __pos = __sz;
1131 for (const _CharT* __ps = __p + __pos; __ps != __p;)1133 for (const _CharT* __ps = __p + __pos; __ps != __p;)
1132 if (_Traits::find(__s, __n, *--__ps) == 0)1134 if (_Traits::find(__s, __n, *--__ps) == nullptr)
1133 return static_cast<_SizeT>(__ps - __p);1135 return static_cast<_SizeT>(__ps - __p);
1134 return __npos;1136 return __npos;
1135}1137}
lib/libcxx/include/__threading_support+36-26
...@@ -11,10 +11,15 @@...@@ -11,10 +11,15 @@
11#define _LIBCPP_THREADING_SUPPORT11#define _LIBCPP_THREADING_SUPPORT
1212
13#include <__config>13#include <__config>
14#include <__availability>
14#include <chrono>15#include <chrono>
15#include <iosfwd>16#include <iosfwd>
16#include <errno.h>17#include <errno.h>
1718
19#ifdef __MVS__
20# include <support/ibm/nanosleep.h>
21#endif
22
18#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER23#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
19#pragma GCC system_header24#pragma GCC system_header
20#endif25#endif
...@@ -26,7 +31,7 @@...@@ -26,7 +31,7 @@
26#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)31#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
27# include <pthread.h>32# include <pthread.h>
28# include <sched.h>33# include <sched.h>
29# ifdef __APPLE__34# if defined(__APPLE__) || defined(__MVS__)
30# define _LIBCPP_NO_NATIVE_SEMAPHORES35# define _LIBCPP_NO_NATIVE_SEMAPHORES
31# endif36# endif
32# ifndef _LIBCPP_NO_NATIVE_SEMAPHORES37# ifndef _LIBCPP_NO_NATIVE_SEMAPHORES
...@@ -82,11 +87,14 @@ typedef pthread_once_t __libcpp_exec_once_flag;...@@ -82,11 +87,14 @@ typedef pthread_once_t __libcpp_exec_once_flag;
82#define _LIBCPP_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT87#define _LIBCPP_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT
8388
84// Thread id89// Thread id
85typedef pthread_t __libcpp_thread_id;90#if defined(__MVS__)
91 typedef unsigned long long __libcpp_thread_id;
92#else
93 typedef pthread_t __libcpp_thread_id;
94#endif
8695
87// Thread96// Thread
88#define _LIBCPP_NULL_THREAD 0U97#define _LIBCPP_NULL_THREAD ((__libcpp_thread_t()))
89
90typedef pthread_t __libcpp_thread_t;98typedef pthread_t __libcpp_thread_t;
9199
92// Thread Local Storage100// Thread Local Storage
...@@ -278,24 +286,21 @@ int __libcpp_tls_set(__libcpp_tls_key __key, void *__p);...@@ -278,24 +286,21 @@ int __libcpp_tls_set(__libcpp_tls_key __key, void *__p);
278#endif // !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)286#endif // !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
279287
280struct __libcpp_timed_backoff_policy {288struct __libcpp_timed_backoff_policy {
281 _LIBCPP_THREAD_ABI_VISIBILITY289 _LIBCPP_INLINE_VISIBILITY
282 bool operator()(chrono::nanoseconds __elapsed) const;290 bool operator()(chrono::nanoseconds __elapsed) const
291 {
292 if(__elapsed > chrono::milliseconds(128))
293 __libcpp_thread_sleep_for(chrono::milliseconds(8));
294 else if(__elapsed > chrono::microseconds(64))
295 __libcpp_thread_sleep_for(__elapsed / 2);
296 else if(__elapsed > chrono::microseconds(4))
297 __libcpp_thread_yield();
298 else
299 {} // poll
300 return false;
301 }
283};302};
284303
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;304static _LIBCPP_CONSTEXPR const int __libcpp_polling_count = 64;
300305
301template<class _Fn, class _BFn>306template<class _Fn, class _BFn>
...@@ -484,7 +489,7 @@ int __libcpp_execute_once(__libcpp_exec_once_flag *flag,...@@ -484,7 +489,7 @@ int __libcpp_execute_once(__libcpp_exec_once_flag *flag,
484// Returns non-zero if the thread ids are equal, otherwise 0489// Returns non-zero if the thread ids are equal, otherwise 0
485bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2)490bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2)
486{491{
487 return pthread_equal(t1, t2) != 0;492 return t1 == t2;
488}493}
489494
490// Returns non-zero if t1 < t2, otherwise 0495// Returns non-zero if t1 < t2, otherwise 0
...@@ -495,28 +500,33 @@ bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2)...@@ -495,28 +500,33 @@ bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2)
495500
496// Thread501// Thread
497bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) {502bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) {
498 return *__t == 0;503 return *__t == __libcpp_thread_t();
499}504}
500505
501int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),506int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
502 void *__arg)507 void *__arg)
503{508{
504 return pthread_create(__t, 0, __func, __arg);509 return pthread_create(__t, nullptr, __func, __arg);
505}510}
506511
507__libcpp_thread_id __libcpp_thread_get_current_id()512__libcpp_thread_id __libcpp_thread_get_current_id()
508{513{
509 return pthread_self();514 const __libcpp_thread_t thread = pthread_self();
515 return __libcpp_thread_get_id(&thread);
510}516}
511517
512__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t)518__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t)
513{519{
520#if defined(__MVS__)
521 return __t->__;
522#else
514 return *__t;523 return *__t;
524#endif
515}525}
516526
517int __libcpp_thread_join(__libcpp_thread_t *__t)527int __libcpp_thread_join(__libcpp_thread_t *__t)
518{528{
519 return pthread_join(*__t, 0);529 return pthread_join(*__t, nullptr);
520}530}
521531
522int __libcpp_thread_detach(__libcpp_thread_t *__t)532int __libcpp_thread_detach(__libcpp_thread_t *__t)
...@@ -651,7 +661,7 @@ bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2)...@@ -651,7 +661,7 @@ bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2)
651661
652// Thread662// Thread
653bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) {663bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) {
654 return *__t == 0;664 return __libcpp_thread_get_id(__t) == 0;
655}665}
656666
657int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),667int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
lib/libcxx/include/__tree+15-115
...@@ -533,19 +533,17 @@ __tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEPT...@@ -533,19 +533,17 @@ __tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEPT
533// node traits533// node traits
534534
535535
536#ifndef _LIBCPP_CXX03_LANG
537template <class _Tp>536template <class _Tp>
538struct __is_tree_value_type_imp : false_type {};537struct __is_tree_value_type_imp : false_type {};
539538
540template <class _Key, class _Value>539template <class _Key, class _Value>
541struct __is_tree_value_type_imp<__value_type<_Key, _Value>> : true_type {};540struct __is_tree_value_type_imp<__value_type<_Key, _Value> > : true_type {};
542541
543template <class ..._Args>542template <class ..._Args>
544struct __is_tree_value_type : false_type {};543struct __is_tree_value_type : false_type {};
545544
546template <class _One>545template <class _One>
547struct __is_tree_value_type<_One> : __is_tree_value_type_imp<typename __uncvref<_One>::type> {};546struct __is_tree_value_type<_One> : __is_tree_value_type_imp<typename __uncvref<_One>::type> {};
548#endif
549547
550template <class _Tp>548template <class _Tp>
551struct __tree_key_value_types {549struct __tree_key_value_types {
...@@ -566,12 +564,10 @@ struct __tree_key_value_types {...@@ -566,12 +564,10 @@ struct __tree_key_value_types {
566 static __container_value_type* __get_ptr(__node_value_type& __n) {564 static __container_value_type* __get_ptr(__node_value_type& __n) {
567 return _VSTD::addressof(__n);565 return _VSTD::addressof(__n);
568 }566 }
569#ifndef _LIBCPP_CXX03_LANG
570 _LIBCPP_INLINE_VISIBILITY567 _LIBCPP_INLINE_VISIBILITY
571 static __container_value_type&& __move(__node_value_type& __v) {568 static __container_value_type&& __move(__node_value_type& __v) {
572 return _VSTD::move(__v);569 return _VSTD::move(__v);
573 }570 }
574#endif
575};571};
576572
577template <class _Key, class _Tp>573template <class _Key, class _Tp>
...@@ -616,12 +612,10 @@ struct __tree_key_value_types<__value_type<_Key, _Tp> > {...@@ -616,12 +612,10 @@ struct __tree_key_value_types<__value_type<_Key, _Tp> > {
616 return _VSTD::addressof(__n.__get_value());612 return _VSTD::addressof(__n.__get_value());
617 }613 }
618614
619#ifndef _LIBCPP_CXX03_LANG
620 _LIBCPP_INLINE_VISIBILITY615 _LIBCPP_INLINE_VISIBILITY
621 static pair<key_type&&, mapped_type&&> __move(__node_value_type& __v) {616 static pair<key_type&&, mapped_type&&> __move(__node_value_type& __v) {
622 return __v.__move();617 return __v.__move();
623 }618 }
624#endif
625};619};
626620
627template <class _VoidPtr>621template <class _VoidPtr>
...@@ -973,7 +967,7 @@ private:...@@ -973,7 +967,7 @@ private:
973967
974template<class _Tp, class _Compare>968template<class _Tp, class _Compare>
975#ifndef _LIBCPP_CXX03_LANG969#ifndef _LIBCPP_CXX03_LANG
976 _LIBCPP_DIAGNOSE_WARNING(!std::__invokable<_Compare const&, _Tp const&, _Tp const&>::value,970 _LIBCPP_DIAGNOSE_WARNING(!__invokable<_Compare const&, _Tp const&, _Tp const&>::value,
977 "the specified comparator type does not provide a viable const call operator")971 "the specified comparator type does not provide a viable const call operator")
978#endif972#endif
979int __diagnose_non_const_comparator();973int __diagnose_non_const_comparator();
...@@ -1103,7 +1097,6 @@ public:...@@ -1103,7 +1097,6 @@ public:
1103 void __assign_unique(_ForwardIterator __first, _ForwardIterator __last);1097 void __assign_unique(_ForwardIterator __first, _ForwardIterator __last);
1104 template <class _InputIterator>1098 template <class _InputIterator>
1105 void __assign_multi(_InputIterator __first, _InputIterator __last);1099 void __assign_multi(_InputIterator __first, _InputIterator __last);
1106#ifndef _LIBCPP_CXX03_LANG
1107 __tree(__tree&& __t)1100 __tree(__tree&& __t)
1108 _NOEXCEPT_(1101 _NOEXCEPT_(
1109 is_nothrow_move_constructible<__node_allocator>::value &&1102 is_nothrow_move_constructible<__node_allocator>::value &&
...@@ -1114,8 +1107,6 @@ public:...@@ -1114,8 +1107,6 @@ public:
1114 __node_traits::propagate_on_container_move_assignment::value &&1107 __node_traits::propagate_on_container_move_assignment::value &&
1115 is_nothrow_move_assignable<value_compare>::value &&1108 is_nothrow_move_assignable<value_compare>::value &&
1116 is_nothrow_move_assignable<__node_allocator>::value);1109 is_nothrow_move_assignable<__node_allocator>::value);
1117#endif // _LIBCPP_CXX03_LANG
1118
1119 ~__tree();1110 ~__tree();
11201111
1121 _LIBCPP_INLINE_VISIBILITY1112 _LIBCPP_INLINE_VISIBILITY
...@@ -1129,7 +1120,7 @@ public:...@@ -1129,7 +1120,7 @@ public:
11291120
1130 _LIBCPP_INLINE_VISIBILITY1121 _LIBCPP_INLINE_VISIBILITY
1131 size_type max_size() const _NOEXCEPT1122 size_type max_size() const _NOEXCEPT
1132 {return std::min<size_type>(1123 {return _VSTD::min<size_type>(
1133 __node_traits::max_size(__node_alloc()),1124 __node_traits::max_size(__node_alloc()),
1134 numeric_limits<difference_type >::max());}1125 numeric_limits<difference_type >::max());}
11351126
...@@ -1146,12 +1137,11 @@ public:...@@ -1146,12 +1137,11 @@ public:
1146 _NOEXCEPT_(__is_nothrow_swappable<value_compare>::value);1137 _NOEXCEPT_(__is_nothrow_swappable<value_compare>::value);
1147#endif1138#endif
11481139
1149#ifndef _LIBCPP_CXX03_LANG
1150 template <class _Key, class ..._Args>1140 template <class _Key, class ..._Args>
1151 pair<iterator, bool>1141 pair<iterator, bool>
1152 __emplace_unique_key_args(_Key const&, _Args&&... __args);1142 __emplace_unique_key_args(_Key const&, _Args&&... __args);
1153 template <class _Key, class ..._Args>1143 template <class _Key, class ..._Args>
1154 iterator1144 pair<iterator, bool>
1155 __emplace_hint_unique_key_args(const_iterator, _Key const&, _Args&&...);1145 __emplace_hint_unique_key_args(const_iterator, _Key const&, _Args&&...);
11561146
1157 template <class... _Args>1147 template <class... _Args>
...@@ -1225,7 +1215,7 @@ public:...@@ -1225,7 +1215,7 @@ public:
1225 >::type __emplace_hint_unique(const_iterator __p, _First&& __f, _Second&& __s) {1215 >::type __emplace_hint_unique(const_iterator __p, _First&& __f, _Second&& __s) {
1226 return __emplace_hint_unique_key_args(__p, __f,1216 return __emplace_hint_unique_key_args(__p, __f,
1227 _VSTD::forward<_First>(__f),1217 _VSTD::forward<_First>(__f),
1228 _VSTD::forward<_Second>(__s));1218 _VSTD::forward<_Second>(__s)).first;
1229 }1219 }
12301220
1231 template <class... _Args>1221 template <class... _Args>
...@@ -1245,25 +1235,16 @@ public:...@@ -1245,25 +1235,16 @@ public:
1245 _LIBCPP_INLINE_VISIBILITY1235 _LIBCPP_INLINE_VISIBILITY
1246 iterator1236 iterator
1247 __emplace_hint_unique_extract_key(const_iterator __p, _Pp&& __x, __extract_key_self_tag) {1237 __emplace_hint_unique_extract_key(const_iterator __p, _Pp&& __x, __extract_key_self_tag) {
1248 return __emplace_hint_unique_key_args(__p, __x, _VSTD::forward<_Pp>(__x));1238 return __emplace_hint_unique_key_args(__p, __x, _VSTD::forward<_Pp>(__x)).first;
1249 }1239 }
12501240
1251 template <class _Pp>1241 template <class _Pp>
1252 _LIBCPP_INLINE_VISIBILITY1242 _LIBCPP_INLINE_VISIBILITY
1253 iterator1243 iterator
1254 __emplace_hint_unique_extract_key(const_iterator __p, _Pp&& __x, __extract_key_first_tag) {1244 __emplace_hint_unique_extract_key(const_iterator __p, _Pp&& __x, __extract_key_first_tag) {
1255 return __emplace_hint_unique_key_args(__p, __x.first, _VSTD::forward<_Pp>(__x));1245 return __emplace_hint_unique_key_args(__p, __x.first, _VSTD::forward<_Pp>(__x)).first;
1256 }1246 }
12571247
1258#else
1259 template <class _Key, class _Args>
1260 _LIBCPP_INLINE_VISIBILITY
1261 pair<iterator, bool> __emplace_unique_key_args(_Key const&, _Args& __args);
1262 template <class _Key, class _Args>
1263 _LIBCPP_INLINE_VISIBILITY
1264 iterator __emplace_hint_unique_key_args(const_iterator, _Key const&, _Args&);
1265#endif
1266
1267 _LIBCPP_INLINE_VISIBILITY1248 _LIBCPP_INLINE_VISIBILITY
1268 pair<iterator, bool> __insert_unique(const __container_value_type& __v) {1249 pair<iterator, bool> __insert_unique(const __container_value_type& __v) {
1269 return __emplace_unique_key_args(_NodeTypes::__get_key(__v), __v);1250 return __emplace_unique_key_args(_NodeTypes::__get_key(__v), __v);
...@@ -1271,15 +1252,9 @@ public:...@@ -1271,15 +1252,9 @@ public:
12711252
1272 _LIBCPP_INLINE_VISIBILITY1253 _LIBCPP_INLINE_VISIBILITY
1273 iterator __insert_unique(const_iterator __p, const __container_value_type& __v) {1254 iterator __insert_unique(const_iterator __p, const __container_value_type& __v) {
1274 return __emplace_hint_unique_key_args(__p, _NodeTypes::__get_key(__v), __v);1255 return __emplace_hint_unique_key_args(__p, _NodeTypes::__get_key(__v), __v).first;
1275 }1256 }
12761257
1277#ifdef _LIBCPP_CXX03_LANG
1278 _LIBCPP_INLINE_VISIBILITY
1279 iterator __insert_multi(const __container_value_type& __v);
1280 _LIBCPP_INLINE_VISIBILITY
1281 iterator __insert_multi(const_iterator __p, const __container_value_type& __v);
1282#else
1283 _LIBCPP_INLINE_VISIBILITY1258 _LIBCPP_INLINE_VISIBILITY
1284 pair<iterator, bool> __insert_unique(__container_value_type&& __v) {1259 pair<iterator, bool> __insert_unique(__container_value_type&& __v) {
1285 return __emplace_unique_key_args(_NodeTypes::__get_key(__v), _VSTD::move(__v));1260 return __emplace_unique_key_args(_NodeTypes::__get_key(__v), _VSTD::move(__v));
...@@ -1287,7 +1262,7 @@ public:...@@ -1287,7 +1262,7 @@ public:
12871262
1288 _LIBCPP_INLINE_VISIBILITY1263 _LIBCPP_INLINE_VISIBILITY
1289 iterator __insert_unique(const_iterator __p, __container_value_type&& __v) {1264 iterator __insert_unique(const_iterator __p, __container_value_type&& __v) {
1290 return __emplace_hint_unique_key_args(__p, _NodeTypes::__get_key(__v), _VSTD::move(__v));1265 return __emplace_hint_unique_key_args(__p, _NodeTypes::__get_key(__v), _VSTD::move(__v)).first;
1291 }1266 }
12921267
1293 template <class _Vp, class = typename enable_if<1268 template <class _Vp, class = typename enable_if<
...@@ -1332,8 +1307,6 @@ public:...@@ -1332,8 +1307,6 @@ public:
1332 return __emplace_hint_multi(__p, _VSTD::forward<_Vp>(__v));1307 return __emplace_hint_multi(__p, _VSTD::forward<_Vp>(__v));
1333 }1308 }
13341309
1335#endif // !_LIBCPP_CXX03_LANG
1336
1337 _LIBCPP_INLINE_VISIBILITY1310 _LIBCPP_INLINE_VISIBILITY
1338 pair<iterator, bool> __node_assign_unique(const __container_value_type& __v, __node_pointer __dest);1311 pair<iterator, bool> __node_assign_unique(const __container_value_type& __v, __node_pointer __dest);
13391312
...@@ -1455,7 +1428,7 @@ private:...@@ -1455,7 +1428,7 @@ private:
1455 __node_base_pointer&1428 __node_base_pointer&
1456 __find_leaf(const_iterator __hint,1429 __find_leaf(const_iterator __hint,
1457 __parent_pointer& __parent, const key_type& __v);1430 __parent_pointer& __parent, const key_type& __v);
1458 // FIXME: Make this function const qualified. Unfortunetly doing so1431 // FIXME: Make this function const qualified. Unfortunately doing so
1459 // breaks existing code which uses non-const callable comparators.1432 // breaks existing code which uses non-const callable comparators.
1460 template <class _Key>1433 template <class _Key>
1461 __node_base_pointer&1434 __node_base_pointer&
...@@ -1471,12 +1444,8 @@ private:...@@ -1471,12 +1444,8 @@ private:
1471 __node_base_pointer& __dummy,1444 __node_base_pointer& __dummy,
1472 const _Key& __v);1445 const _Key& __v);
14731446
1474#ifndef _LIBCPP_CXX03_LANG
1475 template <class ..._Args>1447 template <class ..._Args>
1476 __node_holder __construct_node(_Args&& ...__args);1448 __node_holder __construct_node(_Args&& ...__args);
1477#else
1478 __node_holder __construct_node(const __container_value_type& __v);
1479#endif
14801449
1481 void destroy(__node_pointer __nd) _NOEXCEPT;1450 void destroy(__node_pointer __nd) _NOEXCEPT;
14821451
...@@ -1706,8 +1675,6 @@ __tree<_Tp, _Compare, _Allocator>::__tree(const __tree& __t)...@@ -1706,8 +1675,6 @@ __tree<_Tp, _Compare, _Allocator>::__tree(const __tree& __t)
1706 __begin_node() = __end_node();1675 __begin_node() = __end_node();
1707}1676}
17081677
1709#ifndef _LIBCPP_CXX03_LANG
1710
1711template <class _Tp, class _Compare, class _Allocator>1678template <class _Tp, class _Compare, class _Allocator>
1712__tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t)1679__tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t)
1713 _NOEXCEPT_(1680 _NOEXCEPT_(
...@@ -1814,8 +1781,6 @@ __tree<_Tp, _Compare, _Allocator>::operator=(__tree&& __t)...@@ -1814,8 +1781,6 @@ __tree<_Tp, _Compare, _Allocator>::operator=(__tree&& __t)
1814 return *this;1781 return *this;
1815}1782}
18161783
1817#endif // _LIBCPP_CXX03_LANG
1818
1819template <class _Tp, class _Compare, class _Allocator>1784template <class _Tp, class _Compare, class _Allocator>
1820__tree<_Tp, _Compare, _Allocator>::~__tree()1785__tree<_Tp, _Compare, _Allocator>::~__tree()
1821{1786{
...@@ -1854,7 +1819,7 @@ __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t)...@@ -1854,7 +1819,7 @@ __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t)
1854 using _VSTD::swap;1819 using _VSTD::swap;
1855 swap(__begin_node_, __t.__begin_node_);1820 swap(__begin_node_, __t.__begin_node_);
1856 swap(__pair1_.first(), __t.__pair1_.first());1821 swap(__pair1_.first(), __t.__pair1_.first());
1857 __swap_allocator(__node_alloc(), __t.__node_alloc());1822 _VSTD::__swap_allocator(__node_alloc(), __t.__node_alloc());
1858 __pair3_.swap(__t.__pair3_);1823 __pair3_.swap(__t.__pair3_);
1859 if (size() == 0)1824 if (size() == 0)
1860 __begin_node() = __end_node();1825 __begin_node() = __end_node();
...@@ -2117,17 +2082,10 @@ void __tree<_Tp, _Compare, _Allocator>::__insert_node_at(...@@ -2117,17 +2082,10 @@ void __tree<_Tp, _Compare, _Allocator>::__insert_node_at(
2117 ++size();2082 ++size();
2118}2083}
21192084
2120#ifndef _LIBCPP_CXX03_LANG
2121template <class _Tp, class _Compare, class _Allocator>2085template <class _Tp, class _Compare, class _Allocator>
2122template <class _Key, class... _Args>2086template <class _Key, class... _Args>
2123pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>2087pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>
2124__tree<_Tp, _Compare, _Allocator>::__emplace_unique_key_args(_Key const& __k, _Args&&... __args)2088__tree<_Tp, _Compare, _Allocator>::__emplace_unique_key_args(_Key const& __k, _Args&&... __args)
2125#else
2126template <class _Tp, class _Compare, class _Allocator>
2127template <class _Key, class _Args>
2128pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>
2129__tree<_Tp, _Compare, _Allocator>::__emplace_unique_key_args(_Key const& __k, _Args& __args)
2130#endif
2131{2089{
2132 __parent_pointer __parent;2090 __parent_pointer __parent;
2133 __node_base_pointer& __child = __find_equal(__parent, __k);2091 __node_base_pointer& __child = __find_equal(__parent, __k);
...@@ -2135,11 +2093,7 @@ __tree<_Tp, _Compare, _Allocator>::__emplace_unique_key_args(_Key const& __k, _A...@@ -2135,11 +2093,7 @@ __tree<_Tp, _Compare, _Allocator>::__emplace_unique_key_args(_Key const& __k, _A
2135 bool __inserted = false;2093 bool __inserted = false;
2136 if (__child == nullptr)2094 if (__child == nullptr)
2137 {2095 {
2138#ifndef _LIBCPP_CXX03_LANG
2139 __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);2096 __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
2140#else
2141 __node_holder __h = __construct_node(__args);
2142#endif
2143 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));2097 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
2144 __r = __h.release();2098 __r = __h.release();
2145 __inserted = true;2099 __inserted = true;
...@@ -2147,41 +2101,27 @@ __tree<_Tp, _Compare, _Allocator>::__emplace_unique_key_args(_Key const& __k, _A...@@ -2147,41 +2101,27 @@ __tree<_Tp, _Compare, _Allocator>::__emplace_unique_key_args(_Key const& __k, _A
2147 return pair<iterator, bool>(iterator(__r), __inserted);2101 return pair<iterator, bool>(iterator(__r), __inserted);
2148}2102}
21492103
2150
2151#ifndef _LIBCPP_CXX03_LANG
2152template <class _Tp, class _Compare, class _Allocator>2104template <class _Tp, class _Compare, class _Allocator>
2153template <class _Key, class... _Args>2105template <class _Key, class... _Args>
2154typename __tree<_Tp, _Compare, _Allocator>::iterator2106pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>
2155__tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_key_args(2107__tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_key_args(
2156 const_iterator __p, _Key const& __k, _Args&&... __args)2108 const_iterator __p, _Key const& __k, _Args&&... __args)
2157#else
2158template <class _Tp, class _Compare, class _Allocator>
2159template <class _Key, class _Args>
2160typename __tree<_Tp, _Compare, _Allocator>::iterator
2161__tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_key_args(
2162 const_iterator __p, _Key const& __k, _Args& __args)
2163#endif
2164{2109{
2165 __parent_pointer __parent;2110 __parent_pointer __parent;
2166 __node_base_pointer __dummy;2111 __node_base_pointer __dummy;
2167 __node_base_pointer& __child = __find_equal(__p, __parent, __dummy, __k);2112 __node_base_pointer& __child = __find_equal(__p, __parent, __dummy, __k);
2168 __node_pointer __r = static_cast<__node_pointer>(__child);2113 __node_pointer __r = static_cast<__node_pointer>(__child);
2114 bool __inserted = false;
2169 if (__child == nullptr)2115 if (__child == nullptr)
2170 {2116 {
2171#ifndef _LIBCPP_CXX03_LANG
2172 __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);2117 __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
2173#else
2174 __node_holder __h = __construct_node(__args);
2175#endif
2176 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));2118 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
2177 __r = __h.release();2119 __r = __h.release();
2120 __inserted = true;
2178 }2121 }
2179 return iterator(__r);2122 return pair<iterator, bool>(iterator(__r), __inserted);
2180}2123}
21812124
2182
2183#ifndef _LIBCPP_CXX03_LANG
2184
2185template <class _Tp, class _Compare, class _Allocator>2125template <class _Tp, class _Compare, class _Allocator>
2186template <class ..._Args>2126template <class ..._Args>
2187typename __tree<_Tp, _Compare, _Allocator>::__node_holder2127typename __tree<_Tp, _Compare, _Allocator>::__node_holder
...@@ -2259,46 +2199,6 @@ __tree<_Tp, _Compare, _Allocator>::__emplace_hint_multi(const_iterator __p,...@@ -2259,46 +2199,6 @@ __tree<_Tp, _Compare, _Allocator>::__emplace_hint_multi(const_iterator __p,
2259 return iterator(static_cast<__node_pointer>(__h.release()));2199 return iterator(static_cast<__node_pointer>(__h.release()));
2260}2200}
22612201
2262
2263#else // _LIBCPP_CXX03_LANG
2264
2265template <class _Tp, class _Compare, class _Allocator>
2266typename __tree<_Tp, _Compare, _Allocator>::__node_holder
2267__tree<_Tp, _Compare, _Allocator>::__construct_node(const __container_value_type& __v)
2268{
2269 __node_allocator& __na = __node_alloc();
2270 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
2271 __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), __v);
2272 __h.get_deleter().__value_constructed = true;
2273 return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03
2274}
2275
2276#endif // _LIBCPP_CXX03_LANG
2277
2278#ifdef _LIBCPP_CXX03_LANG
2279template <class _Tp, class _Compare, class _Allocator>
2280typename __tree<_Tp, _Compare, _Allocator>::iterator
2281__tree<_Tp, _Compare, _Allocator>::__insert_multi(const __container_value_type& __v)
2282{
2283 __parent_pointer __parent;
2284 __node_base_pointer& __child = __find_leaf_high(__parent, _NodeTypes::__get_key(__v));
2285 __node_holder __h = __construct_node(__v);
2286 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
2287 return iterator(__h.release());
2288}
2289
2290template <class _Tp, class _Compare, class _Allocator>
2291typename __tree<_Tp, _Compare, _Allocator>::iterator
2292__tree<_Tp, _Compare, _Allocator>::__insert_multi(const_iterator __p, const __container_value_type& __v)
2293{
2294 __parent_pointer __parent;
2295 __node_base_pointer& __child = __find_leaf(__p, __parent, _NodeTypes::__get_key(__v));
2296 __node_holder __h = __construct_node(__v);
2297 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
2298 return iterator(__h.release());
2299}
2300#endif
2301
2302template <class _Tp, class _Compare, class _Allocator>2202template <class _Tp, class _Compare, class _Allocator>
2303pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>2203pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>
2304__tree<_Tp, _Compare, _Allocator>::__node_assign_unique(const __container_value_type& __v, __node_pointer __nd)2204__tree<_Tp, _Compare, _Allocator>::__node_assign_unique(const __container_value_type& __v, __node_pointer __nd)
lib/libcxx/include/algorithm+273-248
...@@ -47,16 +47,16 @@ template <class InputIterator, class Predicate>...@@ -47,16 +47,16 @@ template <class InputIterator, class Predicate>
47 find_if(InputIterator first, InputIterator last, Predicate pred);47 find_if(InputIterator first, InputIterator last, Predicate pred);
4848
49template<class InputIterator, class Predicate>49template<class InputIterator, class Predicate>
50 InputIterator // constexpr in C++2050 constexpr InputIterator // constexpr in C++20
51 find_if_not(InputIterator first, InputIterator last, Predicate pred);51 find_if_not(InputIterator first, InputIterator last, Predicate pred);
5252
53template <class ForwardIterator1, class ForwardIterator2>53template <class ForwardIterator1, class ForwardIterator2>
54 ForwardIterator1 // constexpr in C++2054 constexpr ForwardIterator1 // constexpr in C++20
55 find_end(ForwardIterator1 first1, ForwardIterator1 last1,55 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
56 ForwardIterator2 first2, ForwardIterator2 last2);56 ForwardIterator2 first2, ForwardIterator2 last2);
5757
58template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>58template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
59 ForwardIterator1 // constexpr in C++2059 constexpr ForwardIterator1 // constexpr in C++20
60 find_end(ForwardIterator1 first1, ForwardIterator1 last1,60 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
61 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);61 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
6262
...@@ -185,11 +185,11 @@ template <class BidirectionalIterator1, class BidirectionalIterator2>...@@ -185,11 +185,11 @@ template <class BidirectionalIterator1, class BidirectionalIterator2>
185 BidirectionalIterator2 result);185 BidirectionalIterator2 result);
186186
187template <class ForwardIterator1, class ForwardIterator2>187template <class ForwardIterator1, class ForwardIterator2>
188 ForwardIterator2188 constexpr ForwardIterator2 // constexpr in C++20
189 swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2);189 swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2);
190190
191template <class ForwardIterator1, class ForwardIterator2>191template <class ForwardIterator1, class ForwardIterator2>
192 void192 constexpr void // constexpr in C++20
193 iter_swap(ForwardIterator1 a, ForwardIterator2 b);193 iter_swap(ForwardIterator1 a, ForwardIterator2 b);
194194
195template <class InputIterator, class OutputIterator, class UnaryOperation>195template <class InputIterator, class OutputIterator, class UnaryOperation>
...@@ -251,19 +251,19 @@ template <class InputIterator, class OutputIterator, class Predicate>...@@ -251,19 +251,19 @@ template <class InputIterator, class OutputIterator, class Predicate>
251 remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred);251 remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred);
252252
253template <class ForwardIterator>253template <class ForwardIterator>
254 ForwardIterator254 constexpr ForwardIterator // constexpr in C++20
255 unique(ForwardIterator first, ForwardIterator last);255 unique(ForwardIterator first, ForwardIterator last);
256256
257template <class ForwardIterator, class BinaryPredicate>257template <class ForwardIterator, class BinaryPredicate>
258 ForwardIterator258 constexpr ForwardIterator // constexpr in C++20
259 unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);259 unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
260260
261template <class InputIterator, class OutputIterator>261template <class InputIterator, class OutputIterator>
262 OutputIterator262 constexpr OutputIterator // constexpr in C++20
263 unique_copy(InputIterator first, InputIterator last, OutputIterator result);263 unique_copy(InputIterator first, InputIterator last, OutputIterator result);
264264
265template <class InputIterator, class OutputIterator, class BinaryPredicate>265template <class InputIterator, class OutputIterator, class BinaryPredicate>
266 OutputIterator266 constexpr OutputIterator // constexpr in C++20
267 unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred);267 unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred);
268268
269template <class BidirectionalIterator>269template <class BidirectionalIterator>
...@@ -275,11 +275,11 @@ template <class BidirectionalIterator, class OutputIterator>...@@ -275,11 +275,11 @@ template <class BidirectionalIterator, class OutputIterator>
275 reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result);275 reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result);
276276
277template <class ForwardIterator>277template <class ForwardIterator>
278 ForwardIterator278 constexpr ForwardIterator // constexpr in C++20
279 rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last);279 rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last);
280280
281template <class ForwardIterator, class OutputIterator>281template <class ForwardIterator, class OutputIterator>
282 OutputIterator282 constexpr OutputIterator // constexpr in C++20
283 rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result);283 rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result);
284284
285template <class RandomAccessIterator>285template <class RandomAccessIterator>
...@@ -329,7 +329,7 @@ template <class ForwardIterator>...@@ -329,7 +329,7 @@ template <class ForwardIterator>
329 is_sorted(ForwardIterator first, ForwardIterator last);329 is_sorted(ForwardIterator first, ForwardIterator last);
330330
331template <class ForwardIterator, class Compare>331template <class ForwardIterator, class Compare>
332 bool332 constexpr bool // constexpr in C++20
333 is_sorted(ForwardIterator first, ForwardIterator last, Compare comp);333 is_sorted(ForwardIterator first, ForwardIterator last, Compare comp);
334334
335template<class ForwardIterator>335template<class ForwardIterator>
...@@ -415,12 +415,12 @@ template <class ForwardIterator, class T, class Compare>...@@ -415,12 +415,12 @@ template <class ForwardIterator, class T, class Compare>
415 binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);415 binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
416416
417template <class InputIterator1, class InputIterator2, class OutputIterator>417template <class InputIterator1, class InputIterator2, class OutputIterator>
418 OutputIterator418 constexpr OutputIterator // constexpr in C++20
419 merge(InputIterator1 first1, InputIterator1 last1,419 merge(InputIterator1 first1, InputIterator1 last1,
420 InputIterator2 first2, InputIterator2 last2, OutputIterator result);420 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
421421
422template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>422template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
423 OutputIterator423 constexpr OutputIterator // constexpr in C++20
424 merge(InputIterator1 first1, InputIterator1 last1,424 merge(InputIterator1 first1, InputIterator1 last1,
425 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);425 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
426426
...@@ -441,12 +441,12 @@ template <class InputIterator1, class InputIterator2, class Compare>...@@ -441,12 +441,12 @@ template <class InputIterator1, class InputIterator2, class Compare>
441 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp);441 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp);
442442
443template <class InputIterator1, class InputIterator2, class OutputIterator>443template <class InputIterator1, class InputIterator2, class OutputIterator>
444 OutputIterator444 constexpr OutputIterator // constexpr in C++20
445 set_union(InputIterator1 first1, InputIterator1 last1,445 set_union(InputIterator1 first1, InputIterator1 last1,
446 InputIterator2 first2, InputIterator2 last2, OutputIterator result);446 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
447447
448template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>448template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
449 OutputIterator449 constexpr OutputIterator // constexpr in C++20
450 set_union(InputIterator1 first1, InputIterator1 last1,450 set_union(InputIterator1 first1, InputIterator1 last1,
451 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);451 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
452452
...@@ -461,22 +461,22 @@ template <class InputIterator1, class InputIterator2, class OutputIterator, clas...@@ -461,22 +461,22 @@ template <class InputIterator1, class InputIterator2, class OutputIterator, clas
461 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);461 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
462462
463template <class InputIterator1, class InputIterator2, class OutputIterator>463template <class InputIterator1, class InputIterator2, class OutputIterator>
464 OutputIterator464 constexpr OutputIterator // constexpr in C++20
465 set_difference(InputIterator1 first1, InputIterator1 last1,465 set_difference(InputIterator1 first1, InputIterator1 last1,
466 InputIterator2 first2, InputIterator2 last2, OutputIterator result);466 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
467467
468template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>468template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
469 OutputIterator469 constexpr OutputIterator // constexpr in C++20
470 set_difference(InputIterator1 first1, InputIterator1 last1,470 set_difference(InputIterator1 first1, InputIterator1 last1,
471 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);471 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
472472
473template <class InputIterator1, class InputIterator2, class OutputIterator>473template <class InputIterator1, class InputIterator2, class OutputIterator>
474 OutputIterator474 constexpr OutputIterator // constexpr in C++20
475 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,475 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
476 InputIterator2 first2, InputIterator2 last2, OutputIterator result);476 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
477477
478template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>478template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
479 OutputIterator479 constexpr OutputIterator // constexpr in C++20
480 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,480 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
481 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);481 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
482482
...@@ -529,82 +529,82 @@ template <class RandomAccessIterator, class Compare>...@@ -529,82 +529,82 @@ template <class RandomAccessIterator, class Compare>
529 is_heap_until(RandomAccessIterator first, RandomAccessiterator last, Compare comp);529 is_heap_until(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
530530
531template <class ForwardIterator>531template <class ForwardIterator>
532 ForwardIterator532 constexpr ForwardIterator // constexpr in C++14
533 min_element(ForwardIterator first, ForwardIterator last); // constexpr in C++14533 min_element(ForwardIterator first, ForwardIterator last);
534534
535template <class ForwardIterator, class Compare>535template <class ForwardIterator, class Compare>
536 ForwardIterator536 constexpr ForwardIterator // constexpr in C++14
537 min_element(ForwardIterator first, ForwardIterator last, Compare comp); // constexpr in C++14537 min_element(ForwardIterator first, ForwardIterator last, Compare comp);
538538
539template <class T>539template <class T>
540 const T&540 constexpr const T& // constexpr in C++14
541 min(const T& a, const T& b); // constexpr in C++14541 min(const T& a, const T& b);
542542
543template <class T, class Compare>543template <class T, class Compare>
544 const T&544 constexpr const T& // constexpr in C++14
545 min(const T& a, const T& b, Compare comp); // constexpr in C++14545 min(const T& a, const T& b, Compare comp);
546546
547template<class T>547template<class T>
548 T548 constexpr T // constexpr in C++14
549 min(initializer_list<T> t); // constexpr in C++14549 min(initializer_list<T> t);
550550
551template<class T, class Compare>551template<class T, class Compare>
552 T552 constexpr T // constexpr in C++14
553 min(initializer_list<T> t, Compare comp); // constexpr in C++14553 min(initializer_list<T> t, Compare comp);
554554
555template<class T>555template<class T>
556 constexpr const T& clamp( const T& v, const T& lo, const T& hi ); // C++17556 constexpr const T& clamp(const T& v, const T& lo, const T& hi); // C++17
557557
558template<class T, class Compare>558template<class T, class Compare>
559 constexpr const T& clamp( const T& v, const T& lo, const T& hi, Compare comp ); // C++17559 constexpr const T& clamp(const T& v, const T& lo, const T& hi, Compare comp); // C++17
560560
561template <class ForwardIterator>561template <class ForwardIterator>
562 ForwardIterator562 constexpr ForwardIterator // constexpr in C++14
563 max_element(ForwardIterator first, ForwardIterator last); // constexpr in C++14563 max_element(ForwardIterator first, ForwardIterator last);
564564
565template <class ForwardIterator, class Compare>565template <class ForwardIterator, class Compare>
566 ForwardIterator566 constexpr ForwardIterator // constexpr in C++14
567 max_element(ForwardIterator first, ForwardIterator last, Compare comp); // constexpr in C++14567 max_element(ForwardIterator first, ForwardIterator last, Compare comp);
568568
569template <class T>569template <class T>
570 const T&570 constexpr const T& // constexpr in C++14
571 max(const T& a, const T& b); // constexpr in C++14571 max(const T& a, const T& b);
572572
573template <class T, class Compare>573template <class T, class Compare>
574 const T&574 constexpr const T& // constexpr in C++14
575 max(const T& a, const T& b, Compare comp); // constexpr in C++14575 max(const T& a, const T& b, Compare comp);
576576
577template<class T>577template<class T>
578 T578 constexpr T // constexpr in C++14
579 max(initializer_list<T> t); // constexpr in C++14579 max(initializer_list<T> t);
580580
581template<class T, class Compare>581template<class T, class Compare>
582 T582 constexpr T // constexpr in C++14
583 max(initializer_list<T> t, Compare comp); // constexpr in C++14583 max(initializer_list<T> t, Compare comp);
584584
585template<class ForwardIterator>585template<class ForwardIterator>
586 pair<ForwardIterator, ForwardIterator>586 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
587 minmax_element(ForwardIterator first, ForwardIterator last); // constexpr in C++14587 minmax_element(ForwardIterator first, ForwardIterator last);
588588
589template<class ForwardIterator, class Compare>589template<class ForwardIterator, class Compare>
590 pair<ForwardIterator, ForwardIterator>590 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
591 minmax_element(ForwardIterator first, ForwardIterator last, Compare comp); // constexpr in C++14591 minmax_element(ForwardIterator first, ForwardIterator last, Compare comp);
592592
593template<class T>593template<class T>
594 pair<const T&, const T&>594 constexpr pair<const T&, const T&> // constexpr in C++14
595 minmax(const T& a, const T& b); // constexpr in C++14595 minmax(const T& a, const T& b);
596596
597template<class T, class Compare>597template<class T, class Compare>
598 pair<const T&, const T&>598 constexpr pair<const T&, const T&> // constexpr in C++14
599 minmax(const T& a, const T& b, Compare comp); // constexpr in C++14599 minmax(const T& a, const T& b, Compare comp);
600600
601template<class T>601template<class T>
602 pair<T, T>602 constexpr pair<T, T> // constexpr in C++14
603 minmax(initializer_list<T> t); // constexpr in C++14603 minmax(initializer_list<T> t);
604604
605template<class T, class Compare>605template<class T, class Compare>
606 pair<T, T>606 constexpr pair<T, T> // constexpr in C++14
607 minmax(initializer_list<T> t, Compare comp); // constexpr in C++14607 minmax(initializer_list<T> t, Compare comp);
608608
609template <class InputIterator1, class InputIterator2>609template <class InputIterator1, class InputIterator2>
610 constexpr bool // constexpr in C++20610 constexpr bool // constexpr in C++20
...@@ -895,7 +895,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17...@@ -895,7 +895,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
895_InputIterator895_InputIterator
896for_each_n(_InputIterator __first, _Size __orig_n, _Function __f)896for_each_n(_InputIterator __first, _Size __orig_n, _Function __f)
897{897{
898 typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize;898 typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
899 _IntegralSize __n = __orig_n;899 _IntegralSize __n = __orig_n;
900 while (__n > 0)900 while (__n > 0)
901 {901 {
...@@ -1614,7 +1614,7 @@ search_n(_ForwardIterator __first, _ForwardIterator __last,...@@ -1614,7 +1614,7 @@ search_n(_ForwardIterator __first, _ForwardIterator __last,
1614 _Size __count, const _Tp& __value_, _BinaryPredicate __pred)1614 _Size __count, const _Tp& __value_, _BinaryPredicate __pred)
1615{1615{
1616 return _VSTD::__search_n<typename add_lvalue_reference<_BinaryPredicate>::type>1616 return _VSTD::__search_n<typename add_lvalue_reference<_BinaryPredicate>::type>
1617 (__first, __last, __convert_to_integral(__count), __value_, __pred,1617 (__first, __last, _VSTD::__convert_to_integral(__count), __value_, __pred,
1618 typename iterator_traits<_ForwardIterator>::iterator_category());1618 typename iterator_traits<_ForwardIterator>::iterator_category());
1619}1619}
16201620
...@@ -1625,13 +1625,13 @@ _ForwardIterator...@@ -1625,13 +1625,13 @@ _ForwardIterator
1625search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value_)1625search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value_)
1626{1626{
1627 typedef typename iterator_traits<_ForwardIterator>::value_type __v;1627 typedef typename iterator_traits<_ForwardIterator>::value_type __v;
1628 return _VSTD::search_n(__first, __last, __convert_to_integral(__count),1628 return _VSTD::search_n(__first, __last, _VSTD::__convert_to_integral(__count),
1629 __value_, __equal_to<__v, _Tp>());1629 __value_, __equal_to<__v, _Tp>());
1630}1630}
16311631
1632// copy1632// copy
1633template <class _Iter>1633template <class _Iter>
1634inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171634inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
1635_Iter1635_Iter
1636__unwrap_iter(_Iter __i)1636__unwrap_iter(_Iter __i)
1637{1637{
...@@ -1639,7 +1639,7 @@ __unwrap_iter(_Iter __i)...@@ -1639,7 +1639,7 @@ __unwrap_iter(_Iter __i)
1639}1639}
16401640
1641template <class _Tp>1641template <class _Tp>
1642inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171642inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
1643typename enable_if1643typename enable_if
1644<1644<
1645 is_trivially_copy_assignable<_Tp>::value,1645 is_trivially_copy_assignable<_Tp>::value,
...@@ -1653,7 +1653,7 @@ __unwrap_iter(move_iterator<_Tp*> __i)...@@ -1653,7 +1653,7 @@ __unwrap_iter(move_iterator<_Tp*> __i)
1653#if _LIBCPP_DEBUG_LEVEL < 21653#if _LIBCPP_DEBUG_LEVEL < 2
16541654
1655template <class _Tp>1655template <class _Tp>
1656inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG1656inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
1657typename enable_if1657typename enable_if
1658<1658<
1659 is_trivially_copy_assignable<_Tp>::value,1659 is_trivially_copy_assignable<_Tp>::value,
...@@ -1665,7 +1665,7 @@ __unwrap_iter(__wrap_iter<_Tp*> __i)...@@ -1665,7 +1665,7 @@ __unwrap_iter(__wrap_iter<_Tp*> __i)
1665}1665}
16661666
1667template <class _Tp>1667template <class _Tp>
1668inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG1668inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
1669typename enable_if1669typename enable_if
1670<1670<
1671 is_trivially_copy_assignable<_Tp>::value,1671 is_trivially_copy_assignable<_Tp>::value,
...@@ -1679,7 +1679,7 @@ __unwrap_iter(__wrap_iter<const _Tp*> __i)...@@ -1679,7 +1679,7 @@ __unwrap_iter(__wrap_iter<const _Tp*> __i)
1679#else1679#else
16801680
1681template <class _Tp>1681template <class _Tp>
1682inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG1682inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
1683typename enable_if1683typename enable_if
1684<1684<
1685 is_trivially_copy_assignable<_Tp>::value,1685 is_trivially_copy_assignable<_Tp>::value,
...@@ -1707,7 +1707,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -1707,7 +1707,7 @@ inline _LIBCPP_INLINE_VISIBILITY
1707_OutputIterator1707_OutputIterator
1708__copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result)1708__copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
1709{1709{
1710 return __copy_constexpr(__first, __last, __result);1710 return _VSTD::__copy_constexpr(__first, __last, __result);
1711}1711}
17121712
1713template <class _Tp, class _Up>1713template <class _Tp, class _Up>
...@@ -1727,16 +1727,16 @@ __copy(_Tp* __first, _Tp* __last, _Up* __result)...@@ -1727,16 +1727,16 @@ __copy(_Tp* __first, _Tp* __last, _Up* __result)
1727}1727}
17281728
1729template <class _InputIterator, class _OutputIterator>1729template <class _InputIterator, class _OutputIterator>
1730inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED1730inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1731_OutputIterator1731_OutputIterator
1732copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result)1732copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
1733{1733{
1734 if (__libcpp_is_constant_evaluated()) {1734 if (__libcpp_is_constant_evaluated()) {
1735 return _VSTD::__copy_constexpr(1735 return _VSTD::__copy_constexpr(
1736 __unwrap_iter(__first), __unwrap_iter(__last), __unwrap_iter(__result));1736 _VSTD::__unwrap_iter(__first), _VSTD::__unwrap_iter(__last), _VSTD::__unwrap_iter(__result));
1737 } else {1737 } else {
1738 return _VSTD::__copy(1738 return _VSTD::__copy(
1739 __unwrap_iter(__first), __unwrap_iter(__last), __unwrap_iter(__result));1739 _VSTD::__unwrap_iter(__first), _VSTD::__unwrap_iter(__last), _VSTD::__unwrap_iter(__result));
1740 }1740 }
1741}1741}
17421742
...@@ -1757,7 +1757,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -1757,7 +1757,7 @@ inline _LIBCPP_INLINE_VISIBILITY
1757_OutputIterator1757_OutputIterator
1758__copy_backward(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result)1758__copy_backward(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result)
1759{1759{
1760 return __copy_backward_constexpr(__first, __last, __result);1760 return _VSTD::__copy_backward_constexpr(__first, __last, __result);
1761}1761}
17621762
1763template <class _Tp, class _Up>1763template <class _Tp, class _Up>
...@@ -1780,19 +1780,19 @@ __copy_backward(_Tp* __first, _Tp* __last, _Up* __result)...@@ -1780,19 +1780,19 @@ __copy_backward(_Tp* __first, _Tp* __last, _Up* __result)
1780}1780}
17811781
1782template <class _BidirectionalIterator1, class _BidirectionalIterator2>1782template <class _BidirectionalIterator1, class _BidirectionalIterator2>
1783inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED1783inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1784_BidirectionalIterator21784_BidirectionalIterator2
1785copy_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last,1785copy_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last,
1786 _BidirectionalIterator2 __result)1786 _BidirectionalIterator2 __result)
1787{1787{
1788 if (__libcpp_is_constant_evaluated()) {1788 if (__libcpp_is_constant_evaluated()) {
1789 return _VSTD::__copy_backward_constexpr(__unwrap_iter(__first),1789 return _VSTD::__copy_backward_constexpr(_VSTD::__unwrap_iter(__first),
1790 __unwrap_iter(__last),1790 _VSTD::__unwrap_iter(__last),
1791 __unwrap_iter(__result));1791 _VSTD::__unwrap_iter(__result));
1792 } else {1792 } else {
1793 return _VSTD::__copy_backward(__unwrap_iter(__first),1793 return _VSTD::__copy_backward(_VSTD::__unwrap_iter(__first),
1794 __unwrap_iter(__last),1794 _VSTD::__unwrap_iter(__last),
1795 __unwrap_iter(__result));1795 _VSTD::__unwrap_iter(__result));
1796 }1796 }
1797}1797}
17981798
...@@ -1818,7 +1818,7 @@ copy_if(_InputIterator __first, _InputIterator __last,...@@ -1818,7 +1818,7 @@ copy_if(_InputIterator __first, _InputIterator __last,
1818// copy_n1818// copy_n
18191819
1820template<class _InputIterator, class _Size, class _OutputIterator>1820template<class _InputIterator, class _Size, class _OutputIterator>
1821inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED1821inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1822typename enable_if1822typename enable_if
1823<1823<
1824 __is_cpp17_input_iterator<_InputIterator>::value &&1824 __is_cpp17_input_iterator<_InputIterator>::value &&
...@@ -1827,7 +1827,7 @@ typename enable_if...@@ -1827,7 +1827,7 @@ typename enable_if
1827>::type1827>::type
1828copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)1828copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
1829{1829{
1830 typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize;1830 typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
1831 _IntegralSize __n = __orig_n;1831 _IntegralSize __n = __orig_n;
1832 if (__n > 0)1832 if (__n > 0)
1833 {1833 {
...@@ -1844,7 +1844,7 @@ copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)...@@ -1844,7 +1844,7 @@ copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
1844}1844}
18451845
1846template<class _InputIterator, class _Size, class _OutputIterator>1846template<class _InputIterator, class _Size, class _OutputIterator>
1847inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED1847inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1848typename enable_if1848typename enable_if
1849<1849<
1850 __is_cpp17_random_access_iterator<_InputIterator>::value,1850 __is_cpp17_random_access_iterator<_InputIterator>::value,
...@@ -1852,25 +1852,35 @@ typename enable_if...@@ -1852,25 +1852,35 @@ typename enable_if
1852>::type1852>::type
1853copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)1853copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
1854{1854{
1855 typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize;1855 typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
1856 _IntegralSize __n = __orig_n;1856 _IntegralSize __n = __orig_n;
1857 return _VSTD::copy(__first, __first + __n, __result);1857 return _VSTD::copy(__first, __first + __n, __result);
1858}1858}
18591859
1860// move1860// move
18611861
1862// __move_constexpr exists so that __move doesn't call itself when delegating to the constexpr
1863// version of __move.
1862template <class _InputIterator, class _OutputIterator>1864template <class _InputIterator, class _OutputIterator>
1863inline _LIBCPP_INLINE_VISIBILITY1865inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1864_OutputIterator1866_OutputIterator
1865__move(_InputIterator __first, _InputIterator __last, _OutputIterator __result)1867__move_constexpr(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
1866{1868{
1867 for (; __first != __last; ++__first, (void) ++__result)1869 for (; __first != __last; ++__first, (void) ++__result)
1868 *__result = _VSTD::move(*__first);1870 *__result = _VSTD::move(*__first);
1869 return __result;1871 return __result;
1870}1872}
18711873
1874template <class _InputIterator, class _OutputIterator>
1875inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1876_OutputIterator
1877__move(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
1878{
1879 return _VSTD::__move_constexpr(__first, __last, __result);
1880}
1881
1872template <class _Tp, class _Up>1882template <class _Tp, class _Up>
1873inline _LIBCPP_INLINE_VISIBILITY1883inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1874typename enable_if1884typename enable_if
1875<1885<
1876 is_same<typename remove_const<_Tp>::type, _Up>::value &&1886 is_same<typename remove_const<_Tp>::type, _Up>::value &&
...@@ -1879,6 +1889,8 @@ typename enable_if...@@ -1879,6 +1889,8 @@ typename enable_if
1879>::type1889>::type
1880__move(_Tp* __first, _Tp* __last, _Up* __result)1890__move(_Tp* __first, _Tp* __last, _Up* __result)
1881{1891{
1892 if (__libcpp_is_constant_evaluated())
1893 return _VSTD::__move_constexpr(__first, __last, __result);
1882 const size_t __n = static_cast<size_t>(__last - __first);1894 const size_t __n = static_cast<size_t>(__last - __first);
1883 if (__n > 0)1895 if (__n > 0)
1884 _VSTD::memmove(__result, __first, __n * sizeof(_Up));1896 _VSTD::memmove(__result, __first, __n * sizeof(_Up));
...@@ -1886,27 +1898,37 @@ __move(_Tp* __first, _Tp* __last, _Up* __result)...@@ -1886,27 +1898,37 @@ __move(_Tp* __first, _Tp* __last, _Up* __result)
1886}1898}
18871899
1888template <class _InputIterator, class _OutputIterator>1900template <class _InputIterator, class _OutputIterator>
1889inline _LIBCPP_INLINE_VISIBILITY1901inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1890_OutputIterator1902_OutputIterator
1891move(_InputIterator __first, _InputIterator __last, _OutputIterator __result)1903move(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
1892{1904{
1893 return _VSTD::__move(__unwrap_iter(__first), __unwrap_iter(__last), __unwrap_iter(__result));1905 return _VSTD::__move(_VSTD::__unwrap_iter(__first), _VSTD::__unwrap_iter(__last), _VSTD::__unwrap_iter(__result));
1894}1906}
18951907
1896// move_backward1908// move_backward
18971909
1910// __move_backward_constexpr exists so that __move_backward doesn't call itself when delegating to
1911// the constexpr version of __move_backward.
1898template <class _InputIterator, class _OutputIterator>1912template <class _InputIterator, class _OutputIterator>
1899inline _LIBCPP_INLINE_VISIBILITY1913inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1900_OutputIterator1914_OutputIterator
1901__move_backward(_InputIterator __first, _InputIterator __last, _OutputIterator __result)1915__move_backward_constexpr(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
1902{1916{
1903 while (__first != __last)1917 while (__first != __last)
1904 *--__result = _VSTD::move(*--__last);1918 *--__result = _VSTD::move(*--__last);
1905 return __result;1919 return __result;
1906}1920}
19071921
1922template <class _InputIterator, class _OutputIterator>
1923inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1924_OutputIterator
1925__move_backward(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
1926{
1927 return _VSTD::__move_backward_constexpr(__first, __last, __result);
1928}
1929
1908template <class _Tp, class _Up>1930template <class _Tp, class _Up>
1909inline _LIBCPP_INLINE_VISIBILITY1931inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1910typename enable_if1932typename enable_if
1911<1933<
1912 is_same<typename remove_const<_Tp>::type, _Up>::value &&1934 is_same<typename remove_const<_Tp>::type, _Up>::value &&
...@@ -1915,6 +1937,8 @@ typename enable_if...@@ -1915,6 +1937,8 @@ typename enable_if
1915>::type1937>::type
1916__move_backward(_Tp* __first, _Tp* __last, _Up* __result)1938__move_backward(_Tp* __first, _Tp* __last, _Up* __result)
1917{1939{
1940 if (__libcpp_is_constant_evaluated())
1941 return _VSTD::__move_backward_constexpr(__first, __last, __result);
1918 const size_t __n = static_cast<size_t>(__last - __first);1942 const size_t __n = static_cast<size_t>(__last - __first);
1919 if (__n > 0)1943 if (__n > 0)
1920 {1944 {
...@@ -1925,12 +1949,12 @@ __move_backward(_Tp* __first, _Tp* __last, _Up* __result)...@@ -1925,12 +1949,12 @@ __move_backward(_Tp* __first, _Tp* __last, _Up* __result)
1925}1949}
19261950
1927template <class _BidirectionalIterator1, class _BidirectionalIterator2>1951template <class _BidirectionalIterator1, class _BidirectionalIterator2>
1928inline _LIBCPP_INLINE_VISIBILITY1952inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1929_BidirectionalIterator21953_BidirectionalIterator2
1930move_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last,1954move_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last,
1931 _BidirectionalIterator2 __result)1955 _BidirectionalIterator2 __result)
1932{1956{
1933 return _VSTD::__move_backward(__unwrap_iter(__first), __unwrap_iter(__last), __unwrap_iter(__result));1957 return _VSTD::__move_backward(_VSTD::__unwrap_iter(__first), _VSTD::__unwrap_iter(__last), _VSTD::__unwrap_iter(__result));
1934}1958}
19351959
1936// iter_swap1960// iter_swap
...@@ -2033,7 +2057,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17...@@ -2033,7 +2057,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2033_OutputIterator2057_OutputIterator
2034fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_)2058fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_)
2035{2059{
2036 return _VSTD::__fill_n(__first, __convert_to_integral(__n), __value_);2060 return _VSTD::__fill_n(__first, _VSTD::__convert_to_integral(__n), __value_);
2037}2061}
20382062
2039// fill2063// fill
...@@ -2081,7 +2105,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17...@@ -2081,7 +2105,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2081_OutputIterator2105_OutputIterator
2082generate_n(_OutputIterator __first, _Size __orig_n, _Generator __gen)2106generate_n(_OutputIterator __first, _Size __orig_n, _Generator __gen)
2083{2107{
2084 typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize;2108 typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
2085 _IntegralSize __n = __orig_n;2109 _IntegralSize __n = __orig_n;
2086 for (; __n > 0; ++__first, (void) --__n)2110 for (; __n > 0; ++__first, (void) --__n)
2087 *__first = __gen();2111 *__first = __gen();
...@@ -2333,7 +2357,7 @@ reverse_copy(_BidirectionalIterator __first, _BidirectionalIterator __last, _Out...@@ -2333,7 +2357,7 @@ reverse_copy(_BidirectionalIterator __first, _BidirectionalIterator __last, _Out
2333// rotate2357// rotate
23342358
2335template <class _ForwardIterator>2359template <class _ForwardIterator>
2336_ForwardIterator2360_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
2337__rotate_left(_ForwardIterator __first, _ForwardIterator __last)2361__rotate_left(_ForwardIterator __first, _ForwardIterator __last)
2338{2362{
2339 typedef typename iterator_traits<_ForwardIterator>::value_type value_type;2363 typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
...@@ -2344,7 +2368,7 @@ __rotate_left(_ForwardIterator __first, _ForwardIterator __last)...@@ -2344,7 +2368,7 @@ __rotate_left(_ForwardIterator __first, _ForwardIterator __last)
2344}2368}
23452369
2346template <class _BidirectionalIterator>2370template <class _BidirectionalIterator>
2347_BidirectionalIterator2371_LIBCPP_CONSTEXPR_AFTER_CXX11 _BidirectionalIterator
2348__rotate_right(_BidirectionalIterator __first, _BidirectionalIterator __last)2372__rotate_right(_BidirectionalIterator __first, _BidirectionalIterator __last)
2349{2373{
2350 typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;2374 typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
...@@ -2356,7 +2380,7 @@ __rotate_right(_BidirectionalIterator __first, _BidirectionalIterator __last)...@@ -2356,7 +2380,7 @@ __rotate_right(_BidirectionalIterator __first, _BidirectionalIterator __last)
2356}2380}
23572381
2358template <class _ForwardIterator>2382template <class _ForwardIterator>
2359_ForwardIterator2383_LIBCPP_CONSTEXPR_AFTER_CXX14 _ForwardIterator
2360__rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last)2384__rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last)
2361{2385{
2362 _ForwardIterator __i = __middle;2386 _ForwardIterator __i = __middle;
...@@ -2392,7 +2416,7 @@ __rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIt...@@ -2392,7 +2416,7 @@ __rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIt
23922416
2393template<typename _Integral>2417template<typename _Integral>
2394inline _LIBCPP_INLINE_VISIBILITY2418inline _LIBCPP_INLINE_VISIBILITY
2395_Integral2419_LIBCPP_CONSTEXPR_AFTER_CXX14 _Integral
2396__algo_gcd(_Integral __x, _Integral __y)2420__algo_gcd(_Integral __x, _Integral __y)
2397{2421{
2398 do2422 do
...@@ -2405,7 +2429,7 @@ __algo_gcd(_Integral __x, _Integral __y)...@@ -2405,7 +2429,7 @@ __algo_gcd(_Integral __x, _Integral __y)
2405}2429}
24062430
2407template<typename _RandomAccessIterator>2431template<typename _RandomAccessIterator>
2408_RandomAccessIterator2432_LIBCPP_CONSTEXPR_AFTER_CXX14 _RandomAccessIterator
2409__rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last)2433__rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last)
2410{2434{
2411 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;2435 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
...@@ -2441,7 +2465,7 @@ __rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ran...@@ -2441,7 +2465,7 @@ __rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ran
24412465
2442template <class _ForwardIterator>2466template <class _ForwardIterator>
2443inline _LIBCPP_INLINE_VISIBILITY2467inline _LIBCPP_INLINE_VISIBILITY
2444_ForwardIterator2468_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
2445__rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last,2469__rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last,
2446 _VSTD::forward_iterator_tag)2470 _VSTD::forward_iterator_tag)
2447{2471{
...@@ -2456,7 +2480,7 @@ __rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator _...@@ -2456,7 +2480,7 @@ __rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator _
24562480
2457template <class _BidirectionalIterator>2481template <class _BidirectionalIterator>
2458inline _LIBCPP_INLINE_VISIBILITY2482inline _LIBCPP_INLINE_VISIBILITY
2459_BidirectionalIterator2483_LIBCPP_CONSTEXPR_AFTER_CXX11 _BidirectionalIterator
2460__rotate(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,2484__rotate(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
2461 _VSTD::bidirectional_iterator_tag)2485 _VSTD::bidirectional_iterator_tag)
2462{2486{
...@@ -2473,7 +2497,7 @@ __rotate(_BidirectionalIterator __first, _BidirectionalIterator __middle, _Bidir...@@ -2473,7 +2497,7 @@ __rotate(_BidirectionalIterator __first, _BidirectionalIterator __middle, _Bidir
24732497
2474template <class _RandomAccessIterator>2498template <class _RandomAccessIterator>
2475inline _LIBCPP_INLINE_VISIBILITY2499inline _LIBCPP_INLINE_VISIBILITY
2476_RandomAccessIterator2500_LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator
2477__rotate(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,2501__rotate(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,
2478 _VSTD::random_access_iterator_tag)2502 _VSTD::random_access_iterator_tag)
2479{2503{
...@@ -2491,7 +2515,7 @@ __rotate(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomA...@@ -2491,7 +2515,7 @@ __rotate(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomA
24912515
2492template <class _ForwardIterator>2516template <class _ForwardIterator>
2493inline _LIBCPP_INLINE_VISIBILITY2517inline _LIBCPP_INLINE_VISIBILITY
2494_ForwardIterator2518_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
2495rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last)2519rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last)
2496{2520{
2497 if (__first == __middle)2521 if (__first == __middle)
...@@ -2505,7 +2529,7 @@ rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __l...@@ -2505,7 +2529,7 @@ rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __l
2505// rotate_copy2529// rotate_copy
25062530
2507template <class _ForwardIterator, class _OutputIterator>2531template <class _ForwardIterator, class _OutputIterator>
2508inline _LIBCPP_INLINE_VISIBILITY2532inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2509_OutputIterator2533_OutputIterator
2510rotate_copy(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last, _OutputIterator __result)2534rotate_copy(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last, _OutputIterator __result)
2511{2535{
...@@ -2684,12 +2708,12 @@ clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi)...@@ -2684,12 +2708,12 @@ clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi)
26842708
2685template <class _ForwardIterator, class _Compare>2709template <class _ForwardIterator, class _Compare>
2686_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX112710_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX11
2687std::pair<_ForwardIterator, _ForwardIterator>2711pair<_ForwardIterator, _ForwardIterator>
2688minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)2712minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
2689{2713{
2690 static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,2714 static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
2691 "std::minmax_element requires a ForwardIterator");2715 "std::minmax_element requires a ForwardIterator");
2692 std::pair<_ForwardIterator, _ForwardIterator> __result(__first, __first);2716 pair<_ForwardIterator, _ForwardIterator> __result(__first, __first);
2693 if (__first != __last)2717 if (__first != __last)
2694 {2718 {
2695 if (++__first != __last)2719 if (++__first != __last)
...@@ -2735,7 +2759,7 @@ minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __com...@@ -2735,7 +2759,7 @@ minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __com
2735template <class _ForwardIterator>2759template <class _ForwardIterator>
2736_LIBCPP_NODISCARD_EXT inline2760_LIBCPP_NODISCARD_EXT inline
2737_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX112761_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
2738std::pair<_ForwardIterator, _ForwardIterator>2762pair<_ForwardIterator, _ForwardIterator>
2739minmax_element(_ForwardIterator __first, _ForwardIterator __last)2763minmax_element(_ForwardIterator __first, _ForwardIterator __last)
2740{2764{
2741 return _VSTD::minmax_element(__first, __last,2765 return _VSTD::minmax_element(__first, __last,
...@@ -2774,7 +2798,7 @@ minmax(initializer_list<_Tp> __t, _Compare __comp)...@@ -2774,7 +2798,7 @@ minmax(initializer_list<_Tp> __t, _Compare __comp)
2774 typedef typename initializer_list<_Tp>::const_iterator _Iter;2798 typedef typename initializer_list<_Tp>::const_iterator _Iter;
2775 _Iter __first = __t.begin();2799 _Iter __first = __t.begin();
2776 _Iter __last = __t.end();2800 _Iter __last = __t.end();
2777 std::pair<_Tp, _Tp> __result(*__first, *__first);2801 pair<_Tp, _Tp> __result(*__first, *__first);
27782802
2779 ++__first;2803 ++__first;
2780 if (__t.size() % 2 == 0)2804 if (__t.size() % 2 == 0)
...@@ -3050,7 +3074,7 @@ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK...@@ -3050,7 +3074,7 @@ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
3050 if (_Rp == 0)3074 if (_Rp == 0)
3051 return static_cast<result_type>(_Eng(__g, _Dt)());3075 return static_cast<result_type>(_Eng(__g, _Dt)());
3052 size_t __w = _Dt - __libcpp_clz(_Rp) - 1;3076 size_t __w = _Dt - __libcpp_clz(_Rp) - 1;
3053 if ((_Rp & (std::numeric_limits<_UIntType>::max() >> (_Dt - __w))) != 0)3077 if ((_Rp & (numeric_limits<_UIntType>::max() >> (_Dt - __w))) != 0)
3054 ++__w;3078 ++__w;
3055 _Eng __e(__g, __w);3079 _Eng __e(__g, __w);
3056 _UIntType __u;3080 _UIntType __u;
...@@ -3380,8 +3404,8 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate...@@ -3380,8 +3404,8 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate
3380 // Move the falses into the temporary buffer, and the trues to the front of the line3404 // Move the falses into the temporary buffer, and the trues to the front of the line
3381 // Update __first to always point to the end of the trues3405 // Update __first to always point to the end of the trues
3382 value_type* __t = __p.first;3406 value_type* __t = __p.first;
3383 ::new(__t) value_type(_VSTD::move(*__first));3407 ::new ((void*)__t) value_type(_VSTD::move(*__first));
3384 __d.__incr((value_type*)0);3408 __d.template __incr<value_type>();
3385 ++__t;3409 ++__t;
3386 _ForwardIterator __i = __first;3410 _ForwardIterator __i = __first;
3387 while (++__i != __last)3411 while (++__i != __last)
...@@ -3393,8 +3417,8 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate...@@ -3393,8 +3417,8 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate
3393 }3417 }
3394 else3418 else
3395 {3419 {
3396 ::new(__t) value_type(_VSTD::move(*__i));3420 ::new ((void*)__t) value_type(_VSTD::move(*__i));
3397 __d.__incr((value_type*)0);3421 __d.template __incr<value_type>();
3398 ++__t;3422 ++__t;
3399 }3423 }
3400 }3424 }
...@@ -3415,7 +3439,7 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate...@@ -3415,7 +3439,7 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate
3415 // F?????????????????3439 // F?????????????????
3416 // f m l3440 // f m l
3417 typedef typename add_lvalue_reference<_Predicate>::type _PredRef;3441 typedef typename add_lvalue_reference<_Predicate>::type _PredRef;
3418 _ForwardIterator __first_false = __stable_partition<_PredRef>(__first, __m, __pred, __len2, __p, __fit);3442 _ForwardIterator __first_false = _VSTD::__stable_partition<_PredRef>(__first, __m, __pred, __len2, __p, __fit);
3419 // TTTFFFFF??????????3443 // TTTFFFFF??????????
3420 // f ff m l3444 // f ff m l
3421 // recurse on [__m, __last], except increase __m until *(__m) is false, *__last know to be true3445 // recurse on [__m, __last], except increase __m until *(__m) is false, *__last know to be true
...@@ -3430,7 +3454,7 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate...@@ -3430,7 +3454,7 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate
3430 }3454 }
3431 // TTTFFFFFTTTF??????3455 // TTTFFFFFTTTF??????
3432 // f ff m m1 l3456 // f ff m m1 l
3433 __second_false = __stable_partition<_PredRef>(__m1, __last, __pred, __len_half, __p, __fit);3457 __second_false = _VSTD::__stable_partition<_PredRef>(__m1, __last, __pred, __len_half, __p, __fit);
3434__second_half_done:3458__second_half_done:
3435 // TTTFFFFFTTTTTFFFFF3459 // TTTFFFFFTTTTTFFFFF
3436 // f ff m sf l3460 // f ff m sf l
...@@ -3472,7 +3496,7 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate...@@ -3472,7 +3496,7 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate
3472 __p = _VSTD::get_temporary_buffer<value_type>(__len);3496 __p = _VSTD::get_temporary_buffer<value_type>(__len);
3473 __h.reset(__p.first);3497 __h.reset(__p.first);
3474 }3498 }
3475 return __stable_partition<typename add_lvalue_reference<_Predicate>::type>3499 return _VSTD::__stable_partition<typename add_lvalue_reference<_Predicate>::type>
3476 (__first, __last, __pred, __len, __p, forward_iterator_tag());3500 (__first, __last, __pred, __len, __p, forward_iterator_tag());
3477}3501}
34783502
...@@ -3510,8 +3534,8 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last...@@ -3510,8 +3534,8 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last
3510 // Move the falses into the temporary buffer, and the trues to the front of the line3534 // Move the falses into the temporary buffer, and the trues to the front of the line
3511 // Update __first to always point to the end of the trues3535 // Update __first to always point to the end of the trues
3512 value_type* __t = __p.first;3536 value_type* __t = __p.first;
3513 ::new(__t) value_type(_VSTD::move(*__first));3537 ::new ((void*)__t) value_type(_VSTD::move(*__first));
3514 __d.__incr((value_type*)0);3538 __d.template __incr<value_type>();
3515 ++__t;3539 ++__t;
3516 _BidirectionalIterator __i = __first;3540 _BidirectionalIterator __i = __first;
3517 while (++__i != __last)3541 while (++__i != __last)
...@@ -3523,8 +3547,8 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last...@@ -3523,8 +3547,8 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last
3523 }3547 }
3524 else3548 else
3525 {3549 {
3526 ::new(__t) value_type(_VSTD::move(*__i));3550 ::new ((void*)__t) value_type(_VSTD::move(*__i));
3527 __d.__incr((value_type*)0);3551 __d.template __incr<value_type>();
3528 ++__t;3552 ++__t;
3529 }3553 }
3530 }3554 }
...@@ -3558,7 +3582,7 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last...@@ -3558,7 +3582,7 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last
3558 // F???TFFF?????????T3582 // F???TFFF?????????T
3559 // f m1 m l3583 // f m1 m l
3560 typedef typename add_lvalue_reference<_Predicate>::type _PredRef;3584 typedef typename add_lvalue_reference<_Predicate>::type _PredRef;
3561 __first_false = __stable_partition<_PredRef>(__first, __m1, __pred, __len_half, __p, __bit);3585 __first_false = _VSTD::__stable_partition<_PredRef>(__first, __m1, __pred, __len_half, __p, __bit);
3562__first_half_done:3586__first_half_done:
3563 // TTTFFFFF?????????T3587 // TTTFFFFF?????????T
3564 // f ff m l3588 // f ff m l
...@@ -3575,7 +3599,7 @@ __first_half_done:...@@ -3575,7 +3599,7 @@ __first_half_done:
3575 }3599 }
3576 // TTTFFFFFTTTF?????T3600 // TTTFFFFFTTTF?????T
3577 // f ff m m1 l3601 // f ff m m1 l
3578 __second_false = __stable_partition<_PredRef>(__m1, __last, __pred, __len_half, __p, __bit);3602 __second_false = _VSTD::__stable_partition<_PredRef>(__m1, __last, __pred, __len_half, __p, __bit);
3579__second_half_done:3603__second_half_done:
3580 // TTTFFFFFTTTTTFFFFF3604 // TTTFFFFFTTTTTFFFFF
3581 // f ff m sf l3605 // f ff m sf l
...@@ -3620,7 +3644,7 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last...@@ -3620,7 +3644,7 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last
3620 __p = _VSTD::get_temporary_buffer<value_type>(__len);3644 __p = _VSTD::get_temporary_buffer<value_type>(__len);
3621 __h.reset(__p.first);3645 __h.reset(__p.first);
3622 }3646 }
3623 return __stable_partition<typename add_lvalue_reference<_Predicate>::type>3647 return _VSTD::__stable_partition<typename add_lvalue_reference<_Predicate>::type>
3624 (__first, __last, __pred, __len, __p, bidirectional_iterator_tag());3648 (__first, __last, __pred, __len, __p, bidirectional_iterator_tag());
3625}3649}
36263650
...@@ -3629,7 +3653,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -3629,7 +3653,7 @@ inline _LIBCPP_INLINE_VISIBILITY
3629_ForwardIterator3653_ForwardIterator
3630stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)3654stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
3631{3655{
3632 return __stable_partition<typename add_lvalue_reference<_Predicate>::type>3656 return _VSTD::__stable_partition<typename add_lvalue_reference<_Predicate>::type>
3633 (__first, __last, __pred, typename iterator_traits<_ForwardIterator>::iterator_category());3657 (__first, __last, __pred, typename iterator_traits<_ForwardIterator>::iterator_category());
3634}3658}
36353659
...@@ -3727,7 +3751,7 @@ unsigned...@@ -3727,7 +3751,7 @@ unsigned
3727__sort4(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3,3751__sort4(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3,
3728 _ForwardIterator __x4, _Compare __c)3752 _ForwardIterator __x4, _Compare __c)
3729{3753{
3730 unsigned __r = __sort3<_Compare>(__x1, __x2, __x3, __c);3754 unsigned __r = _VSTD::__sort3<_Compare>(__x1, __x2, __x3, __c);
3731 if (__c(*__x4, *__x3))3755 if (__c(*__x4, *__x3))
3732 {3756 {
3733 swap(*__x3, *__x4);3757 swap(*__x3, *__x4);
...@@ -3754,7 +3778,7 @@ unsigned...@@ -3754,7 +3778,7 @@ unsigned
3754__sort5(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3,3778__sort5(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3,
3755 _ForwardIterator __x4, _ForwardIterator __x5, _Compare __c)3779 _ForwardIterator __x4, _ForwardIterator __x5, _Compare __c)
3756{3780{
3757 unsigned __r = __sort4<_Compare>(__x1, __x2, __x3, __x4, __c);3781 unsigned __r = _VSTD::__sort4<_Compare>(__x1, __x2, __x3, __x4, __c);
3758 if (__c(*__x5, *__x4))3782 if (__c(*__x5, *__x4))
3759 {3783 {
3760 swap(*__x4, *__x5);3784 swap(*__x4, *__x5);
...@@ -3779,14 +3803,14 @@ __sort5(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3,...@@ -3779,14 +3803,14 @@ __sort5(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3,
3779}3803}
37803804
3781// Assumes size > 03805// Assumes size > 0
3782template <class _Compare, class _BirdirectionalIterator>3806template <class _Compare, class _BidirectionalIterator>
3783void3807void
3784__selection_sort(_BirdirectionalIterator __first, _BirdirectionalIterator __last, _Compare __comp)3808__selection_sort(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
3785{3809{
3786 _BirdirectionalIterator __lm1 = __last;3810 _BidirectionalIterator __lm1 = __last;
3787 for (--__lm1; __first != __lm1; ++__first)3811 for (--__lm1; __first != __lm1; ++__first)
3788 {3812 {
3789 _BirdirectionalIterator __i = _VSTD::min_element<_BirdirectionalIterator,3813 _BidirectionalIterator __i = _VSTD::min_element<_BidirectionalIterator,
3790 typename add_lvalue_reference<_Compare>::type>3814 typename add_lvalue_reference<_Compare>::type>
3791 (__first, __last, __comp);3815 (__first, __last, __comp);
3792 if (__i != __first)3816 if (__i != __first)
...@@ -3794,19 +3818,19 @@ __selection_sort(_BirdirectionalIterator __first, _BirdirectionalIterator __last...@@ -3794,19 +3818,19 @@ __selection_sort(_BirdirectionalIterator __first, _BirdirectionalIterator __last
3794 }3818 }
3795}3819}
37963820
3797template <class _Compare, class _BirdirectionalIterator>3821template <class _Compare, class _BidirectionalIterator>
3798void3822void
3799__insertion_sort(_BirdirectionalIterator __first, _BirdirectionalIterator __last, _Compare __comp)3823__insertion_sort(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
3800{3824{
3801 typedef typename iterator_traits<_BirdirectionalIterator>::value_type value_type;3825 typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
3802 if (__first != __last)3826 if (__first != __last)
3803 {3827 {
3804 _BirdirectionalIterator __i = __first;3828 _BidirectionalIterator __i = __first;
3805 for (++__i; __i != __last; ++__i)3829 for (++__i; __i != __last; ++__i)
3806 {3830 {
3807 _BirdirectionalIterator __j = __i;3831 _BidirectionalIterator __j = __i;
3808 value_type __t(_VSTD::move(*__j));3832 value_type __t(_VSTD::move(*__j));
3809 for (_BirdirectionalIterator __k = __i; __k != __first && __comp(__t, *--__k); --__j)3833 for (_BidirectionalIterator __k = __i; __k != __first && __comp(__t, *--__k); --__j)
3810 *__j = _VSTD::move(*__k);3834 *__j = _VSTD::move(*__k);
3811 *__j = _VSTD::move(__t);3835 *__j = _VSTD::move(__t);
3812 }3836 }
...@@ -3819,7 +3843,7 @@ __insertion_sort_3(_RandomAccessIterator __first, _RandomAccessIterator __last,...@@ -3819,7 +3843,7 @@ __insertion_sort_3(_RandomAccessIterator __first, _RandomAccessIterator __last,
3819{3843{
3820 typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;3844 typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
3821 _RandomAccessIterator __j = __first+2;3845 _RandomAccessIterator __j = __first+2;
3822 __sort3<_Compare>(__first, __first+1, __j, __comp);3846 _VSTD::__sort3<_Compare>(__first, __first+1, __j, __comp);
3823 for (_RandomAccessIterator __i = __j+1; __i != __last; ++__i)3847 for (_RandomAccessIterator __i = __j+1; __i != __last; ++__i)
3824 {3848 {
3825 if (__comp(*__i, *__j))3849 if (__comp(*__i, *__j))
...@@ -3863,7 +3887,7 @@ __insertion_sort_incomplete(_RandomAccessIterator __first, _RandomAccessIterator...@@ -3863,7 +3887,7 @@ __insertion_sort_incomplete(_RandomAccessIterator __first, _RandomAccessIterator
3863 }3887 }
3864 typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;3888 typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
3865 _RandomAccessIterator __j = __first+2;3889 _RandomAccessIterator __j = __first+2;
3866 __sort3<_Compare>(__first, __first+1, __j, __comp);3890 _VSTD::__sort3<_Compare>(__first, __first+1, __j, __comp);
3867 const unsigned __limit = 8;3891 const unsigned __limit = 8;
3868 unsigned __count = 0;3892 unsigned __count = 0;
3869 for (_RandomAccessIterator __i = __j+1; __i != __last; ++__i)3893 for (_RandomAccessIterator __i = __j+1; __i != __last; ++__i)
...@@ -3887,35 +3911,35 @@ __insertion_sort_incomplete(_RandomAccessIterator __first, _RandomAccessIterator...@@ -3887,35 +3911,35 @@ __insertion_sort_incomplete(_RandomAccessIterator __first, _RandomAccessIterator
3887 return true;3911 return true;
3888}3912}
38893913
3890template <class _Compare, class _BirdirectionalIterator>3914template <class _Compare, class _BidirectionalIterator>
3891void3915void
3892__insertion_sort_move(_BirdirectionalIterator __first1, _BirdirectionalIterator __last1,3916__insertion_sort_move(_BidirectionalIterator __first1, _BidirectionalIterator __last1,
3893 typename iterator_traits<_BirdirectionalIterator>::value_type* __first2, _Compare __comp)3917 typename iterator_traits<_BidirectionalIterator>::value_type* __first2, _Compare __comp)
3894{3918{
3895 typedef typename iterator_traits<_BirdirectionalIterator>::value_type value_type;3919 typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
3896 if (__first1 != __last1)3920 if (__first1 != __last1)
3897 {3921 {
3898 __destruct_n __d(0);3922 __destruct_n __d(0);
3899 unique_ptr<value_type, __destruct_n&> __h(__first2, __d);3923 unique_ptr<value_type, __destruct_n&> __h(__first2, __d);
3900 value_type* __last2 = __first2;3924 value_type* __last2 = __first2;
3901 ::new(__last2) value_type(_VSTD::move(*__first1));3925 ::new ((void*)__last2) value_type(_VSTD::move(*__first1));
3902 __d.__incr((value_type*)0);3926 __d.template __incr<value_type>();
3903 for (++__last2; ++__first1 != __last1; ++__last2)3927 for (++__last2; ++__first1 != __last1; ++__last2)
3904 {3928 {
3905 value_type* __j2 = __last2;3929 value_type* __j2 = __last2;
3906 value_type* __i2 = __j2;3930 value_type* __i2 = __j2;
3907 if (__comp(*__first1, *--__i2))3931 if (__comp(*__first1, *--__i2))
3908 {3932 {
3909 ::new(__j2) value_type(_VSTD::move(*__i2));3933 ::new ((void*)__j2) value_type(_VSTD::move(*__i2));
3910 __d.__incr((value_type*)0);3934 __d.template __incr<value_type>();
3911 for (--__j2; __i2 != __first2 && __comp(*__first1, *--__i2); --__j2)3935 for (--__j2; __i2 != __first2 && __comp(*__first1, *--__i2); --__j2)
3912 *__j2 = _VSTD::move(*__i2);3936 *__j2 = _VSTD::move(*__i2);
3913 *__j2 = _VSTD::move(*__first1);3937 *__j2 = _VSTD::move(*__first1);
3914 }3938 }
3915 else3939 else
3916 {3940 {
3917 ::new(__j2) value_type(_VSTD::move(*__first1));3941 ::new ((void*)__j2) value_type(_VSTD::move(*__first1));
3918 __d.__incr((value_type*)0);3942 __d.template __incr<value_type>();
3919 }3943 }
3920 }3944 }
3921 __h.release();3945 __h.release();
...@@ -4032,7 +4056,7 @@ __sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __c...@@ -4032,7 +4056,7 @@ __sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __c
4032 ++__i;4056 ++__i;
4033 }4057 }
4034 // [__first, __i) == *__first and *__first < [__i, __last)4058 // [__first, __i) == *__first and *__first < [__i, __last)
4035 // The first part is sorted, sort the secod part4059 // The first part is sorted, sort the second part
4036 // _VSTD::__sort<_Compare>(__i, __last, __comp);4060 // _VSTD::__sort<_Compare>(__i, __last, __comp);
4037 __first = __i;4061 __first = __i;
4038 goto __restart;4062 goto __restart;
...@@ -4138,7 +4162,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -4138,7 +4162,7 @@ inline _LIBCPP_INLINE_VISIBILITY
4138void4162void
4139sort(_Tp** __first, _Tp** __last)4163sort(_Tp** __first, _Tp** __last)
4140{4164{
4141 _VSTD::sort((size_t*)__first, (size_t*)__last, __less<size_t>());4165 _VSTD::sort((uintptr_t*)__first, (uintptr_t*)__last, __less<uintptr_t>());
4142}4166}
41434167
4144template <class _Tp>4168template <class _Tp>
...@@ -4223,7 +4247,7 @@ _ForwardIterator...@@ -4223,7 +4247,7 @@ _ForwardIterator
4223lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)4247lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
4224{4248{
4225 typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;4249 typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
4226 return __lower_bound<_Comp_ref>(__first, __last, __value_, __comp);4250 return _VSTD::__lower_bound<_Comp_ref>(__first, __last, __value_, __comp);
4227}4251}
42284252
4229template <class _ForwardIterator, class _Tp>4253template <class _ForwardIterator, class _Tp>
...@@ -4267,7 +4291,7 @@ _ForwardIterator...@@ -4267,7 +4291,7 @@ _ForwardIterator
4267upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)4291upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
4268{4292{
4269 typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;4293 typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
4270 return __upper_bound<_Comp_ref>(__first, __last, __value_, __comp);4294 return _VSTD::__upper_bound<_Comp_ref>(__first, __last, __value_, __comp);
4271}4295}
42724296
4273template <class _ForwardIterator, class _Tp>4297template <class _ForwardIterator, class _Tp>
...@@ -4308,8 +4332,8 @@ __equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va...@@ -4308,8 +4332,8 @@ __equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va
4308 _ForwardIterator __mp1 = __m;4332 _ForwardIterator __mp1 = __m;
4309 return pair<_ForwardIterator, _ForwardIterator>4333 return pair<_ForwardIterator, _ForwardIterator>
4310 (4334 (
4311 __lower_bound<_Compare>(__first, __m, __value_, __comp),4335 _VSTD::__lower_bound<_Compare>(__first, __m, __value_, __comp),
4312 __upper_bound<_Compare>(++__mp1, __last, __value_, __comp)4336 _VSTD::__upper_bound<_Compare>(++__mp1, __last, __value_, __comp)
4313 );4337 );
4314 }4338 }
4315 }4339 }
...@@ -4323,7 +4347,7 @@ pair<_ForwardIterator, _ForwardIterator>...@@ -4323,7 +4347,7 @@ pair<_ForwardIterator, _ForwardIterator>
4323equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)4347equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
4324{4348{
4325 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;4349 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
4326 return __equal_range<_Comp_ref>(__first, __last, __value_, __comp);4350 return _VSTD::__equal_range<_Comp_ref>(__first, __last, __value_, __comp);
4327}4351}
43284352
4329template <class _ForwardIterator, class _Tp>4353template <class _ForwardIterator, class _Tp>
...@@ -4343,7 +4367,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17...@@ -4343,7 +4367,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
4343bool4367bool
4344__binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)4368__binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
4345{4369{
4346 __first = __lower_bound<_Compare>(__first, __last, __value_, __comp);4370 __first = _VSTD::__lower_bound<_Compare>(__first, __last, __value_, __comp);
4347 return __first != __last && !__comp(__value_, *__first);4371 return __first != __last && !__comp(__value_, *__first);
4348}4372}
43494373
...@@ -4354,7 +4378,7 @@ bool...@@ -4354,7 +4378,7 @@ bool
4354binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)4378binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
4355{4379{
4356 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;4380 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
4357 return __binary_search<_Comp_ref>(__first, __last, __value_, __comp);4381 return _VSTD::__binary_search<_Comp_ref>(__first, __last, __value_, __comp);
4358}4382}
43594383
4360template <class _ForwardIterator, class _Tp>4384template <class _ForwardIterator, class _Tp>
...@@ -4370,6 +4394,7 @@ binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va...@@ -4370,6 +4394,7 @@ binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va
4370// merge4394// merge
43714395
4372template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>4396template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
4397_LIBCPP_CONSTEXPR_AFTER_CXX17
4373_OutputIterator4398_OutputIterator
4374__merge(_InputIterator1 __first1, _InputIterator1 __last1,4399__merge(_InputIterator1 __first1, _InputIterator1 __last1,
4375 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)4400 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
...@@ -4393,7 +4418,7 @@ __merge(_InputIterator1 __first1, _InputIterator1 __last1,...@@ -4393,7 +4418,7 @@ __merge(_InputIterator1 __first1, _InputIterator1 __last1,
4393}4418}
43944419
4395template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>4420template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
4396inline _LIBCPP_INLINE_VISIBILITY4421inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
4397_OutputIterator4422_OutputIterator
4398merge(_InputIterator1 __first1, _InputIterator1 __last1,4423merge(_InputIterator1 __first1, _InputIterator1 __last1,
4399 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)4424 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
...@@ -4403,7 +4428,7 @@ merge(_InputIterator1 __first1, _InputIterator1 __last1,...@@ -4403,7 +4428,7 @@ merge(_InputIterator1 __first1, _InputIterator1 __last1,
4403}4428}
44044429
4405template <class _InputIterator1, class _InputIterator2, class _OutputIterator>4430template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
4406inline _LIBCPP_INLINE_VISIBILITY4431inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
4407_OutputIterator4432_OutputIterator
4408merge(_InputIterator1 __first1, _InputIterator1 __last1,4433merge(_InputIterator1 __first1, _InputIterator1 __last1,
4409 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)4434 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
...@@ -4456,20 +4481,20 @@ __buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator...@@ -4456,20 +4481,20 @@ __buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator
4456 if (__len1 <= __len2)4481 if (__len1 <= __len2)
4457 {4482 {
4458 value_type* __p = __buff;4483 value_type* __p = __buff;
4459 for (_BidirectionalIterator __i = __first; __i != __middle; __d.__incr((value_type*)0), (void) ++__i, (void) ++__p)4484 for (_BidirectionalIterator __i = __first; __i != __middle; __d.template __incr<value_type>(), (void) ++__i, (void) ++__p)
4460 ::new(__p) value_type(_VSTD::move(*__i));4485 ::new ((void*)__p) value_type(_VSTD::move(*__i));
4461 __half_inplace_merge(__buff, __p, __middle, __last, __first, __comp);4486 _VSTD::__half_inplace_merge(__buff, __p, __middle, __last, __first, __comp);
4462 }4487 }
4463 else4488 else
4464 {4489 {
4465 value_type* __p = __buff;4490 value_type* __p = __buff;
4466 for (_BidirectionalIterator __i = __middle; __i != __last; __d.__incr((value_type*)0), (void) ++__i, (void) ++__p)4491 for (_BidirectionalIterator __i = __middle; __i != __last; __d.template __incr<value_type>(), (void) ++__i, (void) ++__p)
4467 ::new(__p) value_type(_VSTD::move(*__i));4492 ::new ((void*)__p) value_type(_VSTD::move(*__i));
4468 typedef reverse_iterator<_BidirectionalIterator> _RBi;4493 typedef reverse_iterator<_BidirectionalIterator> _RBi;
4469 typedef reverse_iterator<value_type*> _Rv;4494 typedef reverse_iterator<value_type*> _Rv;
4470 __half_inplace_merge(_Rv(__p), _Rv(__buff),4495 _VSTD::__half_inplace_merge(_Rv(__p), _Rv(__buff),
4471 _RBi(__middle), _RBi(__first),4496 _RBi(__middle), _RBi(__first),
4472 _RBi(__last), __invert<_Compare>(__comp));4497 _RBi(__last), _VSTD::__invert<_Compare>(__comp));
4473 }4498 }
4474}4499}
44754500
...@@ -4487,7 +4512,7 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,...@@ -4487,7 +4512,7 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,
4487 if (__len2 == 0)4512 if (__len2 == 0)
4488 return;4513 return;
4489 if (__len1 <= __buff_size || __len2 <= __buff_size)4514 if (__len1 <= __buff_size || __len2 <= __buff_size)
4490 return __buffered_inplace_merge<_Compare>4515 return _VSTD::__buffered_inplace_merge<_Compare>
4491 (__first, __middle, __last, __comp, __len1, __len2, __buff);4516 (__first, __middle, __last, __comp, __len1, __len2, __buff);
4492 // shrink [__first, __middle) as much as possible (with no moves), returning if it shrinks to 04517 // shrink [__first, __middle) as much as possible (with no moves), returning if it shrinks to 0
4493 for (; true; ++__first, (void) --__len1)4518 for (; true; ++__first, (void) --__len1)
...@@ -4515,7 +4540,7 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,...@@ -4515,7 +4540,7 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,
4515 __len21 = __len2 / 2;4540 __len21 = __len2 / 2;
4516 __m2 = __middle;4541 __m2 = __middle;
4517 _VSTD::advance(__m2, __len21);4542 _VSTD::advance(__m2, __len21);
4518 __m1 = __upper_bound<_Compare>(__first, __middle, *__m2, __comp);4543 __m1 = _VSTD::__upper_bound<_Compare>(__first, __middle, *__m2, __comp);
4519 __len11 = _VSTD::distance(__first, __m1);4544 __len11 = _VSTD::distance(__first, __m1);
4520 }4545 }
4521 else4546 else
...@@ -4530,7 +4555,7 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,...@@ -4530,7 +4555,7 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,
4530 __len11 = __len1 / 2;4555 __len11 = __len1 / 2;
4531 __m1 = __first;4556 __m1 = __first;
4532 _VSTD::advance(__m1, __len11);4557 _VSTD::advance(__m1, __len11);
4533 __m2 = __lower_bound<_Compare>(__middle, __last, *__m1, __comp);4558 __m2 = _VSTD::__lower_bound<_Compare>(__middle, __last, *__m1, __comp);
4534 __len21 = _VSTD::distance(__middle, __m2);4559 __len21 = _VSTD::distance(__middle, __m2);
4535 }4560 }
4536 difference_type __len12 = __len1 - __len11; // distance(__m1, __middle)4561 difference_type __len12 = __len1 - __len11; // distance(__m1, __middle)
...@@ -4539,11 +4564,11 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,...@@ -4539,11 +4564,11 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,
4539 // swap middle two partitions4564 // swap middle two partitions
4540 __middle = _VSTD::rotate(__m1, __middle, __m2);4565 __middle = _VSTD::rotate(__m1, __middle, __m2);
4541 // __len12 and __len21 now have swapped meanings4566 // __len12 and __len21 now have swapped meanings
4542 // merge smaller range with recurisve call and larger with tail recursion elimination4567 // merge smaller range with recursive call and larger with tail recursion elimination
4543 if (__len11 + __len21 < __len12 + __len22)4568 if (__len11 + __len21 < __len12 + __len22)
4544 {4569 {
4545 __inplace_merge<_Compare>(__first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size);4570 _VSTD::__inplace_merge<_Compare>(__first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size);
4546// __inplace_merge<_Compare>(__middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size);4571// _VSTD::__inplace_merge<_Compare>(__middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size);
4547 __first = __middle;4572 __first = __middle;
4548 __middle = __m2;4573 __middle = __m2;
4549 __len1 = __len12;4574 __len1 = __len12;
...@@ -4551,8 +4576,8 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,...@@ -4551,8 +4576,8 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,
4551 }4576 }
4552 else4577 else
4553 {4578 {
4554 __inplace_merge<_Compare>(__middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size);4579 _VSTD::__inplace_merge<_Compare>(__middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size);
4555// __inplace_merge<_Compare>(__first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size);4580// _VSTD::__inplace_merge<_Compare>(__first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size);
4556 __last = __middle;4581 __last = __middle;
4557 __middle = __m1;4582 __middle = __m1;
4558 __len1 = __len11;4583 __len1 = __len11;
...@@ -4603,28 +4628,28 @@ __merge_move_construct(_InputIterator1 __first1, _InputIterator1 __last1,...@@ -4603,28 +4628,28 @@ __merge_move_construct(_InputIterator1 __first1, _InputIterator1 __last1,
4603 {4628 {
4604 if (__first1 == __last1)4629 if (__first1 == __last1)
4605 {4630 {
4606 for (; __first2 != __last2; ++__first2, ++__result, (void) __d.__incr((value_type*)0))4631 for (; __first2 != __last2; ++__first2, ++__result, (void)__d.template __incr<value_type>())
4607 ::new (__result) value_type(_VSTD::move(*__first2));4632 ::new ((void*)__result) value_type(_VSTD::move(*__first2));
4608 __h.release();4633 __h.release();
4609 return;4634 return;
4610 }4635 }
4611 if (__first2 == __last2)4636 if (__first2 == __last2)
4612 {4637 {
4613 for (; __first1 != __last1; ++__first1, ++__result, (void) __d.__incr((value_type*)0))4638 for (; __first1 != __last1; ++__first1, ++__result, (void)__d.template __incr<value_type>())
4614 ::new (__result) value_type(_VSTD::move(*__first1));4639 ::new ((void*)__result) value_type(_VSTD::move(*__first1));
4615 __h.release();4640 __h.release();
4616 return;4641 return;
4617 }4642 }
4618 if (__comp(*__first2, *__first1))4643 if (__comp(*__first2, *__first1))
4619 {4644 {
4620 ::new (__result) value_type(_VSTD::move(*__first2));4645 ::new ((void*)__result) value_type(_VSTD::move(*__first2));
4621 __d.__incr((value_type*)0);4646 __d.template __incr<value_type>();
4622 ++__first2;4647 ++__first2;
4623 }4648 }
4624 else4649 else
4625 {4650 {
4626 ::new (__result) value_type(_VSTD::move(*__first1));4651 ::new ((void*)__result) value_type(_VSTD::move(*__first1));
4627 __d.__incr((value_type*)0);4652 __d.template __incr<value_type>();
4628 ++__first1;4653 ++__first1;
4629 }4654 }
4630 }4655 }
...@@ -4677,38 +4702,38 @@ __stable_sort_move(_RandomAccessIterator __first1, _RandomAccessIterator __last1...@@ -4677,38 +4702,38 @@ __stable_sort_move(_RandomAccessIterator __first1, _RandomAccessIterator __last1
4677 case 0:4702 case 0:
4678 return;4703 return;
4679 case 1:4704 case 1:
4680 ::new(__first2) value_type(_VSTD::move(*__first1));4705 ::new ((void*)__first2) value_type(_VSTD::move(*__first1));
4681 return;4706 return;
4682 case 2:4707 case 2:
4683 __destruct_n __d(0);4708 __destruct_n __d(0);
4684 unique_ptr<value_type, __destruct_n&> __h2(__first2, __d);4709 unique_ptr<value_type, __destruct_n&> __h2(__first2, __d);
4685 if (__comp(*--__last1, *__first1))4710 if (__comp(*--__last1, *__first1))
4686 {4711 {
4687 ::new(__first2) value_type(_VSTD::move(*__last1));4712 ::new ((void*)__first2) value_type(_VSTD::move(*__last1));
4688 __d.__incr((value_type*)0);4713 __d.template __incr<value_type>();
4689 ++__first2;4714 ++__first2;
4690 ::new(__first2) value_type(_VSTD::move(*__first1));4715 ::new ((void*)__first2) value_type(_VSTD::move(*__first1));
4691 }4716 }
4692 else4717 else
4693 {4718 {
4694 ::new(__first2) value_type(_VSTD::move(*__first1));4719 ::new ((void*)__first2) value_type(_VSTD::move(*__first1));
4695 __d.__incr((value_type*)0);4720 __d.template __incr<value_type>();
4696 ++__first2;4721 ++__first2;
4697 ::new(__first2) value_type(_VSTD::move(*__last1));4722 ::new ((void*)__first2) value_type(_VSTD::move(*__last1));
4698 }4723 }
4699 __h2.release();4724 __h2.release();
4700 return;4725 return;
4701 }4726 }
4702 if (__len <= 8)4727 if (__len <= 8)
4703 {4728 {
4704 __insertion_sort_move<_Compare>(__first1, __last1, __first2, __comp);4729 _VSTD::__insertion_sort_move<_Compare>(__first1, __last1, __first2, __comp);
4705 return;4730 return;
4706 }4731 }
4707 typename iterator_traits<_RandomAccessIterator>::difference_type __l2 = __len / 2;4732 typename iterator_traits<_RandomAccessIterator>::difference_type __l2 = __len / 2;
4708 _RandomAccessIterator __m = __first1 + __l2;4733 _RandomAccessIterator __m = __first1 + __l2;
4709 __stable_sort<_Compare>(__first1, __m, __comp, __l2, __first2, __l2);4734 _VSTD::__stable_sort<_Compare>(__first1, __m, __comp, __l2, __first2, __l2);
4710 __stable_sort<_Compare>(__m, __last1, __comp, __len - __l2, __first2 + __l2, __len - __l2);4735 _VSTD::__stable_sort<_Compare>(__m, __last1, __comp, __len - __l2, __first2 + __l2, __len - __l2);
4711 __merge_move_construct<_Compare>(__first1, __m, __m, __last1, __first2, __comp);4736 _VSTD::__merge_move_construct<_Compare>(__first1, __m, __m, __last1, __first2, __comp);
4712}4737}
47134738
4714template <class _Tp>4739template <class _Tp>
...@@ -4737,7 +4762,7 @@ __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp...@@ -4737,7 +4762,7 @@ __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp
4737 }4762 }
4738 if (__len <= static_cast<difference_type>(__stable_sort_switch<value_type>::value))4763 if (__len <= static_cast<difference_type>(__stable_sort_switch<value_type>::value))
4739 {4764 {
4740 __insertion_sort<_Compare>(__first, __last, __comp);4765 _VSTD::__insertion_sort<_Compare>(__first, __last, __comp);
4741 return;4766 return;
4742 }4767 }
4743 typename iterator_traits<_RandomAccessIterator>::difference_type __l2 = __len / 2;4768 typename iterator_traits<_RandomAccessIterator>::difference_type __l2 = __len / 2;
...@@ -4746,21 +4771,21 @@ __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp...@@ -4746,21 +4771,21 @@ __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp
4746 {4771 {
4747 __destruct_n __d(0);4772 __destruct_n __d(0);
4748 unique_ptr<value_type, __destruct_n&> __h2(__buff, __d);4773 unique_ptr<value_type, __destruct_n&> __h2(__buff, __d);
4749 __stable_sort_move<_Compare>(__first, __m, __comp, __l2, __buff);4774 _VSTD::__stable_sort_move<_Compare>(__first, __m, __comp, __l2, __buff);
4750 __d.__set(__l2, (value_type*)0);4775 __d.__set(__l2, (value_type*)nullptr);
4751 __stable_sort_move<_Compare>(__m, __last, __comp, __len - __l2, __buff + __l2);4776 _VSTD::__stable_sort_move<_Compare>(__m, __last, __comp, __len - __l2, __buff + __l2);
4752 __d.__set(__len, (value_type*)0);4777 __d.__set(__len, (value_type*)nullptr);
4753 __merge_move_assign<_Compare>(__buff, __buff + __l2, __buff + __l2, __buff + __len, __first, __comp);4778 _VSTD::__merge_move_assign<_Compare>(__buff, __buff + __l2, __buff + __l2, __buff + __len, __first, __comp);
4754// __merge<_Compare>(move_iterator<value_type*>(__buff),4779// _VSTD::__merge<_Compare>(move_iterator<value_type*>(__buff),
4755// move_iterator<value_type*>(__buff + __l2),4780// move_iterator<value_type*>(__buff + __l2),
4756// move_iterator<_RandomAccessIterator>(__buff + __l2),4781// move_iterator<_RandomAccessIterator>(__buff + __l2),
4757// move_iterator<_RandomAccessIterator>(__buff + __len),4782// move_iterator<_RandomAccessIterator>(__buff + __len),
4758// __first, __comp);4783// __first, __comp);
4759 return;4784 return;
4760 }4785 }
4761 __stable_sort<_Compare>(__first, __m, __comp, __l2, __buff, __buff_size);4786 _VSTD::__stable_sort<_Compare>(__first, __m, __comp, __l2, __buff, __buff_size);
4762 __stable_sort<_Compare>(__m, __last, __comp, __len - __l2, __buff, __buff_size);4787 _VSTD::__stable_sort<_Compare>(__m, __last, __comp, __len - __l2, __buff, __buff_size);
4763 __inplace_merge<_Compare>(__first, __m, __last, __comp, __l2, __len - __l2, __buff, __buff_size);4788 _VSTD::__inplace_merge<_Compare>(__first, __m, __last, __comp, __l2, __len - __l2, __buff, __buff_size);
4764}4789}
47654790
4766template <class _RandomAccessIterator, class _Compare>4791template <class _RandomAccessIterator, class _Compare>
...@@ -4779,7 +4804,7 @@ stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compar...@@ -4779,7 +4804,7 @@ stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compar
4779 __h.reset(__buf.first);4804 __h.reset(__buf.first);
4780 }4805 }
4781 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;4806 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
4782 __stable_sort<_Comp_ref>(__first, __last, __comp, __len, __buf.first, __buf.second);4807 _VSTD::__stable_sort<_Comp_ref>(__first, __last, __comp, __len, __buf.first, __buf.second);
4783}4808}
47844809
4785template <class _RandomAccessIterator>4810template <class _RandomAccessIterator>
...@@ -4883,7 +4908,7 @@ void...@@ -4883,7 +4908,7 @@ void
4883push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)4908push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
4884{4909{
4885 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;4910 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
4886 __sift_up<_Comp_ref>(__first, __last, __comp, __last - __first);4911 _VSTD::__sift_up<_Comp_ref>(__first, __last, __comp, __last - __first);
4887}4912}
48884913
4889template <class _RandomAccessIterator>4914template <class _RandomAccessIterator>
...@@ -4960,7 +4985,7 @@ __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare...@@ -4960,7 +4985,7 @@ __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare
4960 if (__len > 1)4985 if (__len > 1)
4961 {4986 {
4962 swap(*__first, *--__last);4987 swap(*__first, *--__last);
4963 __sift_down<_Compare>(__first, __last, __comp, __len - 1, __first);4988 _VSTD::__sift_down<_Compare>(__first, __last, __comp, __len - 1, __first);
4964 }4989 }
4965}4990}
49664991
...@@ -4970,7 +4995,7 @@ void...@@ -4970,7 +4995,7 @@ void
4970pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)4995pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
4971{4996{
4972 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;4997 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
4973 __pop_heap<_Comp_ref>(__first, __last, __comp, __last - __first);4998 _VSTD::__pop_heap<_Comp_ref>(__first, __last, __comp, __last - __first);
4974}4999}
49755000
4976template <class _RandomAccessIterator>5001template <class _RandomAccessIterator>
...@@ -4994,7 +5019,7 @@ __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compar...@@ -4994,7 +5019,7 @@ __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compar
4994 // start from the first parent, there is no need to consider children5019 // start from the first parent, there is no need to consider children
4995 for (difference_type __start = (__n - 2) / 2; __start >= 0; --__start)5020 for (difference_type __start = (__n - 2) / 2; __start >= 0; --__start)
4996 {5021 {
4997 __sift_down<_Compare>(__first, __last, __comp, __n, __first + __start);5022 _VSTD::__sift_down<_Compare>(__first, __last, __comp, __n, __first + __start);
4998 }5023 }
4999 }5024 }
5000}5025}
...@@ -5005,7 +5030,7 @@ void...@@ -5005,7 +5030,7 @@ void
5005make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)5030make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
5006{5031{
5007 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;5032 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
5008 __make_heap<_Comp_ref>(__first, __last, __comp);5033 _VSTD::__make_heap<_Comp_ref>(__first, __last, __comp);
5009}5034}
50105035
5011template <class _RandomAccessIterator>5036template <class _RandomAccessIterator>
...@@ -5024,7 +5049,7 @@ __sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compar...@@ -5024,7 +5049,7 @@ __sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compar
5024{5049{
5025 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;5050 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
5026 for (difference_type __n = __last - __first; __n > 1; --__last, (void) --__n)5051 for (difference_type __n = __last - __first; __n > 1; --__last, (void) --__n)
5027 __pop_heap<_Compare>(__first, __last, __comp, __n);5052 _VSTD::__pop_heap<_Compare>(__first, __last, __comp, __n);
5028}5053}
50295054
5030template <class _RandomAccessIterator, class _Compare>5055template <class _RandomAccessIterator, class _Compare>
...@@ -5033,7 +5058,7 @@ void...@@ -5033,7 +5058,7 @@ void
5033sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)5058sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
5034{5059{
5035 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;5060 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
5036 __sort_heap<_Comp_ref>(__first, __last, __comp);5061 _VSTD::__sort_heap<_Comp_ref>(__first, __last, __comp);
5037}5062}
50385063
5039template <class _RandomAccessIterator>5064template <class _RandomAccessIterator>
...@@ -5051,17 +5076,17 @@ void...@@ -5051,17 +5076,17 @@ void
5051__partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,5076__partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,
5052 _Compare __comp)5077 _Compare __comp)
5053{5078{
5054 __make_heap<_Compare>(__first, __middle, __comp);5079 _VSTD::__make_heap<_Compare>(__first, __middle, __comp);
5055 typename iterator_traits<_RandomAccessIterator>::difference_type __len = __middle - __first;5080 typename iterator_traits<_RandomAccessIterator>::difference_type __len = __middle - __first;
5056 for (_RandomAccessIterator __i = __middle; __i != __last; ++__i)5081 for (_RandomAccessIterator __i = __middle; __i != __last; ++__i)
5057 {5082 {
5058 if (__comp(*__i, *__first))5083 if (__comp(*__i, *__first))
5059 {5084 {
5060 swap(*__i, *__first);5085 swap(*__i, *__first);
5061 __sift_down<_Compare>(__first, __middle, __comp, __len, __first);5086 _VSTD::__sift_down<_Compare>(__first, __middle, __comp, __len, __first);
5062 }5087 }
5063 }5088 }
5064 __sort_heap<_Compare>(__first, __middle, __comp);5089 _VSTD::__sort_heap<_Compare>(__first, __middle, __comp);
5065}5090}
50665091
5067template <class _RandomAccessIterator, class _Compare>5092template <class _RandomAccessIterator, class _Compare>
...@@ -5071,7 +5096,7 @@ partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ran...@@ -5071,7 +5096,7 @@ partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ran
5071 _Compare __comp)5096 _Compare __comp)
5072{5097{
5073 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;5098 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
5074 __partial_sort<_Comp_ref>(__first, __middle, __last, __comp);5099 _VSTD::__partial_sort<_Comp_ref>(__first, __middle, __last, __comp);
5075}5100}
50765101
5077template <class _RandomAccessIterator>5102template <class _RandomAccessIterator>
...@@ -5095,15 +5120,15 @@ __partial_sort_copy(_InputIterator __first, _InputIterator __last,...@@ -5095,15 +5120,15 @@ __partial_sort_copy(_InputIterator __first, _InputIterator __last,
5095 {5120 {
5096 for (; __first != __last && __r != __result_last; ++__first, (void) ++__r)5121 for (; __first != __last && __r != __result_last; ++__first, (void) ++__r)
5097 *__r = *__first;5122 *__r = *__first;
5098 __make_heap<_Compare>(__result_first, __r, __comp);5123 _VSTD::__make_heap<_Compare>(__result_first, __r, __comp);
5099 typename iterator_traits<_RandomAccessIterator>::difference_type __len = __r - __result_first;5124 typename iterator_traits<_RandomAccessIterator>::difference_type __len = __r - __result_first;
5100 for (; __first != __last; ++__first)5125 for (; __first != __last; ++__first)
5101 if (__comp(*__first, *__result_first))5126 if (__comp(*__first, *__result_first))
5102 {5127 {
5103 *__result_first = *__first;5128 *__result_first = *__first;
5104 __sift_down<_Compare>(__result_first, __r, __comp, __len, __result_first);5129 _VSTD::__sift_down<_Compare>(__result_first, __r, __comp, __len, __result_first);
5105 }5130 }
5106 __sort_heap<_Compare>(__result_first, __r, __comp);5131 _VSTD::__sort_heap<_Compare>(__result_first, __r, __comp);
5107 }5132 }
5108 return __r;5133 return __r;
5109}5134}
...@@ -5115,7 +5140,7 @@ partial_sort_copy(_InputIterator __first, _InputIterator __last,...@@ -5115,7 +5140,7 @@ partial_sort_copy(_InputIterator __first, _InputIterator __last,
5115 _RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp)5140 _RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp)
5116{5141{
5117 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;5142 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
5118 return __partial_sort_copy<_Comp_ref>(__first, __last, __result_first, __result_last, __comp);5143 return _VSTD::__partial_sort_copy<_Comp_ref>(__first, __last, __result_first, __result_last, __comp);
5119}5144}
51205145
5121template <class _InputIterator, class _RandomAccessIterator>5146template <class _InputIterator, class _RandomAccessIterator>
...@@ -5161,7 +5186,7 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando...@@ -5161,7 +5186,7 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando
5161 }5186 }
5162 if (__len <= __limit)5187 if (__len <= __limit)
5163 {5188 {
5164 __selection_sort<_Compare>(__first, __last, __comp);5189 _VSTD::__selection_sort<_Compare>(__first, __last, __comp);
5165 return;5190 return;
5166 }5191 }
5167 // __len > __limit >= 35192 // __len > __limit >= 3
...@@ -5185,7 +5210,7 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando...@@ -5185,7 +5210,7 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando
5185 if (__i == --__j)5210 if (__i == --__j)
5186 {5211 {
5187 // *__first == *__m, *__m <= all other elements5212 // *__first == *__m, *__m <= all other elements
5188 // Parition instead into [__first, __i) == *__first and *__first < [__i, __last)5213 // Partition instead into [__first, __i) == *__first and *__first < [__i, __last)
5189 ++__i; // __first + 15214 ++__i; // __first + 1
5190 __j = __last;5215 __j = __last;
5191 if (!__comp(*__first, *--__j)) // we need a guard if *__first == *(__last-1)5216 if (!__comp(*__first, *--__j)) // we need a guard if *__first == *(__last-1)
...@@ -5223,8 +5248,8 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando...@@ -5223,8 +5248,8 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando
5223 // The first part is sorted,5248 // The first part is sorted,
5224 if (__nth < __i)5249 if (__nth < __i)
5225 return;5250 return;
5226 // __nth_element the secod part5251 // __nth_element the second part
5227 // __nth_element<_Compare>(__i, __nth, __last, __comp);5252 // _VSTD::__nth_element<_Compare>(__i, __nth, __last, __comp);
5228 __first = __i;5253 __first = __i;
5229 goto __restart;5254 goto __restart;
5230 }5255 }
...@@ -5306,12 +5331,12 @@ not_sorted:...@@ -5306,12 +5331,12 @@ not_sorted:
5306 // __nth_element on range containing __nth5331 // __nth_element on range containing __nth
5307 if (__nth < __i)5332 if (__nth < __i)
5308 {5333 {
5309 // __nth_element<_Compare>(__first, __nth, __i, __comp);5334 // _VSTD::__nth_element<_Compare>(__first, __nth, __i, __comp);
5310 __last = __i;5335 __last = __i;
5311 }5336 }
5312 else5337 else
5313 {5338 {
5314 // __nth_element<_Compare>(__i+1, __nth, __last, __comp);5339 // _VSTD::__nth_element<_Compare>(__i+1, __nth, __last, __comp);
5315 __first = ++__i;5340 __first = ++__i;
5316 }5341 }
5317 }5342 }
...@@ -5323,7 +5348,7 @@ void...@@ -5323,7 +5348,7 @@ void
5323nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp)5348nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp)
5324{5349{
5325 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;5350 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
5326 __nth_element<_Comp_ref>(__first, __nth, __last, __comp);5351 _VSTD::__nth_element<_Comp_ref>(__first, __nth, __last, __comp);
5327}5352}
53285353
5329template <class _RandomAccessIterator>5354template <class _RandomAccessIterator>
...@@ -5359,7 +5384,7 @@ includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __fi...@@ -5359,7 +5384,7 @@ includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __fi
5359 _Compare __comp)5384 _Compare __comp)
5360{5385{
5361 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;5386 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
5362 return __includes<_Comp_ref>(__first1, __last1, __first2, __last2, __comp);5387 return _VSTD::__includes<_Comp_ref>(__first1, __last1, __first2, __last2, __comp);
5363}5388}
53645389
5365template <class _InputIterator1, class _InputIterator2>5390template <class _InputIterator1, class _InputIterator2>
...@@ -5376,7 +5401,7 @@ includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __fi...@@ -5376,7 +5401,7 @@ includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __fi
5376// set_union5401// set_union
53775402
5378template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>5403template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
5379_OutputIterator5404_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
5380__set_union(_InputIterator1 __first1, _InputIterator1 __last1,5405__set_union(_InputIterator1 __first1, _InputIterator1 __last1,
5381 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)5406 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
5382{5407{
...@@ -5401,17 +5426,17 @@ __set_union(_InputIterator1 __first1, _InputIterator1 __last1,...@@ -5401,17 +5426,17 @@ __set_union(_InputIterator1 __first1, _InputIterator1 __last1,
5401}5426}
54025427
5403template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>5428template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
5404inline _LIBCPP_INLINE_VISIBILITY5429inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
5405_OutputIterator5430_OutputIterator
5406set_union(_InputIterator1 __first1, _InputIterator1 __last1,5431set_union(_InputIterator1 __first1, _InputIterator1 __last1,
5407 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)5432 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
5408{5433{
5409 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;5434 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
5410 return __set_union<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);5435 return _VSTD::__set_union<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
5411}5436}
54125437
5413template <class _InputIterator1, class _InputIterator2, class _OutputIterator>5438template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
5414inline _LIBCPP_INLINE_VISIBILITY5439inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
5415_OutputIterator5440_OutputIterator
5416set_union(_InputIterator1 __first1, _InputIterator1 __last1,5441set_union(_InputIterator1 __first1, _InputIterator1 __last1,
5417 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)5442 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
...@@ -5453,7 +5478,7 @@ set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,...@@ -5453,7 +5478,7 @@ set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
5453 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)5478 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
5454{5479{
5455 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;5480 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
5456 return __set_intersection<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);5481 return _VSTD::__set_intersection<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
5457}5482}
54585483
5459template <class _InputIterator1, class _InputIterator2, class _OutputIterator>5484template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
...@@ -5470,7 +5495,7 @@ set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,...@@ -5470,7 +5495,7 @@ set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
5470// set_difference5495// set_difference
54715496
5472template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>5497template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
5473_OutputIterator5498_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
5474__set_difference(_InputIterator1 __first1, _InputIterator1 __last1,5499__set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
5475 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)5500 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
5476{5501{
...@@ -5495,17 +5520,17 @@ __set_difference(_InputIterator1 __first1, _InputIterator1 __last1,...@@ -5495,17 +5520,17 @@ __set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
5495}5520}
54965521
5497template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>5522template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
5498inline _LIBCPP_INLINE_VISIBILITY5523inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
5499_OutputIterator5524_OutputIterator
5500set_difference(_InputIterator1 __first1, _InputIterator1 __last1,5525set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
5501 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)5526 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
5502{5527{
5503 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;5528 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
5504 return __set_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);5529 return _VSTD::__set_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
5505}5530}
55065531
5507template <class _InputIterator1, class _InputIterator2, class _OutputIterator>5532template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
5508inline _LIBCPP_INLINE_VISIBILITY5533inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
5509_OutputIterator5534_OutputIterator
5510set_difference(_InputIterator1 __first1, _InputIterator1 __last1,5535set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
5511 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)5536 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
...@@ -5518,7 +5543,7 @@ set_difference(_InputIterator1 __first1, _InputIterator1 __last1,...@@ -5518,7 +5543,7 @@ set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
5518// set_symmetric_difference5543// set_symmetric_difference
55195544
5520template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>5545template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
5521_OutputIterator5546_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
5522__set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,5547__set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,
5523 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)5548 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
5524{5549{
...@@ -5548,17 +5573,17 @@ __set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,...@@ -5548,17 +5573,17 @@ __set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,
5548}5573}
55495574
5550template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>5575template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
5551inline _LIBCPP_INLINE_VISIBILITY5576inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
5552_OutputIterator5577_OutputIterator
5553set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,5578set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,
5554 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)5579 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
5555{5580{
5556 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;5581 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
5557 return __set_symmetric_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);5582 return _VSTD::__set_symmetric_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
5558}5583}
55595584
5560template <class _InputIterator1, class _InputIterator2, class _OutputIterator>5585template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
5561inline _LIBCPP_INLINE_VISIBILITY5586inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
5562_OutputIterator5587_OutputIterator
5563set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,5588set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,
5564 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)5589 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
...@@ -5593,7 +5618,7 @@ lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,...@@ -5593,7 +5618,7 @@ lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
5593 _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp)5618 _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp)
5594{5619{
5595 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;5620 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
5596 return __lexicographical_compare<_Comp_ref>(__first1, __last1, __first2, __last2, __comp);5621 return _VSTD::__lexicographical_compare<_Comp_ref>(__first1, __last1, __first2, __last2, __comp);
5597}5622}
55985623
5599template <class _InputIterator1, class _InputIterator2>5624template <class _InputIterator1, class _InputIterator2>
...@@ -5643,7 +5668,7 @@ bool...@@ -5643,7 +5668,7 @@ bool
5643next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)5668next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
5644{5669{
5645 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;5670 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
5646 return __next_permutation<_Comp_ref>(__first, __last, __comp);5671 return _VSTD::__next_permutation<_Comp_ref>(__first, __last, __comp);
5647}5672}
56485673
5649template <class _BidirectionalIterator>5674template <class _BidirectionalIterator>
...@@ -5690,7 +5715,7 @@ bool...@@ -5690,7 +5715,7 @@ bool
5690prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)5715prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
5691{5716{
5692 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;5717 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
5693 return __prev_permutation<_Comp_ref>(__first, __last, __comp);5718 return _VSTD::__prev_permutation<_Comp_ref>(__first, __last, __comp);
5694}5719}
56955720
5696template <class _BidirectionalIterator>5721template <class _BidirectionalIterator>
lib/libcxx/include/any+22-8
...@@ -81,8 +81,8 @@ namespace std {...@@ -81,8 +81,8 @@ namespace std {
81*/81*/
8282
83#include <experimental/__config>83#include <experimental/__config>
84#include <__availability>
84#include <memory>85#include <memory>
85#include <new>
86#include <typeinfo>86#include <typeinfo>
87#include <type_traits>87#include <type_traits>
88#include <cstdlib>88#include <cstdlib>
...@@ -157,7 +157,7 @@ namespace __any_imp...@@ -157,7 +157,7 @@ namespace __any_imp
157 template <class _Tp>157 template <class _Tp>
158 inline _LIBCPP_INLINE_VISIBILITY158 inline _LIBCPP_INLINE_VISIBILITY
159 constexpr const void* __get_fallback_typeid() {159 constexpr const void* __get_fallback_typeid() {
160 return &__unique_typeinfo<decay_t<_Tp>>::__id;160 return &__unique_typeinfo<remove_cv_t<remove_reference_t<_Tp>>>::__id;
161 }161 }
162162
163 template <class _Tp>163 template <class _Tp>
...@@ -368,7 +368,11 @@ namespace __any_imp...@@ -368,7 +368,11 @@ namespace __any_imp
368 template <class ..._Args>368 template <class ..._Args>
369 _LIBCPP_INLINE_VISIBILITY369 _LIBCPP_INLINE_VISIBILITY
370 static _Tp& __create(any & __dest, _Args&&... __args) {370 static _Tp& __create(any & __dest, _Args&&... __args) {
371 _Tp* __ret = ::new (static_cast<void*>(&__dest.__s.__buf)) _Tp(_VSTD::forward<_Args>(__args)...);371 typedef allocator<_Tp> _Alloc;
372 typedef allocator_traits<_Alloc> _ATraits;
373 _Alloc __a;
374 _Tp * __ret = static_cast<_Tp*>(static_cast<void*>(&__dest.__s.__buf));
375 _ATraits::construct(__a, __ret, _VSTD::forward<_Args>(__args)...);
372 __dest.__h = &_SmallHandler::__handle;376 __dest.__h = &_SmallHandler::__handle;
373 return *__ret;377 return *__ret;
374 }378 }
...@@ -376,8 +380,11 @@ namespace __any_imp...@@ -376,8 +380,11 @@ namespace __any_imp
376 private:380 private:
377 _LIBCPP_INLINE_VISIBILITY381 _LIBCPP_INLINE_VISIBILITY
378 static void __destroy(any & __this) {382 static void __destroy(any & __this) {
379 _Tp & __value = *static_cast<_Tp *>(static_cast<void*>(&__this.__s.__buf));383 typedef allocator<_Tp> _Alloc;
380 __value.~_Tp();384 typedef allocator_traits<_Alloc> _ATraits;
385 _Alloc __a;
386 _Tp * __p = static_cast<_Tp *>(static_cast<void*>(&__this.__s.__buf));
387 _ATraits::destroy(__a, __p);
381 __this.__h = nullptr;388 __this.__h = nullptr;
382 }389 }
383390
...@@ -445,10 +452,12 @@ namespace __any_imp...@@ -445,10 +452,12 @@ namespace __any_imp
445 _LIBCPP_INLINE_VISIBILITY452 _LIBCPP_INLINE_VISIBILITY
446 static _Tp& __create(any & __dest, _Args&&... __args) {453 static _Tp& __create(any & __dest, _Args&&... __args) {
447 typedef allocator<_Tp> _Alloc;454 typedef allocator<_Tp> _Alloc;
455 typedef allocator_traits<_Alloc> _ATraits;
448 typedef __allocator_destructor<_Alloc> _Dp;456 typedef __allocator_destructor<_Alloc> _Dp;
449 _Alloc __a;457 _Alloc __a;
450 unique_ptr<_Tp, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));458 unique_ptr<_Tp, _Dp> __hold(_ATraits::allocate(__a, 1), _Dp(__a, 1));
451 _Tp* __ret = ::new ((void*)__hold.get()) _Tp(_VSTD::forward<_Args>(__args)...);459 _Tp * __ret = __hold.get();
460 _ATraits::construct(__a, __ret, _VSTD::forward<_Args>(__args)...);
452 __dest.__s.__ptr = __hold.release();461 __dest.__s.__ptr = __hold.release();
453 __dest.__h = &_LargeHandler::__handle;462 __dest.__h = &_LargeHandler::__handle;
454 return *__ret;463 return *__ret;
...@@ -458,7 +467,12 @@ namespace __any_imp...@@ -458,7 +467,12 @@ namespace __any_imp
458467
459 _LIBCPP_INLINE_VISIBILITY468 _LIBCPP_INLINE_VISIBILITY
460 static void __destroy(any & __this){469 static void __destroy(any & __this){
461 delete static_cast<_Tp*>(__this.__s.__ptr);470 typedef allocator<_Tp> _Alloc;
471 typedef allocator_traits<_Alloc> _ATraits;
472 _Alloc __a;
473 _Tp * __p = static_cast<_Tp *>(__this.__s.__ptr);
474 _ATraits::destroy(__a, __p);
475 _ATraits::deallocate(__a, __p, 1);
462 __this.__h = nullptr;476 __this.__h = nullptr;
463 }477 }
464478
lib/libcxx/include/array+5-9
...@@ -142,8 +142,8 @@ struct _LIBCPP_TEMPLATE_VIS array...@@ -142,8 +142,8 @@ struct _LIBCPP_TEMPLATE_VIS array
142 typedef const value_type* const_pointer;142 typedef const value_type* const_pointer;
143 typedef size_t size_type;143 typedef size_t size_type;
144 typedef ptrdiff_t difference_type;144 typedef ptrdiff_t difference_type;
145 typedef std::reverse_iterator<iterator> reverse_iterator;145 typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
146 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;146 typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
147147
148 _Tp __elems_[_Size];148 _Tp __elems_[_Size];
149149
...@@ -155,7 +155,7 @@ struct _LIBCPP_TEMPLATE_VIS array...@@ -155,7 +155,7 @@ struct _LIBCPP_TEMPLATE_VIS array
155155
156 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17156 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
157 void swap(array& __a) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) {157 void swap(array& __a) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) {
158 std::swap_ranges(data(), data() + _Size, __a.data());158 _VSTD::swap_ranges(data(), data() + _Size, __a.data());
159 }159 }
160160
161 // iterators:161 // iterators:
...@@ -245,8 +245,8 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0>...@@ -245,8 +245,8 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0>
245 typedef const value_type* const_pointer;245 typedef const value_type* const_pointer;
246 typedef size_t size_type;246 typedef size_t size_type;
247 typedef ptrdiff_t difference_type;247 typedef ptrdiff_t difference_type;
248 typedef std::reverse_iterator<iterator> reverse_iterator;248 typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
249 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;249 typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
250250
251 typedef typename conditional<is_const<_Tp>::value, const char,251 typedef typename conditional<is_const<_Tp>::value, const char,
252 char>::type _CharType;252 char>::type _CharType;
...@@ -459,8 +459,6 @@ get(const array<_Tp, _Size>& __a) _NOEXCEPT...@@ -459,8 +459,6 @@ get(const array<_Tp, _Size>& __a) _NOEXCEPT
459 return __a.__elems_[_Ip];459 return __a.__elems_[_Ip];
460}460}
461461
462#ifndef _LIBCPP_CXX03_LANG
463
464template <size_t _Ip, class _Tp, size_t _Size>462template <size_t _Ip, class _Tp, size_t _Size>
465inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11463inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
466_Tp&&464_Tp&&
...@@ -479,8 +477,6 @@ get(const array<_Tp, _Size>&& __a) _NOEXCEPT...@@ -479,8 +477,6 @@ get(const array<_Tp, _Size>&& __a) _NOEXCEPT
479 return _VSTD::move(__a.__elems_[_Ip]);477 return _VSTD::move(__a.__elems_[_Ip]);
480}478}
481479
482#endif // !_LIBCPP_CXX03_LANG
483
484#if _LIBCPP_STD_VER > 17480#if _LIBCPP_STD_VER > 17
485481
486template <typename _Tp, size_t _Size, size_t... _Index>482template <typename _Tp, size_t _Size, size_t... _Index>
lib/libcxx/include/atomic+93-77
...@@ -16,9 +16,12 @@...@@ -16,9 +16,12 @@
16namespace std16namespace std
17{17{
1818
19// feature test macro19// feature test macro [version.syn]
2020
21#define __cpp_lib_atomic_is_always_lock_free // as specified by SG1021#define __cpp_lib_atomic_is_always_lock_free
22#define __cpp_lib_atomic_flag_test
23#define __cpp_lib_atomic_lock_free_type_aliases
24#define __cpp_lib_atomic_wait
2225
23 // order and consistency26 // order and consistency
2427
...@@ -45,6 +48,7 @@ template <class T> T kill_dependency(T y) noexcept;...@@ -45,6 +48,7 @@ template <class T> T kill_dependency(T y) noexcept;
4548
46#define ATOMIC_BOOL_LOCK_FREE unspecified49#define ATOMIC_BOOL_LOCK_FREE unspecified
47#define ATOMIC_CHAR_LOCK_FREE unspecified50#define ATOMIC_CHAR_LOCK_FREE unspecified
51#define ATOMIC_CHAR8_T_LOCK_FREE unspecified // C++20
48#define ATOMIC_CHAR16_T_LOCK_FREE unspecified52#define ATOMIC_CHAR16_T_LOCK_FREE unspecified
49#define ATOMIC_CHAR32_T_LOCK_FREE unspecified53#define ATOMIC_CHAR32_T_LOCK_FREE unspecified
50#define ATOMIC_WCHAR_T_LOCK_FREE unspecified54#define ATOMIC_WCHAR_T_LOCK_FREE unspecified
...@@ -108,6 +112,7 @@ template <>...@@ -108,6 +112,7 @@ template <>
108struct atomic<integral>112struct atomic<integral>
109{113{
110 using value_type = integral;114 using value_type = integral;
115 using difference_type = value_type;
111116
112 static constexpr bool is_always_lock_free;117 static constexpr bool is_always_lock_free;
113 bool is_lock_free() const volatile noexcept;118 bool is_lock_free() const volatile noexcept;
...@@ -190,6 +195,7 @@ template <class T>...@@ -190,6 +195,7 @@ template <class T>
190struct atomic<T*>195struct atomic<T*>
191{196{
192 using value_type = T*;197 using value_type = T*;
198 using difference_type = ptrdiff_t;
193199
194 static constexpr bool is_always_lock_free;200 static constexpr bool is_always_lock_free;
195 bool is_lock_free() const volatile noexcept;201 bool is_lock_free() const volatile noexcept;
...@@ -460,6 +466,7 @@ typedef atomic<long> atomic_long;...@@ -460,6 +466,7 @@ typedef atomic<long> atomic_long;
460typedef atomic<unsigned long> atomic_ulong;466typedef atomic<unsigned long> atomic_ulong;
461typedef atomic<long long> atomic_llong;467typedef atomic<long long> atomic_llong;
462typedef atomic<unsigned long long> atomic_ullong;468typedef atomic<unsigned long long> atomic_ullong;
469typedef atomic<char8_t> atomic_char8_t; // C++20
463typedef atomic<char16_t> atomic_char16_t;470typedef atomic<char16_t> atomic_char16_t;
464typedef atomic<char32_t> atomic_char32_t;471typedef atomic<char32_t> atomic_char32_t;
465typedef atomic<wchar_t> atomic_wchar_t;472typedef atomic<wchar_t> atomic_wchar_t;
...@@ -477,7 +484,7 @@ typedef atomic<int_fast8_t> atomic_int_fast8_t;...@@ -477,7 +484,7 @@ typedef atomic<int_fast8_t> atomic_int_fast8_t;
477typedef atomic<uint_fast8_t> atomic_uint_fast8_t;484typedef atomic<uint_fast8_t> atomic_uint_fast8_t;
478typedef atomic<int_fast16_t> atomic_int_fast16_t;485typedef atomic<int_fast16_t> atomic_int_fast16_t;
479typedef atomic<uint_fast16_t> atomic_uint_fast16_t;486typedef atomic<uint_fast16_t> atomic_uint_fast16_t;
480typedef atomic<int_fast32_t> atomic_int_fast32_t; 487typedef atomic<int_fast32_t> atomic_int_fast32_t;
481typedef atomic<uint_fast32_t> atomic_uint_fast32_t;488typedef atomic<uint_fast32_t> atomic_uint_fast32_t;
482typedef atomic<int_fast64_t> atomic_int_fast64_t;489typedef atomic<int_fast64_t> atomic_int_fast64_t;
483typedef atomic<uint_fast64_t> atomic_uint_fast64_t;490typedef atomic<uint_fast64_t> atomic_uint_fast64_t;
...@@ -568,6 +575,7 @@ template <class T>...@@ -568,6 +575,7 @@ template <class T>
568*/575*/
569576
570#include <__config>577#include <__config>
578#include <__availability>
571#include <__threading_support>579#include <__threading_support>
572#include <cstddef>580#include <cstddef>
573#include <cstdint>581#include <cstdint>
...@@ -654,7 +662,7 @@ typedef enum memory_order {...@@ -654,7 +662,7 @@ typedef enum memory_order {
654662
655template <typename _Tp> _LIBCPP_INLINE_VISIBILITY663template <typename _Tp> _LIBCPP_INLINE_VISIBILITY
656bool __cxx_nonatomic_compare_equal(_Tp const& __lhs, _Tp const& __rhs) {664bool __cxx_nonatomic_compare_equal(_Tp const& __lhs, _Tp const& __rhs) {
657 return memcmp(&__lhs, &__rhs, sizeof(_Tp)) == 0;665 return _VSTD::memcmp(&__lhs, &__rhs, sizeof(_Tp)) == 0;
658}666}
659667
660static_assert((is_same<underlying_type<memory_order>::type, __memory_order_underlying_t>::value),668static_assert((is_same<underlying_type<memory_order>::type, __memory_order_underlying_t>::value),
...@@ -1119,6 +1127,9 @@ _Tp kill_dependency(_Tp __y) _NOEXCEPT...@@ -1119,6 +1127,9 @@ _Tp kill_dependency(_Tp __y) _NOEXCEPT
1119#if defined(__CLANG_ATOMIC_BOOL_LOCK_FREE)1127#if defined(__CLANG_ATOMIC_BOOL_LOCK_FREE)
1120# define ATOMIC_BOOL_LOCK_FREE __CLANG_ATOMIC_BOOL_LOCK_FREE1128# define ATOMIC_BOOL_LOCK_FREE __CLANG_ATOMIC_BOOL_LOCK_FREE
1121# define ATOMIC_CHAR_LOCK_FREE __CLANG_ATOMIC_CHAR_LOCK_FREE1129# define ATOMIC_CHAR_LOCK_FREE __CLANG_ATOMIC_CHAR_LOCK_FREE
1130#ifndef _LIBCPP_NO_HAS_CHAR8_T
1131# define ATOMIC_CHAR8_T_LOCK_FREE __CLANG_ATOMIC_CHAR8_T_LOCK_FREE
1132#endif
1122# define ATOMIC_CHAR16_T_LOCK_FREE __CLANG_ATOMIC_CHAR16_T_LOCK_FREE1133# define ATOMIC_CHAR16_T_LOCK_FREE __CLANG_ATOMIC_CHAR16_T_LOCK_FREE
1123# define ATOMIC_CHAR32_T_LOCK_FREE __CLANG_ATOMIC_CHAR32_T_LOCK_FREE1134# define ATOMIC_CHAR32_T_LOCK_FREE __CLANG_ATOMIC_CHAR32_T_LOCK_FREE
1124# define ATOMIC_WCHAR_T_LOCK_FREE __CLANG_ATOMIC_WCHAR_T_LOCK_FREE1135# define ATOMIC_WCHAR_T_LOCK_FREE __CLANG_ATOMIC_WCHAR_T_LOCK_FREE
...@@ -1130,6 +1141,9 @@ _Tp kill_dependency(_Tp __y) _NOEXCEPT...@@ -1130,6 +1141,9 @@ _Tp kill_dependency(_Tp __y) _NOEXCEPT
1130#elif defined(__GCC_ATOMIC_BOOL_LOCK_FREE)1141#elif defined(__GCC_ATOMIC_BOOL_LOCK_FREE)
1131# define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE1142# define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE
1132# define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE1143# define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE
1144#ifndef _LIBCPP_NO_HAS_CHAR8_T
1145# define ATOMIC_CHAR8_T_LOCK_FREE __GCC_ATOMIC_CHAR8_T_LOCK_FREE
1146#endif
1133# define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE1147# define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE
1134# define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE1148# define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE
1135# define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE1149# define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE
...@@ -1245,10 +1259,10 @@ template <typename _Tp>...@@ -1245,10 +1259,10 @@ template <typename _Tp>
1245_LIBCPP_INLINE_VISIBILITY1259_LIBCPP_INLINE_VISIBILITY
1246bool __cxx_atomic_compare_exchange_strong(volatile __cxx_atomic_lock_impl<_Tp>* __a,1260bool __cxx_atomic_compare_exchange_strong(volatile __cxx_atomic_lock_impl<_Tp>* __a,
1247 _Tp* __expected, _Tp __value, memory_order, memory_order) {1261 _Tp* __expected, _Tp __value, memory_order, memory_order) {
1248 __a->__lock();
1249 _Tp __temp;1262 _Tp __temp;
1263 __a->__lock();
1250 __cxx_atomic_assign_volatile(__temp, __a->__a_value);1264 __cxx_atomic_assign_volatile(__temp, __a->__a_value);
1251 bool __ret = __temp == *__expected;1265 bool __ret = (_VSTD::memcmp(&__temp, __expected, sizeof(_Tp)) == 0);
1252 if(__ret)1266 if(__ret)
1253 __cxx_atomic_assign_volatile(__a->__a_value, __value);1267 __cxx_atomic_assign_volatile(__a->__a_value, __value);
1254 else1268 else
...@@ -1261,11 +1275,11 @@ _LIBCPP_INLINE_VISIBILITY...@@ -1261,11 +1275,11 @@ _LIBCPP_INLINE_VISIBILITY
1261bool __cxx_atomic_compare_exchange_strong(__cxx_atomic_lock_impl<_Tp>* __a,1275bool __cxx_atomic_compare_exchange_strong(__cxx_atomic_lock_impl<_Tp>* __a,
1262 _Tp* __expected, _Tp __value, memory_order, memory_order) {1276 _Tp* __expected, _Tp __value, memory_order, memory_order) {
1263 __a->__lock();1277 __a->__lock();
1264 bool __ret = __a->__a_value == *__expected;1278 bool __ret = (_VSTD::memcmp(&__a->__a_value, __expected, sizeof(_Tp)) == 0);
1265 if(__ret)1279 if(__ret)
1266 __a->__a_value = __value;1280 _VSTD::memcpy(&__a->__a_value, &__value, sizeof(_Tp));
1267 else1281 else
1268 *__expected = __a->__a_value;1282 _VSTD::memcpy(__expected, &__a->__a_value, sizeof(_Tp));
1269 __a->__unlock();1283 __a->__unlock();
1270 return __ret;1284 return __ret;
1271}1285}
...@@ -1274,10 +1288,10 @@ template <typename _Tp>...@@ -1274,10 +1288,10 @@ template <typename _Tp>
1274_LIBCPP_INLINE_VISIBILITY1288_LIBCPP_INLINE_VISIBILITY
1275bool __cxx_atomic_compare_exchange_weak(volatile __cxx_atomic_lock_impl<_Tp>* __a,1289bool __cxx_atomic_compare_exchange_weak(volatile __cxx_atomic_lock_impl<_Tp>* __a,
1276 _Tp* __expected, _Tp __value, memory_order, memory_order) {1290 _Tp* __expected, _Tp __value, memory_order, memory_order) {
1277 __a->__lock();
1278 _Tp __temp;1291 _Tp __temp;
1292 __a->__lock();
1279 __cxx_atomic_assign_volatile(__temp, __a->__a_value);1293 __cxx_atomic_assign_volatile(__temp, __a->__a_value);
1280 bool __ret = __temp == *__expected;1294 bool __ret = (_VSTD::memcmp(&__temp, __expected, sizeof(_Tp)) == 0);
1281 if(__ret)1295 if(__ret)
1282 __cxx_atomic_assign_volatile(__a->__a_value, __value);1296 __cxx_atomic_assign_volatile(__a->__a_value, __value);
1283 else1297 else
...@@ -1290,11 +1304,11 @@ _LIBCPP_INLINE_VISIBILITY...@@ -1290,11 +1304,11 @@ _LIBCPP_INLINE_VISIBILITY
1290bool __cxx_atomic_compare_exchange_weak(__cxx_atomic_lock_impl<_Tp>* __a,1304bool __cxx_atomic_compare_exchange_weak(__cxx_atomic_lock_impl<_Tp>* __a,
1291 _Tp* __expected, _Tp __value, memory_order, memory_order) {1305 _Tp* __expected, _Tp __value, memory_order, memory_order) {
1292 __a->__lock();1306 __a->__lock();
1293 bool __ret = __a->__a_value == *__expected;1307 bool __ret = (_VSTD::memcmp(&__a->__a_value, __expected, sizeof(_Tp)) == 0);
1294 if(__ret)1308 if(__ret)
1295 __a->__a_value = __value;1309 _VSTD::memcpy(&__a->__a_value, &__value, sizeof(_Tp));
1296 else1310 else
1297 *__expected = __a->__a_value;1311 _VSTD::memcpy(__expected, &__a->__a_value, sizeof(_Tp));
1298 __a->__unlock();1312 __a->__unlock();
1299 return __ret;1313 return __ret;
1300}1314}
...@@ -1444,6 +1458,9 @@ template<> struct __cxx_is_always_lock_free<bool> { enum { __value = 2 == ATOMIC...@@ -1444,6 +1458,9 @@ template<> struct __cxx_is_always_lock_free<bool> { enum { __value = 2 == ATOMIC
1444template<> struct __cxx_is_always_lock_free<char> { enum { __value = 2 == ATOMIC_CHAR_LOCK_FREE }; };1458template<> struct __cxx_is_always_lock_free<char> { enum { __value = 2 == ATOMIC_CHAR_LOCK_FREE }; };
1445template<> struct __cxx_is_always_lock_free<signed char> { enum { __value = 2 == ATOMIC_CHAR_LOCK_FREE }; };1459template<> struct __cxx_is_always_lock_free<signed char> { enum { __value = 2 == ATOMIC_CHAR_LOCK_FREE }; };
1446template<> struct __cxx_is_always_lock_free<unsigned char> { enum { __value = 2 == ATOMIC_CHAR_LOCK_FREE }; };1460template<> struct __cxx_is_always_lock_free<unsigned char> { enum { __value = 2 == ATOMIC_CHAR_LOCK_FREE }; };
1461#ifndef _LIBCPP_NO_HAS_CHAR8_T
1462template<> struct __cxx_is_always_lock_free<char8_t> { enum { __value = 2 == ATOMIC_CHAR8_T_LOCK_FREE }; };
1463#endif
1447template<> struct __cxx_is_always_lock_free<char16_t> { enum { __value = 2 == ATOMIC_CHAR16_T_LOCK_FREE }; };1464template<> struct __cxx_is_always_lock_free<char16_t> { enum { __value = 2 == ATOMIC_CHAR16_T_LOCK_FREE }; };
1448template<> struct __cxx_is_always_lock_free<char32_t> { enum { __value = 2 == ATOMIC_CHAR32_T_LOCK_FREE }; };1465template<> struct __cxx_is_always_lock_free<char32_t> { enum { __value = 2 == ATOMIC_CHAR32_T_LOCK_FREE }; };
1449template<> struct __cxx_is_always_lock_free<wchar_t> { enum { __value = 2 == ATOMIC_WCHAR_T_LOCK_FREE }; };1466template<> struct __cxx_is_always_lock_free<wchar_t> { enum { __value = 2 == ATOMIC_WCHAR_T_LOCK_FREE }; };
...@@ -1486,8 +1503,6 @@ struct __cxx_atomic_impl : public _Base {...@@ -1486,8 +1503,6 @@ struct __cxx_atomic_impl : public _Base {
1486 using __cxx_contention_t = int64_t;1503 using __cxx_contention_t = int64_t;
1487#endif //__linux__1504#endif //__linux__
14881505
1489#if _LIBCPP_STD_VER >= 11
1490
1491using __cxx_atomic_contention_t = __cxx_atomic_impl<__cxx_contention_t>;1506using __cxx_atomic_contention_t = __cxx_atomic_impl<__cxx_contention_t>;
14921507
1493#ifndef _LIBCPP_HAS_NO_PLATFORM_WAIT1508#ifndef _LIBCPP_HAS_NO_PLATFORM_WAIT
...@@ -1519,7 +1534,7 @@ struct __libcpp_atomic_wait_backoff_impl {...@@ -1519,7 +1534,7 @@ struct __libcpp_atomic_wait_backoff_impl {
1519 else if(__elapsed > chrono::microseconds(4))1534 else if(__elapsed > chrono::microseconds(4))
1520 __libcpp_thread_yield();1535 __libcpp_thread_yield();
1521 else1536 else
1522 ; // poll1537 {} // poll
1523 return false;1538 return false;
1524 }1539 }
1525};1540};
...@@ -1565,8 +1580,6 @@ _LIBCPP_INLINE_VISIBILITY bool __cxx_atomic_wait(_Atp* __a, _Tp const __val, mem...@@ -1565,8 +1580,6 @@ _LIBCPP_INLINE_VISIBILITY bool __cxx_atomic_wait(_Atp* __a, _Tp const __val, mem
1565 return __cxx_atomic_wait(__a, __test_fn);1580 return __cxx_atomic_wait(__a, __test_fn);
1566}1581}
15671582
1568#endif //_LIBCPP_STD_VER >= 11
1569
1570// general atomic<T>1583// general atomic<T>
15711584
1572template <class _Tp, bool = is_integral<_Tp>::value && !is_same<_Tp, bool>::value>1585template <class _Tp, bool = is_integral<_Tp>::value && !is_same<_Tp, bool>::value>
...@@ -1775,6 +1788,7 @@ struct atomic...@@ -1775,6 +1788,7 @@ struct atomic
1775{1788{
1776 typedef __atomic_base<_Tp> __base;1789 typedef __atomic_base<_Tp> __base;
1777 typedef _Tp value_type;1790 typedef _Tp value_type;
1791 typedef value_type difference_type;
1778 _LIBCPP_INLINE_VISIBILITY1792 _LIBCPP_INLINE_VISIBILITY
1779 atomic() _NOEXCEPT _LIBCPP_DEFAULT1793 atomic() _NOEXCEPT _LIBCPP_DEFAULT
1780 _LIBCPP_INLINE_VISIBILITY1794 _LIBCPP_INLINE_VISIBILITY
...@@ -1796,6 +1810,7 @@ struct atomic<_Tp*>...@@ -1796,6 +1810,7 @@ struct atomic<_Tp*>
1796{1810{
1797 typedef __atomic_base<_Tp*> __base;1811 typedef __atomic_base<_Tp*> __base;
1798 typedef _Tp* value_type;1812 typedef _Tp* value_type;
1813 typedef ptrdiff_t difference_type;
1799 _LIBCPP_INLINE_VISIBILITY1814 _LIBCPP_INLINE_VISIBILITY
1800 atomic() _NOEXCEPT _LIBCPP_DEFAULT1815 atomic() _NOEXCEPT _LIBCPP_DEFAULT
1801 _LIBCPP_INLINE_VISIBILITY1816 _LIBCPP_INLINE_VISIBILITY
...@@ -1872,7 +1887,7 @@ atomic_is_lock_free(const atomic<_Tp>* __o) _NOEXCEPT...@@ -1872,7 +1887,7 @@ atomic_is_lock_free(const atomic<_Tp>* __o) _NOEXCEPT
1872template <class _Tp>1887template <class _Tp>
1873_LIBCPP_INLINE_VISIBILITY1888_LIBCPP_INLINE_VISIBILITY
1874void1889void
1875atomic_init(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT1890atomic_init(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d) _NOEXCEPT
1876{1891{
1877 __cxx_atomic_init(&__o->__a_, __d);1892 __cxx_atomic_init(&__o->__a_, __d);
1878}1893}
...@@ -1880,7 +1895,7 @@ atomic_init(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT...@@ -1880,7 +1895,7 @@ atomic_init(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
1880template <class _Tp>1895template <class _Tp>
1881_LIBCPP_INLINE_VISIBILITY1896_LIBCPP_INLINE_VISIBILITY
1882void1897void
1883atomic_init(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT1898atomic_init(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d) _NOEXCEPT
1884{1899{
1885 __cxx_atomic_init(&__o->__a_, __d);1900 __cxx_atomic_init(&__o->__a_, __d);
1886}1901}
...@@ -1890,7 +1905,7 @@ atomic_init(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT...@@ -1890,7 +1905,7 @@ atomic_init(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
1890template <class _Tp>1905template <class _Tp>
1891_LIBCPP_INLINE_VISIBILITY1906_LIBCPP_INLINE_VISIBILITY
1892void1907void
1893atomic_store(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT1908atomic_store(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d) _NOEXCEPT
1894{1909{
1895 __o->store(__d);1910 __o->store(__d);
1896}1911}
...@@ -1898,7 +1913,7 @@ atomic_store(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT...@@ -1898,7 +1913,7 @@ atomic_store(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
1898template <class _Tp>1913template <class _Tp>
1899_LIBCPP_INLINE_VISIBILITY1914_LIBCPP_INLINE_VISIBILITY
1900void1915void
1901atomic_store(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT1916atomic_store(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d) _NOEXCEPT
1902{1917{
1903 __o->store(__d);1918 __o->store(__d);
1904}1919}
...@@ -1908,7 +1923,7 @@ atomic_store(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT...@@ -1908,7 +1923,7 @@ atomic_store(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
1908template <class _Tp>1923template <class _Tp>
1909_LIBCPP_INLINE_VISIBILITY1924_LIBCPP_INLINE_VISIBILITY
1910void1925void
1911atomic_store_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT1926atomic_store_explicit(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d, memory_order __m) _NOEXCEPT
1912 _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m)1927 _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m)
1913{1928{
1914 __o->store(__d, __m);1929 __o->store(__d, __m);
...@@ -1917,7 +1932,7 @@ atomic_store_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOE...@@ -1917,7 +1932,7 @@ atomic_store_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOE
1917template <class _Tp>1932template <class _Tp>
1918_LIBCPP_INLINE_VISIBILITY1933_LIBCPP_INLINE_VISIBILITY
1919void1934void
1920atomic_store_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT1935atomic_store_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d, memory_order __m) _NOEXCEPT
1921 _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m)1936 _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m)
1922{1937{
1923 __o->store(__d, __m);1938 __o->store(__d, __m);
...@@ -1966,7 +1981,7 @@ atomic_load_explicit(const atomic<_Tp>* __o, memory_order __m) _NOEXCEPT...@@ -1966,7 +1981,7 @@ atomic_load_explicit(const atomic<_Tp>* __o, memory_order __m) _NOEXCEPT
1966template <class _Tp>1981template <class _Tp>
1967_LIBCPP_INLINE_VISIBILITY1982_LIBCPP_INLINE_VISIBILITY
1968_Tp1983_Tp
1969atomic_exchange(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT1984atomic_exchange(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d) _NOEXCEPT
1970{1985{
1971 return __o->exchange(__d);1986 return __o->exchange(__d);
1972}1987}
...@@ -1974,7 +1989,7 @@ atomic_exchange(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT...@@ -1974,7 +1989,7 @@ atomic_exchange(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
1974template <class _Tp>1989template <class _Tp>
1975_LIBCPP_INLINE_VISIBILITY1990_LIBCPP_INLINE_VISIBILITY
1976_Tp1991_Tp
1977atomic_exchange(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT1992atomic_exchange(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d) _NOEXCEPT
1978{1993{
1979 return __o->exchange(__d);1994 return __o->exchange(__d);
1980}1995}
...@@ -1984,7 +1999,7 @@ atomic_exchange(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT...@@ -1984,7 +1999,7 @@ atomic_exchange(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
1984template <class _Tp>1999template <class _Tp>
1985_LIBCPP_INLINE_VISIBILITY2000_LIBCPP_INLINE_VISIBILITY
1986_Tp2001_Tp
1987atomic_exchange_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT2002atomic_exchange_explicit(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d, memory_order __m) _NOEXCEPT
1988{2003{
1989 return __o->exchange(__d, __m);2004 return __o->exchange(__d, __m);
1990}2005}
...@@ -1992,7 +2007,7 @@ atomic_exchange_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _...@@ -1992,7 +2007,7 @@ atomic_exchange_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _
1992template <class _Tp>2007template <class _Tp>
1993_LIBCPP_INLINE_VISIBILITY2008_LIBCPP_INLINE_VISIBILITY
1994_Tp2009_Tp
1995atomic_exchange_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT2010atomic_exchange_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d, memory_order __m) _NOEXCEPT
1996{2011{
1997 return __o->exchange(__d, __m);2012 return __o->exchange(__d, __m);
1998}2013}
...@@ -2002,7 +2017,7 @@ atomic_exchange_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT...@@ -2002,7 +2017,7 @@ atomic_exchange_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
2002template <class _Tp>2017template <class _Tp>
2003_LIBCPP_INLINE_VISIBILITY2018_LIBCPP_INLINE_VISIBILITY
2004bool2019bool
2005atomic_compare_exchange_weak(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT2020atomic_compare_exchange_weak(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type* __e, typename atomic<_Tp>::value_type __d) _NOEXCEPT
2006{2021{
2007 return __o->compare_exchange_weak(*__e, __d);2022 return __o->compare_exchange_weak(*__e, __d);
2008}2023}
...@@ -2010,7 +2025,7 @@ atomic_compare_exchange_weak(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEX...@@ -2010,7 +2025,7 @@ atomic_compare_exchange_weak(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEX
2010template <class _Tp>2025template <class _Tp>
2011_LIBCPP_INLINE_VISIBILITY2026_LIBCPP_INLINE_VISIBILITY
2012bool2027bool
2013atomic_compare_exchange_weak(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT2028atomic_compare_exchange_weak(atomic<_Tp>* __o, typename atomic<_Tp>::value_type* __e, typename atomic<_Tp>::value_type __d) _NOEXCEPT
2014{2029{
2015 return __o->compare_exchange_weak(*__e, __d);2030 return __o->compare_exchange_weak(*__e, __d);
2016}2031}
...@@ -2020,7 +2035,7 @@ atomic_compare_exchange_weak(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT...@@ -2020,7 +2035,7 @@ atomic_compare_exchange_weak(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
2020template <class _Tp>2035template <class _Tp>
2021_LIBCPP_INLINE_VISIBILITY2036_LIBCPP_INLINE_VISIBILITY
2022bool2037bool
2023atomic_compare_exchange_strong(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT2038atomic_compare_exchange_strong(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type* __e, typename atomic<_Tp>::value_type __d) _NOEXCEPT
2024{2039{
2025 return __o->compare_exchange_strong(*__e, __d);2040 return __o->compare_exchange_strong(*__e, __d);
2026}2041}
...@@ -2028,7 +2043,7 @@ atomic_compare_exchange_strong(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NO...@@ -2028,7 +2043,7 @@ atomic_compare_exchange_strong(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NO
2028template <class _Tp>2043template <class _Tp>
2029_LIBCPP_INLINE_VISIBILITY2044_LIBCPP_INLINE_VISIBILITY
2030bool2045bool
2031atomic_compare_exchange_strong(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT2046atomic_compare_exchange_strong(atomic<_Tp>* __o, typename atomic<_Tp>::value_type* __e, typename atomic<_Tp>::value_type __d) _NOEXCEPT
2032{2047{
2033 return __o->compare_exchange_strong(*__e, __d);2048 return __o->compare_exchange_strong(*__e, __d);
2034}2049}
...@@ -2038,8 +2053,8 @@ atomic_compare_exchange_strong(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT...@@ -2038,8 +2053,8 @@ atomic_compare_exchange_strong(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
2038template <class _Tp>2053template <class _Tp>
2039_LIBCPP_INLINE_VISIBILITY2054_LIBCPP_INLINE_VISIBILITY
2040bool2055bool
2041atomic_compare_exchange_weak_explicit(volatile atomic<_Tp>* __o, _Tp* __e,2056atomic_compare_exchange_weak_explicit(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type* __e,
2042 _Tp __d,2057 typename atomic<_Tp>::value_type __d,
2043 memory_order __s, memory_order __f) _NOEXCEPT2058 memory_order __s, memory_order __f) _NOEXCEPT
2044 _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)2059 _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
2045{2060{
...@@ -2049,7 +2064,7 @@ atomic_compare_exchange_weak_explicit(volatile atomic<_Tp>* __o, _Tp* __e,...@@ -2049,7 +2064,7 @@ atomic_compare_exchange_weak_explicit(volatile atomic<_Tp>* __o, _Tp* __e,
2049template <class _Tp>2064template <class _Tp>
2050_LIBCPP_INLINE_VISIBILITY2065_LIBCPP_INLINE_VISIBILITY
2051bool2066bool
2052atomic_compare_exchange_weak_explicit(atomic<_Tp>* __o, _Tp* __e, _Tp __d,2067atomic_compare_exchange_weak_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::value_type* __e, typename atomic<_Tp>::value_type __d,
2053 memory_order __s, memory_order __f) _NOEXCEPT2068 memory_order __s, memory_order __f) _NOEXCEPT
2054 _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)2069 _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
2055{2070{
...@@ -2062,7 +2077,7 @@ template <class _Tp>...@@ -2062,7 +2077,7 @@ template <class _Tp>
2062_LIBCPP_INLINE_VISIBILITY2077_LIBCPP_INLINE_VISIBILITY
2063bool2078bool
2064atomic_compare_exchange_strong_explicit(volatile atomic<_Tp>* __o,2079atomic_compare_exchange_strong_explicit(volatile atomic<_Tp>* __o,
2065 _Tp* __e, _Tp __d,2080 typename atomic<_Tp>::value_type* __e, typename atomic<_Tp>::value_type __d,
2066 memory_order __s, memory_order __f) _NOEXCEPT2081 memory_order __s, memory_order __f) _NOEXCEPT
2067 _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)2082 _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
2068{2083{
...@@ -2072,8 +2087,8 @@ atomic_compare_exchange_strong_explicit(volatile atomic<_Tp>* __o,...@@ -2072,8 +2087,8 @@ atomic_compare_exchange_strong_explicit(volatile atomic<_Tp>* __o,
2072template <class _Tp>2087template <class _Tp>
2073_LIBCPP_INLINE_VISIBILITY2088_LIBCPP_INLINE_VISIBILITY
2074bool2089bool
2075atomic_compare_exchange_strong_explicit(atomic<_Tp>* __o, _Tp* __e,2090atomic_compare_exchange_strong_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::value_type* __e,
2076 _Tp __d,2091 typename atomic<_Tp>::value_type __d,
2077 memory_order __s, memory_order __f) _NOEXCEPT2092 memory_order __s, memory_order __f) _NOEXCEPT
2078 _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)2093 _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
2079{2094{
...@@ -2156,10 +2171,10 @@ template <class _Tp>...@@ -2156,10 +2171,10 @@ template <class _Tp>
2156_LIBCPP_INLINE_VISIBILITY2171_LIBCPP_INLINE_VISIBILITY
2157typename enable_if2172typename enable_if
2158<2173<
2159 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,2174 is_integral<_Tp>::value && !is_same<_Tp, bool>::value && !is_const<_Tp>::value,
2160 _Tp2175 _Tp
2161>::type2176>::type
2162atomic_fetch_add(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT2177atomic_fetch_add(volatile atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op) _NOEXCEPT
2163{2178{
2164 return __o->fetch_add(__op);2179 return __o->fetch_add(__op);
2165}2180}
...@@ -2168,10 +2183,10 @@ template <class _Tp>...@@ -2168,10 +2183,10 @@ template <class _Tp>
2168_LIBCPP_INLINE_VISIBILITY2183_LIBCPP_INLINE_VISIBILITY
2169typename enable_if2184typename enable_if
2170<2185<
2171 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,2186 is_integral<_Tp>::value && !is_same<_Tp, bool>::value && !is_const<_Tp>::value,
2172 _Tp2187 _Tp
2173>::type2188>::type
2174atomic_fetch_add(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT2189atomic_fetch_add(atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op) _NOEXCEPT
2175{2190{
2176 return __o->fetch_add(__op);2191 return __o->fetch_add(__op);
2177}2192}
...@@ -2179,7 +2194,7 @@ atomic_fetch_add(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT...@@ -2179,7 +2194,7 @@ atomic_fetch_add(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
2179template <class _Tp>2194template <class _Tp>
2180_LIBCPP_INLINE_VISIBILITY2195_LIBCPP_INLINE_VISIBILITY
2181_Tp*2196_Tp*
2182atomic_fetch_add(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT2197atomic_fetch_add(volatile atomic<_Tp*>* __o, typename atomic<_Tp*>::difference_type __op) _NOEXCEPT
2183{2198{
2184 return __o->fetch_add(__op);2199 return __o->fetch_add(__op);
2185}2200}
...@@ -2187,7 +2202,7 @@ atomic_fetch_add(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT...@@ -2187,7 +2202,7 @@ atomic_fetch_add(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
2187template <class _Tp>2202template <class _Tp>
2188_LIBCPP_INLINE_VISIBILITY2203_LIBCPP_INLINE_VISIBILITY
2189_Tp*2204_Tp*
2190atomic_fetch_add(atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT2205atomic_fetch_add(atomic<_Tp*>* __o, typename atomic<_Tp*>::difference_type __op) _NOEXCEPT
2191{2206{
2192 return __o->fetch_add(__op);2207 return __o->fetch_add(__op);
2193}2208}
...@@ -2198,10 +2213,10 @@ template <class _Tp>...@@ -2198,10 +2213,10 @@ template <class _Tp>
2198_LIBCPP_INLINE_VISIBILITY2213_LIBCPP_INLINE_VISIBILITY
2199typename enable_if2214typename enable_if
2200<2215<
2201 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,2216 is_integral<_Tp>::value && !is_same<_Tp, bool>::value && !is_const<_Tp>::value,
2202 _Tp2217 _Tp
2203>::type2218>::type
2204atomic_fetch_add_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT2219atomic_fetch_add_explicit(volatile atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op, memory_order __m) _NOEXCEPT
2205{2220{
2206 return __o->fetch_add(__op, __m);2221 return __o->fetch_add(__op, __m);
2207}2222}
...@@ -2210,10 +2225,10 @@ template <class _Tp>...@@ -2210,10 +2225,10 @@ template <class _Tp>
2210_LIBCPP_INLINE_VISIBILITY2225_LIBCPP_INLINE_VISIBILITY
2211typename enable_if2226typename enable_if
2212<2227<
2213 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,2228 is_integral<_Tp>::value && !is_same<_Tp, bool>::value && !is_const<_Tp>::value,
2214 _Tp2229 _Tp
2215>::type2230>::type
2216atomic_fetch_add_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT2231atomic_fetch_add_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op, memory_order __m) _NOEXCEPT
2217{2232{
2218 return __o->fetch_add(__op, __m);2233 return __o->fetch_add(__op, __m);
2219}2234}
...@@ -2221,8 +2236,7 @@ atomic_fetch_add_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEP...@@ -2221,8 +2236,7 @@ atomic_fetch_add_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEP
2221template <class _Tp>2236template <class _Tp>
2222_LIBCPP_INLINE_VISIBILITY2237_LIBCPP_INLINE_VISIBILITY
2223_Tp*2238_Tp*
2224atomic_fetch_add_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op,2239atomic_fetch_add_explicit(volatile atomic<_Tp*>* __o, typename atomic<_Tp*>::difference_type __op, memory_order __m) _NOEXCEPT
2225 memory_order __m) _NOEXCEPT
2226{2240{
2227 return __o->fetch_add(__op, __m);2241 return __o->fetch_add(__op, __m);
2228}2242}
...@@ -2230,7 +2244,7 @@ atomic_fetch_add_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op,...@@ -2230,7 +2244,7 @@ atomic_fetch_add_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op,
2230template <class _Tp>2244template <class _Tp>
2231_LIBCPP_INLINE_VISIBILITY2245_LIBCPP_INLINE_VISIBILITY
2232_Tp*2246_Tp*
2233atomic_fetch_add_explicit(atomic<_Tp*>* __o, ptrdiff_t __op, memory_order __m) _NOEXCEPT2247atomic_fetch_add_explicit(atomic<_Tp*>* __o, typename atomic<_Tp*>::difference_type __op, memory_order __m) _NOEXCEPT
2234{2248{
2235 return __o->fetch_add(__op, __m);2249 return __o->fetch_add(__op, __m);
2236}2250}
...@@ -2241,10 +2255,10 @@ template <class _Tp>...@@ -2241,10 +2255,10 @@ template <class _Tp>
2241_LIBCPP_INLINE_VISIBILITY2255_LIBCPP_INLINE_VISIBILITY
2242typename enable_if2256typename enable_if
2243<2257<
2244 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,2258 is_integral<_Tp>::value && !is_same<_Tp, bool>::value && !is_const<_Tp>::value,
2245 _Tp2259 _Tp
2246>::type2260>::type
2247atomic_fetch_sub(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT2261atomic_fetch_sub(volatile atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op) _NOEXCEPT
2248{2262{
2249 return __o->fetch_sub(__op);2263 return __o->fetch_sub(__op);
2250}2264}
...@@ -2253,10 +2267,10 @@ template <class _Tp>...@@ -2253,10 +2267,10 @@ template <class _Tp>
2253_LIBCPP_INLINE_VISIBILITY2267_LIBCPP_INLINE_VISIBILITY
2254typename enable_if2268typename enable_if
2255<2269<
2256 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,2270 is_integral<_Tp>::value && !is_same<_Tp, bool>::value && !is_const<_Tp>::value,
2257 _Tp2271 _Tp
2258>::type2272>::type
2259atomic_fetch_sub(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT2273atomic_fetch_sub(atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op) _NOEXCEPT
2260{2274{
2261 return __o->fetch_sub(__op);2275 return __o->fetch_sub(__op);
2262}2276}
...@@ -2264,7 +2278,7 @@ atomic_fetch_sub(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT...@@ -2264,7 +2278,7 @@ atomic_fetch_sub(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
2264template <class _Tp>2278template <class _Tp>
2265_LIBCPP_INLINE_VISIBILITY2279_LIBCPP_INLINE_VISIBILITY
2266_Tp*2280_Tp*
2267atomic_fetch_sub(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT2281atomic_fetch_sub(volatile atomic<_Tp*>* __o, typename atomic<_Tp*>::difference_type __op) _NOEXCEPT
2268{2282{
2269 return __o->fetch_sub(__op);2283 return __o->fetch_sub(__op);
2270}2284}
...@@ -2272,7 +2286,7 @@ atomic_fetch_sub(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT...@@ -2272,7 +2286,7 @@ atomic_fetch_sub(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
2272template <class _Tp>2286template <class _Tp>
2273_LIBCPP_INLINE_VISIBILITY2287_LIBCPP_INLINE_VISIBILITY
2274_Tp*2288_Tp*
2275atomic_fetch_sub(atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT2289atomic_fetch_sub(atomic<_Tp*>* __o, typename atomic<_Tp*>::difference_type __op) _NOEXCEPT
2276{2290{
2277 return __o->fetch_sub(__op);2291 return __o->fetch_sub(__op);
2278}2292}
...@@ -2283,10 +2297,10 @@ template <class _Tp>...@@ -2283,10 +2297,10 @@ template <class _Tp>
2283_LIBCPP_INLINE_VISIBILITY2297_LIBCPP_INLINE_VISIBILITY
2284typename enable_if2298typename enable_if
2285<2299<
2286 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,2300 is_integral<_Tp>::value && !is_same<_Tp, bool>::value && !is_const<_Tp>::value,
2287 _Tp2301 _Tp
2288>::type2302>::type
2289atomic_fetch_sub_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT2303atomic_fetch_sub_explicit(volatile atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op, memory_order __m) _NOEXCEPT
2290{2304{
2291 return __o->fetch_sub(__op, __m);2305 return __o->fetch_sub(__op, __m);
2292}2306}
...@@ -2295,10 +2309,10 @@ template <class _Tp>...@@ -2295,10 +2309,10 @@ template <class _Tp>
2295_LIBCPP_INLINE_VISIBILITY2309_LIBCPP_INLINE_VISIBILITY
2296typename enable_if2310typename enable_if
2297<2311<
2298 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,2312 is_integral<_Tp>::value && !is_same<_Tp, bool>::value && !is_const<_Tp>::value,
2299 _Tp2313 _Tp
2300>::type2314>::type
2301atomic_fetch_sub_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT2315atomic_fetch_sub_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op, memory_order __m) _NOEXCEPT
2302{2316{
2303 return __o->fetch_sub(__op, __m);2317 return __o->fetch_sub(__op, __m);
2304}2318}
...@@ -2306,8 +2320,7 @@ atomic_fetch_sub_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEP...@@ -2306,8 +2320,7 @@ atomic_fetch_sub_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEP
2306template <class _Tp>2320template <class _Tp>
2307_LIBCPP_INLINE_VISIBILITY2321_LIBCPP_INLINE_VISIBILITY
2308_Tp*2322_Tp*
2309atomic_fetch_sub_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op,2323atomic_fetch_sub_explicit(volatile atomic<_Tp*>* __o, typename atomic<_Tp*>::difference_type __op, memory_order __m) _NOEXCEPT
2310 memory_order __m) _NOEXCEPT
2311{2324{
2312 return __o->fetch_sub(__op, __m);2325 return __o->fetch_sub(__op, __m);
2313}2326}
...@@ -2315,7 +2328,7 @@ atomic_fetch_sub_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op,...@@ -2315,7 +2328,7 @@ atomic_fetch_sub_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op,
2315template <class _Tp>2328template <class _Tp>
2316_LIBCPP_INLINE_VISIBILITY2329_LIBCPP_INLINE_VISIBILITY
2317_Tp*2330_Tp*
2318atomic_fetch_sub_explicit(atomic<_Tp*>* __o, ptrdiff_t __op, memory_order __m) _NOEXCEPT2331atomic_fetch_sub_explicit(atomic<_Tp*>* __o, typename atomic<_Tp*>::difference_type __op, memory_order __m) _NOEXCEPT
2319{2332{
2320 return __o->fetch_sub(__op, __m);2333 return __o->fetch_sub(__op, __m);
2321}2334}
...@@ -2329,7 +2342,7 @@ typename enable_if...@@ -2329,7 +2342,7 @@ typename enable_if
2329 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,2342 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
2330 _Tp2343 _Tp
2331>::type2344>::type
2332atomic_fetch_and(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT2345atomic_fetch_and(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op) _NOEXCEPT
2333{2346{
2334 return __o->fetch_and(__op);2347 return __o->fetch_and(__op);
2335}2348}
...@@ -2341,7 +2354,7 @@ typename enable_if...@@ -2341,7 +2354,7 @@ typename enable_if
2341 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,2354 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
2342 _Tp2355 _Tp
2343>::type2356>::type
2344atomic_fetch_and(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT2357atomic_fetch_and(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op) _NOEXCEPT
2345{2358{
2346 return __o->fetch_and(__op);2359 return __o->fetch_and(__op);
2347}2360}
...@@ -2355,7 +2368,7 @@ typename enable_if...@@ -2355,7 +2368,7 @@ typename enable_if
2355 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,2368 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
2356 _Tp2369 _Tp
2357>::type2370>::type
2358atomic_fetch_and_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT2371atomic_fetch_and_explicit(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op, memory_order __m) _NOEXCEPT
2359{2372{
2360 return __o->fetch_and(__op, __m);2373 return __o->fetch_and(__op, __m);
2361}2374}
...@@ -2367,7 +2380,7 @@ typename enable_if...@@ -2367,7 +2380,7 @@ typename enable_if
2367 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,2380 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
2368 _Tp2381 _Tp
2369>::type2382>::type
2370atomic_fetch_and_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT2383atomic_fetch_and_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op, memory_order __m) _NOEXCEPT
2371{2384{
2372 return __o->fetch_and(__op, __m);2385 return __o->fetch_and(__op, __m);
2373}2386}
...@@ -2381,7 +2394,7 @@ typename enable_if...@@ -2381,7 +2394,7 @@ typename enable_if
2381 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,2394 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
2382 _Tp2395 _Tp
2383>::type2396>::type
2384atomic_fetch_or(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT2397atomic_fetch_or(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op) _NOEXCEPT
2385{2398{
2386 return __o->fetch_or(__op);2399 return __o->fetch_or(__op);
2387}2400}
...@@ -2393,7 +2406,7 @@ typename enable_if...@@ -2393,7 +2406,7 @@ typename enable_if
2393 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,2406 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
2394 _Tp2407 _Tp
2395>::type2408>::type
2396atomic_fetch_or(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT2409atomic_fetch_or(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op) _NOEXCEPT
2397{2410{
2398 return __o->fetch_or(__op);2411 return __o->fetch_or(__op);
2399}2412}
...@@ -2407,7 +2420,7 @@ typename enable_if...@@ -2407,7 +2420,7 @@ typename enable_if
2407 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,2420 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
2408 _Tp2421 _Tp
2409>::type2422>::type
2410atomic_fetch_or_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT2423atomic_fetch_or_explicit(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op, memory_order __m) _NOEXCEPT
2411{2424{
2412 return __o->fetch_or(__op, __m);2425 return __o->fetch_or(__op, __m);
2413}2426}
...@@ -2419,7 +2432,7 @@ typename enable_if...@@ -2419,7 +2432,7 @@ typename enable_if
2419 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,2432 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
2420 _Tp2433 _Tp
2421>::type2434>::type
2422atomic_fetch_or_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT2435atomic_fetch_or_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op, memory_order __m) _NOEXCEPT
2423{2436{
2424 return __o->fetch_or(__op, __m);2437 return __o->fetch_or(__op, __m);
2425}2438}
...@@ -2433,7 +2446,7 @@ typename enable_if...@@ -2433,7 +2446,7 @@ typename enable_if
2433 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,2446 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
2434 _Tp2447 _Tp
2435>::type2448>::type
2436atomic_fetch_xor(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT2449atomic_fetch_xor(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op) _NOEXCEPT
2437{2450{
2438 return __o->fetch_xor(__op);2451 return __o->fetch_xor(__op);
2439}2452}
...@@ -2445,7 +2458,7 @@ typename enable_if...@@ -2445,7 +2458,7 @@ typename enable_if
2445 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,2458 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
2446 _Tp2459 _Tp
2447>::type2460>::type
2448atomic_fetch_xor(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT2461atomic_fetch_xor(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op) _NOEXCEPT
2449{2462{
2450 return __o->fetch_xor(__op);2463 return __o->fetch_xor(__op);
2451}2464}
...@@ -2459,7 +2472,7 @@ typename enable_if...@@ -2459,7 +2472,7 @@ typename enable_if
2459 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,2472 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
2460 _Tp2473 _Tp
2461>::type2474>::type
2462atomic_fetch_xor_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT2475atomic_fetch_xor_explicit(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op, memory_order __m) _NOEXCEPT
2463{2476{
2464 return __o->fetch_xor(__op, __m);2477 return __o->fetch_xor(__op, __m);
2465}2478}
...@@ -2471,7 +2484,7 @@ typename enable_if...@@ -2471,7 +2484,7 @@ typename enable_if
2471 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,2484 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
2472 _Tp2485 _Tp
2473>::type2486>::type
2474atomic_fetch_xor_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT2487atomic_fetch_xor_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op, memory_order __m) _NOEXCEPT
2475{2488{
2476 return __o->fetch_xor(__op, __m);2489 return __o->fetch_xor(__op, __m);
2477}2490}
...@@ -2715,6 +2728,9 @@ typedef atomic<long> atomic_long;...@@ -2715,6 +2728,9 @@ typedef atomic<long> atomic_long;
2715typedef atomic<unsigned long> atomic_ulong;2728typedef atomic<unsigned long> atomic_ulong;
2716typedef atomic<long long> atomic_llong;2729typedef atomic<long long> atomic_llong;
2717typedef atomic<unsigned long long> atomic_ullong;2730typedef atomic<unsigned long long> atomic_ullong;
2731#ifndef _LIBCPP_NO_HAS_CHAR8_T
2732typedef atomic<char8_t> atomic_char8_t;
2733#endif
2718typedef atomic<char16_t> atomic_char16_t;2734typedef atomic<char16_t> atomic_char16_t;
2719typedef atomic<char32_t> atomic_char32_t;2735typedef atomic<char32_t> atomic_char32_t;
2720typedef atomic<wchar_t> atomic_wchar_t;2736typedef atomic<wchar_t> atomic_wchar_t;
lib/libcxx/include/barrier+10-2
...@@ -22,6 +22,8 @@ namespace std...@@ -22,6 +22,8 @@ namespace std
22 public:22 public:
23 using arrival_token = see below;23 using arrival_token = see below;
2424
25 static constexpr ptrdiff_t max() noexcept;
26
25 constexpr explicit barrier(ptrdiff_t phase_count,27 constexpr explicit barrier(ptrdiff_t phase_count,
26 CompletionFunction f = CompletionFunction());28 CompletionFunction f = CompletionFunction());
27 ~barrier();29 ~barrier();
...@@ -44,6 +46,7 @@ namespace std...@@ -44,6 +46,7 @@ namespace std
44*/46*/
4547
46#include <__config>48#include <__config>
49#include <__availability>
47#include <atomic>50#include <atomic>
48#ifndef _LIBCPP_HAS_NO_TREE_BARRIER51#ifndef _LIBCPP_HAS_NO_TREE_BARRIER
49# include <memory>52# include <memory>
...@@ -57,6 +60,9 @@ namespace std...@@ -57,6 +60,9 @@ namespace std
57# error <barrier> is not supported on this single threaded system60# error <barrier> is not supported on this single threaded system
58#endif61#endif
5962
63_LIBCPP_PUSH_MACROS
64#include <__undef_macros>
65
60#if _LIBCPP_STD_VER >= 1466#if _LIBCPP_STD_VER >= 14
6167
62_LIBCPP_BEGIN_NAMESPACE_STD68_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -287,7 +293,7 @@ public:...@@ -287,7 +293,7 @@ public:
287293
288 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY294 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
289 barrier(ptrdiff_t __count, _CompletionF __completion = _CompletionF())295 barrier(ptrdiff_t __count, _CompletionF __completion = _CompletionF())
290 : __b(__count, std::move(__completion)) {296 : __b(__count, _VSTD::move(__completion)) {
291 }297 }
292298
293 barrier(barrier const&) = delete;299 barrier(barrier const&) = delete;
...@@ -301,7 +307,7 @@ public:...@@ -301,7 +307,7 @@ public:
301 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY307 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
302 void wait(arrival_token&& __phase) const308 void wait(arrival_token&& __phase) const
303 {309 {
304 __b.wait(std::move(__phase));310 __b.wait(_VSTD::move(__phase));
305 }311 }
306 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY312 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
307 void arrive_and_wait()313 void arrive_and_wait()
...@@ -319,4 +325,6 @@ _LIBCPP_END_NAMESPACE_STD...@@ -319,4 +325,6 @@ _LIBCPP_END_NAMESPACE_STD
319325
320#endif // _LIBCPP_STD_VER >= 14326#endif // _LIBCPP_STD_VER >= 14
321327
328_LIBCPP_POP_MACROS
329
322#endif //_LIBCPP_BARRIER330#endif //_LIBCPP_BARRIER
lib/libcxx/include/bit+14-15
...@@ -17,13 +17,13 @@ namespace std {...@@ -17,13 +17,13 @@ namespace std {
1717
18 // [bit.pow.two], integral powers of 218 // [bit.pow.two], integral powers of 2
19 template <class T>19 template <class T>
20 constexpr bool ispow2(T x) noexcept; // C++2020 constexpr bool has_single_bit(T x) noexcept; // C++20
21 template <class T>21 template <class T>
22 constexpr T ceil2(T x); // C++2022 constexpr T bit_ceil(T x); // C++20
23 template <class T>23 template <class T>
24 constexpr T floor2(T x) noexcept; // C++2024 constexpr T bit_floor(T x) noexcept; // C++20
25 template <class T>25 template <class T>
26 constexpr T log2p1(T x) noexcept; // C++2026 constexpr T bit_width(T x) noexcept; // C++20
2727
28 // [bit.rotate], rotating28 // [bit.rotate], rotating
29 template<class T>29 template<class T>
...@@ -343,14 +343,14 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11...@@ -343,14 +343,14 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
343unsigned __bit_log2(_Tp __t) _NOEXCEPT343unsigned __bit_log2(_Tp __t) _NOEXCEPT
344{344{
345 static_assert(__bitop_unsigned_integer<_Tp>::value, "__bit_log2 requires unsigned");345 static_assert(__bitop_unsigned_integer<_Tp>::value, "__bit_log2 requires unsigned");
346 return std::numeric_limits<_Tp>::digits - 1 - __countl_zero(__t);346 return numeric_limits<_Tp>::digits - 1 - __countl_zero(__t);
347}347}
348348
349template <class _Tp>349template <class _Tp>
350_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR350_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
351bool __ispow2(_Tp __t) _NOEXCEPT351bool __has_single_bit(_Tp __t) _NOEXCEPT
352{352{
353 static_assert(__bitop_unsigned_integer<_Tp>::value, "__ispow2 requires unsigned");353 static_assert(__bitop_unsigned_integer<_Tp>::value, "__has_single_bit requires unsigned");
354 return __t != 0 && (((__t & (__t - 1)) == 0));354 return __t != 0 && (((__t & (__t - 1)) == 0));
355}355}
356356
...@@ -399,7 +399,7 @@ _LIBCPP_INLINE_VISIBILITY constexpr...@@ -399,7 +399,7 @@ _LIBCPP_INLINE_VISIBILITY constexpr
399enable_if_t<__bitop_unsigned_integer<_Tp>::value, int>399enable_if_t<__bitop_unsigned_integer<_Tp>::value, int>
400countr_zero(_Tp __t) noexcept400countr_zero(_Tp __t) noexcept
401{401{
402 return __countr_zero(__t);402 return __countr_zero(__t);
403}403}
404404
405405
...@@ -424,15 +424,15 @@ popcount(_Tp __t) noexcept...@@ -424,15 +424,15 @@ popcount(_Tp __t) noexcept
424template <class _Tp>424template <class _Tp>
425_LIBCPP_INLINE_VISIBILITY constexpr425_LIBCPP_INLINE_VISIBILITY constexpr
426enable_if_t<__bitop_unsigned_integer<_Tp>::value, bool>426enable_if_t<__bitop_unsigned_integer<_Tp>::value, bool>
427ispow2(_Tp __t) noexcept427has_single_bit(_Tp __t) noexcept
428{428{
429 return __ispow2(__t);429 return __has_single_bit(__t);
430}430}
431431
432template <class _Tp>432template <class _Tp>
433_LIBCPP_INLINE_VISIBILITY constexpr433_LIBCPP_INLINE_VISIBILITY constexpr
434enable_if_t<__bitop_unsigned_integer<_Tp>::value, _Tp>434enable_if_t<__bitop_unsigned_integer<_Tp>::value, _Tp>
435floor2(_Tp __t) noexcept435bit_floor(_Tp __t) noexcept
436{436{
437 return __t == 0 ? 0 : _Tp{1} << __bit_log2(__t);437 return __t == 0 ? 0 : _Tp{1} << __bit_log2(__t);
438}438}
...@@ -440,11 +440,11 @@ floor2(_Tp __t) noexcept...@@ -440,11 +440,11 @@ floor2(_Tp __t) noexcept
440template <class _Tp>440template <class _Tp>
441_LIBCPP_INLINE_VISIBILITY constexpr441_LIBCPP_INLINE_VISIBILITY constexpr
442enable_if_t<__bitop_unsigned_integer<_Tp>::value, _Tp>442enable_if_t<__bitop_unsigned_integer<_Tp>::value, _Tp>
443ceil2(_Tp __t) noexcept443bit_ceil(_Tp __t) noexcept
444{444{
445 if (__t < 2) return 1;445 if (__t < 2) return 1;
446 const unsigned __n = numeric_limits<_Tp>::digits - countl_zero((_Tp)(__t - 1u));446 const unsigned __n = numeric_limits<_Tp>::digits - countl_zero((_Tp)(__t - 1u));
447 _LIBCPP_DEBUG_ASSERT(__libcpp_is_constant_evaluated() || __n != numeric_limits<_Tp>::digits, "Bad input to ceil2");447 _LIBCPP_DEBUG_ASSERT(__libcpp_is_constant_evaluated() || __n != numeric_limits<_Tp>::digits, "Bad input to bit_ceil");
448448
449 if constexpr (sizeof(_Tp) >= sizeof(unsigned))449 if constexpr (sizeof(_Tp) >= sizeof(unsigned))
450 return _Tp{1} << __n;450 return _Tp{1} << __n;
...@@ -459,12 +459,11 @@ ceil2(_Tp __t) noexcept...@@ -459,12 +459,11 @@ ceil2(_Tp __t) noexcept
459template <class _Tp>459template <class _Tp>
460_LIBCPP_INLINE_VISIBILITY constexpr460_LIBCPP_INLINE_VISIBILITY constexpr
461enable_if_t<__bitop_unsigned_integer<_Tp>::value, _Tp>461enable_if_t<__bitop_unsigned_integer<_Tp>::value, _Tp>
462log2p1(_Tp __t) noexcept462bit_width(_Tp __t) noexcept
463{463{
464 return __t == 0 ? 0 : __bit_log2(__t) + 1;464 return __t == 0 ? 0 : __bit_log2(__t) + 1;
465}465}
466466
467
468enum class endian467enum class endian
469{468{
470 little = 0xDEAD,469 little = 0xDEAD,
lib/libcxx/include/bitset+5-5
...@@ -380,7 +380,7 @@ unsigned long long...@@ -380,7 +380,7 @@ unsigned long long
380__bitset<_N_words, _Size>::to_ullong(true_type, true_type) const380__bitset<_N_words, _Size>::to_ullong(true_type, true_type) const
381{381{
382 unsigned long long __r = __first_[0];382 unsigned long long __r = __first_[0];
383 for (std::size_t __i = 1; __i < sizeof(unsigned long long) / sizeof(__storage_type); ++__i)383 for (size_t __i = 1; __i < sizeof(unsigned long long) / sizeof(__storage_type); ++__i)
384 __r |= static_cast<unsigned long long>(__first_[__i]) << (sizeof(__storage_type) * CHAR_BIT);384 __r |= static_cast<unsigned long long>(__first_[__i]) << (sizeof(__storage_type) * CHAR_BIT);
385 return __r;385 return __r;
386}386}
...@@ -625,13 +625,13 @@ protected:...@@ -625,13 +625,13 @@ protected:
625 explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long) _NOEXCEPT;625 explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long) _NOEXCEPT;
626626
627 _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t) _NOEXCEPT627 _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t) _NOEXCEPT
628 {return reference(0, 1);}628 {return reference(nullptr, 1);}
629 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t) const _NOEXCEPT629 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t) const _NOEXCEPT
630 {return const_reference(0, 1);}630 {return const_reference(nullptr, 1);}
631 _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_t) _NOEXCEPT631 _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_t) _NOEXCEPT
632 {return iterator(0, 0);}632 {return iterator(nullptr, 0);}
633 _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t) const _NOEXCEPT633 _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t) const _NOEXCEPT
634 {return const_iterator(0, 0);}634 {return const_iterator(nullptr, 0);}
635635
636 _LIBCPP_INLINE_VISIBILITY void operator&=(const __bitset&) _NOEXCEPT {}636 _LIBCPP_INLINE_VISIBILITY void operator&=(const __bitset&) _NOEXCEPT {}
637 _LIBCPP_INLINE_VISIBILITY void operator|=(const __bitset&) _NOEXCEPT {}637 _LIBCPP_INLINE_VISIBILITY void operator|=(const __bitset&) _NOEXCEPT {}
lib/libcxx/include/charconv+14-13
...@@ -74,12 +74,13 @@ namespace std {...@@ -74,12 +74,13 @@ namespace std {
74*/74*/
7575
76#include <__config>76#include <__config>
77#include <__availability>
77#include <__errc>78#include <__errc>
78#include <type_traits>79#include <cmath> // for log2f
80#include <cstdint>
81#include <cstring>
79#include <limits>82#include <limits>
80#include <stdint.h>83#include <type_traits>
81#include <string.h>
82#include <math.h>
8384
84#include <__debug>85#include <__debug>
8586
...@@ -206,7 +207,7 @@ __mul_overflowed(unsigned char __a, _Tp __b, unsigned char& __r)...@@ -206,7 +207,7 @@ __mul_overflowed(unsigned char __a, _Tp __b, unsigned char& __r)
206{207{
207 auto __c = __a * __b;208 auto __c = __a * __b;
208 __r = __c;209 __r = __c;
209 return __c > (numeric_limits<unsigned char>::max)();210 return __c > numeric_limits<unsigned char>::max();
210}211}
211212
212template <typename _Tp>213template <typename _Tp>
...@@ -215,7 +216,7 @@ __mul_overflowed(unsigned short __a, _Tp __b, unsigned short& __r)...@@ -215,7 +216,7 @@ __mul_overflowed(unsigned short __a, _Tp __b, unsigned short& __r)
215{216{
216 auto __c = __a * __b;217 auto __c = __a * __b;
217 __r = __c;218 __r = __c;
218 return __c > (numeric_limits<unsigned short>::max)();219 return __c > numeric_limits<unsigned short>::max();
219}220}
220221
221template <typename _Tp>222template <typename _Tp>
...@@ -226,7 +227,7 @@ __mul_overflowed(_Tp __a, _Tp __b, _Tp& __r)...@@ -226,7 +227,7 @@ __mul_overflowed(_Tp __a, _Tp __b, _Tp& __r)
226#if !defined(_LIBCPP_COMPILER_MSVC)227#if !defined(_LIBCPP_COMPILER_MSVC)
227 return __builtin_mul_overflow(__a, __b, &__r);228 return __builtin_mul_overflow(__a, __b, &__r);
228#else229#else
229 bool __did = __b && ((numeric_limits<_Tp>::max)() / __b) < __a;230 bool __did = __b && (numeric_limits<_Tp>::max() / __b) < __a;
230 __r = __a * __b;231 __r = __a * __b;
231 return __did;232 return __did;
232#endif233#endif
...@@ -332,7 +333,7 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type)...@@ -332,7 +333,7 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type)
332 auto __len = __p - __buf;333 auto __len = __p - __buf;
333 if (__len <= __diff)334 if (__len <= __diff)
334 {335 {
335 memcpy(__first, __buf, __len);336 _VSTD::memcpy(__first, __buf, __len);
336 return {__first + __len, {}};337 return {__first + __len, {}};
337 }338 }
338 else339 else
...@@ -381,7 +382,7 @@ __to_chars_integral(char* __first, char* __last, _Tp __value, int __base,...@@ -381,7 +382,7 @@ __to_chars_integral(char* __first, char* __last, _Tp __value, int __base,
381 return {__last, errc::value_too_large};382 return {__last, errc::value_too_large};
382 else383 else
383 {384 {
384 memmove(__first, __p, __len);385 _VSTD::memmove(__first, __p, __len);
385 return {__first + __len, {}};386 return {__first + __len, {}};
386 }387 }
387}388}
...@@ -428,13 +429,13 @@ __sign_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts... __args)...@@ -428,13 +429,13 @@ __sign_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts... __args)
428 if (__x <= __complement(__to_unsigned(__tl::min())))429 if (__x <= __complement(__to_unsigned(__tl::min())))
429 {430 {
430 __x = __complement(__x);431 __x = __complement(__x);
431 memcpy(&__value, &__x, sizeof(__x));432 _VSTD::memcpy(&__value, &__x, sizeof(__x));
432 return __r;433 return __r;
433 }434 }
434 }435 }
435 else436 else
436 {437 {
437 if (__x <= (__tl::max)())438 if (__x <= __tl::max())
438 {439 {
439 __value = __x;440 __value = __x;
440 return __r;441 return __r;
...@@ -525,7 +526,7 @@ __from_chars_atoi(const char* __first, const char* __last, _Tp& __value)...@@ -525,7 +526,7 @@ __from_chars_atoi(const char* __first, const char* __last, _Tp& __value)
525 auto __p = __tx::__read(__first, __last, __a, __b);526 auto __p = __tx::__read(__first, __last, __a, __b);
526 if (__p == __last || !__in_pattern(*__p))527 if (__p == __last || !__in_pattern(*__p))
527 {528 {
528 __output_type __m = (numeric_limits<_Tp>::max)();529 __output_type __m = numeric_limits<_Tp>::max();
529 if (__m >= __a && __m - __a >= __b)530 if (__m >= __a && __m - __a >= __b)
530 {531 {
531 __value = __a + __b;532 __value = __a + __b;
...@@ -580,7 +581,7 @@ __from_chars_integral(const char* __first, const char* __last, _Tp& __value,...@@ -580,7 +581,7 @@ __from_chars_integral(const char* __first, const char* __last, _Tp& __value,
580581
581 if (__p == __last || !__in_pattern(*__p, __base))582 if (__p == __last || !__in_pattern(*__p, __base))
582 {583 {
583 if ((__tl::max)() - __a >= __b)584 if (__tl::max() - __a >= __b)
584 {585 {
585 __value = __a + __b;586 __value = __a + __b;
586 return {__p, {}};587 return {__p, {}};
lib/libcxx/include/chrono+4-3
...@@ -824,6 +824,7 @@ constexpr chrono::year operator ""y(unsigned lo...@@ -824,6 +824,7 @@ constexpr chrono::year operator ""y(unsigned lo
824*/824*/
825825
826#include <__config>826#include <__config>
827#include <__availability>
827#include <ctime>828#include <ctime>
828#include <type_traits>829#include <type_traits>
829#include <ratio>830#include <ratio>
...@@ -1076,7 +1077,7 @@ public:...@@ -1076,7 +1077,7 @@ public:
1076 is_convertible<_Rep2, rep>::value &&1077 is_convertible<_Rep2, rep>::value &&
1077 (treat_as_floating_point<rep>::value ||1078 (treat_as_floating_point<rep>::value ||
1078 !treat_as_floating_point<_Rep2>::value)1079 !treat_as_floating_point<_Rep2>::value)
1079 >::type* = 0)1080 >::type* = nullptr)
1080 : __rep_(__r) {}1081 : __rep_(__r) {}
10811082
1082 // conversions1083 // conversions
...@@ -1089,7 +1090,7 @@ public:...@@ -1089,7 +1090,7 @@ public:
1089 treat_as_floating_point<rep>::value ||1090 treat_as_floating_point<rep>::value ||
1090 (__no_overflow<_Period2, period>::type::den == 1 &&1091 (__no_overflow<_Period2, period>::type::den == 1 &&
1091 !treat_as_floating_point<_Rep2>::value))1092 !treat_as_floating_point<_Rep2>::value))
1092 >::type* = 0)1093 >::type* = nullptr)
1093 : __rep_(_VSTD::chrono::duration_cast<duration>(__d).count()) {}1094 : __rep_(_VSTD::chrono::duration_cast<duration>(__d).count()) {}
10941095
1095 // observer1096 // observer
...@@ -1375,7 +1376,7 @@ public:...@@ -1375,7 +1376,7 @@ public:
1375 typename enable_if1376 typename enable_if
1376 <1377 <
1377 is_convertible<_Duration2, duration>::value1378 is_convertible<_Duration2, duration>::value
1378 >::type* = 0)1379 >::type* = nullptr)
1379 : __d_(t.time_since_epoch()) {}1380 : __d_(t.time_since_epoch()) {}
13801381
1381 // observer1382 // observer
lib/libcxx/include/cmath+2-2
...@@ -660,8 +660,8 @@ _LIBCPP_CONSTEXPR _IntT __max_representable_int_for_float() _NOEXCEPT {...@@ -660,8 +660,8 @@ _LIBCPP_CONSTEXPR _IntT __max_representable_int_for_float() _NOEXCEPT {
660template <class _IntT, class _RealT>660template <class _IntT, class _RealT>
661_LIBCPP_INLINE_VISIBILITY661_LIBCPP_INLINE_VISIBILITY
662_IntT __clamp_to_integral(_RealT __r) _NOEXCEPT {662_IntT __clamp_to_integral(_RealT __r) _NOEXCEPT {
663 using _Lim = std::numeric_limits<_IntT>;663 using _Lim = numeric_limits<_IntT>;
664 const _IntT _MaxVal = std::__max_representable_int_for_float<_IntT, _RealT>();664 const _IntT _MaxVal = __max_representable_int_for_float<_IntT, _RealT>();
665 if (__r >= ::nextafter(static_cast<_RealT>(_MaxVal), INFINITY)) {665 if (__r >= ::nextafter(static_cast<_RealT>(_MaxVal), INFINITY)) {
666 return _Lim::max();666 return _Lim::max();
667 } else if (__r <= _Lim::lowest()) {667 } else if (__r <= _Lim::lowest()) {
lib/libcxx/include/codecvt+24
...@@ -109,6 +109,7 @@ protected:...@@ -109,6 +109,7 @@ protected:
109 virtual int do_max_length() const _NOEXCEPT;109 virtual int do_max_length() const _NOEXCEPT;
110};110};
111111
112_LIBCPP_SUPPRESS_DEPRECATED_PUSH
112template <>113template <>
113class _LIBCPP_TYPE_VIS __codecvt_utf8<char16_t>114class _LIBCPP_TYPE_VIS __codecvt_utf8<char16_t>
114 : public codecvt<char16_t, char, mbstate_t>115 : public codecvt<char16_t, char, mbstate_t>
...@@ -125,6 +126,8 @@ public:...@@ -125,6 +126,8 @@ public:
125 codecvt_mode _Mode)126 codecvt_mode _Mode)
126 : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),127 : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
127 _Mode_(_Mode) {}128 _Mode_(_Mode) {}
129_LIBCPP_SUPPRESS_DEPRECATED_POP
130
128protected:131protected:
129 virtual result132 virtual result
130 do_out(state_type& __st,133 do_out(state_type& __st,
...@@ -144,6 +147,7 @@ protected:...@@ -144,6 +147,7 @@ protected:
144 virtual int do_max_length() const _NOEXCEPT;147 virtual int do_max_length() const _NOEXCEPT;
145};148};
146149
150_LIBCPP_SUPPRESS_DEPRECATED_PUSH
147template <>151template <>
148class _LIBCPP_TYPE_VIS __codecvt_utf8<char32_t>152class _LIBCPP_TYPE_VIS __codecvt_utf8<char32_t>
149 : public codecvt<char32_t, char, mbstate_t>153 : public codecvt<char32_t, char, mbstate_t>
...@@ -160,6 +164,8 @@ public:...@@ -160,6 +164,8 @@ public:
160 codecvt_mode _Mode)164 codecvt_mode _Mode)
161 : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),165 : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
162 _Mode_(_Mode) {}166 _Mode_(_Mode) {}
167_LIBCPP_SUPPRESS_DEPRECATED_POP
168
163protected:169protected:
164 virtual result170 virtual result
165 do_out(state_type& __st,171 do_out(state_type& __st,
...@@ -267,6 +273,7 @@ protected:...@@ -267,6 +273,7 @@ protected:
267 virtual int do_max_length() const _NOEXCEPT;273 virtual int do_max_length() const _NOEXCEPT;
268};274};
269275
276_LIBCPP_SUPPRESS_DEPRECATED_PUSH
270template <>277template <>
271class _LIBCPP_TYPE_VIS __codecvt_utf16<char16_t, false>278class _LIBCPP_TYPE_VIS __codecvt_utf16<char16_t, false>
272 : public codecvt<char16_t, char, mbstate_t>279 : public codecvt<char16_t, char, mbstate_t>
...@@ -283,6 +290,8 @@ public:...@@ -283,6 +290,8 @@ public:
283 codecvt_mode _Mode)290 codecvt_mode _Mode)
284 : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),291 : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
285 _Mode_(_Mode) {}292 _Mode_(_Mode) {}
293_LIBCPP_SUPPRESS_DEPRECATED_POP
294
286protected:295protected:
287 virtual result296 virtual result
288 do_out(state_type& __st,297 do_out(state_type& __st,
...@@ -302,6 +311,7 @@ protected:...@@ -302,6 +311,7 @@ protected:
302 virtual int do_max_length() const _NOEXCEPT;311 virtual int do_max_length() const _NOEXCEPT;
303};312};
304313
314_LIBCPP_SUPPRESS_DEPRECATED_PUSH
305template <>315template <>
306class _LIBCPP_TYPE_VIS __codecvt_utf16<char16_t, true>316class _LIBCPP_TYPE_VIS __codecvt_utf16<char16_t, true>
307 : public codecvt<char16_t, char, mbstate_t>317 : public codecvt<char16_t, char, mbstate_t>
...@@ -318,6 +328,8 @@ public:...@@ -318,6 +328,8 @@ public:
318 codecvt_mode _Mode)328 codecvt_mode _Mode)
319 : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),329 : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
320 _Mode_(_Mode) {}330 _Mode_(_Mode) {}
331_LIBCPP_SUPPRESS_DEPRECATED_POP
332
321protected:333protected:
322 virtual result334 virtual result
323 do_out(state_type& __st,335 do_out(state_type& __st,
...@@ -337,6 +349,7 @@ protected:...@@ -337,6 +349,7 @@ protected:
337 virtual int do_max_length() const _NOEXCEPT;349 virtual int do_max_length() const _NOEXCEPT;
338};350};
339351
352_LIBCPP_SUPPRESS_DEPRECATED_PUSH
340template <>353template <>
341class _LIBCPP_TYPE_VIS __codecvt_utf16<char32_t, false>354class _LIBCPP_TYPE_VIS __codecvt_utf16<char32_t, false>
342 : public codecvt<char32_t, char, mbstate_t>355 : public codecvt<char32_t, char, mbstate_t>
...@@ -353,6 +366,8 @@ public:...@@ -353,6 +366,8 @@ public:
353 codecvt_mode _Mode)366 codecvt_mode _Mode)
354 : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),367 : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
355 _Mode_(_Mode) {}368 _Mode_(_Mode) {}
369_LIBCPP_SUPPRESS_DEPRECATED_POP
370
356protected:371protected:
357 virtual result372 virtual result
358 do_out(state_type& __st,373 do_out(state_type& __st,
...@@ -372,6 +387,7 @@ protected:...@@ -372,6 +387,7 @@ protected:
372 virtual int do_max_length() const _NOEXCEPT;387 virtual int do_max_length() const _NOEXCEPT;
373};388};
374389
390_LIBCPP_SUPPRESS_DEPRECATED_PUSH
375template <>391template <>
376class _LIBCPP_TYPE_VIS __codecvt_utf16<char32_t, true>392class _LIBCPP_TYPE_VIS __codecvt_utf16<char32_t, true>
377 : public codecvt<char32_t, char, mbstate_t>393 : public codecvt<char32_t, char, mbstate_t>
...@@ -388,6 +404,8 @@ public:...@@ -388,6 +404,8 @@ public:
388 codecvt_mode _Mode)404 codecvt_mode _Mode)
389 : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),405 : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
390 _Mode_(_Mode) {}406 _Mode_(_Mode) {}
407_LIBCPP_SUPPRESS_DEPRECATED_POP
408
391protected:409protected:
392 virtual result410 virtual result
393 do_out(state_type& __st,411 do_out(state_type& __st,
...@@ -460,6 +478,7 @@ protected:...@@ -460,6 +478,7 @@ protected:
460 virtual int do_max_length() const _NOEXCEPT;478 virtual int do_max_length() const _NOEXCEPT;
461};479};
462480
481_LIBCPP_SUPPRESS_DEPRECATED_PUSH
463template <>482template <>
464class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<char32_t>483class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<char32_t>
465 : public codecvt<char32_t, char, mbstate_t>484 : public codecvt<char32_t, char, mbstate_t>
...@@ -476,6 +495,8 @@ public:...@@ -476,6 +495,8 @@ public:
476 codecvt_mode _Mode)495 codecvt_mode _Mode)
477 : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),496 : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
478 _Mode_(_Mode) {}497 _Mode_(_Mode) {}
498_LIBCPP_SUPPRESS_DEPRECATED_POP
499
479protected:500protected:
480 virtual result501 virtual result
481 do_out(state_type& __st,502 do_out(state_type& __st,
...@@ -495,6 +516,7 @@ protected:...@@ -495,6 +516,7 @@ protected:
495 virtual int do_max_length() const _NOEXCEPT;516 virtual int do_max_length() const _NOEXCEPT;
496};517};
497518
519_LIBCPP_SUPPRESS_DEPRECATED_PUSH
498template <>520template <>
499class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<char16_t>521class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<char16_t>
500 : public codecvt<char16_t, char, mbstate_t>522 : public codecvt<char16_t, char, mbstate_t>
...@@ -511,6 +533,8 @@ public:...@@ -511,6 +533,8 @@ public:
511 codecvt_mode _Mode)533 codecvt_mode _Mode)
512 : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),534 : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
513 _Mode_(_Mode) {}535 _Mode_(_Mode) {}
536_LIBCPP_SUPPRESS_DEPRECATED_POP
537
514protected:538protected:
515 virtual result539 virtual result
516 do_out(state_type& __st,540 do_out(state_type& __st,
lib/libcxx/include/compare+9-4
...@@ -154,8 +154,13 @@ enum class _LIBCPP_ENUM_VIS _NCmpResult : signed char {...@@ -154,8 +154,13 @@ enum class _LIBCPP_ENUM_VIS _NCmpResult : signed char {
154 __unordered = -127154 __unordered = -127
155};155};
156156
157struct _CmpUnspecifiedType;157struct _CmpUnspecifiedParam {
158using _CmpUnspecifiedParam = void (_CmpUnspecifiedType::*)();158 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEVAL
159 _CmpUnspecifiedParam(int _CmpUnspecifiedParam::*) noexcept {}
160
161 template<typename _Tp, typename = _VSTD::enable_if_t<!_VSTD::is_same_v<_Tp, int>>>
162 _CmpUnspecifiedParam(_Tp) = delete;
163};
159164
160class weak_equality {165class weak_equality {
161 _LIBCPP_INLINE_VISIBILITY166 _LIBCPP_INLINE_VISIBILITY
...@@ -696,8 +701,8 @@ constexpr _ClassifyCompCategory __type_to_enum() noexcept {...@@ -696,8 +701,8 @@ constexpr _ClassifyCompCategory __type_to_enum() noexcept {
696701
697template <size_t _Size>702template <size_t _Size>
698constexpr _ClassifyCompCategory703constexpr _ClassifyCompCategory
699__compute_comp_type(std::array<_ClassifyCompCategory, _Size> __types) {704__compute_comp_type(array<_ClassifyCompCategory, _Size> __types) {
700 std::array<int, _CCC_Size> __seen = {};705 array<int, _CCC_Size> __seen = {};
701 for (auto __type : __types)706 for (auto __type : __types)
702 ++__seen[__type];707 ++__seen[__type];
703 if (__seen[_None])708 if (__seen[_None])
lib/libcxx/include/complex+7-10
...@@ -227,14 +227,6 @@ template<class T> complex<T> sqrt (const complex<T>&);...@@ -227,14 +227,6 @@ template<class T> complex<T> sqrt (const complex<T>&);
227template<class T> complex<T> tan (const complex<T>&);227template<class T> complex<T> tan (const complex<T>&);
228template<class T> complex<T> tanh (const complex<T>&);228template<class T> complex<T> tanh (const complex<T>&);
229229
230template<class T, class charT, class traits>
231 basic_istream<charT, traits>&
232 operator>>(basic_istream<charT, traits>& is, complex<T>& x);
233
234template<class T, class charT, class traits>
235 basic_ostream<charT, traits>&
236 operator<<(basic_ostream<charT, traits>& o, const complex<T>& x);
237
238} // std230} // std
239231
240*/232*/
...@@ -244,9 +236,12 @@ template<class T, class charT, class traits>...@@ -244,9 +236,12 @@ template<class T, class charT, class traits>
244#include <stdexcept>236#include <stdexcept>
245#include <cmath>237#include <cmath>
246#include <iosfwd>238#include <iosfwd>
247#include <sstream>
248#include <version>239#include <version>
249240
241#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
242# include <sstream> // for std::basic_ostringstream
243#endif
244
250#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)245#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
251#pragma GCC system_header246#pragma GCC system_header
252#endif247#endif
...@@ -955,7 +950,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -955,7 +950,7 @@ inline _LIBCPP_INLINE_VISIBILITY
955complex<_Tp>950complex<_Tp>
956proj(const complex<_Tp>& __c)951proj(const complex<_Tp>& __c)
957{952{
958 std::complex<_Tp> __r = __c;953 complex<_Tp> __r = __c;
959 if (__libcpp_isinf_or_builtin(__c.real()) || __libcpp_isinf_or_builtin(__c.imag()))954 if (__libcpp_isinf_or_builtin(__c.real()) || __libcpp_isinf_or_builtin(__c.imag()))
960 __r = complex<_Tp>(INFINITY, copysign(_Tp(0), __c.imag()));955 __r = complex<_Tp>(INFINITY, copysign(_Tp(0), __c.imag()));
961 return __r;956 return __r;
...@@ -1438,6 +1433,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x)...@@ -1438,6 +1433,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x)
1438 return __is;1433 return __is;
1439}1434}
14401435
1436#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
1441template<class _Tp, class _CharT, class _Traits>1437template<class _Tp, class _CharT, class _Traits>
1442basic_ostream<_CharT, _Traits>&1438basic_ostream<_CharT, _Traits>&
1443operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x)1439operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x)
...@@ -1449,6 +1445,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x)...@@ -1449,6 +1445,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x)
1449 __s << '(' << __x.real() << ',' << __x.imag() << ')';1445 __s << '(' << __x.real() << ',' << __x.imag() << ')';
1450 return __os << __s.str();1446 return __os << __s.str();
1451}1447}
1448#endif // !_LIBCPP_HAS_NO_LOCALIZATION
14521449
1453#if _LIBCPP_STD_VER > 111450#if _LIBCPP_STD_VER > 11
1454// Literal suffix for complex number literals [complex.literals]1451// Literal suffix for complex number literals [complex.literals]
lib/libcxx/include/ctime+15-1
...@@ -52,6 +52,20 @@ int timespec_get( struct timespec *ts, int base); // C++17...@@ -52,6 +52,20 @@ int timespec_get( struct timespec *ts, int base); // C++17
52#pragma GCC system_header52#pragma GCC system_header
53#endif53#endif
5454
55// FIXME:
56// Apple SDKs don't define ::timespec_get unconditionally in C++ mode. This
57// should be fixed in future SDKs, but for the time being we need to avoid
58// trying to use that declaration when the SDK doesn't provide it. Note that
59// we're detecting this here instead of in <__config> because we can't include
60// system headers from <__config>, since it leads to circular module dependencies.
61// This is also meant to be a very temporary workaround until the SDKs are fixed.
62#if defined(__APPLE__)
63# include <sys/cdefs.h>
64# if defined(_LIBCPP_HAS_TIMESPEC_GET) && (__DARWIN_C_LEVEL < __DARWIN_C_FULL)
65# define _LIBCPP_HAS_TIMESPEC_GET_NOT_ACTUALLY_PROVIDED
66# endif
67#endif
68
55_LIBCPP_BEGIN_NAMESPACE_STD69_LIBCPP_BEGIN_NAMESPACE_STD
5670
57using ::clock_t;71using ::clock_t;
...@@ -72,7 +86,7 @@ using ::gmtime;...@@ -72,7 +86,7 @@ using ::gmtime;
72using ::localtime;86using ::localtime;
73#endif87#endif
74using ::strftime;88using ::strftime;
75#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_TIMESPEC_GET)89#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_TIMESPEC_GET) && !defined(_LIBCPP_HAS_TIMESPEC_GET_NOT_ACTUALLY_PROVIDED)
76using ::timespec_get;90using ::timespec_get;
77#endif91#endif
7892
lib/libcxx/include/deque+8-8
...@@ -1237,7 +1237,7 @@ __deque_base<_Tp, _Allocator>::swap(__deque_base& __c)...@@ -1237,7 +1237,7 @@ __deque_base<_Tp, _Allocator>::swap(__deque_base& __c)
1237 __map_.swap(__c.__map_);1237 __map_.swap(__c.__map_);
1238 _VSTD::swap(__start_, __c.__start_);1238 _VSTD::swap(__start_, __c.__start_);
1239 _VSTD::swap(size(), __c.size());1239 _VSTD::swap(size(), __c.size());
1240 __swap_allocator(__alloc(), __c.__alloc());1240 _VSTD::__swap_allocator(__alloc(), __c.__alloc());
1241}1241}
12421242
1243template <class _Tp, class _Allocator>1243template <class _Tp, class _Allocator>
...@@ -1393,7 +1393,7 @@ public:...@@ -1393,7 +1393,7 @@ public:
1393 size_type size() const _NOEXCEPT {return __base::size();}1393 size_type size() const _NOEXCEPT {return __base::size();}
1394 _LIBCPP_INLINE_VISIBILITY1394 _LIBCPP_INLINE_VISIBILITY
1395 size_type max_size() const _NOEXCEPT1395 size_type max_size() const _NOEXCEPT
1396 {return std::min<size_type>(1396 {return _VSTD::min<size_type>(
1397 __alloc_traits::max_size(__base::__alloc()),1397 __alloc_traits::max_size(__base::__alloc()),
1398 numeric_limits<difference_type>::max());}1398 numeric_limits<difference_type>::max());}
1399 void resize(size_type __n);1399 void resize(size_type __n);
...@@ -1586,7 +1586,7 @@ public:...@@ -1586,7 +1586,7 @@ public:
15861586
1587#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES1587#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
1588template<class _InputIterator,1588template<class _InputIterator,
1589 class _Alloc = typename std::allocator<typename iterator_traits<_InputIterator>::value_type>,1589 class _Alloc = allocator<typename iterator_traits<_InputIterator>::value_type>,
1590 class = typename enable_if<__is_allocator<_Alloc>::value, void>::type1590 class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
1591 >1591 >
1592deque(_InputIterator, _InputIterator)1592deque(_InputIterator, _InputIterator)
...@@ -2376,7 +2376,7 @@ deque<_Tp, _Allocator>::__append(_ForIter __f, _ForIter __l,...@@ -2376,7 +2376,7 @@ deque<_Tp, _Allocator>::__append(_ForIter __f, _ForIter __l,
2376 for (__deque_block_range __br : __deque_range(__base::end(), __base::end() + __n)) {2376 for (__deque_block_range __br : __deque_range(__base::end(), __base::end() + __n)) {
2377 _ConstructTransaction __tx(this, __br);2377 _ConstructTransaction __tx(this, __br);
2378 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_, (void)++__f) {2378 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_, (void)++__f) {
2379 __alloc_traits::construct(__a, std::__to_address(__tx.__pos_), *__f);2379 __alloc_traits::construct(__a, _VSTD::__to_address(__tx.__pos_), *__f);
2380 }2380 }
2381 }2381 }
2382}2382}
...@@ -2393,7 +2393,7 @@ deque<_Tp, _Allocator>::__append(size_type __n)...@@ -2393,7 +2393,7 @@ deque<_Tp, _Allocator>::__append(size_type __n)
2393 for (__deque_block_range __br : __deque_range(__base::end(), __base::end() + __n)) {2393 for (__deque_block_range __br : __deque_range(__base::end(), __base::end() + __n)) {
2394 _ConstructTransaction __tx(this, __br);2394 _ConstructTransaction __tx(this, __br);
2395 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) {2395 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) {
2396 __alloc_traits::construct(__a, std::__to_address(__tx.__pos_));2396 __alloc_traits::construct(__a, _VSTD::__to_address(__tx.__pos_));
2397 }2397 }
2398 }2398 }
2399}2399}
...@@ -2410,7 +2410,7 @@ deque<_Tp, _Allocator>::__append(size_type __n, const value_type& __v)...@@ -2410,7 +2410,7 @@ deque<_Tp, _Allocator>::__append(size_type __n, const value_type& __v)
2410 for (__deque_block_range __br : __deque_range(__base::end(), __base::end() + __n)) {2410 for (__deque_block_range __br : __deque_range(__base::end(), __base::end() + __n)) {
2411 _ConstructTransaction __tx(this, __br);2411 _ConstructTransaction __tx(this, __br);
2412 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) {2412 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) {
2413 __alloc_traits::construct(__a, std::__to_address(__tx.__pos_), __v);2413 __alloc_traits::construct(__a, _VSTD::__to_address(__tx.__pos_), __v);
2414 }2414 }
2415 }2415 }
24162416
...@@ -2708,7 +2708,7 @@ void...@@ -2708,7 +2708,7 @@ void
2708deque<_Tp, _Allocator>::pop_front()2708deque<_Tp, _Allocator>::pop_front()
2709{2709{
2710 allocator_type& __a = __base::__alloc();2710 allocator_type& __a = __base::__alloc();
2711 __alloc_traits::destroy(__a, __to_address(*(__base::__map_.begin() +2711 __alloc_traits::destroy(__a, _VSTD::__to_address(*(__base::__map_.begin() +
2712 __base::__start_ / __base::__block_size) +2712 __base::__start_ / __base::__block_size) +
2713 __base::__start_ % __base::__block_size));2713 __base::__start_ % __base::__block_size));
2714 --__base::size();2714 --__base::size();
...@@ -2723,7 +2723,7 @@ deque<_Tp, _Allocator>::pop_back()...@@ -2723,7 +2723,7 @@ deque<_Tp, _Allocator>::pop_back()
2723 _LIBCPP_ASSERT(!empty(), "deque::pop_back called for empty deque");2723 _LIBCPP_ASSERT(!empty(), "deque::pop_back called for empty deque");
2724 allocator_type& __a = __base::__alloc();2724 allocator_type& __a = __base::__alloc();
2725 size_type __p = __base::size() + __base::__start_ - 1;2725 size_type __p = __base::size() + __base::__start_ - 1;
2726 __alloc_traits::destroy(__a, __to_address(*(__base::__map_.begin() +2726 __alloc_traits::destroy(__a, _VSTD::__to_address(*(__base::__map_.begin() +
2727 __p / __base::__block_size) +2727 __p / __base::__block_size) +
2728 __p % __base::__block_size));2728 __p % __base::__block_size));
2729 --__base::size();2729 --__base::size();
lib/libcxx/include/exception+2
...@@ -77,6 +77,8 @@ template <class E> void rethrow_if_nested(const E& e);...@@ -77,6 +77,8 @@ template <class E> void rethrow_if_nested(const E& e);
77*/77*/
7878
79#include <__config>79#include <__config>
80#include <__availability>
81#include <__memory/base.h>
80#include <cstddef>82#include <cstddef>
81#include <cstdlib>83#include <cstdlib>
82#include <type_traits>84#include <type_traits>
lib/libcxx/include/experimental/memory_resource+2-3
...@@ -116,7 +116,7 @@ public:...@@ -116,7 +116,7 @@ public:
116 { return do_is_equal(__other); }116 { return do_is_equal(__other); }
117117
118// 8.5.3, memory.resource.priv118// 8.5.3, memory.resource.priv
119protected:119private:
120 virtual void* do_allocate(size_t, size_t) = 0;120 virtual void* do_allocate(size_t, size_t) = 0;
121 virtual void do_deallocate(void*, size_t, size_t) = 0;121 virtual void do_deallocate(void*, size_t, size_t) = 0;
122 virtual bool do_is_equal(memory_resource const &) const _NOEXCEPT = 0;122 virtual bool do_is_equal(memory_resource const &) const _NOEXCEPT = 0;
...@@ -381,7 +381,7 @@ public:...@@ -381,7 +381,7 @@ public:
381 { return __alloc_; }381 { return __alloc_; }
382382
383// 8.7.3, memory.resource.adaptor.mem383// 8.7.3, memory.resource.adaptor.mem
384protected:384private:
385 virtual void * do_allocate(size_t __bytes, size_t)385 virtual void * do_allocate(size_t __bytes, size_t)
386 {386 {
387 if (__bytes > __max_size()) {387 if (__bytes > __max_size()) {
...@@ -407,7 +407,6 @@ protected:...@@ -407,7 +407,6 @@ protected:
407 return __p ? __alloc_ == __p->__alloc_ : false;407 return __p ? __alloc_ == __p->__alloc_ : false;
408 }408 }
409409
410private:
411 _LIBCPP_INLINE_VISIBILITY410 _LIBCPP_INLINE_VISIBILITY
412 size_t __max_size() const _NOEXCEPT {411 size_t __max_size() const _NOEXCEPT {
413 return numeric_limits<size_t>::max() - _MaxAlign;412 return numeric_limits<size_t>::max() - _MaxAlign;
lib/libcxx/include/experimental/simd+5
...@@ -659,6 +659,9 @@ public:...@@ -659,6 +659,9 @@ public:
659#pragma GCC system_header659#pragma GCC system_header
660#endif660#endif
661661
662_LIBCPP_PUSH_MACROS
663#include <__undef_macros>
664
662_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD665_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD
663666
664#if _LIBCPP_STD_VER >= 17667#if _LIBCPP_STD_VER >= 17
...@@ -1566,4 +1569,6 @@ public:...@@ -1566,4 +1569,6 @@ public:
15661569
1567_LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD1570_LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD
15681571
1572_LIBCPP_POP_MACROS
1573
1569#endif /* _LIBCPP_EXPERIMENTAL_SIMD */1574#endif /* _LIBCPP_EXPERIMENTAL_SIMD */
lib/libcxx/include/ext/hash_map+1-1
...@@ -671,7 +671,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(const key_type& __k)...@@ -671,7 +671,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(const key_type& __k)
671 __h.get_deleter().__first_constructed = true;671 __h.get_deleter().__first_constructed = true;
672 __node_traits::construct(__na, _VSTD::addressof(__h->__value_.second));672 __node_traits::construct(__na, _VSTD::addressof(__h->__value_.second));
673 __h.get_deleter().__second_constructed = true;673 __h.get_deleter().__second_constructed = true;
674 return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03674 return __h;
675}675}
676676
677template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>677template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
lib/libcxx/include/filesystem+84-37
...@@ -230,21 +230,25 @@...@@ -230,21 +230,25 @@
230*/230*/
231231
232#include <__config>232#include <__config>
233#include <__availability>
233#include <cstddef>234#include <cstddef>
234#include <cstdlib>235#include <cstdlib>
235#include <chrono>236#include <chrono>
236#include <iterator>237#include <iterator>
237#include <iosfwd>238#include <iosfwd>
238#include <locale>
239#include <memory>239#include <memory>
240#include <stack>240#include <stack>
241#include <string>241#include <string>
242#include <system_error>242#include <system_error>
243#include <utility>243#include <utility>
244#include <iomanip> // for quoted
245#include <string_view>244#include <string_view>
246#include <version>245#include <version>
247246
247#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
248# include <locale>
249# include <iomanip> // for quoted
250#endif
251
248#include <__debug>252#include <__debug>
249253
250#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)254#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -543,6 +547,13 @@ struct __can_convert_char<wchar_t> {...@@ -543,6 +547,13 @@ struct __can_convert_char<wchar_t> {
543 static const bool value = true;547 static const bool value = true;
544 using __char_type = wchar_t;548 using __char_type = wchar_t;
545};549};
550#ifndef _LIBCPP_NO_HAS_CHAR8_T
551template <>
552struct __can_convert_char<char8_t> {
553 static const bool value = true;
554 using __char_type = char8_t;
555};
556#endif
546template <>557template <>
547struct __can_convert_char<char16_t> {558struct __can_convert_char<char16_t> {
548 static const bool value = true;559 static const bool value = true;
...@@ -560,7 +571,7 @@ __is_separator(_ECharT __e) {...@@ -560,7 +571,7 @@ __is_separator(_ECharT __e) {
560 return __e == _ECharT('/');571 return __e == _ECharT('/');
561}572}
562573
563struct _NullSentinal {};574struct _NullSentinel {};
564575
565template <class _Tp>576template <class _Tp>
566using _Void = void;577using _Void = void;
...@@ -615,9 +626,9 @@ struct __is_pathable_char_array<_Source, _ECharT*, _UPtr, true>...@@ -615,9 +626,9 @@ struct __is_pathable_char_array<_Source, _ECharT*, _UPtr, true>
615 static _ECharT const* __range_begin(const _ECharT* __b) { return __b; }626 static _ECharT const* __range_begin(const _ECharT* __b) { return __b; }
616 static _ECharT const* __range_end(const _ECharT* __b) {627 static _ECharT const* __range_end(const _ECharT* __b) {
617 using _Iter = const _ECharT*;628 using _Iter = const _ECharT*;
618 const _ECharT __sentinal = _ECharT{};629 const _ECharT __sentinel = _ECharT{};
619 _Iter __e = __b;630 _Iter __e = __b;
620 for (; *__e != __sentinal; ++__e)631 for (; *__e != __sentinel; ++__e)
621 ;632 ;
622 return __e;633 return __e;
623 }634 }
...@@ -639,7 +650,7 @@ struct __is_pathable_iter<...@@ -639,7 +650,7 @@ struct __is_pathable_iter<
639 using _Base = __can_convert_char<_ECharT>;650 using _Base = __can_convert_char<_ECharT>;
640651
641 static _Iter __range_begin(_Iter __b) { return __b; }652 static _Iter __range_begin(_Iter __b) { return __b; }
642 static _NullSentinal __range_end(_Iter) { return _NullSentinal{}; }653 static _NullSentinel __range_end(_Iter) { return _NullSentinel{}; }
643654
644 static _ECharT __first_or_null(_Iter __b) { return *__b; }655 static _ECharT __first_or_null(_Iter __b) { return *__b; }
645};656};
...@@ -661,6 +672,10 @@ struct __is_pathable<_Tp, false, true, false> : __is_pathable_char_array<_Tp> {...@@ -661,6 +672,10 @@ struct __is_pathable<_Tp, false, true, false> : __is_pathable_char_array<_Tp> {
661template <class _Tp>672template <class _Tp>
662struct __is_pathable<_Tp, false, false, true> : __is_pathable_iter<_Tp> {};673struct __is_pathable<_Tp, false, false, true> : __is_pathable_iter<_Tp> {};
663674
675template <class _ECharT>
676struct _PathCVT;
677
678#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
664template <class _ECharT>679template <class _ECharT>
665struct _PathCVT {680struct _PathCVT {
666 static_assert(__can_convert_char<_ECharT>::value,681 static_assert(__can_convert_char<_ECharT>::value,
...@@ -684,13 +699,13 @@ struct _PathCVT {...@@ -684,13 +699,13 @@ struct _PathCVT {
684 }699 }
685700
686 template <class _Iter>701 template <class _Iter>
687 static void __append_range(string& __dest, _Iter __b, _NullSentinal) {702 static void __append_range(string& __dest, _Iter __b, _NullSentinel) {
688 static_assert(!is_same<_Iter, _ECharT*>::value, "Call const overload");703 static_assert(!is_same<_Iter, _ECharT*>::value, "Call const overload");
689 const _ECharT __sentinal = _ECharT{};704 const _ECharT __sentinel = _ECharT{};
690 if (*__b == __sentinal)705 if (*__b == __sentinel)
691 return;706 return;
692 basic_string<_ECharT> __tmp;707 basic_string<_ECharT> __tmp;
693 for (; *__b != __sentinal; ++__b)708 for (; *__b != __sentinel; ++__b)
694 __tmp.push_back(*__b);709 __tmp.push_back(*__b);
695 _Narrower()(back_inserter(__dest), __tmp.data(),710 _Narrower()(back_inserter(__dest), __tmp.data(),
696 __tmp.data() + __tmp.length());711 __tmp.data() + __tmp.length());
...@@ -703,6 +718,7 @@ struct _PathCVT {...@@ -703,6 +718,7 @@ struct _PathCVT {
703 _Traits::__range_end(__s));718 _Traits::__range_end(__s));
704 }719 }
705};720};
721#endif // !_LIBCPP_HAS_NO_LOCALIZATION
706722
707template <>723template <>
708struct _PathCVT<char> {724struct _PathCVT<char> {
...@@ -721,9 +737,9 @@ struct _PathCVT<char> {...@@ -721,9 +737,9 @@ struct _PathCVT<char> {
721 }737 }
722738
723 template <class _Iter>739 template <class _Iter>
724 static void __append_range(string& __dest, _Iter __b, _NullSentinal) {740 static void __append_range(string& __dest, _Iter __b, _NullSentinel) {
725 const char __sentinal = char{};741 const char __sentinel = char{};
726 for (; *__b != __sentinal; ++__b)742 for (; *__b != __sentinel; ++__b)
727 __dest.push_back(*__b);743 __dest.push_back(*__b);
728 }744 }
729745
...@@ -779,12 +795,14 @@ public:...@@ -779,12 +795,14 @@ public:
779 _PathCVT<_ItVal>::__append_range(__pn_, __first, __last);795 _PathCVT<_ItVal>::__append_range(__pn_, __first, __last);
780 }796 }
781797
798#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
782 // TODO Implement locale conversions.799 // TODO Implement locale conversions.
783 template <class _Source, class = _EnableIfPathable<_Source, void> >800 template <class _Source, class = _EnableIfPathable<_Source, void> >
784 path(const _Source& __src, const locale& __loc, format = format::auto_format);801 path(const _Source& __src, const locale& __loc, format = format::auto_format);
785 template <class _InputIt>802 template <class _InputIt>
786 path(_InputIt __first, _InputIt _last, const locale& __loc,803 path(_InputIt __first, _InputIt _last, const locale& __loc,
787 format = format::auto_format);804 format = format::auto_format);
805#endif
788806
789 _LIBCPP_INLINE_VISIBILITY807 _LIBCPP_INLINE_VISIBILITY
790 ~path() = default;808 ~path() = default;
...@@ -922,9 +940,8 @@ public:...@@ -922,9 +940,8 @@ public:
922 template <class _ECharT>940 template <class _ECharT>
923 typename enable_if<__can_convert_char<_ECharT>::value, path&>::type941 typename enable_if<__can_convert_char<_ECharT>::value, path&>::type
924 operator+=(_ECharT __x) {942 operator+=(_ECharT __x) {
925 basic_string<_ECharT> __tmp;943 _PathCVT<_ECharT>::__append_source(__pn_,
926 __tmp += __x;944 basic_string_view<_ECharT>(&__x, 1));
927 _PathCVT<_ECharT>::__append_source(__pn_, __tmp);
928 return *this;945 return *this;
929 }946 }
930947
...@@ -983,6 +1000,14 @@ public:...@@ -983,6 +1000,14 @@ public:
9831000
984 _LIBCPP_INLINE_VISIBILITY operator string_type() const { return __pn_; }1001 _LIBCPP_INLINE_VISIBILITY operator string_type() const { return __pn_; }
9851002
1003 _LIBCPP_INLINE_VISIBILITY _VSTD::string string() const { return __pn_; }
1004#ifndef _LIBCPP_NO_HAS_CHAR8_T
1005 _LIBCPP_INLINE_VISIBILITY _VSTD::u8string u8string() const { return _VSTD::u8string(__pn_.begin(), __pn_.end()); }
1006#else
1007 _LIBCPP_INLINE_VISIBILITY _VSTD::string u8string() const { return __pn_; }
1008#endif
1009
1010#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
986 template <class _ECharT, class _Traits = char_traits<_ECharT>,1011 template <class _ECharT, class _Traits = char_traits<_ECharT>,
987 class _Allocator = allocator<_ECharT> >1012 class _Allocator = allocator<_ECharT> >
988 basic_string<_ECharT, _Traits, _Allocator>1013 basic_string<_ECharT, _Traits, _Allocator>
...@@ -995,19 +1020,26 @@ public:...@@ -995,19 +1020,26 @@ public:
995 return __s;1020 return __s;
996 }1021 }
9971022
998 _LIBCPP_INLINE_VISIBILITY std::string string() const { return __pn_; }1023 _LIBCPP_INLINE_VISIBILITY _VSTD::wstring wstring() const {
999 _LIBCPP_INLINE_VISIBILITY std::wstring wstring() const {
1000 return string<wchar_t>();1024 return string<wchar_t>();
1001 }1025 }
1002 _LIBCPP_INLINE_VISIBILITY std::string u8string() const { return __pn_; }1026 _LIBCPP_INLINE_VISIBILITY _VSTD::u16string u16string() const {
1003 _LIBCPP_INLINE_VISIBILITY std::u16string u16string() const {
1004 return string<char16_t>();1027 return string<char16_t>();
1005 }1028 }
1006 _LIBCPP_INLINE_VISIBILITY std::u32string u32string() const {1029 _LIBCPP_INLINE_VISIBILITY _VSTD::u32string u32string() const {
1007 return string<char32_t>();1030 return string<char32_t>();
1008 }1031 }
1032#endif
10091033
1010 // generic format observers1034 // generic format observers
1035 _VSTD::string generic_string() const { return __pn_; }
1036#ifndef _LIBCPP_NO_HAS_CHAR8_T
1037 _VSTD::u8string generic_u8string() const { return _VSTD::u8string(__pn_.begin(), __pn_.end()); }
1038#else
1039 _VSTD::string generic_u8string() const { return __pn_; }
1040#endif
1041
1042#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
1011 template <class _ECharT, class _Traits = char_traits<_ECharT>,1043 template <class _ECharT, class _Traits = char_traits<_ECharT>,
1012 class _Allocator = allocator<_ECharT> >1044 class _Allocator = allocator<_ECharT> >
1013 basic_string<_ECharT, _Traits, _Allocator>1045 basic_string<_ECharT, _Traits, _Allocator>
...@@ -1015,11 +1047,10 @@ public:...@@ -1015,11 +1047,10 @@ public:
1015 return string<_ECharT, _Traits, _Allocator>(__a);1047 return string<_ECharT, _Traits, _Allocator>(__a);
1016 }1048 }
10171049
1018 std::string generic_string() const { return __pn_; }1050 _VSTD::wstring generic_wstring() const { return string<wchar_t>(); }
1019 std::wstring generic_wstring() const { return string<wchar_t>(); }1051 _VSTD::u16string generic_u16string() const { return string<char16_t>(); }
1020 std::string generic_u8string() const { return __pn_; }1052 _VSTD::u32string generic_u32string() const { return string<char32_t>(); }
1021 std::u16string generic_u16string() const { return string<char16_t>(); }1053#endif
1022 std::u32string generic_u32string() const { return string<char32_t>(); }
10231054
1024private:1055private:
1025 int __compare(__string_view) const;1056 int __compare(__string_view) const;
...@@ -1123,13 +1154,14 @@ public:...@@ -1123,13 +1154,14 @@ public:
1123 iterator begin() const;1154 iterator begin() const;
1124 iterator end() const;1155 iterator end() const;
11251156
1157#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
1126 template <class _CharT, class _Traits>1158 template <class _CharT, class _Traits>
1127 _LIBCPP_INLINE_VISIBILITY friend1159 _LIBCPP_INLINE_VISIBILITY friend
1128 typename enable_if<is_same<_CharT, char>::value &&1160 typename enable_if<is_same<_CharT, char>::value &&
1129 is_same<_Traits, char_traits<char> >::value,1161 is_same<_Traits, char_traits<char> >::value,
1130 basic_ostream<_CharT, _Traits>&>::type1162 basic_ostream<_CharT, _Traits>&>::type
1131 operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) {1163 operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) {
1132 __os << std::__quoted(__p.native());1164 __os << _VSTD::__quoted(__p.native());
1133 return __os;1165 return __os;
1134 }1166 }
11351167
...@@ -1139,7 +1171,7 @@ public:...@@ -1139,7 +1171,7 @@ public:
1139 !is_same<_Traits, char_traits<char> >::value,1171 !is_same<_Traits, char_traits<char> >::value,
1140 basic_ostream<_CharT, _Traits>&>::type1172 basic_ostream<_CharT, _Traits>&>::type
1141 operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) {1173 operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) {
1142 __os << std::__quoted(__p.string<_CharT, _Traits>());1174 __os << _VSTD::__quoted(__p.string<_CharT, _Traits>());
1143 return __os;1175 return __os;
1144 }1176 }
11451177
...@@ -1151,6 +1183,7 @@ public:...@@ -1151,6 +1183,7 @@ public:
1151 __p = __tmp;1183 __p = __tmp;
1152 return __is;1184 return __is;
1153 }1185 }
1186#endif // !_LIBCPP_HAS_NO_LOCALIZATION
11541187
1155 friend _LIBCPP_INLINE_VISIBILITY bool operator==(const path& __lhs, const path& __rhs) noexcept {1188 friend _LIBCPP_INLINE_VISIBILITY bool operator==(const path& __lhs, const path& __rhs) noexcept {
1156 return __lhs.compare(__rhs) == 0;1189 return __lhs.compare(__rhs) == 0;
...@@ -1194,23 +1227,37 @@ _LIBCPP_FUNC_VIS...@@ -1194,23 +1227,37 @@ _LIBCPP_FUNC_VIS
1194size_t hash_value(const path& __p) noexcept;1227size_t hash_value(const path& __p) noexcept;
11951228
1196template <class _Source>1229template <class _Source>
1197_LIBCPP_INLINE_VISIBILITY1230_LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_WITH_CHAR8_T
1198 typename enable_if<__is_pathable<_Source>::value, path>::type1231 typename enable_if<__is_pathable<_Source>::value, path>::type
1199 u8path(const _Source& __s) {1232 u8path(const _Source& __s) {
1200 static_assert(1233 static_assert(
1234#ifndef _LIBCPP_NO_HAS_CHAR8_T
1235 is_same<typename __is_pathable<_Source>::__char_type, char8_t>::value ||
1236#endif
1201 is_same<typename __is_pathable<_Source>::__char_type, char>::value,1237 is_same<typename __is_pathable<_Source>::__char_type, char>::value,
1202 "u8path(Source const&) requires Source have a character type of type "1238 "u8path(Source const&) requires Source have a character type of type "
1203 "'char'");1239 "'char'"
1240#ifndef _LIBCPP_NO_HAS_CHAR8_T
1241 " or 'char8_t'"
1242#endif
1243 );
1204 return path(__s);1244 return path(__s);
1205}1245}
12061246
1207template <class _InputIt>1247template <class _InputIt>
1208_LIBCPP_INLINE_VISIBILITY1248_LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_WITH_CHAR8_T
1209 typename enable_if<__is_pathable<_InputIt>::value, path>::type1249 typename enable_if<__is_pathable<_InputIt>::value, path>::type
1210 u8path(_InputIt __f, _InputIt __l) {1250 u8path(_InputIt __f, _InputIt __l) {
1211 static_assert(1251 static_assert(
1252#ifndef _LIBCPP_NO_HAS_CHAR8_T
1253 is_same<typename __is_pathable<_InputIt>::__char_type, char8_t>::value ||
1254#endif
1212 is_same<typename __is_pathable<_InputIt>::__char_type, char>::value,1255 is_same<typename __is_pathable<_InputIt>::__char_type, char>::value,
1213 "u8path(Iter, Iter) requires Iter have a value_type of type 'char'");1256 "u8path(Iter, Iter) requires Iter have a value_type of type 'char'"
1257#ifndef _LIBCPP_NO_HAS_CHAR8_T
1258 " or 'char8_t'"
1259#endif
1260 );
1214 return path(__f, __l);1261 return path(__f, __l);
1215}1262}
12161263
...@@ -1230,7 +1277,7 @@ public:...@@ -1230,7 +1277,7 @@ public:
1230 typedef bidirectional_iterator_tag iterator_category;1277 typedef bidirectional_iterator_tag iterator_category;
12311278
1232 typedef path value_type;1279 typedef path value_type;
1233 typedef std::ptrdiff_t difference_type;1280 typedef ptrdiff_t difference_type;
1234 typedef const path* pointer;1281 typedef const path* pointer;
1235 typedef const path& reference;1282 typedef const path& reference;
12361283
...@@ -1374,7 +1421,7 @@ template <class... _Args>...@@ -1374,7 +1421,7 @@ template <class... _Args>
1374_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY1421_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
1375#ifndef _LIBCPP_NO_EXCEPTIONS1422#ifndef _LIBCPP_NO_EXCEPTIONS
1376void __throw_filesystem_error(_Args&&... __args) {1423void __throw_filesystem_error(_Args&&... __args) {
1377 throw filesystem_error(std::forward<_Args>(__args)...);1424 throw filesystem_error(_VSTD::forward<_Args>(__args)...);
1378}1425}
1379#else1426#else
1380void __throw_filesystem_error(_Args&&...) {1427void __throw_filesystem_error(_Args&&...) {
...@@ -2204,7 +2251,7 @@ private:...@@ -2204,7 +2251,7 @@ private:
22042251
2205 _LIBCPP_INLINE_VISIBILITY2252 _LIBCPP_INLINE_VISIBILITY
2206 void __assign_iter_entry(_Path&& __p, __cached_data __dt) {2253 void __assign_iter_entry(_Path&& __p, __cached_data __dt) {
2207 __p_ = std::move(__p);2254 __p_ = _VSTD::move(__p);
2208 __data_ = __dt;2255 __data_ = __dt;
2209 }2256 }
22102257
...@@ -2505,10 +2552,10 @@ end(const directory_iterator&) noexcept {...@@ -2505,10 +2552,10 @@ end(const directory_iterator&) noexcept {
2505class recursive_directory_iterator {2552class recursive_directory_iterator {
2506public:2553public:
2507 using value_type = directory_entry;2554 using value_type = directory_entry;
2508 using difference_type = std::ptrdiff_t;2555 using difference_type = ptrdiff_t;
2509 using pointer = directory_entry const*;2556 using pointer = directory_entry const*;
2510 using reference = directory_entry const&;2557 using reference = directory_entry const&;
2511 using iterator_category = std::input_iterator_tag;2558 using iterator_category = input_iterator_tag;
25122559
2513public:2560public:
2514 // constructors and destructor2561 // constructors and destructor
lib/libcxx/include/forward_list+3-3
...@@ -603,7 +603,7 @@ __forward_list_base<_Tp, _Alloc>::swap(__forward_list_base& __x)...@@ -603,7 +603,7 @@ __forward_list_base<_Tp, _Alloc>::swap(__forward_list_base& __x)
603 __is_nothrow_swappable<__node_allocator>::value)603 __is_nothrow_swappable<__node_allocator>::value)
604#endif604#endif
605{605{
606 __swap_allocator(__alloc(), __x.__alloc(),606 _VSTD::__swap_allocator(__alloc(), __x.__alloc(),
607 integral_constant<bool, __node_traits::propagate_on_container_swap::value>());607 integral_constant<bool, __node_traits::propagate_on_container_swap::value>());
608 using _VSTD::swap;608 using _VSTD::swap;
609 swap(__before_begin()->__next_, __x.__before_begin()->__next_);609 swap(__before_begin()->__next_, __x.__before_begin()->__next_);
...@@ -758,7 +758,7 @@ public:...@@ -758,7 +758,7 @@ public:
758 {return base::__before_begin()->__next_ == nullptr;}758 {return base::__before_begin()->__next_ == nullptr;}
759 _LIBCPP_INLINE_VISIBILITY759 _LIBCPP_INLINE_VISIBILITY
760 size_type max_size() const _NOEXCEPT {760 size_type max_size() const _NOEXCEPT {
761 return std::min<size_type>(761 return _VSTD::min<size_type>(
762 __node_traits::max_size(base::__alloc()),762 __node_traits::max_size(base::__alloc()),
763 numeric_limits<difference_type>::max());763 numeric_limits<difference_type>::max());
764 }764 }
...@@ -871,7 +871,7 @@ private:...@@ -871,7 +871,7 @@ private:
871871
872#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES872#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
873template<class _InputIterator,873template<class _InputIterator,
874 class _Alloc = typename std::allocator<typename iterator_traits<_InputIterator>::value_type>,874 class _Alloc = allocator<typename iterator_traits<_InputIterator>::value_type>,
875 class = typename enable_if<__is_allocator<_Alloc>::value, void>::type875 class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
876 >876 >
877forward_list(_InputIterator, _InputIterator)877forward_list(_InputIterator, _InputIterator)
lib/libcxx/include/fstream+72-64
...@@ -180,6 +180,7 @@ typedef basic_fstream<wchar_t> wfstream;...@@ -180,6 +180,7 @@ typedef basic_fstream<wchar_t> wfstream;
180*/180*/
181181
182#include <__config>182#include <__config>
183#include <__availability>
183#include <ostream>184#include <ostream>
184#include <istream>185#include <istream>
185#include <__locale>186#include <__locale>
...@@ -240,7 +241,7 @@ public:...@@ -240,7 +241,7 @@ public:
240 return open(__p.c_str(), __mode);241 return open(__p.c_str(), __mode);
241 }242 }
242#endif243#endif
243 _LIBCPP_INLINE_VISIBILITY244 inline _LIBCPP_INLINE_VISIBILITY
244 basic_filebuf* __open(int __fd, ios_base::openmode __mode);245 basic_filebuf* __open(int __fd, ios_base::openmode __mode);
245#endif246#endif
246 basic_filebuf* close();247 basic_filebuf* close();
...@@ -286,13 +287,13 @@ private:...@@ -286,13 +287,13 @@ private:
286287
287template <class _CharT, class _Traits>288template <class _CharT, class _Traits>
288basic_filebuf<_CharT, _Traits>::basic_filebuf()289basic_filebuf<_CharT, _Traits>::basic_filebuf()
289 : __extbuf_(0),290 : __extbuf_(nullptr),
290 __extbufnext_(0),291 __extbufnext_(nullptr),
291 __extbufend_(0),292 __extbufend_(nullptr),
292 __ebs_(0),293 __ebs_(0),
293 __intbuf_(0),294 __intbuf_(nullptr),
294 __ibs_(0),295 __ibs_(0),
295 __file_(0),296 __file_(nullptr),
296 __cv_(nullptr),297 __cv_(nullptr),
297 __st_(),298 __st_(),
298 __st_last_(),299 __st_last_(),
...@@ -307,7 +308,7 @@ basic_filebuf<_CharT, _Traits>::basic_filebuf()...@@ -307,7 +308,7 @@ basic_filebuf<_CharT, _Traits>::basic_filebuf()
307 __cv_ = &use_facet<codecvt<char_type, char, state_type> >(this->getloc());308 __cv_ = &use_facet<codecvt<char_type, char, state_type> >(this->getloc());
308 __always_noconv_ = __cv_->always_noconv();309 __always_noconv_ = __cv_->always_noconv();
309 }310 }
310 setbuf(0, 4096);311 setbuf(nullptr, 4096);
311}312}
312313
313#ifndef _LIBCPP_CXX03_LANG314#ifndef _LIBCPP_CXX03_LANG
...@@ -359,13 +360,13 @@ basic_filebuf<_CharT, _Traits>::basic_filebuf(basic_filebuf&& __rhs)...@@ -359,13 +360,13 @@ basic_filebuf<_CharT, _Traits>::basic_filebuf(basic_filebuf&& __rhs)
359 (char_type*)__extbuf_ + (__rhs.gptr() - __rhs.eback()),360 (char_type*)__extbuf_ + (__rhs.gptr() - __rhs.eback()),
360 (char_type*)__extbuf_ + (__rhs.egptr() - __rhs.eback()));361 (char_type*)__extbuf_ + (__rhs.egptr() - __rhs.eback()));
361 }362 }
362 __rhs.__extbuf_ = 0;363 __rhs.__extbuf_ = nullptr;
363 __rhs.__extbufnext_ = 0;364 __rhs.__extbufnext_ = nullptr;
364 __rhs.__extbufend_ = 0;365 __rhs.__extbufend_ = nullptr;
365 __rhs.__ebs_ = 0;366 __rhs.__ebs_ = 0;
366 __rhs.__intbuf_ = 0;367 __rhs.__intbuf_ = 0;
367 __rhs.__ibs_ = 0;368 __rhs.__ibs_ = 0;
368 __rhs.__file_ = 0;369 __rhs.__file_ = nullptr;
369 __rhs.__st_ = state_type();370 __rhs.__st_ = state_type();
370 __rhs.__st_last_ = state_type();371 __rhs.__st_last_ = state_type();
371 __rhs.__om_ = 0;372 __rhs.__om_ = 0;
...@@ -499,7 +500,7 @@ inline...@@ -499,7 +500,7 @@ inline
499bool500bool
500basic_filebuf<_CharT, _Traits>::is_open() const501basic_filebuf<_CharT, _Traits>::is_open() const
501{502{
502 return __file_ != 0;503 return __file_ != nullptr;
503}504}
504505
505template <class _CharT, class _Traits>506template <class _CharT, class _Traits>
...@@ -547,8 +548,8 @@ template <class _CharT, class _Traits>...@@ -547,8 +548,8 @@ template <class _CharT, class _Traits>
547basic_filebuf<_CharT, _Traits>*548basic_filebuf<_CharT, _Traits>*
548basic_filebuf<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)549basic_filebuf<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
549{550{
550 basic_filebuf<_CharT, _Traits>* __rt = 0;551 basic_filebuf<_CharT, _Traits>* __rt = nullptr;
551 if (__file_ == 0)552 if (__file_ == nullptr)
552 {553 {
553 if (const char* __mdstr = __make_mdstring(__mode)) {554 if (const char* __mdstr = __make_mdstring(__mode)) {
554 __rt = this;555 __rt = this;
...@@ -558,22 +559,23 @@ basic_filebuf<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)...@@ -558,22 +559,23 @@ basic_filebuf<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
558 if (__mode & ios_base::ate) {559 if (__mode & ios_base::ate) {
559 if (fseek(__file_, 0, SEEK_END)) {560 if (fseek(__file_, 0, SEEK_END)) {
560 fclose(__file_);561 fclose(__file_);
561 __file_ = 0;562 __file_ = nullptr;
562 __rt = 0;563 __rt = nullptr;
563 }564 }
564 }565 }
565 } else566 } else
566 __rt = 0;567 __rt = nullptr;
567 }568 }
568 }569 }
569 return __rt;570 return __rt;
570}571}
571572
572template <class _CharT, class _Traits>573template <class _CharT, class _Traits>
573_LIBCPP_INLINE_VISIBILITY basic_filebuf<_CharT, _Traits>*574inline _LIBCPP_INLINE_VISIBILITY
575basic_filebuf<_CharT, _Traits>*
574basic_filebuf<_CharT, _Traits>::__open(int __fd, ios_base::openmode __mode) {576basic_filebuf<_CharT, _Traits>::__open(int __fd, ios_base::openmode __mode) {
575 basic_filebuf<_CharT, _Traits>* __rt = 0;577 basic_filebuf<_CharT, _Traits>* __rt = nullptr;
576 if (__file_ == 0) {578 if (__file_ == nullptr) {
577 if (const char* __mdstr = __make_mdstring(__mode)) {579 if (const char* __mdstr = __make_mdstring(__mode)) {
578 __rt = this;580 __rt = this;
579 __file_ = fdopen(__fd, __mdstr);581 __file_ = fdopen(__fd, __mdstr);
...@@ -582,12 +584,12 @@ basic_filebuf<_CharT, _Traits>::__open(int __fd, ios_base::openmode __mode) {...@@ -582,12 +584,12 @@ basic_filebuf<_CharT, _Traits>::__open(int __fd, ios_base::openmode __mode) {
582 if (__mode & ios_base::ate) {584 if (__mode & ios_base::ate) {
583 if (fseek(__file_, 0, SEEK_END)) {585 if (fseek(__file_, 0, SEEK_END)) {
584 fclose(__file_);586 fclose(__file_);
585 __file_ = 0;587 __file_ = nullptr;
586 __rt = 0;588 __rt = nullptr;
587 }589 }
588 }590 }
589 } else591 } else
590 __rt = 0;592 __rt = nullptr;
591 }593 }
592 }594 }
593 return __rt;595 return __rt;
...@@ -600,8 +602,8 @@ template <class _CharT, class _Traits>...@@ -600,8 +602,8 @@ template <class _CharT, class _Traits>
600basic_filebuf<_CharT, _Traits>*602basic_filebuf<_CharT, _Traits>*
601basic_filebuf<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode)603basic_filebuf<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode)
602{604{
603 basic_filebuf<_CharT, _Traits>* __rt = 0;605 basic_filebuf<_CharT, _Traits>* __rt = nullptr;
604 if (__file_ == 0)606 if (__file_ == nullptr)
605 {607 {
606 __rt = this;608 __rt = this;
607 const wchar_t* __mdstr;609 const wchar_t* __mdstr;
...@@ -650,7 +652,7 @@ basic_filebuf<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mo...@@ -650,7 +652,7 @@ basic_filebuf<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mo
650 __mdstr = L"a+b";652 __mdstr = L"a+b";
651 break;653 break;
652 default:654 default:
653 __rt = 0;655 __rt = nullptr;
654 break;656 break;
655 }657 }
656 if (__rt)658 if (__rt)
...@@ -664,13 +666,13 @@ basic_filebuf<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mo...@@ -664,13 +666,13 @@ basic_filebuf<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mo
664 if (fseek(__file_, 0, SEEK_END))666 if (fseek(__file_, 0, SEEK_END))
665 {667 {
666 fclose(__file_);668 fclose(__file_);
667 __file_ = 0;669 __file_ = nullptr;
668 __rt = 0;670 __rt = nullptr;
669 }671 }
670 }672 }
671 }673 }
672 else674 else
673 __rt = 0;675 __rt = nullptr;
674 }676 }
675 }677 }
676 return __rt;678 return __rt;
...@@ -690,16 +692,16 @@ template <class _CharT, class _Traits>...@@ -690,16 +692,16 @@ template <class _CharT, class _Traits>
690basic_filebuf<_CharT, _Traits>*692basic_filebuf<_CharT, _Traits>*
691basic_filebuf<_CharT, _Traits>::close()693basic_filebuf<_CharT, _Traits>::close()
692{694{
693 basic_filebuf<_CharT, _Traits>* __rt = 0;695 basic_filebuf<_CharT, _Traits>* __rt = nullptr;
694 if (__file_)696 if (__file_)
695 {697 {
696 __rt = this;698 __rt = this;
697 unique_ptr<FILE, int(*)(FILE*)> __h(__file_, fclose);699 unique_ptr<FILE, int(*)(FILE*)> __h(__file_, fclose);
698 if (sync())700 if (sync())
699 __rt = 0;701 __rt = nullptr;
700 if (fclose(__h.release()))702 if (fclose(__h.release()))
701 __rt = 0;703 __rt = nullptr;
702 __file_ = 0;704 __file_ = nullptr;
703 setbuf(0, 0);705 setbuf(0, 0);
704 }706 }
705 return __rt;707 return __rt;
...@@ -709,17 +711,17 @@ template <class _CharT, class _Traits>...@@ -709,17 +711,17 @@ template <class _CharT, class _Traits>
709typename basic_filebuf<_CharT, _Traits>::int_type711typename basic_filebuf<_CharT, _Traits>::int_type
710basic_filebuf<_CharT, _Traits>::underflow()712basic_filebuf<_CharT, _Traits>::underflow()
711{713{
712 if (__file_ == 0)714 if (__file_ == nullptr)
713 return traits_type::eof();715 return traits_type::eof();
714 bool __initial = __read_mode();716 bool __initial = __read_mode();
715 char_type __1buf;717 char_type __1buf;
716 if (this->gptr() == 0)718 if (this->gptr() == nullptr)
717 this->setg(&__1buf, &__1buf+1, &__1buf+1);719 this->setg(&__1buf, &__1buf+1, &__1buf+1);
718 const size_t __unget_sz = __initial ? 0 : min<size_t>((this->egptr() - this->eback()) / 2, 4);720 const size_t __unget_sz = __initial ? 0 : min<size_t>((this->egptr() - this->eback()) / 2, 4);
719 int_type __c = traits_type::eof();721 int_type __c = traits_type::eof();
720 if (this->gptr() == this->egptr())722 if (this->gptr() == this->egptr())
721 {723 {
722 memmove(this->eback(), this->egptr() - __unget_sz, __unget_sz * sizeof(char_type));724 _VSTD::memmove(this->eback(), this->egptr() - __unget_sz, __unget_sz * sizeof(char_type));
723 if (__always_noconv_)725 if (__always_noconv_)
724 {726 {
725 size_t __nmemb = static_cast<size_t>(this->egptr() - this->eback() - __unget_sz);727 size_t __nmemb = static_cast<size_t>(this->egptr() - this->eback() - __unget_sz);
...@@ -736,7 +738,7 @@ basic_filebuf<_CharT, _Traits>::underflow()...@@ -736,7 +738,7 @@ basic_filebuf<_CharT, _Traits>::underflow()
736 {738 {
737 _LIBCPP_ASSERT ( !(__extbufnext_ == NULL && (__extbufend_ != __extbufnext_)), "underflow moving from NULL" );739 _LIBCPP_ASSERT ( !(__extbufnext_ == NULL && (__extbufend_ != __extbufnext_)), "underflow moving from NULL" );
738 if (__extbufend_ != __extbufnext_)740 if (__extbufend_ != __extbufnext_)
739 memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);741 _VSTD::memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);
740 __extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_);742 __extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_);
741 __extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? sizeof(__extbuf_min_) : __ebs_);743 __extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? sizeof(__extbuf_min_) : __ebs_);
742 size_t __nmemb = _VSTD::min(static_cast<size_t>(__ibs_ - __unget_sz),744 size_t __nmemb = _VSTD::min(static_cast<size_t>(__ibs_ - __unget_sz),
...@@ -771,7 +773,7 @@ basic_filebuf<_CharT, _Traits>::underflow()...@@ -771,7 +773,7 @@ basic_filebuf<_CharT, _Traits>::underflow()
771 else773 else
772 __c = traits_type::to_int_type(*this->gptr());774 __c = traits_type::to_int_type(*this->gptr());
773 if (this->eback() == &__1buf)775 if (this->eback() == &__1buf)
774 this->setg(0, 0, 0);776 this->setg(nullptr, nullptr, nullptr);
775 return __c;777 return __c;
776}778}
777779
...@@ -801,7 +803,7 @@ template <class _CharT, class _Traits>...@@ -801,7 +803,7 @@ template <class _CharT, class _Traits>
801typename basic_filebuf<_CharT, _Traits>::int_type803typename basic_filebuf<_CharT, _Traits>::int_type
802basic_filebuf<_CharT, _Traits>::overflow(int_type __c)804basic_filebuf<_CharT, _Traits>::overflow(int_type __c)
803{805{
804 if (__file_ == 0)806 if (__file_ == nullptr)
805 return traits_type::eof();807 return traits_type::eof();
806 __write_mode();808 __write_mode();
807 char_type __1buf;809 char_type __1buf;
...@@ -809,7 +811,7 @@ basic_filebuf<_CharT, _Traits>::overflow(int_type __c)...@@ -809,7 +811,7 @@ basic_filebuf<_CharT, _Traits>::overflow(int_type __c)
809 char_type* __epb_save = this->epptr();811 char_type* __epb_save = this->epptr();
810 if (!traits_type::eq_int_type(__c, traits_type::eof()))812 if (!traits_type::eq_int_type(__c, traits_type::eof()))
811 {813 {
812 if (this->pptr() == 0)814 if (this->pptr() == nullptr)
813 this->setp(&__1buf, &__1buf+1);815 this->setp(&__1buf, &__1buf+1);
814 *this->pptr() = traits_type::to_char_type(__c);816 *this->pptr() = traits_type::to_char_type(__c);
815 this->pbump(1);817 this->pbump(1);
...@@ -866,8 +868,8 @@ template <class _CharT, class _Traits>...@@ -866,8 +868,8 @@ template <class _CharT, class _Traits>
866basic_streambuf<_CharT, _Traits>*868basic_streambuf<_CharT, _Traits>*
867basic_filebuf<_CharT, _Traits>::setbuf(char_type* __s, streamsize __n)869basic_filebuf<_CharT, _Traits>::setbuf(char_type* __s, streamsize __n)
868{870{
869 this->setg(0, 0, 0);871 this->setg(nullptr, nullptr, nullptr);
870 this->setp(0, 0);872 this->setp(nullptr, nullptr);
871 if (__owns_eb_)873 if (__owns_eb_)
872 delete [] __extbuf_;874 delete [] __extbuf_;
873 if (__owns_ib_)875 if (__owns_ib_)
...@@ -909,7 +911,7 @@ basic_filebuf<_CharT, _Traits>::setbuf(char_type* __s, streamsize __n)...@@ -909,7 +911,7 @@ basic_filebuf<_CharT, _Traits>::setbuf(char_type* __s, streamsize __n)
909 else911 else
910 {912 {
911 __ibs_ = 0;913 __ibs_ = 0;
912 __intbuf_ = 0;914 __intbuf_ = nullptr;
913 __owns_ib_ = false;915 __owns_ib_ = false;
914 }916 }
915 return this;917 return this;
...@@ -924,7 +926,7 @@ basic_filebuf<_CharT, _Traits>::seekoff(off_type __off, ios_base::seekdir __way,...@@ -924,7 +926,7 @@ basic_filebuf<_CharT, _Traits>::seekoff(off_type __off, ios_base::seekdir __way,
924 __throw_bad_cast();926 __throw_bad_cast();
925927
926 int __width = __cv_->encoding();928 int __width = __cv_->encoding();
927 if (__file_ == 0 || (__width <= 0 && __off != 0) || sync())929 if (__file_ == nullptr || (__width <= 0 && __off != 0) || sync())
928 return pos_type(off_type(-1));930 return pos_type(off_type(-1));
929 // __width > 0 || __off == 0931 // __width > 0 || __off == 0
930 int __whence;932 int __whence;
...@@ -959,7 +961,7 @@ template <class _CharT, class _Traits>...@@ -959,7 +961,7 @@ template <class _CharT, class _Traits>
959typename basic_filebuf<_CharT, _Traits>::pos_type961typename basic_filebuf<_CharT, _Traits>::pos_type
960basic_filebuf<_CharT, _Traits>::seekpos(pos_type __sp, ios_base::openmode)962basic_filebuf<_CharT, _Traits>::seekpos(pos_type __sp, ios_base::openmode)
961{963{
962 if (__file_ == 0 || sync())964 if (__file_ == nullptr || sync())
963 return pos_type(off_type(-1));965 return pos_type(off_type(-1));
964#if defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS)966#if defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS)
965 if (fseek(__file_, __sp, SEEK_SET))967 if (fseek(__file_, __sp, SEEK_SET))
...@@ -976,7 +978,7 @@ template <class _CharT, class _Traits>...@@ -976,7 +978,7 @@ template <class _CharT, class _Traits>
976int978int
977basic_filebuf<_CharT, _Traits>::sync()979basic_filebuf<_CharT, _Traits>::sync()
978{980{
979 if (__file_ == 0)981 if (__file_ == nullptr)
980 return 0;982 return 0;
981 if (!__cv_)983 if (!__cv_)
982 __throw_bad_cast();984 __throw_bad_cast();
...@@ -1035,7 +1037,7 @@ basic_filebuf<_CharT, _Traits>::sync()...@@ -1035,7 +1037,7 @@ basic_filebuf<_CharT, _Traits>::sync()
1035 if (__update_st)1037 if (__update_st)
1036 __st_ = __state;1038 __st_ = __state;
1037 __extbufnext_ = __extbufend_ = __extbuf_;1039 __extbufnext_ = __extbufend_ = __extbuf_;
1038 this->setg(0, 0, 0);1040 this->setg(nullptr, nullptr, nullptr);
1039 __cm_ = 0;1041 __cm_ = 0;
1040 }1042 }
1041 return 0;1043 return 0;
...@@ -1051,8 +1053,8 @@ basic_filebuf<_CharT, _Traits>::imbue(const locale& __loc)...@@ -1051,8 +1053,8 @@ basic_filebuf<_CharT, _Traits>::imbue(const locale& __loc)
1051 __always_noconv_ = __cv_->always_noconv();1053 __always_noconv_ = __cv_->always_noconv();
1052 if (__old_anc != __always_noconv_)1054 if (__old_anc != __always_noconv_)
1053 {1055 {
1054 this->setg(0, 0, 0);1056 this->setg(nullptr, nullptr, nullptr);
1055 this->setp(0, 0);1057 this->setp(nullptr, nullptr);
1056 // invariant, char_type is char, else we couldn't get here1058 // invariant, char_type is char, else we couldn't get here
1057 if (__always_noconv_) // need to dump __intbuf_1059 if (__always_noconv_) // need to dump __intbuf_
1058 {1060 {
...@@ -1062,7 +1064,7 @@ basic_filebuf<_CharT, _Traits>::imbue(const locale& __loc)...@@ -1062,7 +1064,7 @@ basic_filebuf<_CharT, _Traits>::imbue(const locale& __loc)
1062 __ebs_ = __ibs_;1064 __ebs_ = __ibs_;
1063 __extbuf_ = (char*)__intbuf_;1065 __extbuf_ = (char*)__intbuf_;
1064 __ibs_ = 0;1066 __ibs_ = 0;
1065 __intbuf_ = 0;1067 __intbuf_ = nullptr;
1066 __owns_ib_ = false;1068 __owns_ib_ = false;
1067 }1069 }
1068 else // need to obtain an __intbuf_.1070 else // need to obtain an __intbuf_.
...@@ -1091,7 +1093,7 @@ basic_filebuf<_CharT, _Traits>::__read_mode()...@@ -1091,7 +1093,7 @@ basic_filebuf<_CharT, _Traits>::__read_mode()
1091{1093{
1092 if (!(__cm_ & ios_base::in))1094 if (!(__cm_ & ios_base::in))
1093 {1095 {
1094 this->setp(0, 0);1096 this->setp(nullptr, nullptr);
1095 if (__always_noconv_)1097 if (__always_noconv_)
1096 this->setg((char_type*)__extbuf_,1098 this->setg((char_type*)__extbuf_,
1097 (char_type*)__extbuf_ + __ebs_,1099 (char_type*)__extbuf_ + __ebs_,
...@@ -1110,7 +1112,7 @@ basic_filebuf<_CharT, _Traits>::__write_mode()...@@ -1110,7 +1112,7 @@ basic_filebuf<_CharT, _Traits>::__write_mode()
1110{1112{
1111 if (!(__cm_ & ios_base::out))1113 if (!(__cm_ & ios_base::out))
1112 {1114 {
1113 this->setg(0, 0, 0);1115 this->setg(nullptr, nullptr, nullptr);
1114 if (__ebs_ > sizeof(__extbuf_min_))1116 if (__ebs_ > sizeof(__extbuf_min_))
1115 {1117 {
1116 if (__always_noconv_)1118 if (__always_noconv_)
...@@ -1120,7 +1122,7 @@ basic_filebuf<_CharT, _Traits>::__write_mode()...@@ -1120,7 +1122,7 @@ basic_filebuf<_CharT, _Traits>::__write_mode()
1120 this->setp(__intbuf_, __intbuf_ + (__ibs_ - 1));1122 this->setp(__intbuf_, __intbuf_ + (__ibs_ - 1));
1121 }1123 }
1122 else1124 else
1123 this->setp(0, 0);1125 this->setp(nullptr, nullptr);
1124 __cm_ = ios_base::out;1126 __cm_ = ios_base::out;
1125 }1127 }
1126}1128}
...@@ -1206,7 +1208,7 @@ inline...@@ -1206,7 +1208,7 @@ inline
1206basic_ifstream<_CharT, _Traits>::basic_ifstream(const char* __s, ios_base::openmode __mode)1208basic_ifstream<_CharT, _Traits>::basic_ifstream(const char* __s, ios_base::openmode __mode)
1207 : basic_istream<char_type, traits_type>(&__sb_)1209 : basic_istream<char_type, traits_type>(&__sb_)
1208{1210{
1209 if (__sb_.open(__s, __mode | ios_base::in) == 0)1211 if (__sb_.open(__s, __mode | ios_base::in) == nullptr)
1210 this->setstate(ios_base::failbit);1212 this->setstate(ios_base::failbit);
1211}1213}
12121214
...@@ -1216,7 +1218,7 @@ inline...@@ -1216,7 +1218,7 @@ inline
1216basic_ifstream<_CharT, _Traits>::basic_ifstream(const wchar_t* __s, ios_base::openmode __mode)1218basic_ifstream<_CharT, _Traits>::basic_ifstream(const wchar_t* __s, ios_base::openmode __mode)
1217 : basic_istream<char_type, traits_type>(&__sb_)1219 : basic_istream<char_type, traits_type>(&__sb_)
1218{1220{
1219 if (__sb_.open(__s, __mode | ios_base::in) == 0)1221 if (__sb_.open(__s, __mode | ios_base::in) == nullptr)
1220 this->setstate(ios_base::failbit);1222 this->setstate(ios_base::failbit);
1221}1223}
1222#endif1224#endif
...@@ -1226,7 +1228,7 @@ inline...@@ -1226,7 +1228,7 @@ inline
1226basic_ifstream<_CharT, _Traits>::basic_ifstream(const string& __s, ios_base::openmode __mode)1228basic_ifstream<_CharT, _Traits>::basic_ifstream(const string& __s, ios_base::openmode __mode)
1227 : basic_istream<char_type, traits_type>(&__sb_)1229 : basic_istream<char_type, traits_type>(&__sb_)
1228{1230{
1229 if (__sb_.open(__s, __mode | ios_base::in) == 0)1231 if (__sb_.open(__s, __mode | ios_base::in) == nullptr)
1230 this->setstate(ios_base::failbit);1232 this->setstate(ios_base::failbit);
1231}1233}
1232#endif1234#endif
...@@ -1419,7 +1421,7 @@ inline...@@ -1419,7 +1421,7 @@ inline
1419basic_ofstream<_CharT, _Traits>::basic_ofstream(const char* __s, ios_base::openmode __mode)1421basic_ofstream<_CharT, _Traits>::basic_ofstream(const char* __s, ios_base::openmode __mode)
1420 : basic_ostream<char_type, traits_type>(&__sb_)1422 : basic_ostream<char_type, traits_type>(&__sb_)
1421{1423{
1422 if (__sb_.open(__s, __mode | ios_base::out) == 0)1424 if (__sb_.open(__s, __mode | ios_base::out) == nullptr)
1423 this->setstate(ios_base::failbit);1425 this->setstate(ios_base::failbit);
1424}1426}
14251427
...@@ -1429,7 +1431,7 @@ inline...@@ -1429,7 +1431,7 @@ inline
1429basic_ofstream<_CharT, _Traits>::basic_ofstream(const wchar_t* __s, ios_base::openmode __mode)1431basic_ofstream<_CharT, _Traits>::basic_ofstream(const wchar_t* __s, ios_base::openmode __mode)
1430 : basic_ostream<char_type, traits_type>(&__sb_)1432 : basic_ostream<char_type, traits_type>(&__sb_)
1431{1433{
1432 if (__sb_.open(__s, __mode | ios_base::out) == 0)1434 if (__sb_.open(__s, __mode | ios_base::out) == nullptr)
1433 this->setstate(ios_base::failbit);1435 this->setstate(ios_base::failbit);
1434}1436}
1435#endif1437#endif
...@@ -1439,7 +1441,7 @@ inline...@@ -1439,7 +1441,7 @@ inline
1439basic_ofstream<_CharT, _Traits>::basic_ofstream(const string& __s, ios_base::openmode __mode)1441basic_ofstream<_CharT, _Traits>::basic_ofstream(const string& __s, ios_base::openmode __mode)
1440 : basic_ostream<char_type, traits_type>(&__sb_)1442 : basic_ostream<char_type, traits_type>(&__sb_)
1441{1443{
1442 if (__sb_.open(__s, __mode | ios_base::out) == 0)1444 if (__sb_.open(__s, __mode | ios_base::out) == nullptr)
1443 this->setstate(ios_base::failbit);1445 this->setstate(ios_base::failbit);
1444}1446}
1445#endif1447#endif
...@@ -1548,7 +1550,7 @@ inline...@@ -1548,7 +1550,7 @@ inline
1548void1550void
1549basic_ofstream<_CharT, _Traits>::close()1551basic_ofstream<_CharT, _Traits>::close()
1550{1552{
1551 if (__sb_.close() == 0)1553 if (__sb_.close() == nullptr)
1552 this->setstate(ios_base::failbit);1554 this->setstate(ios_base::failbit);
1553}1555}
15541556
...@@ -1632,7 +1634,7 @@ inline...@@ -1632,7 +1634,7 @@ inline
1632basic_fstream<_CharT, _Traits>::basic_fstream(const char* __s, ios_base::openmode __mode)1634basic_fstream<_CharT, _Traits>::basic_fstream(const char* __s, ios_base::openmode __mode)
1633 : basic_iostream<char_type, traits_type>(&__sb_)1635 : basic_iostream<char_type, traits_type>(&__sb_)
1634{1636{
1635 if (__sb_.open(__s, __mode) == 0)1637 if (__sb_.open(__s, __mode) == nullptr)
1636 this->setstate(ios_base::failbit);1638 this->setstate(ios_base::failbit);
1637}1639}
16381640
...@@ -1642,7 +1644,7 @@ inline...@@ -1642,7 +1644,7 @@ inline
1642basic_fstream<_CharT, _Traits>::basic_fstream(const wchar_t* __s, ios_base::openmode __mode)1644basic_fstream<_CharT, _Traits>::basic_fstream(const wchar_t* __s, ios_base::openmode __mode)
1643 : basic_iostream<char_type, traits_type>(&__sb_)1645 : basic_iostream<char_type, traits_type>(&__sb_)
1644{1646{
1645 if (__sb_.open(__s, __mode) == 0)1647 if (__sb_.open(__s, __mode) == nullptr)
1646 this->setstate(ios_base::failbit);1648 this->setstate(ios_base::failbit);
1647}1649}
1648#endif1650#endif
...@@ -1652,7 +1654,7 @@ inline...@@ -1652,7 +1654,7 @@ inline
1652basic_fstream<_CharT, _Traits>::basic_fstream(const string& __s, ios_base::openmode __mode)1654basic_fstream<_CharT, _Traits>::basic_fstream(const string& __s, ios_base::openmode __mode)
1653 : basic_iostream<char_type, traits_type>(&__sb_)1655 : basic_iostream<char_type, traits_type>(&__sb_)
1654{1656{
1655 if (__sb_.open(__s, __mode) == 0)1657 if (__sb_.open(__s, __mode) == nullptr)
1656 this->setstate(ios_base::failbit);1658 this->setstate(ios_base::failbit);
1657}1659}
1658#endif1660#endif
...@@ -1752,10 +1754,16 @@ inline...@@ -1752,10 +1754,16 @@ inline
1752void1754void
1753basic_fstream<_CharT, _Traits>::close()1755basic_fstream<_CharT, _Traits>::close()
1754{1756{
1755 if (__sb_.close() == 0)1757 if (__sb_.close() == nullptr)
1756 this->setstate(ios_base::failbit);1758 this->setstate(ios_base::failbit);
1757}1759}
17581760
1761#if defined(_LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1)
1762_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ifstream<char>)
1763_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ofstream<char>)
1764_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_filebuf<char>)
1765#endif
1766
1759_LIBCPP_END_NAMESPACE_STD1767_LIBCPP_END_NAMESPACE_STD
17601768
1761_LIBCPP_POP_MACROS1769_LIBCPP_POP_MACROS
lib/libcxx/include/functional+49-49
...@@ -470,6 +470,7 @@ template <> struct hash<bool>;...@@ -470,6 +470,7 @@ template <> struct hash<bool>;
470template <> struct hash<char>;470template <> struct hash<char>;
471template <> struct hash<signed char>;471template <> struct hash<signed char>;
472template <> struct hash<unsigned char>;472template <> struct hash<unsigned char>;
473template <> struct hash<char8_t>; // since C++20
473template <> struct hash<char16_t>;474template <> struct hash<char16_t>;
474template <> struct hash<char32_t>;475template <> struct hash<char32_t>;
475template <> struct hash<wchar_t>;476template <> struct hash<wchar_t>;
...@@ -508,10 +509,6 @@ POLICY: For non-variadic implementations, the number of arguments is limited...@@ -508,10 +509,6 @@ POLICY: For non-variadic implementations, the number of arguments is limited
508509
509#include <__functional_base>510#include <__functional_base>
510511
511#if defined(_LIBCPP_HAS_BLOCKS_RUNTIME) && !defined(_LIBCPP_HAS_OBJC_ARC)
512#include <Block.h>
513#endif
514
515#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)512#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
516#pragma GCC system_header513#pragma GCC system_header
517#endif514#endif
...@@ -1299,7 +1296,7 @@ public:...@@ -1299,7 +1296,7 @@ public:
1299 _LIBCPP_INLINE_VISIBILITY1296 _LIBCPP_INLINE_VISIBILITY
1300 typename __invoke_return<type, _ArgTypes...>::type1297 typename __invoke_return<type, _ArgTypes...>::type
1301 operator() (_ArgTypes&&... __args) const {1298 operator() (_ArgTypes&&... __args) const {
1302 return __invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...);1299 return _VSTD::__invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...);
1303 }1300 }
1304#else1301#else
13051302
...@@ -1307,98 +1304,98 @@ public:...@@ -1307,98 +1304,98 @@ public:
1307 _LIBCPP_INLINE_VISIBILITY1304 _LIBCPP_INLINE_VISIBILITY
1308 typename __invoke_return0<type, _A0>::type1305 typename __invoke_return0<type, _A0>::type
1309 operator() (_A0& __a0) const {1306 operator() (_A0& __a0) const {
1310 return __invoke(__f_, __a0);1307 return _VSTD::__invoke(__f_, __a0);
1311 }1308 }
13121309
1313 template <class _A0>1310 template <class _A0>
1314 _LIBCPP_INLINE_VISIBILITY1311 _LIBCPP_INLINE_VISIBILITY
1315 typename __invoke_return0<type, _A0 const>::type1312 typename __invoke_return0<type, _A0 const>::type
1316 operator() (_A0 const& __a0) const {1313 operator() (_A0 const& __a0) const {
1317 return __invoke(__f_, __a0);1314 return _VSTD::__invoke(__f_, __a0);
1318 }1315 }
13191316
1320 template <class _A0, class _A1>1317 template <class _A0, class _A1>
1321 _LIBCPP_INLINE_VISIBILITY1318 _LIBCPP_INLINE_VISIBILITY
1322 typename __invoke_return1<type, _A0, _A1>::type1319 typename __invoke_return1<type, _A0, _A1>::type
1323 operator() (_A0& __a0, _A1& __a1) const {1320 operator() (_A0& __a0, _A1& __a1) const {
1324 return __invoke(__f_, __a0, __a1);1321 return _VSTD::__invoke(__f_, __a0, __a1);
1325 }1322 }
13261323
1327 template <class _A0, class _A1>1324 template <class _A0, class _A1>
1328 _LIBCPP_INLINE_VISIBILITY1325 _LIBCPP_INLINE_VISIBILITY
1329 typename __invoke_return1<type, _A0 const, _A1>::type1326 typename __invoke_return1<type, _A0 const, _A1>::type
1330 operator() (_A0 const& __a0, _A1& __a1) const {1327 operator() (_A0 const& __a0, _A1& __a1) const {
1331 return __invoke(__f_, __a0, __a1);1328 return _VSTD::__invoke(__f_, __a0, __a1);
1332 }1329 }
13331330
1334 template <class _A0, class _A1>1331 template <class _A0, class _A1>
1335 _LIBCPP_INLINE_VISIBILITY1332 _LIBCPP_INLINE_VISIBILITY
1336 typename __invoke_return1<type, _A0, _A1 const>::type1333 typename __invoke_return1<type, _A0, _A1 const>::type
1337 operator() (_A0& __a0, _A1 const& __a1) const {1334 operator() (_A0& __a0, _A1 const& __a1) const {
1338 return __invoke(__f_, __a0, __a1);1335 return _VSTD::__invoke(__f_, __a0, __a1);
1339 }1336 }
13401337
1341 template <class _A0, class _A1>1338 template <class _A0, class _A1>
1342 _LIBCPP_INLINE_VISIBILITY1339 _LIBCPP_INLINE_VISIBILITY
1343 typename __invoke_return1<type, _A0 const, _A1 const>::type1340 typename __invoke_return1<type, _A0 const, _A1 const>::type
1344 operator() (_A0 const& __a0, _A1 const& __a1) const {1341 operator() (_A0 const& __a0, _A1 const& __a1) const {
1345 return __invoke(__f_, __a0, __a1);1342 return _VSTD::__invoke(__f_, __a0, __a1);
1346 }1343 }
13471344
1348 template <class _A0, class _A1, class _A2>1345 template <class _A0, class _A1, class _A2>
1349 _LIBCPP_INLINE_VISIBILITY1346 _LIBCPP_INLINE_VISIBILITY
1350 typename __invoke_return2<type, _A0, _A1, _A2>::type1347 typename __invoke_return2<type, _A0, _A1, _A2>::type
1351 operator() (_A0& __a0, _A1& __a1, _A2& __a2) const {1348 operator() (_A0& __a0, _A1& __a1, _A2& __a2) const {
1352 return __invoke(__f_, __a0, __a1, __a2);1349 return _VSTD::__invoke(__f_, __a0, __a1, __a2);
1353 }1350 }
13541351
1355 template <class _A0, class _A1, class _A2>1352 template <class _A0, class _A1, class _A2>
1356 _LIBCPP_INLINE_VISIBILITY1353 _LIBCPP_INLINE_VISIBILITY
1357 typename __invoke_return2<type, _A0 const, _A1, _A2>::type1354 typename __invoke_return2<type, _A0 const, _A1, _A2>::type
1358 operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const {1355 operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const {
1359 return __invoke(__f_, __a0, __a1, __a2);1356 return _VSTD::__invoke(__f_, __a0, __a1, __a2);
1360 }1357 }
13611358
1362 template <class _A0, class _A1, class _A2>1359 template <class _A0, class _A1, class _A2>
1363 _LIBCPP_INLINE_VISIBILITY1360 _LIBCPP_INLINE_VISIBILITY
1364 typename __invoke_return2<type, _A0, _A1 const, _A2>::type1361 typename __invoke_return2<type, _A0, _A1 const, _A2>::type
1365 operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const {1362 operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const {
1366 return __invoke(__f_, __a0, __a1, __a2);1363 return _VSTD::__invoke(__f_, __a0, __a1, __a2);
1367 }1364 }
13681365
1369 template <class _A0, class _A1, class _A2>1366 template <class _A0, class _A1, class _A2>
1370 _LIBCPP_INLINE_VISIBILITY1367 _LIBCPP_INLINE_VISIBILITY
1371 typename __invoke_return2<type, _A0, _A1, _A2 const>::type1368 typename __invoke_return2<type, _A0, _A1, _A2 const>::type
1372 operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const {1369 operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const {
1373 return __invoke(__f_, __a0, __a1, __a2);1370 return _VSTD::__invoke(__f_, __a0, __a1, __a2);
1374 }1371 }
13751372
1376 template <class _A0, class _A1, class _A2>1373 template <class _A0, class _A1, class _A2>
1377 _LIBCPP_INLINE_VISIBILITY1374 _LIBCPP_INLINE_VISIBILITY
1378 typename __invoke_return2<type, _A0 const, _A1 const, _A2>::type1375 typename __invoke_return2<type, _A0 const, _A1 const, _A2>::type
1379 operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const {1376 operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const {
1380 return __invoke(__f_, __a0, __a1, __a2);1377 return _VSTD::__invoke(__f_, __a0, __a1, __a2);
1381 }1378 }
13821379
1383 template <class _A0, class _A1, class _A2>1380 template <class _A0, class _A1, class _A2>
1384 _LIBCPP_INLINE_VISIBILITY1381 _LIBCPP_INLINE_VISIBILITY
1385 typename __invoke_return2<type, _A0 const, _A1, _A2 const>::type1382 typename __invoke_return2<type, _A0 const, _A1, _A2 const>::type
1386 operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const {1383 operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const {
1387 return __invoke(__f_, __a0, __a1, __a2);1384 return _VSTD::__invoke(__f_, __a0, __a1, __a2);
1388 }1385 }
13891386
1390 template <class _A0, class _A1, class _A2>1387 template <class _A0, class _A1, class _A2>
1391 _LIBCPP_INLINE_VISIBILITY1388 _LIBCPP_INLINE_VISIBILITY
1392 typename __invoke_return2<type, _A0, _A1 const, _A2 const>::type1389 typename __invoke_return2<type, _A0, _A1 const, _A2 const>::type
1393 operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const {1390 operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const {
1394 return __invoke(__f_, __a0, __a1, __a2);1391 return _VSTD::__invoke(__f_, __a0, __a1, __a2);
1395 }1392 }
13961393
1397 template <class _A0, class _A1, class _A2>1394 template <class _A0, class _A1, class _A2>
1398 _LIBCPP_INLINE_VISIBILITY1395 _LIBCPP_INLINE_VISIBILITY
1399 typename __invoke_return2<type, _A0 const, _A1 const, _A2 const>::type1396 typename __invoke_return2<type, _A0 const, _A1 const, _A2 const>::type
1400 operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const {1397 operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const {
1401 return __invoke(__f_, __a0, __a1, __a2);1398 return _VSTD::__invoke(__f_, __a0, __a1, __a2);
1402 }1399 }
1403#endif1400#endif
1404};1401};
...@@ -1596,7 +1593,7 @@ public:...@@ -1596,7 +1593,7 @@ public:
1596 const _Target& __target() const { return __f_; }1593 const _Target& __target() const { return __f_; }
15971594
1598 _LIBCPP_INLINE_VISIBILITY1595 _LIBCPP_INLINE_VISIBILITY
1599 explicit __default_alloc_func(_Target&& __f) : __f_(std::move(__f)) {}1596 explicit __default_alloc_func(_Target&& __f) : __f_(_VSTD::move(__f)) {}
16001597
1601 _LIBCPP_INLINE_VISIBILITY1598 _LIBCPP_INLINE_VISIBILITY
1602 explicit __default_alloc_func(const _Target& __f) : __f_(__f) {}1599 explicit __default_alloc_func(const _Target& __f) : __f_(__f) {}
...@@ -1612,7 +1609,7 @@ public:...@@ -1612,7 +1609,7 @@ public:
1612 __builtin_new_allocator::__holder_t __hold =1609 __builtin_new_allocator::__holder_t __hold =
1613 __builtin_new_allocator::__allocate_type<__default_alloc_func>(1);1610 __builtin_new_allocator::__allocate_type<__default_alloc_func>(1);
1614 __default_alloc_func* __res =1611 __default_alloc_func* __res =
1615 ::new (__hold.get()) __default_alloc_func(__f_);1612 ::new ((void*)__hold.get()) __default_alloc_func(__f_);
1616 (void)__hold.release();1613 (void)__hold.release();
1617 return __res;1614 return __res;
1618 }1615 }
...@@ -1703,7 +1700,7 @@ template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>...@@ -1703,7 +1700,7 @@ template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1703void1700void
1704__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone(__base<_Rp(_ArgTypes...)>* __p) const1701__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone(__base<_Rp(_ArgTypes...)>* __p) const
1705{1702{
1706 ::new (__p) __func(__f_.__target(), __f_.__get_allocator());1703 ::new ((void*)__p) __func(__f_.__target(), __f_.__get_allocator());
1707}1704}
17081705
1709template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>1706template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
...@@ -1739,7 +1736,7 @@ __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOE...@@ -1739,7 +1736,7 @@ __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOE
1739{1736{
1740 if (__ti == typeid(_Fp))1737 if (__ti == typeid(_Fp))
1741 return &__f_.__target();1738 return &__f_.__target();
1742 return (const void*)0;1739 return nullptr;
1743}1740}
17441741
1745template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>1742template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
...@@ -1769,11 +1766,11 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>...@@ -1769,11 +1766,11 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
17691766
1770 public:1767 public:
1771 _LIBCPP_INLINE_VISIBILITY1768 _LIBCPP_INLINE_VISIBILITY
1772 __value_func() _NOEXCEPT : __f_(0) {}1769 __value_func() _NOEXCEPT : __f_(nullptr) {}
17731770
1774 template <class _Fp, class _Alloc>1771 template <class _Fp, class _Alloc>
1775 _LIBCPP_INLINE_VISIBILITY __value_func(_Fp&& __f, const _Alloc& __a)1772 _LIBCPP_INLINE_VISIBILITY __value_func(_Fp&& __f, const _Alloc& __a)
1776 : __f_(0)1773 : __f_(nullptr)
1777 {1774 {
1778 typedef allocator_traits<_Alloc> __alloc_traits;1775 typedef allocator_traits<_Alloc> __alloc_traits;
1779 typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _Fun;1776 typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _Fun;
...@@ -1803,13 +1800,13 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>...@@ -1803,13 +1800,13 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
1803 template <class _Fp,1800 template <class _Fp,
1804 class = typename enable_if<!is_same<typename decay<_Fp>::type, __value_func>::value>::type>1801 class = typename enable_if<!is_same<typename decay<_Fp>::type, __value_func>::value>::type>
1805 _LIBCPP_INLINE_VISIBILITY explicit __value_func(_Fp&& __f)1802 _LIBCPP_INLINE_VISIBILITY explicit __value_func(_Fp&& __f)
1806 : __value_func(std::forward<_Fp>(__f), allocator<_Fp>()) {}1803 : __value_func(_VSTD::forward<_Fp>(__f), allocator<_Fp>()) {}
18071804
1808 _LIBCPP_INLINE_VISIBILITY1805 _LIBCPP_INLINE_VISIBILITY
1809 __value_func(const __value_func& __f)1806 __value_func(const __value_func& __f)
1810 {1807 {
1811 if (__f.__f_ == 0)1808 if (__f.__f_ == nullptr)
1812 __f_ = 0;1809 __f_ = nullptr;
1813 else if ((void*)__f.__f_ == &__f.__buf_)1810 else if ((void*)__f.__f_ == &__f.__buf_)
1814 {1811 {
1815 __f_ = __as_base(&__buf_);1812 __f_ = __as_base(&__buf_);
...@@ -1822,8 +1819,8 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>...@@ -1822,8 +1819,8 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
1822 _LIBCPP_INLINE_VISIBILITY1819 _LIBCPP_INLINE_VISIBILITY
1823 __value_func(__value_func&& __f) _NOEXCEPT1820 __value_func(__value_func&& __f) _NOEXCEPT
1824 {1821 {
1825 if (__f.__f_ == 0)1822 if (__f.__f_ == nullptr)
1826 __f_ = 0;1823 __f_ = nullptr;
1827 else if ((void*)__f.__f_ == &__f.__buf_)1824 else if ((void*)__f.__f_ == &__f.__buf_)
1828 {1825 {
1829 __f_ = __as_base(&__buf_);1826 __f_ = __as_base(&__buf_);
...@@ -1832,7 +1829,7 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>...@@ -1832,7 +1829,7 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
1832 else1829 else
1833 {1830 {
1834 __f_ = __f.__f_;1831 __f_ = __f.__f_;
1835 __f.__f_ = 0;1832 __f.__f_ = nullptr;
1836 }1833 }
1837 }1834 }
18381835
...@@ -1849,8 +1846,8 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>...@@ -1849,8 +1846,8 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
1849 __value_func& operator=(__value_func&& __f)1846 __value_func& operator=(__value_func&& __f)
1850 {1847 {
1851 *this = nullptr;1848 *this = nullptr;
1852 if (__f.__f_ == 0)1849 if (__f.__f_ == nullptr)
1853 __f_ = 0;1850 __f_ = nullptr;
1854 else if ((void*)__f.__f_ == &__f.__buf_)1851 else if ((void*)__f.__f_ == &__f.__buf_)
1855 {1852 {
1856 __f_ = __as_base(&__buf_);1853 __f_ = __as_base(&__buf_);
...@@ -1859,7 +1856,7 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>...@@ -1859,7 +1856,7 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
1859 else1856 else
1860 {1857 {
1861 __f_ = __f.__f_;1858 __f_ = __f.__f_;
1862 __f.__f_ = 0;1859 __f.__f_ = nullptr;
1863 }1860 }
1864 return *this;1861 return *this;
1865 }1862 }
...@@ -1868,7 +1865,7 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>...@@ -1868,7 +1865,7 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
1868 __value_func& operator=(nullptr_t)1865 __value_func& operator=(nullptr_t)
1869 {1866 {
1870 __func* __f = __f_;1867 __func* __f = __f_;
1871 __f_ = 0;1868 __f_ = nullptr;
1872 if ((void*)__f == &__buf_)1869 if ((void*)__f == &__buf_)
1873 __f->destroy();1870 __f->destroy();
1874 else if (__f)1871 else if (__f)
...@@ -1879,7 +1876,7 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>...@@ -1879,7 +1876,7 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
1879 _LIBCPP_INLINE_VISIBILITY1876 _LIBCPP_INLINE_VISIBILITY
1880 _Rp operator()(_ArgTypes&&... __args) const1877 _Rp operator()(_ArgTypes&&... __args) const
1881 {1878 {
1882 if (__f_ == 0)1879 if (__f_ == nullptr)
1883 __throw_bad_function_call();1880 __throw_bad_function_call();
1884 return (*__f_)(_VSTD::forward<_ArgTypes>(__args)...);1881 return (*__f_)(_VSTD::forward<_ArgTypes>(__args)...);
1885 }1882 }
...@@ -1895,10 +1892,10 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>...@@ -1895,10 +1892,10 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
1895 __func* __t = __as_base(&__tempbuf);1892 __func* __t = __as_base(&__tempbuf);
1896 __f_->__clone(__t);1893 __f_->__clone(__t);
1897 __f_->destroy();1894 __f_->destroy();
1898 __f_ = 0;1895 __f_ = nullptr;
1899 __f.__f_->__clone(__as_base(&__buf_));1896 __f.__f_->__clone(__as_base(&__buf_));
1900 __f.__f_->destroy();1897 __f.__f_->destroy();
1901 __f.__f_ = 0;1898 __f.__f_ = nullptr;
1902 __f_ = __as_base(&__buf_);1899 __f_ = __as_base(&__buf_);
1903 __t->__clone(__as_base(&__f.__buf_));1900 __t->__clone(__as_base(&__f.__buf_));
1904 __t->destroy();1901 __t->destroy();
...@@ -1923,13 +1920,13 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>...@@ -1923,13 +1920,13 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
1923 }1920 }
19241921
1925 _LIBCPP_INLINE_VISIBILITY1922 _LIBCPP_INLINE_VISIBILITY
1926 _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT { return __f_ != 0; }1923 _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT { return __f_ != nullptr; }
19271924
1928#ifndef _LIBCPP_NO_RTTI1925#ifndef _LIBCPP_NO_RTTI
1929 _LIBCPP_INLINE_VISIBILITY1926 _LIBCPP_INLINE_VISIBILITY
1930 const std::type_info& target_type() const _NOEXCEPT1927 const std::type_info& target_type() const _NOEXCEPT
1931 {1928 {
1932 if (__f_ == 0)1929 if (__f_ == nullptr)
1933 return typeid(void);1930 return typeid(void);
1934 return __f_->target_type();1931 return __f_->target_type();
1935 }1932 }
...@@ -1937,8 +1934,8 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>...@@ -1937,8 +1934,8 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
1937 template <typename _Tp>1934 template <typename _Tp>
1938 _LIBCPP_INLINE_VISIBILITY const _Tp* target() const _NOEXCEPT1935 _LIBCPP_INLINE_VISIBILITY const _Tp* target() const _NOEXCEPT
1939 {1936 {
1940 if (__f_ == 0)1937 if (__f_ == nullptr)
1941 return 0;1938 return nullptr;
1942 return (const _Tp*)__f_->target(typeid(_Tp));1939 return (const _Tp*)__f_->target(typeid(_Tp));
1943 }1940 }
1944#endif // _LIBCPP_NO_RTTI1941#endif // _LIBCPP_NO_RTTI
...@@ -2157,7 +2154,7 @@ template <class _Rp, class... _ArgTypes> class __policy_func<_Rp(_ArgTypes...)>...@@ -2157,7 +2154,7 @@ template <class _Rp, class... _ArgTypes> class __policy_func<_Rp(_ArgTypes...)>
2157 } else {2154 } else {
2158 __builtin_new_allocator::__holder_t __hold =2155 __builtin_new_allocator::__holder_t __hold =
2159 __builtin_new_allocator::__allocate_type<_Fun>(1);2156 __builtin_new_allocator::__allocate_type<_Fun>(1);
2160 __buf_.__large = ::new (__hold.get()) _Fun(_VSTD::move(__f));2157 __buf_.__large = ::new ((void*)__hold.get()) _Fun(_VSTD::move(__f));
2161 (void)__hold.release();2158 (void)__hold.release();
2162 }2159 }
2163 }2160 }
...@@ -2257,6 +2254,9 @@ template <class _Rp, class... _ArgTypes> class __policy_func<_Rp(_ArgTypes...)>...@@ -2257,6 +2254,9 @@ template <class _Rp, class... _ArgTypes> class __policy_func<_Rp(_ArgTypes...)>
22572254
2258#if defined(_LIBCPP_HAS_BLOCKS_RUNTIME) && !defined(_LIBCPP_HAS_OBJC_ARC)2255#if defined(_LIBCPP_HAS_BLOCKS_RUNTIME) && !defined(_LIBCPP_HAS_OBJC_ARC)
22592256
2257extern "C" void *_Block_copy(const void *);
2258extern "C" void _Block_release(const void *);
2259
2260template<class _Rp1, class ..._ArgTypes1, class _Alloc, class _Rp, class ..._ArgTypes>2260template<class _Rp1, class ..._ArgTypes1, class _Alloc, class _Rp, class ..._ArgTypes>
2261class __func<_Rp1(^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)>2261class __func<_Rp1(^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)>
2262 : public __base<_Rp(_ArgTypes...)>2262 : public __base<_Rp(_ArgTypes...)>
...@@ -2267,14 +2267,14 @@ class __func<_Rp1(^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)>...@@ -2267,14 +2267,14 @@ class __func<_Rp1(^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)>
2267public:2267public:
2268 _LIBCPP_INLINE_VISIBILITY2268 _LIBCPP_INLINE_VISIBILITY
2269 explicit __func(__block_type const& __f)2269 explicit __func(__block_type const& __f)
2270 : __f_(__f ? Block_copy(__f) : (__block_type)0)2270 : __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr))
2271 { }2271 { }
22722272
2273 // [TODO] add && to save on a retain2273 // [TODO] add && to save on a retain
22742274
2275 _LIBCPP_INLINE_VISIBILITY2275 _LIBCPP_INLINE_VISIBILITY
2276 explicit __func(__block_type __f, const _Alloc& /* unused */)2276 explicit __func(__block_type __f, const _Alloc& /* unused */)
2277 : __f_(__f ? Block_copy(__f) : (__block_type)0)2277 : __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr))
2278 { }2278 { }
22792279
2280 virtual __base<_Rp(_ArgTypes...)>* __clone() const {2280 virtual __base<_Rp(_ArgTypes...)>* __clone() const {
...@@ -2286,12 +2286,12 @@ public:...@@ -2286,12 +2286,12 @@ public:
2286 }2286 }
22872287
2288 virtual void __clone(__base<_Rp(_ArgTypes...)>* __p) const {2288 virtual void __clone(__base<_Rp(_ArgTypes...)>* __p) const {
2289 ::new (__p) __func(__f_);2289 ::new ((void*)__p) __func(__f_);
2290 }2290 }
22912291
2292 virtual void destroy() _NOEXCEPT {2292 virtual void destroy() _NOEXCEPT {
2293 if (__f_)2293 if (__f_)
2294 Block_release(__f_);2294 _Block_release(__f_);
2295 __f_ = 0;2295 __f_ = 0;
2296 }2296 }
22972297
...@@ -2303,7 +2303,7 @@ public:...@@ -2303,7 +2303,7 @@ public:
2303 }2303 }
23042304
2305 virtual _Rp operator()(_ArgTypes&& ... __arg) {2305 virtual _Rp operator()(_ArgTypes&& ... __arg) {
2306 return __invoke(__f_, _VSTD::forward<_ArgTypes>(__arg)...);2306 return _VSTD::__invoke(__f_, _VSTD::forward<_ArgTypes>(__arg)...);
2307 }2307 }
23082308
2309#ifndef _LIBCPP_NO_RTTI2309#ifndef _LIBCPP_NO_RTTI
...@@ -2518,7 +2518,7 @@ template<class _Rp, class ..._ArgTypes>...@@ -2518,7 +2518,7 @@ template<class _Rp, class ..._ArgTypes>
2518function<_Rp(_ArgTypes...)>&2518function<_Rp(_ArgTypes...)>&
2519function<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT2519function<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT
2520{2520{
2521 __f_ = std::move(__f.__f_);2521 __f_ = _VSTD::move(__f.__f_);
2522 return *this;2522 return *this;
2523}2523}
25242524
lib/libcxx/include/future+43-193
...@@ -362,6 +362,7 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;...@@ -362,6 +362,7 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;
362*/362*/
363363
364#include <__config>364#include <__config>
365#include <__availability>
365#include <system_error>366#include <system_error>
366#include <memory>367#include <memory>
367#include <chrono>368#include <chrono>
...@@ -624,18 +625,10 @@ protected:...@@ -624,18 +625,10 @@ protected:
624public:625public:
625626
626 template <class _Arg>627 template <class _Arg>
627#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES628 void set_value(_Arg&& __arg);
628 void set_value(_Arg&& __arg);
629#else
630 void set_value(_Arg& __arg);
631#endif
632629
633 template <class _Arg>630 template <class _Arg>
634#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES631 void set_value_at_thread_exit(_Arg&& __arg);
635 void set_value_at_thread_exit(_Arg&& __arg);
636#else
637 void set_value_at_thread_exit(_Arg& __arg);
638#endif
639632
640 _Rp move();633 _Rp move();
641 typename add_lvalue_reference<_Rp>::type copy();634 typename add_lvalue_reference<_Rp>::type copy();
...@@ -654,16 +647,12 @@ template <class _Rp>...@@ -654,16 +647,12 @@ template <class _Rp>
654template <class _Arg>647template <class _Arg>
655_LIBCPP_AVAILABILITY_FUTURE648_LIBCPP_AVAILABILITY_FUTURE
656void649void
657#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
658__assoc_state<_Rp>::set_value(_Arg&& __arg)650__assoc_state<_Rp>::set_value(_Arg&& __arg)
659#else
660__assoc_state<_Rp>::set_value(_Arg& __arg)
661#endif
662{651{
663 unique_lock<mutex> __lk(this->__mut_);652 unique_lock<mutex> __lk(this->__mut_);
664 if (this->__has_value())653 if (this->__has_value())
665 __throw_future_error(future_errc::promise_already_satisfied);654 __throw_future_error(future_errc::promise_already_satisfied);
666 ::new(&__value_) _Rp(_VSTD::forward<_Arg>(__arg));655 ::new ((void*)&__value_) _Rp(_VSTD::forward<_Arg>(__arg));
667 this->__state_ |= base::__constructed | base::ready;656 this->__state_ |= base::__constructed | base::ready;
668 __cv_.notify_all();657 __cv_.notify_all();
669}658}
...@@ -671,16 +660,12 @@ __assoc_state<_Rp>::set_value(_Arg& __arg)...@@ -671,16 +660,12 @@ __assoc_state<_Rp>::set_value(_Arg& __arg)
671template <class _Rp>660template <class _Rp>
672template <class _Arg>661template <class _Arg>
673void662void
674#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
675__assoc_state<_Rp>::set_value_at_thread_exit(_Arg&& __arg)663__assoc_state<_Rp>::set_value_at_thread_exit(_Arg&& __arg)
676#else
677__assoc_state<_Rp>::set_value_at_thread_exit(_Arg& __arg)
678#endif
679{664{
680 unique_lock<mutex> __lk(this->__mut_);665 unique_lock<mutex> __lk(this->__mut_);
681 if (this->__has_value())666 if (this->__has_value())
682 __throw_future_error(future_errc::promise_already_satisfied);667 __throw_future_error(future_errc::promise_already_satisfied);
683 ::new(&__value_) _Rp(_VSTD::forward<_Arg>(__arg));668 ::new ((void*)&__value_) _Rp(_VSTD::forward<_Arg>(__arg));
684 this->__state_ |= base::__constructed;669 this->__state_ |= base::__constructed;
685 __thread_local_data()->__make_ready_at_thread_exit(this);670 __thread_local_data()->__make_ready_at_thread_exit(this);
686}671}
...@@ -856,16 +841,12 @@ class _LIBCPP_AVAILABILITY_FUTURE __deferred_assoc_state...@@ -856,16 +841,12 @@ class _LIBCPP_AVAILABILITY_FUTURE __deferred_assoc_state
856 _Fp __func_;841 _Fp __func_;
857842
858public:843public:
859#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
860 _LIBCPP_INLINE_VISIBILITY844 _LIBCPP_INLINE_VISIBILITY
861 explicit __deferred_assoc_state(_Fp&& __f);845 explicit __deferred_assoc_state(_Fp&& __f);
862#endif
863846
864 virtual void __execute();847 virtual void __execute();
865};848};
866849
867#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
868
869template <class _Rp, class _Fp>850template <class _Rp, class _Fp>
870inline851inline
871__deferred_assoc_state<_Rp, _Fp>::__deferred_assoc_state(_Fp&& __f)852__deferred_assoc_state<_Rp, _Fp>::__deferred_assoc_state(_Fp&& __f)
...@@ -874,8 +855,6 @@ __deferred_assoc_state<_Rp, _Fp>::__deferred_assoc_state(_Fp&& __f)...@@ -874,8 +855,6 @@ __deferred_assoc_state<_Rp, _Fp>::__deferred_assoc_state(_Fp&& __f)
874 this->__set_deferred();855 this->__set_deferred();
875}856}
876857
877#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
878
879template <class _Rp, class _Fp>858template <class _Rp, class _Fp>
880void859void
881__deferred_assoc_state<_Rp, _Fp>::__execute()860__deferred_assoc_state<_Rp, _Fp>::__execute()
...@@ -903,16 +882,12 @@ class _LIBCPP_AVAILABILITY_FUTURE __deferred_assoc_state<void, _Fp>...@@ -903,16 +882,12 @@ class _LIBCPP_AVAILABILITY_FUTURE __deferred_assoc_state<void, _Fp>
903 _Fp __func_;882 _Fp __func_;
904883
905public:884public:
906#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
907 _LIBCPP_INLINE_VISIBILITY885 _LIBCPP_INLINE_VISIBILITY
908 explicit __deferred_assoc_state(_Fp&& __f);886 explicit __deferred_assoc_state(_Fp&& __f);
909#endif
910887
911 virtual void __execute();888 virtual void __execute();
912};889};
913890
914#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
915
916template <class _Fp>891template <class _Fp>
917inline892inline
918__deferred_assoc_state<void, _Fp>::__deferred_assoc_state(_Fp&& __f)893__deferred_assoc_state<void, _Fp>::__deferred_assoc_state(_Fp&& __f)
...@@ -921,8 +896,6 @@ __deferred_assoc_state<void, _Fp>::__deferred_assoc_state(_Fp&& __f)...@@ -921,8 +896,6 @@ __deferred_assoc_state<void, _Fp>::__deferred_assoc_state(_Fp&& __f)
921 this->__set_deferred();896 this->__set_deferred();
922}897}
923898
924#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
925
926template <class _Fp>899template <class _Fp>
927void900void
928__deferred_assoc_state<void, _Fp>::__execute()901__deferred_assoc_state<void, _Fp>::__execute()
...@@ -952,16 +925,12 @@ class _LIBCPP_AVAILABILITY_FUTURE __async_assoc_state...@@ -952,16 +925,12 @@ class _LIBCPP_AVAILABILITY_FUTURE __async_assoc_state
952925
953 virtual void __on_zero_shared() _NOEXCEPT;926 virtual void __on_zero_shared() _NOEXCEPT;
954public:927public:
955#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
956 _LIBCPP_INLINE_VISIBILITY928 _LIBCPP_INLINE_VISIBILITY
957 explicit __async_assoc_state(_Fp&& __f);929 explicit __async_assoc_state(_Fp&& __f);
958#endif
959930
960 virtual void __execute();931 virtual void __execute();
961};932};
962933
963#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
964
965template <class _Rp, class _Fp>934template <class _Rp, class _Fp>
966inline935inline
967__async_assoc_state<_Rp, _Fp>::__async_assoc_state(_Fp&& __f)936__async_assoc_state<_Rp, _Fp>::__async_assoc_state(_Fp&& __f)
...@@ -969,8 +938,6 @@ __async_assoc_state<_Rp, _Fp>::__async_assoc_state(_Fp&& __f)...@@ -969,8 +938,6 @@ __async_assoc_state<_Rp, _Fp>::__async_assoc_state(_Fp&& __f)
969{938{
970}939}
971940
972#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
973
974template <class _Rp, class _Fp>941template <class _Rp, class _Fp>
975void942void
976__async_assoc_state<_Rp, _Fp>::__execute()943__async_assoc_state<_Rp, _Fp>::__execute()
...@@ -1007,16 +974,12 @@ class _LIBCPP_AVAILABILITY_FUTURE __async_assoc_state<void, _Fp>...@@ -1007,16 +974,12 @@ class _LIBCPP_AVAILABILITY_FUTURE __async_assoc_state<void, _Fp>
1007974
1008 virtual void __on_zero_shared() _NOEXCEPT;975 virtual void __on_zero_shared() _NOEXCEPT;
1009public:976public:
1010#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1011 _LIBCPP_INLINE_VISIBILITY977 _LIBCPP_INLINE_VISIBILITY
1012 explicit __async_assoc_state(_Fp&& __f);978 explicit __async_assoc_state(_Fp&& __f);
1013#endif
1014979
1015 virtual void __execute();980 virtual void __execute();
1016};981};
1017982
1018#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1019
1020template <class _Fp>983template <class _Fp>
1021inline984inline
1022__async_assoc_state<void, _Fp>::__async_assoc_state(_Fp&& __f)985__async_assoc_state<void, _Fp>::__async_assoc_state(_Fp&& __f)
...@@ -1024,8 +987,6 @@ __async_assoc_state<void, _Fp>::__async_assoc_state(_Fp&& __f)...@@ -1024,8 +987,6 @@ __async_assoc_state<void, _Fp>::__async_assoc_state(_Fp&& __f)
1024{987{
1025}988}
1026989
1027#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1028
1029template <class _Fp>990template <class _Fp>
1030void991void
1031__async_assoc_state<void, _Fp>::__execute()992__async_assoc_state<void, _Fp>::__execute()
...@@ -1062,19 +1023,11 @@ template <class _Rp> class _LIBCPP_TEMPLATE_VIS future;...@@ -1062,19 +1023,11 @@ template <class _Rp> class _LIBCPP_TEMPLATE_VIS future;
10621023
1063template <class _Rp, class _Fp>1024template <class _Rp, class _Fp>
1064_LIBCPP_INLINE_VISIBILITY future<_Rp>1025_LIBCPP_INLINE_VISIBILITY future<_Rp>
1065#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1066__make_deferred_assoc_state(_Fp&& __f);1026__make_deferred_assoc_state(_Fp&& __f);
1067#else
1068__make_deferred_assoc_state(_Fp __f);
1069#endif
10701027
1071template <class _Rp, class _Fp>1028template <class _Rp, class _Fp>
1072_LIBCPP_INLINE_VISIBILITY future<_Rp>1029_LIBCPP_INLINE_VISIBILITY future<_Rp>
1073#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1074__make_async_assoc_state(_Fp&& __f);1030__make_async_assoc_state(_Fp&& __f);
1075#else
1076__make_async_assoc_state(_Fp __f);
1077#endif
10781031
1079template <class _Rp>1032template <class _Rp>
1080class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FUTURE future1033class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FUTURE future
...@@ -1086,22 +1039,14 @@ class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FUTURE future...@@ -1086,22 +1039,14 @@ class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FUTURE future
1086 template <class> friend class promise;1039 template <class> friend class promise;
1087 template <class> friend class shared_future;1040 template <class> friend class shared_future;
10881041
1089#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1090 template <class _R1, class _Fp>1042 template <class _R1, class _Fp>
1091 friend future<_R1> __make_deferred_assoc_state(_Fp&& __f);1043 friend future<_R1> __make_deferred_assoc_state(_Fp&& __f);
1092 template <class _R1, class _Fp>1044 template <class _R1, class _Fp>
1093 friend future<_R1> __make_async_assoc_state(_Fp&& __f);1045 friend future<_R1> __make_async_assoc_state(_Fp&& __f);
1094#else
1095 template <class _R1, class _Fp>
1096 friend future<_R1> __make_deferred_assoc_state(_Fp __f);
1097 template <class _R1, class _Fp>
1098 friend future<_R1> __make_async_assoc_state(_Fp __f);
1099#endif
11001046
1101public:1047public:
1102 _LIBCPP_INLINE_VISIBILITY1048 _LIBCPP_INLINE_VISIBILITY
1103 future() _NOEXCEPT : __state_(nullptr) {}1049 future() _NOEXCEPT : __state_(nullptr) {}
1104#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1105 _LIBCPP_INLINE_VISIBILITY1050 _LIBCPP_INLINE_VISIBILITY
1106 future(future&& __rhs) _NOEXCEPT1051 future(future&& __rhs) _NOEXCEPT
1107 : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;}1052 : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;}
...@@ -1110,15 +1055,10 @@ public:...@@ -1110,15 +1055,10 @@ public:
1110 _LIBCPP_INLINE_VISIBILITY1055 _LIBCPP_INLINE_VISIBILITY
1111 future& operator=(future&& __rhs) _NOEXCEPT1056 future& operator=(future&& __rhs) _NOEXCEPT
1112 {1057 {
1113 future(std::move(__rhs)).swap(*this);1058 future(_VSTD::move(__rhs)).swap(*this);
1114 return *this;1059 return *this;
1115 }1060 }
1116#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES1061
1117private:
1118 future(const future&);
1119 future& operator=(const future&);
1120public:
1121#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1122 ~future();1062 ~future();
1123 _LIBCPP_INLINE_VISIBILITY1063 _LIBCPP_INLINE_VISIBILITY
1124 shared_future<_Rp> share() _NOEXCEPT;1064 shared_future<_Rp> share() _NOEXCEPT;
...@@ -1186,22 +1126,14 @@ class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FUTURE future<_Rp&>...@@ -1186,22 +1126,14 @@ class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FUTURE future<_Rp&>
1186 template <class> friend class promise;1126 template <class> friend class promise;
1187 template <class> friend class shared_future;1127 template <class> friend class shared_future;
11881128
1189#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1190 template <class _R1, class _Fp>1129 template <class _R1, class _Fp>
1191 friend future<_R1> __make_deferred_assoc_state(_Fp&& __f);1130 friend future<_R1> __make_deferred_assoc_state(_Fp&& __f);
1192 template <class _R1, class _Fp>1131 template <class _R1, class _Fp>
1193 friend future<_R1> __make_async_assoc_state(_Fp&& __f);1132 friend future<_R1> __make_async_assoc_state(_Fp&& __f);
1194#else
1195 template <class _R1, class _Fp>
1196 friend future<_R1> __make_deferred_assoc_state(_Fp __f);
1197 template <class _R1, class _Fp>
1198 friend future<_R1> __make_async_assoc_state(_Fp __f);
1199#endif
12001133
1201public:1134public:
1202 _LIBCPP_INLINE_VISIBILITY1135 _LIBCPP_INLINE_VISIBILITY
1203 future() _NOEXCEPT : __state_(nullptr) {}1136 future() _NOEXCEPT : __state_(nullptr) {}
1204#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1205 _LIBCPP_INLINE_VISIBILITY1137 _LIBCPP_INLINE_VISIBILITY
1206 future(future&& __rhs) _NOEXCEPT1138 future(future&& __rhs) _NOEXCEPT
1207 : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;}1139 : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;}
...@@ -1210,15 +1142,10 @@ public:...@@ -1210,15 +1142,10 @@ public:
1210 _LIBCPP_INLINE_VISIBILITY1142 _LIBCPP_INLINE_VISIBILITY
1211 future& operator=(future&& __rhs) _NOEXCEPT1143 future& operator=(future&& __rhs) _NOEXCEPT
1212 {1144 {
1213 future(std::move(__rhs)).swap(*this);1145 future(_VSTD::move(__rhs)).swap(*this);
1214 return *this;1146 return *this;
1215 }1147 }
1216#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES1148
1217private:
1218 future(const future&);
1219 future& operator=(const future&);
1220public:
1221#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1222 ~future();1149 ~future();
1223 _LIBCPP_INLINE_VISIBILITY1150 _LIBCPP_INLINE_VISIBILITY
1224 shared_future<_Rp&> share() _NOEXCEPT;1151 shared_future<_Rp&> share() _NOEXCEPT;
...@@ -1281,22 +1208,14 @@ class _LIBCPP_TYPE_VIS _LIBCPP_AVAILABILITY_FUTURE future<void>...@@ -1281,22 +1208,14 @@ class _LIBCPP_TYPE_VIS _LIBCPP_AVAILABILITY_FUTURE future<void>
1281 template <class> friend class promise;1208 template <class> friend class promise;
1282 template <class> friend class shared_future;1209 template <class> friend class shared_future;
12831210
1284#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1285 template <class _R1, class _Fp>1211 template <class _R1, class _Fp>
1286 friend future<_R1> __make_deferred_assoc_state(_Fp&& __f);1212 friend future<_R1> __make_deferred_assoc_state(_Fp&& __f);
1287 template <class _R1, class _Fp>1213 template <class _R1, class _Fp>
1288 friend future<_R1> __make_async_assoc_state(_Fp&& __f);1214 friend future<_R1> __make_async_assoc_state(_Fp&& __f);
1289#else
1290 template <class _R1, class _Fp>
1291 friend future<_R1> __make_deferred_assoc_state(_Fp __f);
1292 template <class _R1, class _Fp>
1293 friend future<_R1> __make_async_assoc_state(_Fp __f);
1294#endif
12951215
1296public:1216public:
1297 _LIBCPP_INLINE_VISIBILITY1217 _LIBCPP_INLINE_VISIBILITY
1298 future() _NOEXCEPT : __state_(nullptr) {}1218 future() _NOEXCEPT : __state_(nullptr) {}
1299#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1300 _LIBCPP_INLINE_VISIBILITY1219 _LIBCPP_INLINE_VISIBILITY
1301 future(future&& __rhs) _NOEXCEPT1220 future(future&& __rhs) _NOEXCEPT
1302 : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;}1221 : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;}
...@@ -1305,15 +1224,10 @@ public:...@@ -1305,15 +1224,10 @@ public:
1305 _LIBCPP_INLINE_VISIBILITY1224 _LIBCPP_INLINE_VISIBILITY
1306 future& operator=(future&& __rhs) _NOEXCEPT1225 future& operator=(future&& __rhs) _NOEXCEPT
1307 {1226 {
1308 future(std::move(__rhs)).swap(*this);1227 future(_VSTD::move(__rhs)).swap(*this);
1309 return *this;1228 return *this;
1310 }1229 }
1311#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES1230
1312private:
1313 future(const future&);
1314 future& operator=(const future&);
1315public:
1316#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1317 ~future();1231 ~future();
1318 _LIBCPP_INLINE_VISIBILITY1232 _LIBCPP_INLINE_VISIBILITY
1319 shared_future<void> share() _NOEXCEPT;1233 shared_future<void> share() _NOEXCEPT;
...@@ -1367,32 +1281,21 @@ public:...@@ -1367,32 +1281,21 @@ public:
1367 promise();1281 promise();
1368 template <class _Alloc>1282 template <class _Alloc>
1369 promise(allocator_arg_t, const _Alloc& __a);1283 promise(allocator_arg_t, const _Alloc& __a);
1370#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1371 _LIBCPP_INLINE_VISIBILITY1284 _LIBCPP_INLINE_VISIBILITY
1372 promise(promise&& __rhs) _NOEXCEPT1285 promise(promise&& __rhs) _NOEXCEPT
1373 : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;}1286 : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;}
1374 promise(const promise& __rhs) = delete;1287 promise(const promise& __rhs) = delete;
1375#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1376private:
1377 promise(const promise& __rhs);
1378public:
1379#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1380 ~promise();1288 ~promise();
13811289
1382 // assignment1290 // assignment
1383#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1384 _LIBCPP_INLINE_VISIBILITY1291 _LIBCPP_INLINE_VISIBILITY
1385 promise& operator=(promise&& __rhs) _NOEXCEPT1292 promise& operator=(promise&& __rhs) _NOEXCEPT
1386 {1293 {
1387 promise(std::move(__rhs)).swap(*this);1294 promise(_VSTD::move(__rhs)).swap(*this);
1388 return *this;1295 return *this;
1389 }1296 }
1390 promise& operator=(const promise& __rhs) = delete;1297 promise& operator=(const promise& __rhs) = delete;
1391#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES1298
1392private:
1393 promise& operator=(const promise& __rhs);
1394public:
1395#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1396 _LIBCPP_INLINE_VISIBILITY1299 _LIBCPP_INLINE_VISIBILITY
1397 void swap(promise& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);}1300 void swap(promise& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);}
13981301
...@@ -1401,16 +1304,12 @@ public:...@@ -1401,16 +1304,12 @@ public:
14011304
1402 // setting the result1305 // setting the result
1403 void set_value(const _Rp& __r);1306 void set_value(const _Rp& __r);
1404#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1405 void set_value(_Rp&& __r);1307 void set_value(_Rp&& __r);
1406#endif
1407 void set_exception(exception_ptr __p);1308 void set_exception(exception_ptr __p);
14081309
1409 // setting the result with deferred notification1310 // setting the result with deferred notification
1410 void set_value_at_thread_exit(const _Rp& __r);1311 void set_value_at_thread_exit(const _Rp& __r);
1411#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1412 void set_value_at_thread_exit(_Rp&& __r);1312 void set_value_at_thread_exit(_Rp&& __r);
1413#endif
1414 void set_exception_at_thread_exit(exception_ptr __p);1313 void set_exception_at_thread_exit(exception_ptr __p);
1415};1314};
14161315
...@@ -1429,7 +1328,7 @@ promise<_Rp>::promise(allocator_arg_t, const _Alloc& __a0)...@@ -1429,7 +1328,7 @@ promise<_Rp>::promise(allocator_arg_t, const _Alloc& __a0)
1429 typedef __allocator_destructor<_A2> _D2;1328 typedef __allocator_destructor<_A2> _D2;
1430 _A2 __a(__a0);1329 _A2 __a(__a0);
1431 unique_ptr<_State, _D2> __hold(__a.allocate(1), _D2(__a, 1));1330 unique_ptr<_State, _D2> __hold(__a.allocate(1), _D2(__a, 1));
1432 ::new(static_cast<void*>(_VSTD::addressof(*__hold.get()))) _State(__a0);1331 ::new ((void*)_VSTD::addressof(*__hold.get())) _State(__a0);
1433 __state_ = _VSTD::addressof(*__hold.release());1332 __state_ = _VSTD::addressof(*__hold.release());
1434}1333}
14351334
...@@ -1464,8 +1363,6 @@ promise<_Rp>::set_value(const _Rp& __r)...@@ -1464,8 +1363,6 @@ promise<_Rp>::set_value(const _Rp& __r)
1464 __state_->set_value(__r);1363 __state_->set_value(__r);
1465}1364}
14661365
1467#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1468
1469template <class _Rp>1366template <class _Rp>
1470void1367void
1471promise<_Rp>::set_value(_Rp&& __r)1368promise<_Rp>::set_value(_Rp&& __r)
...@@ -1475,8 +1372,6 @@ promise<_Rp>::set_value(_Rp&& __r)...@@ -1475,8 +1372,6 @@ promise<_Rp>::set_value(_Rp&& __r)
1475 __state_->set_value(_VSTD::move(__r));1372 __state_->set_value(_VSTD::move(__r));
1476}1373}
14771374
1478#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1479
1480template <class _Rp>1375template <class _Rp>
1481void1376void
1482promise<_Rp>::set_exception(exception_ptr __p)1377promise<_Rp>::set_exception(exception_ptr __p)
...@@ -1496,8 +1391,6 @@ promise<_Rp>::set_value_at_thread_exit(const _Rp& __r)...@@ -1496,8 +1391,6 @@ promise<_Rp>::set_value_at_thread_exit(const _Rp& __r)
1496 __state_->set_value_at_thread_exit(__r);1391 __state_->set_value_at_thread_exit(__r);
1497}1392}
14981393
1499#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1500
1501template <class _Rp>1394template <class _Rp>
1502void1395void
1503promise<_Rp>::set_value_at_thread_exit(_Rp&& __r)1396promise<_Rp>::set_value_at_thread_exit(_Rp&& __r)
...@@ -1507,8 +1400,6 @@ promise<_Rp>::set_value_at_thread_exit(_Rp&& __r)...@@ -1507,8 +1400,6 @@ promise<_Rp>::set_value_at_thread_exit(_Rp&& __r)
1507 __state_->set_value_at_thread_exit(_VSTD::move(__r));1400 __state_->set_value_at_thread_exit(_VSTD::move(__r));
1508}1401}
15091402
1510#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1511
1512template <class _Rp>1403template <class _Rp>
1513void1404void
1514promise<_Rp>::set_exception_at_thread_exit(exception_ptr __p)1405promise<_Rp>::set_exception_at_thread_exit(exception_ptr __p)
...@@ -1535,32 +1426,21 @@ public:...@@ -1535,32 +1426,21 @@ public:
1535 promise();1426 promise();
1536 template <class _Allocator>1427 template <class _Allocator>
1537 promise(allocator_arg_t, const _Allocator& __a);1428 promise(allocator_arg_t, const _Allocator& __a);
1538#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1539 _LIBCPP_INLINE_VISIBILITY1429 _LIBCPP_INLINE_VISIBILITY
1540 promise(promise&& __rhs) _NOEXCEPT1430 promise(promise&& __rhs) _NOEXCEPT
1541 : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;}1431 : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;}
1542 promise(const promise& __rhs) = delete;1432 promise(const promise& __rhs) = delete;
1543#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1544private:
1545 promise(const promise& __rhs);
1546public:
1547#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1548 ~promise();1433 ~promise();
15491434
1550 // assignment1435 // assignment
1551#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1552 _LIBCPP_INLINE_VISIBILITY1436 _LIBCPP_INLINE_VISIBILITY
1553 promise& operator=(promise&& __rhs) _NOEXCEPT1437 promise& operator=(promise&& __rhs) _NOEXCEPT
1554 {1438 {
1555 promise(std::move(__rhs)).swap(*this);1439 promise(_VSTD::move(__rhs)).swap(*this);
1556 return *this;1440 return *this;
1557 }1441 }
1558 promise& operator=(const promise& __rhs) = delete;1442 promise& operator=(const promise& __rhs) = delete;
1559#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES1443
1560private:
1561 promise& operator=(const promise& __rhs);
1562public:
1563#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1564 _LIBCPP_INLINE_VISIBILITY1444 _LIBCPP_INLINE_VISIBILITY
1565 void swap(promise& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);}1445 void swap(promise& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);}
15661446
...@@ -1591,7 +1471,7 @@ promise<_Rp&>::promise(allocator_arg_t, const _Alloc& __a0)...@@ -1591,7 +1471,7 @@ promise<_Rp&>::promise(allocator_arg_t, const _Alloc& __a0)
1591 typedef __allocator_destructor<_A2> _D2;1471 typedef __allocator_destructor<_A2> _D2;
1592 _A2 __a(__a0);1472 _A2 __a(__a0);
1593 unique_ptr<_State, _D2> __hold(__a.allocate(1), _D2(__a, 1));1473 unique_ptr<_State, _D2> __hold(__a.allocate(1), _D2(__a, 1));
1594 ::new(static_cast<void*>(_VSTD::addressof(*__hold.get()))) _State(__a0);1474 ::new ((void*)_VSTD::addressof(*__hold.get())) _State(__a0);
1595 __state_ = _VSTD::addressof(*__hold.release());1475 __state_ = _VSTD::addressof(*__hold.release());
1596}1476}
15971477
...@@ -1672,32 +1552,21 @@ public:...@@ -1672,32 +1552,21 @@ public:
1672 template <class _Allocator>1552 template <class _Allocator>
1673 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1553 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1674 promise(allocator_arg_t, const _Allocator& __a);1554 promise(allocator_arg_t, const _Allocator& __a);
1675#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1676 _LIBCPP_INLINE_VISIBILITY1555 _LIBCPP_INLINE_VISIBILITY
1677 promise(promise&& __rhs) _NOEXCEPT1556 promise(promise&& __rhs) _NOEXCEPT
1678 : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;}1557 : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;}
1679 promise(const promise& __rhs) = delete;1558 promise(const promise& __rhs) = delete;
1680#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1681private:
1682 promise(const promise& __rhs);
1683public:
1684#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1685 ~promise();1559 ~promise();
16861560
1687 // assignment1561 // assignment
1688#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1689 _LIBCPP_INLINE_VISIBILITY1562 _LIBCPP_INLINE_VISIBILITY
1690 promise& operator=(promise&& __rhs) _NOEXCEPT1563 promise& operator=(promise&& __rhs) _NOEXCEPT
1691 {1564 {
1692 promise(std::move(__rhs)).swap(*this);1565 promise(_VSTD::move(__rhs)).swap(*this);
1693 return *this;1566 return *this;
1694 }1567 }
1695 promise& operator=(const promise& __rhs) = delete;1568 promise& operator=(const promise& __rhs) = delete;
1696#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES1569
1697private:
1698 promise& operator=(const promise& __rhs);
1699public:
1700#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1701 _LIBCPP_INLINE_VISIBILITY1570 _LIBCPP_INLINE_VISIBILITY
1702 void swap(promise& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);}1571 void swap(promise& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);}
17031572
...@@ -1721,7 +1590,7 @@ promise<void>::promise(allocator_arg_t, const _Alloc& __a0)...@@ -1721,7 +1590,7 @@ promise<void>::promise(allocator_arg_t, const _Alloc& __a0)
1721 typedef __allocator_destructor<_A2> _D2;1590 typedef __allocator_destructor<_A2> _D2;
1722 _A2 __a(__a0);1591 _A2 __a(__a0);
1723 unique_ptr<_State, _D2> __hold(__a.allocate(1), _D2(__a, 1));1592 unique_ptr<_State, _D2> __hold(__a.allocate(1), _D2(__a, 1));
1724 ::new(static_cast<void*>(_VSTD::addressof(*__hold.get()))) _State(__a0);1593 ::new ((void*)_VSTD::addressof(*__hold.get())) _State(__a0);
1725 __state_ = _VSTD::addressof(*__hold.release());1594 __state_ = _VSTD::addressof(*__hold.release());
1726}1595}
17271596
...@@ -1737,8 +1606,6 @@ template <class _Rp, class _Alloc>...@@ -1737,8 +1606,6 @@ template <class _Rp, class _Alloc>
1737 struct _LIBCPP_TEMPLATE_VIS uses_allocator<promise<_Rp>, _Alloc>1606 struct _LIBCPP_TEMPLATE_VIS uses_allocator<promise<_Rp>, _Alloc>
1738 : public true_type {};1607 : public true_type {};
17391608
1740#ifndef _LIBCPP_HAS_NO_VARIADICS
1741
1742// packaged_task1609// packaged_task
17431610
1744template<class _Fp> class __packaged_task_base;1611template<class _Fp> class __packaged_task_base;
...@@ -1788,7 +1655,7 @@ void...@@ -1788,7 +1655,7 @@ void
1788__packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__move_to(1655__packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__move_to(
1789 __packaged_task_base<_Rp(_ArgTypes...)>* __p) _NOEXCEPT1656 __packaged_task_base<_Rp(_ArgTypes...)>* __p) _NOEXCEPT
1790{1657{
1791 ::new (__p) __packaged_task_func(_VSTD::move(__f_.first()), _VSTD::move(__f_.second()));1658 ::new ((void*)__p) __packaged_task_func(_VSTD::move(__f_.first()), _VSTD::move(__f_.second()));
1792}1659}
17931660
1794template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>1661template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
...@@ -1823,6 +1690,10 @@ template<class _Rp, class ..._ArgTypes>...@@ -1823,6 +1690,10 @@ template<class _Rp, class ..._ArgTypes>
1823class _LIBCPP_AVAILABILITY_FUTURE __packaged_task_function<_Rp(_ArgTypes...)>1690class _LIBCPP_AVAILABILITY_FUTURE __packaged_task_function<_Rp(_ArgTypes...)>
1824{1691{
1825 typedef __packaged_task_base<_Rp(_ArgTypes...)> __base;1692 typedef __packaged_task_base<_Rp(_ArgTypes...)> __base;
1693
1694 _LIBCPP_INLINE_VISIBILITY _LIBCPP_NO_CFI
1695 __base* __get_buf() { return (__base*)&__buf_; }
1696
1826 typename aligned_storage<3*sizeof(void*)>::type __buf_;1697 typename aligned_storage<3*sizeof(void*)>::type __buf_;
1827 __base* __f_;1698 __base* __f_;
18281699
...@@ -1856,10 +1727,10 @@ __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(__packaged...@@ -1856,10 +1727,10 @@ __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(__packaged
1856{1727{
1857 if (__f.__f_ == nullptr)1728 if (__f.__f_ == nullptr)
1858 __f_ = nullptr;1729 __f_ = nullptr;
1859 else if (__f.__f_ == (__base*)&__f.__buf_)1730 else if (__f.__f_ == __f.__get_buf())
1860 {1731 {
1732 __f.__f_->__move_to(__get_buf());
1861 __f_ = (__base*)&__buf_;1733 __f_ = (__base*)&__buf_;
1862 __f.__f_->__move_to(__f_);
1863 }1734 }
1864 else1735 else
1865 {1736 {
...@@ -1877,8 +1748,8 @@ __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(_Fp&& __f)...@@ -1877,8 +1748,8 @@ __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(_Fp&& __f)
1877 typedef __packaged_task_func<_FR, allocator<_FR>, _Rp(_ArgTypes...)> _FF;1748 typedef __packaged_task_func<_FR, allocator<_FR>, _Rp(_ArgTypes...)> _FF;
1878 if (sizeof(_FF) <= sizeof(__buf_))1749 if (sizeof(_FF) <= sizeof(__buf_))
1879 {1750 {
1751 ::new ((void*)&__buf_) _FF(_VSTD::forward<_Fp>(__f));
1880 __f_ = (__base*)&__buf_;1752 __f_ = (__base*)&__buf_;
1881 ::new (__f_) _FF(_VSTD::forward<_Fp>(__f));
1882 }1753 }
1883 else1754 else
1884 {1755 {
...@@ -1886,7 +1757,7 @@ __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(_Fp&& __f)...@@ -1886,7 +1757,7 @@ __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(_Fp&& __f)
1886 _Ap __a;1757 _Ap __a;
1887 typedef __allocator_destructor<_Ap> _Dp;1758 typedef __allocator_destructor<_Ap> _Dp;
1888 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));1759 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1889 ::new (__hold.get()) _FF(_VSTD::forward<_Fp>(__f), allocator<_FR>(__a));1760 ::new ((void*)__hold.get()) _FF(_VSTD::forward<_Fp>(__f), allocator<_FR>(__a));
1890 __f_ = __hold.release();1761 __f_ = __hold.release();
1891 }1762 }
1892}1763}
...@@ -1902,7 +1773,7 @@ __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(...@@ -1902,7 +1773,7 @@ __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(
1902 if (sizeof(_FF) <= sizeof(__buf_))1773 if (sizeof(_FF) <= sizeof(__buf_))
1903 {1774 {
1904 __f_ = (__base*)&__buf_;1775 __f_ = (__base*)&__buf_;
1905 ::new (__f_) _FF(_VSTD::forward<_Fp>(__f));1776 ::new ((void*)__f_) _FF(_VSTD::forward<_Fp>(__f));
1906 }1777 }
1907 else1778 else
1908 {1779 {
...@@ -1910,7 +1781,7 @@ __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(...@@ -1910,7 +1781,7 @@ __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(
1910 _Ap __a(__a0);1781 _Ap __a(__a0);
1911 typedef __allocator_destructor<_Ap> _Dp;1782 typedef __allocator_destructor<_Ap> _Dp;
1912 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));1783 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1913 ::new (static_cast<void*>(_VSTD::addressof(*__hold.get())))1784 ::new ((void*)_VSTD::addressof(*__hold.get()))
1914 _FF(_VSTD::forward<_Fp>(__f), _Alloc(__a));1785 _FF(_VSTD::forward<_Fp>(__f), _Alloc(__a));
1915 __f_ = _VSTD::addressof(*__hold.release());1786 __f_ = _VSTD::addressof(*__hold.release());
1916 }1787 }
...@@ -1920,17 +1791,17 @@ template<class _Rp, class ..._ArgTypes>...@@ -1920,17 +1791,17 @@ template<class _Rp, class ..._ArgTypes>
1920__packaged_task_function<_Rp(_ArgTypes...)>&1791__packaged_task_function<_Rp(_ArgTypes...)>&
1921__packaged_task_function<_Rp(_ArgTypes...)>::operator=(__packaged_task_function&& __f) _NOEXCEPT1792__packaged_task_function<_Rp(_ArgTypes...)>::operator=(__packaged_task_function&& __f) _NOEXCEPT
1922{1793{
1923 if (__f_ == (__base*)&__buf_)1794 if (__f_ == __get_buf())
1924 __f_->destroy();1795 __f_->destroy();
1925 else if (__f_)1796 else if (__f_)
1926 __f_->destroy_deallocate();1797 __f_->destroy_deallocate();
1927 __f_ = nullptr;1798 __f_ = nullptr;
1928 if (__f.__f_ == nullptr)1799 if (__f.__f_ == nullptr)
1929 __f_ = nullptr;1800 __f_ = nullptr;
1930 else if (__f.__f_ == (__base*)&__f.__buf_)1801 else if (__f.__f_ == __f.__get_buf())
1931 {1802 {
1932 __f_ = (__base*)&__buf_;1803 __f.__f_->__move_to(__get_buf());
1933 __f.__f_->__move_to(__f_);1804 __f_ = __get_buf();
1934 }1805 }
1935 else1806 else
1936 {1807 {
...@@ -1943,13 +1814,14 @@ __packaged_task_function<_Rp(_ArgTypes...)>::operator=(__packaged_task_function&...@@ -1943,13 +1814,14 @@ __packaged_task_function<_Rp(_ArgTypes...)>::operator=(__packaged_task_function&
1943template<class _Rp, class ..._ArgTypes>1814template<class _Rp, class ..._ArgTypes>
1944__packaged_task_function<_Rp(_ArgTypes...)>::~__packaged_task_function()1815__packaged_task_function<_Rp(_ArgTypes...)>::~__packaged_task_function()
1945{1816{
1946 if (__f_ == (__base*)&__buf_)1817 if (__f_ == __get_buf())
1947 __f_->destroy();1818 __f_->destroy();
1948 else if (__f_)1819 else if (__f_)
1949 __f_->destroy_deallocate();1820 __f_->destroy_deallocate();
1950}1821}
19511822
1952template<class _Rp, class ..._ArgTypes>1823template<class _Rp, class ..._ArgTypes>
1824_LIBCPP_NO_CFI
1953void1825void
1954__packaged_task_function<_Rp(_ArgTypes...)>::swap(__packaged_task_function& __f) _NOEXCEPT1826__packaged_task_function<_Rp(_ArgTypes...)>::swap(__packaged_task_function& __f) _NOEXCEPT
1955{1827{
...@@ -2268,11 +2140,7 @@ struct _LIBCPP_TEMPLATE_VIS uses_allocator<packaged_task<_Callable>, _Alloc>...@@ -2268,11 +2140,7 @@ struct _LIBCPP_TEMPLATE_VIS uses_allocator<packaged_task<_Callable>, _Alloc>
22682140
2269template <class _Rp, class _Fp>2141template <class _Rp, class _Fp>
2270_LIBCPP_INLINE_VISIBILITY future<_Rp>2142_LIBCPP_INLINE_VISIBILITY future<_Rp>
2271#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2272__make_deferred_assoc_state(_Fp&& __f)2143__make_deferred_assoc_state(_Fp&& __f)
2273#else
2274__make_deferred_assoc_state(_Fp __f)
2275#endif
2276{2144{
2277 unique_ptr<__deferred_assoc_state<_Rp, _Fp>, __release_shared_count>2145 unique_ptr<__deferred_assoc_state<_Rp, _Fp>, __release_shared_count>
2278 __h(new __deferred_assoc_state<_Rp, _Fp>(_VSTD::forward<_Fp>(__f)));2146 __h(new __deferred_assoc_state<_Rp, _Fp>(_VSTD::forward<_Fp>(__f)));
...@@ -2281,11 +2149,7 @@ __make_deferred_assoc_state(_Fp __f)...@@ -2281,11 +2149,7 @@ __make_deferred_assoc_state(_Fp __f)
22812149
2282template <class _Rp, class _Fp>2150template <class _Rp, class _Fp>
2283_LIBCPP_INLINE_VISIBILITY future<_Rp>2151_LIBCPP_INLINE_VISIBILITY future<_Rp>
2284#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2285__make_async_assoc_state(_Fp&& __f)2152__make_async_assoc_state(_Fp&& __f)
2286#else
2287__make_async_assoc_state(_Fp __f)
2288#endif
2289{2153{
2290 unique_ptr<__async_assoc_state<_Rp, _Fp>, __release_shared_count>2154 unique_ptr<__async_assoc_state<_Rp, _Fp>, __release_shared_count>
2291 __h(new __async_assoc_state<_Rp, _Fp>(_VSTD::forward<_Fp>(__f)));2155 __h(new __async_assoc_state<_Rp, _Fp>(_VSTD::forward<_Fp>(__f)));
...@@ -2293,6 +2157,8 @@ __make_async_assoc_state(_Fp __f)...@@ -2293,6 +2157,8 @@ __make_async_assoc_state(_Fp __f)
2293 return future<_Rp>(__h.get());2157 return future<_Rp>(__h.get());
2294}2158}
22952159
2160#ifndef _LIBCPP_CXX03_LANG
2161
2296template <class _Fp, class... _Args>2162template <class _Fp, class... _Args>
2297class _LIBCPP_HIDDEN __async_func2163class _LIBCPP_HIDDEN __async_func
2298{2164{
...@@ -2360,7 +2226,7 @@ async(_Fp&& __f, _Args&&... __args)...@@ -2360,7 +2226,7 @@ async(_Fp&& __f, _Args&&... __args)
2360 _VSTD::forward<_Args>(__args)...);2226 _VSTD::forward<_Args>(__args)...);
2361}2227}
23622228
2363#endif // _LIBCPP_HAS_NO_VARIADICS2229#endif // C++03
23642230
2365// shared_future2231// shared_future
23662232
...@@ -2375,24 +2241,20 @@ public:...@@ -2375,24 +2241,20 @@ public:
2375 _LIBCPP_INLINE_VISIBILITY2241 _LIBCPP_INLINE_VISIBILITY
2376 shared_future(const shared_future& __rhs) _NOEXCEPT : __state_(__rhs.__state_)2242 shared_future(const shared_future& __rhs) _NOEXCEPT : __state_(__rhs.__state_)
2377 {if (__state_) __state_->__add_shared();}2243 {if (__state_) __state_->__add_shared();}
2378#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2379 _LIBCPP_INLINE_VISIBILITY2244 _LIBCPP_INLINE_VISIBILITY
2380 shared_future(future<_Rp>&& __f) _NOEXCEPT : __state_(__f.__state_)2245 shared_future(future<_Rp>&& __f) _NOEXCEPT : __state_(__f.__state_)
2381 {__f.__state_ = nullptr;}2246 {__f.__state_ = nullptr;}
2382 _LIBCPP_INLINE_VISIBILITY2247 _LIBCPP_INLINE_VISIBILITY
2383 shared_future(shared_future&& __rhs) _NOEXCEPT : __state_(__rhs.__state_)2248 shared_future(shared_future&& __rhs) _NOEXCEPT : __state_(__rhs.__state_)
2384 {__rhs.__state_ = nullptr;}2249 {__rhs.__state_ = nullptr;}
2385#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2386 ~shared_future();2250 ~shared_future();
2387 shared_future& operator=(const shared_future& __rhs) _NOEXCEPT;2251 shared_future& operator=(const shared_future& __rhs) _NOEXCEPT;
2388#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2389 _LIBCPP_INLINE_VISIBILITY2252 _LIBCPP_INLINE_VISIBILITY
2390 shared_future& operator=(shared_future&& __rhs) _NOEXCEPT2253 shared_future& operator=(shared_future&& __rhs) _NOEXCEPT
2391 {2254 {
2392 shared_future(std::move(__rhs)).swap(*this);2255 shared_future(_VSTD::move(__rhs)).swap(*this);
2393 return *this;2256 return *this;
2394 }2257 }
2395#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
23962258
2397 // retrieving the value2259 // retrieving the value
2398 _LIBCPP_INLINE_VISIBILITY2260 _LIBCPP_INLINE_VISIBILITY
...@@ -2449,24 +2311,20 @@ public:...@@ -2449,24 +2311,20 @@ public:
2449 _LIBCPP_INLINE_VISIBILITY2311 _LIBCPP_INLINE_VISIBILITY
2450 shared_future(const shared_future& __rhs) : __state_(__rhs.__state_)2312 shared_future(const shared_future& __rhs) : __state_(__rhs.__state_)
2451 {if (__state_) __state_->__add_shared();}2313 {if (__state_) __state_->__add_shared();}
2452#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2453 _LIBCPP_INLINE_VISIBILITY2314 _LIBCPP_INLINE_VISIBILITY
2454 shared_future(future<_Rp&>&& __f) _NOEXCEPT : __state_(__f.__state_)2315 shared_future(future<_Rp&>&& __f) _NOEXCEPT : __state_(__f.__state_)
2455 {__f.__state_ = nullptr;}2316 {__f.__state_ = nullptr;}
2456 _LIBCPP_INLINE_VISIBILITY2317 _LIBCPP_INLINE_VISIBILITY
2457 shared_future(shared_future&& __rhs) _NOEXCEPT : __state_(__rhs.__state_)2318 shared_future(shared_future&& __rhs) _NOEXCEPT : __state_(__rhs.__state_)
2458 {__rhs.__state_ = nullptr;}2319 {__rhs.__state_ = nullptr;}
2459#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2460 ~shared_future();2320 ~shared_future();
2461 shared_future& operator=(const shared_future& __rhs);2321 shared_future& operator=(const shared_future& __rhs);
2462#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2463 _LIBCPP_INLINE_VISIBILITY2322 _LIBCPP_INLINE_VISIBILITY
2464 shared_future& operator=(shared_future&& __rhs) _NOEXCEPT2323 shared_future& operator=(shared_future&& __rhs) _NOEXCEPT
2465 {2324 {
2466 shared_future(std::move(__rhs)).swap(*this);2325 shared_future(_VSTD::move(__rhs)).swap(*this);
2467 return *this;2326 return *this;
2468 }2327 }
2469#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
24702328
2471 // retrieving the value2329 // retrieving the value
2472 _LIBCPP_INLINE_VISIBILITY2330 _LIBCPP_INLINE_VISIBILITY
...@@ -2523,24 +2381,20 @@ public:...@@ -2523,24 +2381,20 @@ public:
2523 _LIBCPP_INLINE_VISIBILITY2381 _LIBCPP_INLINE_VISIBILITY
2524 shared_future(const shared_future& __rhs) : __state_(__rhs.__state_)2382 shared_future(const shared_future& __rhs) : __state_(__rhs.__state_)
2525 {if (__state_) __state_->__add_shared();}2383 {if (__state_) __state_->__add_shared();}
2526#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2527 _LIBCPP_INLINE_VISIBILITY2384 _LIBCPP_INLINE_VISIBILITY
2528 shared_future(future<void>&& __f) _NOEXCEPT : __state_(__f.__state_)2385 shared_future(future<void>&& __f) _NOEXCEPT : __state_(__f.__state_)
2529 {__f.__state_ = nullptr;}2386 {__f.__state_ = nullptr;}
2530 _LIBCPP_INLINE_VISIBILITY2387 _LIBCPP_INLINE_VISIBILITY
2531 shared_future(shared_future&& __rhs) _NOEXCEPT : __state_(__rhs.__state_)2388 shared_future(shared_future&& __rhs) _NOEXCEPT : __state_(__rhs.__state_)
2532 {__rhs.__state_ = nullptr;}2389 {__rhs.__state_ = nullptr;}
2533#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2534 ~shared_future();2390 ~shared_future();
2535 shared_future& operator=(const shared_future& __rhs);2391 shared_future& operator=(const shared_future& __rhs);
2536#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2537 _LIBCPP_INLINE_VISIBILITY2392 _LIBCPP_INLINE_VISIBILITY
2538 shared_future& operator=(shared_future&& __rhs) _NOEXCEPT2393 shared_future& operator=(shared_future&& __rhs) _NOEXCEPT
2539 {2394 {
2540 shared_future(std::move(__rhs)).swap(*this);2395 shared_future(_VSTD::move(__rhs)).swap(*this);
2541 return *this;2396 return *this;
2542 }2397 }
2543#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
25442398
2545 // retrieving the value2399 // retrieving the value
2546 _LIBCPP_INLINE_VISIBILITY2400 _LIBCPP_INLINE_VISIBILITY
...@@ -2591,8 +2445,6 @@ future<_Rp&>::share() _NOEXCEPT...@@ -2591,8 +2445,6 @@ future<_Rp&>::share() _NOEXCEPT
2591 return shared_future<_Rp&>(_VSTD::move(*this));2445 return shared_future<_Rp&>(_VSTD::move(*this));
2592}2446}
25932447
2594#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2595
2596inline2448inline
2597shared_future<void>2449shared_future<void>
2598future<void>::share() _NOEXCEPT2450future<void>::share() _NOEXCEPT
...@@ -2600,8 +2452,6 @@ future<void>::share() _NOEXCEPT...@@ -2600,8 +2452,6 @@ future<void>::share() _NOEXCEPT
2600 return shared_future<void>(_VSTD::move(*this));2452 return shared_future<void>(_VSTD::move(*this));
2601}2453}
26022454
2603#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2604
2605_LIBCPP_END_NAMESPACE_STD2455_LIBCPP_END_NAMESPACE_STD
26062456
2607#endif // !_LIBCPP_HAS_NO_THREADS2457#endif // !_LIBCPP_HAS_NO_THREADS
lib/libcxx/include/iomanip+1-1
...@@ -514,7 +514,7 @@ put_time(const tm* __tm, const _CharT* __fmt)...@@ -514,7 +514,7 @@ put_time(const tm* __tm, const _CharT* __fmt)
514}514}
515515
516template <class _CharT, class _Traits, class _ForwardIterator>516template <class _CharT, class _Traits, class _ForwardIterator>
517std::basic_ostream<_CharT, _Traits> &517basic_ostream<_CharT, _Traits> &
518__quoted_output ( basic_ostream<_CharT, _Traits> &__os,518__quoted_output ( basic_ostream<_CharT, _Traits> &__os,
519 _ForwardIterator __first, _ForwardIterator __last, _CharT __delim, _CharT __escape )519 _ForwardIterator __first, _ForwardIterator __last, _CharT __delim, _CharT __escape )
520{520{
lib/libcxx/include/ios+2-29
...@@ -710,7 +710,7 @@ void...@@ -710,7 +710,7 @@ void
710basic_ios<_CharT, _Traits>::init(basic_streambuf<char_type, traits_type>* __sb)710basic_ios<_CharT, _Traits>::init(basic_streambuf<char_type, traits_type>* __sb)
711{711{
712 ios_base::init(__sb);712 ios_base::init(__sb);
713 __tie_ = 0;713 __tie_ = nullptr;
714 __fill_ = traits_type::eof();714 __fill_ = traits_type::eof();
715}715}
716716
...@@ -821,7 +821,7 @@ basic_ios<_CharT, _Traits>::move(basic_ios& __rhs)...@@ -821,7 +821,7 @@ basic_ios<_CharT, _Traits>::move(basic_ios& __rhs)
821{821{
822 ios_base::move(__rhs);822 ios_base::move(__rhs);
823 __tie_ = __rhs.__tie_;823 __tie_ = __rhs.__tie_;
824 __rhs.__tie_ = 0;824 __rhs.__tie_ = nullptr;
825 __fill_ = __rhs.__fill_;825 __fill_ = __rhs.__fill_;
826}826}
827827
...@@ -1035,33 +1035,6 @@ defaultfloat(ios_base& __str)...@@ -1035,33 +1035,6 @@ defaultfloat(ios_base& __str)
1035 return __str;1035 return __str;
1036}1036}
10371037
1038template <class _CharT, class _Traits>
1039class __save_flags
1040{
1041 typedef basic_ios<_CharT, _Traits> __stream_type;
1042 typedef typename __stream_type::fmtflags fmtflags;
1043
1044 __stream_type& __stream_;
1045 fmtflags __fmtflags_;
1046 _CharT __fill_;
1047
1048 __save_flags(const __save_flags&);
1049 __save_flags& operator=(const __save_flags&);
1050public:
1051 _LIBCPP_INLINE_VISIBILITY
1052 explicit __save_flags(__stream_type& __stream)
1053 : __stream_(__stream),
1054 __fmtflags_(__stream.flags()),
1055 __fill_(__stream.fill())
1056 {}
1057 _LIBCPP_INLINE_VISIBILITY
1058 ~__save_flags()
1059 {
1060 __stream_.flags(__fmtflags_);
1061 __stream_.fill(__fill_);
1062 }
1063};
1064
1065_LIBCPP_END_NAMESPACE_STD1038_LIBCPP_END_NAMESPACE_STD
10661039
1067#endif // _LIBCPP_IOS1040#endif // _LIBCPP_IOS
lib/libcxx/include/iosfwd+59
...@@ -185,6 +185,36 @@ typedef basic_ifstream<wchar_t> wifstream;...@@ -185,6 +185,36 @@ typedef basic_ifstream<wchar_t> wifstream;
185typedef basic_ofstream<wchar_t> wofstream;185typedef basic_ofstream<wchar_t> wofstream;
186typedef basic_fstream<wchar_t> wfstream;186typedef basic_fstream<wchar_t> wfstream;
187187
188template <class _CharT, class _Traits>
189 class _LIBCPP_PREFERRED_NAME(ios) _LIBCPP_PREFERRED_NAME(wios) basic_ios;
190
191template <class _CharT, class _Traits>
192 class _LIBCPP_PREFERRED_NAME(streambuf) _LIBCPP_PREFERRED_NAME(wstreambuf) basic_streambuf;
193template <class _CharT, class _Traits>
194 class _LIBCPP_PREFERRED_NAME(istream) _LIBCPP_PREFERRED_NAME(wistream) basic_istream;
195template <class _CharT, class _Traits>
196 class _LIBCPP_PREFERRED_NAME(ostream) _LIBCPP_PREFERRED_NAME(wostream) basic_ostream;
197template <class _CharT, class _Traits>
198 class _LIBCPP_PREFERRED_NAME(iostream) _LIBCPP_PREFERRED_NAME(wiostream) basic_iostream;
199
200template <class _CharT, class _Traits, class _Allocator>
201 class _LIBCPP_PREFERRED_NAME(stringbuf) _LIBCPP_PREFERRED_NAME(wstringbuf) basic_stringbuf;
202template <class _CharT, class _Traits, class _Allocator>
203 class _LIBCPP_PREFERRED_NAME(istringstream) _LIBCPP_PREFERRED_NAME(wistringstream) basic_istringstream;
204template <class _CharT, class _Traits, class _Allocator>
205 class _LIBCPP_PREFERRED_NAME(ostringstream) _LIBCPP_PREFERRED_NAME(wostringstream) basic_ostringstream;
206template <class _CharT, class _Traits, class _Allocator>
207 class _LIBCPP_PREFERRED_NAME(stringstream) _LIBCPP_PREFERRED_NAME(wstringstream) basic_stringstream;
208
209template <class _CharT, class _Traits>
210 class _LIBCPP_PREFERRED_NAME(filebuf) _LIBCPP_PREFERRED_NAME(wfilebuf) basic_filebuf;
211template <class _CharT, class _Traits>
212 class _LIBCPP_PREFERRED_NAME(ifstream) _LIBCPP_PREFERRED_NAME(wifstream) basic_ifstream;
213template <class _CharT, class _Traits>
214 class _LIBCPP_PREFERRED_NAME(ofstream) _LIBCPP_PREFERRED_NAME(wofstream) basic_ofstream;
215template <class _CharT, class _Traits>
216 class _LIBCPP_PREFERRED_NAME(fstream) _LIBCPP_PREFERRED_NAME(wfstream) basic_fstream;
217
188template <class _State> class _LIBCPP_TEMPLATE_VIS fpos;218template <class _State> class _LIBCPP_TEMPLATE_VIS fpos;
189typedef fpos<mbstate_t> streampos;219typedef fpos<mbstate_t> streampos;
190typedef fpos<mbstate_t> wstreampos;220typedef fpos<mbstate_t> wstreampos;
...@@ -210,11 +240,40 @@ template <class _CharT, // for <stdexcept>...@@ -210,11 +240,40 @@ template <class _CharT, // for <stdexcept>
210typedef basic_string<char, char_traits<char>, allocator<char> > string;240typedef basic_string<char, char_traits<char>, allocator<char> > string;
211typedef basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wstring;241typedef basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wstring;
212242
243template <class _CharT, class _Traits, class _Allocator>
244 class _LIBCPP_PREFERRED_NAME(string) _LIBCPP_PREFERRED_NAME(wstring) basic_string;
213245
214// Include other forward declarations here246// Include other forward declarations here
215template <class _Tp, class _Alloc = allocator<_Tp> >247template <class _Tp, class _Alloc = allocator<_Tp> >
216class _LIBCPP_TEMPLATE_VIS vector;248class _LIBCPP_TEMPLATE_VIS vector;
217249
250template <class _CharT, class _Traits>
251class __save_flags
252{
253 typedef basic_ios<_CharT, _Traits> __stream_type;
254 typedef typename __stream_type::fmtflags fmtflags;
255
256 __stream_type& __stream_;
257 fmtflags __fmtflags_;
258 _CharT __fill_;
259
260 __save_flags(const __save_flags&);
261 __save_flags& operator=(const __save_flags&);
262public:
263 _LIBCPP_INLINE_VISIBILITY
264 explicit __save_flags(__stream_type& __stream)
265 : __stream_(__stream),
266 __fmtflags_(__stream.flags()),
267 __fill_(__stream.fill())
268 {}
269 _LIBCPP_INLINE_VISIBILITY
270 ~__save_flags()
271 {
272 __stream_.flags(__fmtflags_);
273 __stream_.fill(__fill_);
274 }
275};
276
218_LIBCPP_END_NAMESPACE_STD277_LIBCPP_END_NAMESPACE_STD
219278
220#endif // _LIBCPP_IOSFWD279#endif // _LIBCPP_IOSFWD
lib/libcxx/include/istream+21-13
...@@ -150,9 +150,9 @@ template <class charT, class traits>...@@ -150,9 +150,9 @@ template <class charT, class traits>
150 basic_istream<charT,traits>&150 basic_istream<charT,traits>&
151 ws(basic_istream<charT,traits>& is);151 ws(basic_istream<charT,traits>& is);
152152
153template <class charT, class traits, class T>153// rvalue stream extraction
154 basic_istream<charT, traits>&154template <class Stream, class T>
155 operator>>(basic_istream<charT, traits>&& is, T& x);155 Stream&& operator>>(Stream&& is, T&& x);
156156
157} // std157} // std
158158
...@@ -1142,7 +1142,7 @@ basic_istream<_CharT, _Traits>::putback(char_type __c)...@@ -1142,7 +1142,7 @@ basic_istream<_CharT, _Traits>::putback(char_type __c)
1142 try1142 try
1143 {1143 {
1144#endif // _LIBCPP_NO_EXCEPTIONS1144#endif // _LIBCPP_NO_EXCEPTIONS
1145 if (this->rdbuf() == 0 || this->rdbuf()->sputbackc(__c) == traits_type::eof())1145 if (this->rdbuf() == nullptr || this->rdbuf()->sputbackc(__c) == traits_type::eof())
1146 __state |= ios_base::badbit;1146 __state |= ios_base::badbit;
1147#ifndef _LIBCPP_NO_EXCEPTIONS1147#ifndef _LIBCPP_NO_EXCEPTIONS
1148 }1148 }
...@@ -1179,7 +1179,7 @@ basic_istream<_CharT, _Traits>::unget()...@@ -1179,7 +1179,7 @@ basic_istream<_CharT, _Traits>::unget()
1179 try1179 try
1180 {1180 {
1181#endif // _LIBCPP_NO_EXCEPTIONS1181#endif // _LIBCPP_NO_EXCEPTIONS
1182 if (this->rdbuf() == 0 || this->rdbuf()->sungetc() == traits_type::eof())1182 if (this->rdbuf() == nullptr || this->rdbuf()->sungetc() == traits_type::eof())
1183 __state |= ios_base::badbit;1183 __state |= ios_base::badbit;
1184#ifndef _LIBCPP_NO_EXCEPTIONS1184#ifndef _LIBCPP_NO_EXCEPTIONS
1185 }1185 }
...@@ -1215,7 +1215,7 @@ basic_istream<_CharT, _Traits>::sync()...@@ -1215,7 +1215,7 @@ basic_istream<_CharT, _Traits>::sync()
1215 try1215 try
1216 {1216 {
1217#endif // _LIBCPP_NO_EXCEPTIONS1217#endif // _LIBCPP_NO_EXCEPTIONS
1218 if (this->rdbuf() == 0)1218 if (this->rdbuf() == nullptr)
1219 return -1;1219 return -1;
1220 if (this->rdbuf()->pubsync() == -1)1220 if (this->rdbuf()->pubsync() == -1)
1221 {1221 {
...@@ -1378,13 +1378,23 @@ ws(basic_istream<_CharT, _Traits>& __is)...@@ -1378,13 +1378,23 @@ ws(basic_istream<_CharT, _Traits>& __is)
13781378
1379#ifndef _LIBCPP_CXX03_LANG1379#ifndef _LIBCPP_CXX03_LANG
13801380
1381template <class _CharT, class _Traits, class _Tp>1381template <class _Stream, class _Tp, class = void>
1382inline _LIBCPP_INLINE_VISIBILITY1382struct __is_istreamable : false_type { };
1383basic_istream<_CharT, _Traits>&1383
1384operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp&& __x)1384template <class _Stream, class _Tp>
1385struct __is_istreamable<_Stream, _Tp, decltype(
1386 _VSTD::declval<_Stream>() >> _VSTD::declval<_Tp>(), void()
1387)> : true_type { };
1388
1389template <class _Stream, class _Tp, class = typename enable_if<
1390 _And<is_base_of<ios_base, _Stream>,
1391 __is_istreamable<_Stream&, _Tp&&>>::value
1392>::type>
1393_LIBCPP_INLINE_VISIBILITY
1394_Stream&& operator>>(_Stream&& __is, _Tp&& __x)
1385{1395{
1386 __is >> _VSTD::forward<_Tp>(__x);1396 __is >> _VSTD::forward<_Tp>(__x);
1387 return __is;1397 return _VSTD::move(__is);
1388}1398}
13891399
1390#endif // _LIBCPP_CXX03_LANG1400#endif // _LIBCPP_CXX03_LANG
...@@ -1638,11 +1648,9 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)...@@ -1638,11 +1648,9 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)
1638 return __is;1648 return __is;
1639}1649}
16401650
1641#ifndef _LIBCPP_DO_NOT_ASSUME_STREAMS_EXPLICIT_INSTANTIATION_IN_DYLIB
1642_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<char>)1651_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<char>)
1643_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<wchar_t>)1652_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<wchar_t>)
1644_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_iostream<char>)1653_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_iostream<char>)
1645#endif
16461654
1647_LIBCPP_END_NAMESPACE_STD1655_LIBCPP_END_NAMESPACE_STD
16481656
lib/libcxx/include/iterator+69-52
...@@ -420,10 +420,8 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept;...@@ -420,10 +420,8 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept;
420#include <type_traits>420#include <type_traits>
421#include <cstddef>421#include <cstddef>
422#include <initializer_list>422#include <initializer_list>
423#include <__memory/base.h>
423#include <version>424#include <version>
424#ifdef __APPLE__
425#include <Availability.h>
426#endif
427425
428#include <__debug>426#include <__debug>
429427
...@@ -498,12 +496,11 @@ struct __has_iterator_typedefs...@@ -498,12 +496,11 @@ struct __has_iterator_typedefs
498private:496private:
499 struct __two {char __lx; char __lxx;};497 struct __two {char __lx; char __lxx;};
500 template <class _Up> static __two __test(...);498 template <class _Up> static __two __test(...);
501 template <class _Up> static char __test(typename std::__void_t<typename _Up::iterator_category>::type* = 0,499 template <class _Up> static char __test(typename __void_t<typename _Up::iterator_category>::type* = 0,
502 typename std::__void_t<typename _Up::difference_type>::type* = 0,500 typename __void_t<typename _Up::difference_type>::type* = 0,
503 typename std::__void_t<typename _Up::value_type>::type* = 0,501 typename __void_t<typename _Up::value_type>::type* = 0,
504 typename std::__void_t<typename _Up::reference>::type* = 0,502 typename __void_t<typename _Up::reference>::type* = 0,
505 typename std::__void_t<typename _Up::pointer>::type* = 0503 typename __void_t<typename _Up::pointer>::type* = 0);
506 );
507public:504public:
508 static const bool value = sizeof(__test<_Tp>(0,0,0,0,0)) == 1;505 static const bool value = sizeof(__test<_Tp>(0,0,0,0,0)) == 1;
509};506};
...@@ -515,9 +512,9 @@ struct __has_iterator_category...@@ -515,9 +512,9 @@ struct __has_iterator_category
515private:512private:
516 struct __two {char __lx; char __lxx;};513 struct __two {char __lx; char __lxx;};
517 template <class _Up> static __two __test(...);514 template <class _Up> static __two __test(...);
518 template <class _Up> static char __test(typename _Up::iterator_category* = 0);515 template <class _Up> static char __test(typename _Up::iterator_category* = nullptr);
519public:516public:
520 static const bool value = sizeof(__test<_Tp>(0)) == 1;517 static const bool value = sizeof(__test<_Tp>(nullptr)) == 1;
521};518};
522519
523template <class _Iter, bool> struct __iterator_traits_impl {};520template <class _Iter, bool> struct __iterator_traits_impl {};
...@@ -667,9 +664,9 @@ void advance(_InputIter& __i, _Distance __orig_n)...@@ -667,9 +664,9 @@ void advance(_InputIter& __i, _Distance __orig_n)
667{664{
668 _LIBCPP_ASSERT(__orig_n >= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value,665 _LIBCPP_ASSERT(__orig_n >= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value,
669 "Attempt to advance(it, n) with negative n on a non-bidirectional iterator");666 "Attempt to advance(it, n) with negative n on a non-bidirectional iterator");
670 typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize;667 typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
671 _IntegralSize __n = __orig_n;668 _IntegralSize __n = __orig_n;
672 __advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category());669 _VSTD::__advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category());
673}670}
674671
675template <class _InputIter>672template <class _InputIter>
...@@ -696,7 +693,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14...@@ -696,7 +693,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
696typename iterator_traits<_InputIter>::difference_type693typename iterator_traits<_InputIter>::difference_type
697distance(_InputIter __first, _InputIter __last)694distance(_InputIter __first, _InputIter __last)
698{695{
699 return __distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category());696 return _VSTD::__distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category());
700}697}
701698
702template <class _InputIter>699template <class _InputIter>
...@@ -998,11 +995,11 @@ private:...@@ -998,11 +995,11 @@ private:
998 istream_type* __in_stream_;995 istream_type* __in_stream_;
999 _Tp __value_;996 _Tp __value_;
1000public:997public:
1001 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istream_iterator() : __in_stream_(0), __value_() {}998 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istream_iterator() : __in_stream_(nullptr), __value_() {}
1002 _LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) : __in_stream_(_VSTD::addressof(__s))999 _LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) : __in_stream_(_VSTD::addressof(__s))
1003 {1000 {
1004 if (!(*__in_stream_ >> __value_))1001 if (!(*__in_stream_ >> __value_))
1005 __in_stream_ = 0;1002 __in_stream_ = nullptr;
1006 }1003 }
10071004
1008 _LIBCPP_INLINE_VISIBILITY const _Tp& operator*() const {return __value_;}1005 _LIBCPP_INLINE_VISIBILITY const _Tp& operator*() const {return __value_;}
...@@ -1010,7 +1007,7 @@ public:...@@ -1010,7 +1007,7 @@ public:
1010 _LIBCPP_INLINE_VISIBILITY istream_iterator& operator++()1007 _LIBCPP_INLINE_VISIBILITY istream_iterator& operator++()
1011 {1008 {
1012 if (!(*__in_stream_ >> __value_))1009 if (!(*__in_stream_ >> __value_))
1013 __in_stream_ = 0;1010 __in_stream_ = nullptr;
1014 return *this;1011 return *this;
1015 }1012 }
1016 _LIBCPP_INLINE_VISIBILITY istream_iterator operator++(int)1013 _LIBCPP_INLINE_VISIBILITY istream_iterator operator++(int)
...@@ -1052,15 +1049,25 @@ class _LIBCPP_TEMPLATE_VIS ostream_iterator...@@ -1052,15 +1049,25 @@ class _LIBCPP_TEMPLATE_VIS ostream_iterator
1052 : public iterator<output_iterator_tag, void, void, void, void>1049 : public iterator<output_iterator_tag, void, void, void, void>
1053{1050{
1054public:1051public:
1055 typedef _CharT char_type;1052 typedef output_iterator_tag iterator_category;
1056 typedef _Traits traits_type;1053 typedef void value_type;
1057 typedef basic_ostream<_CharT,_Traits> ostream_type;1054#if _LIBCPP_STD_VER > 17
1055 typedef std::ptrdiff_t difference_type;
1056#else
1057 typedef void difference_type;
1058#endif
1059 typedef void pointer;
1060 typedef void reference;
1061 typedef _CharT char_type;
1062 typedef _Traits traits_type;
1063 typedef basic_ostream<_CharT, _Traits> ostream_type;
1064
1058private:1065private:
1059 ostream_type* __out_stream_;1066 ostream_type* __out_stream_;
1060 const char_type* __delim_;1067 const char_type* __delim_;
1061public:1068public:
1062 _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s) _NOEXCEPT1069 _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s) _NOEXCEPT
1063 : __out_stream_(_VSTD::addressof(__s)), __delim_(0) {}1070 : __out_stream_(_VSTD::addressof(__s)), __delim_(nullptr) {}
1064 _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s, const _CharT* __delimiter) _NOEXCEPT1071 _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s, const _CharT* __delimiter) _NOEXCEPT
1065 : __out_stream_(_VSTD::addressof(__s)), __delim_(__delimiter) {}1072 : __out_stream_(_VSTD::addressof(__s)), __delim_(__delimiter) {}
1066 _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const _Tp& __value_)1073 _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const _Tp& __value_)
...@@ -1106,11 +1113,11 @@ private:...@@ -1106,11 +1113,11 @@ private:
1106 bool __test_for_eof() const1113 bool __test_for_eof() const
1107 {1114 {
1108 if (__sbuf_ && traits_type::eq_int_type(__sbuf_->sgetc(), traits_type::eof()))1115 if (__sbuf_ && traits_type::eq_int_type(__sbuf_->sgetc(), traits_type::eof()))
1109 __sbuf_ = 0;1116 __sbuf_ = nullptr;
1110 return __sbuf_ == 0;1117 return __sbuf_ == nullptr;
1111 }1118 }
1112public:1119public:
1113 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istreambuf_iterator() _NOEXCEPT : __sbuf_(0) {}1120 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istreambuf_iterator() _NOEXCEPT : __sbuf_(nullptr) {}
1114 _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(istream_type& __s) _NOEXCEPT1121 _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(istream_type& __s) _NOEXCEPT
1115 : __sbuf_(__s.rdbuf()) {}1122 : __sbuf_(__s.rdbuf()) {}
1116 _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(streambuf_type* __s) _NOEXCEPT1123 _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(streambuf_type* __s) _NOEXCEPT
...@@ -1151,10 +1158,20 @@ class _LIBCPP_TEMPLATE_VIS ostreambuf_iterator...@@ -1151,10 +1158,20 @@ class _LIBCPP_TEMPLATE_VIS ostreambuf_iterator
1151 : public iterator<output_iterator_tag, void, void, void, void>1158 : public iterator<output_iterator_tag, void, void, void, void>
1152{1159{
1153public:1160public:
1154 typedef _CharT char_type;1161 typedef output_iterator_tag iterator_category;
1155 typedef _Traits traits_type;1162 typedef void value_type;
1156 typedef basic_streambuf<_CharT,_Traits> streambuf_type;1163#if _LIBCPP_STD_VER > 17
1157 typedef basic_ostream<_CharT,_Traits> ostream_type;1164 typedef std::ptrdiff_t difference_type;
1165#else
1166 typedef void difference_type;
1167#endif
1168 typedef void pointer;
1169 typedef void reference;
1170 typedef _CharT char_type;
1171 typedef _Traits traits_type;
1172 typedef basic_streambuf<_CharT, _Traits> streambuf_type;
1173 typedef basic_ostream<_CharT, _Traits> ostream_type;
1174
1158private:1175private:
1159 streambuf_type* __sbuf_;1176 streambuf_type* __sbuf_;
1160public:1177public:
...@@ -1165,13 +1182,13 @@ public:...@@ -1165,13 +1182,13 @@ public:
1165 _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator=(_CharT __c)1182 _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator=(_CharT __c)
1166 {1183 {
1167 if (__sbuf_ && traits_type::eq_int_type(__sbuf_->sputc(__c), traits_type::eof()))1184 if (__sbuf_ && traits_type::eq_int_type(__sbuf_->sputc(__c), traits_type::eof()))
1168 __sbuf_ = 0;1185 __sbuf_ = nullptr;
1169 return *this;1186 return *this;
1170 }1187 }
1171 _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator*() {return *this;}1188 _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator*() {return *this;}
1172 _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator++() {return *this;}1189 _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator++() {return *this;}
1173 _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator++(int) {return *this;}1190 _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator++(int) {return *this;}
1174 _LIBCPP_INLINE_VISIBILITY bool failed() const _NOEXCEPT {return __sbuf_ == 0;}1191 _LIBCPP_INLINE_VISIBILITY bool failed() const _NOEXCEPT {return __sbuf_ == nullptr;}
11751192
1176 template <class _Ch, class _Tr>1193 template <class _Ch, class _Tr>
1177 friend1194 friend
...@@ -1373,13 +1390,13 @@ operator+(typename __wrap_iter<_Iter>::difference_type, __wrap_iter<_Iter>) _NOE...@@ -1373,13 +1390,13 @@ operator+(typename __wrap_iter<_Iter>::difference_type, __wrap_iter<_Iter>) _NOE
13731390
1374template <class _Ip, class _Op> _Op _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 copy(_Ip, _Ip, _Op);1391template <class _Ip, class _Op> _Op _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 copy(_Ip, _Ip, _Op);
1375template <class _B1, class _B2> _B2 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 copy_backward(_B1, _B1, _B2);1392template <class _B1, class _B2> _B2 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 copy_backward(_B1, _B1, _B2);
1376template <class _Ip, class _Op> _Op _LIBCPP_INLINE_VISIBILITY move(_Ip, _Ip, _Op);1393template <class _Ip, class _Op> _Op _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 move(_Ip, _Ip, _Op);
1377template <class _B1, class _B2> _B2 _LIBCPP_INLINE_VISIBILITY move_backward(_B1, _B1, _B2);1394template <class _B1, class _B2> _B2 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 move_backward(_B1, _B1, _B2);
13781395
1379#if _LIBCPP_DEBUG_LEVEL < 21396#if _LIBCPP_DEBUG_LEVEL < 2
13801397
1381template <class _Tp>1398template <class _Tp>
1382_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG1399_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
1383typename enable_if1400typename enable_if
1384<1401<
1385 is_trivially_copy_assignable<_Tp>::value,1402 is_trivially_copy_assignable<_Tp>::value,
...@@ -1390,7 +1407,7 @@ __unwrap_iter(__wrap_iter<_Tp*>);...@@ -1390,7 +1407,7 @@ __unwrap_iter(__wrap_iter<_Tp*>);
1390#else1407#else
13911408
1392template <class _Tp>1409template <class _Tp>
1393inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG1410inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
1394typename enable_if1411typename enable_if
1395<1412<
1396 is_trivially_copy_assignable<_Tp>::value,1413 is_trivially_copy_assignable<_Tp>::value,
...@@ -1418,20 +1435,20 @@ public:...@@ -1418,20 +1435,20 @@ public:
1418 : __i{}1435 : __i{}
1419#endif1436#endif
1420 {1437 {
1421#if _LIBCPP_DEBUG_LEVEL >= 21438#if _LIBCPP_DEBUG_LEVEL == 2
1422 __get_db()->__insert_i(this);1439 __get_db()->__insert_i(this);
1423#endif1440#endif
1424 }1441 }
1425 template <class _Up> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG1442 template <class _Up> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1426 __wrap_iter(const __wrap_iter<_Up>& __u,1443 __wrap_iter(const __wrap_iter<_Up>& __u,
1427 typename enable_if<is_convertible<_Up, iterator_type>::value>::type* = 0) _NOEXCEPT1444 typename enable_if<is_convertible<_Up, iterator_type>::value>::type* = nullptr) _NOEXCEPT
1428 : __i(__u.base())1445 : __i(__u.base())
1429 {1446 {
1430#if _LIBCPP_DEBUG_LEVEL >= 21447#if _LIBCPP_DEBUG_LEVEL == 2
1431 __get_db()->__iterator_copy(this, &__u);1448 __get_db()->__iterator_copy(this, &__u);
1432#endif1449#endif
1433 }1450 }
1434#if _LIBCPP_DEBUG_LEVEL >= 21451#if _LIBCPP_DEBUG_LEVEL == 2
1435 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG1452 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1436 __wrap_iter(const __wrap_iter& __x)1453 __wrap_iter(const __wrap_iter& __x)
1437 : __i(__x.base())1454 : __i(__x.base())
...@@ -1456,7 +1473,7 @@ public:...@@ -1456,7 +1473,7 @@ public:
1456#endif1473#endif
1457 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG reference operator*() const _NOEXCEPT1474 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG reference operator*() const _NOEXCEPT
1458 {1475 {
1459#if _LIBCPP_DEBUG_LEVEL >= 21476#if _LIBCPP_DEBUG_LEVEL == 2
1460 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),1477 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
1461 "Attempted to dereference a non-dereferenceable iterator");1478 "Attempted to dereference a non-dereferenceable iterator");
1462#endif1479#endif
...@@ -1464,7 +1481,7 @@ public:...@@ -1464,7 +1481,7 @@ public:
1464 }1481 }
1465 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG pointer operator->() const _NOEXCEPT1482 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG pointer operator->() const _NOEXCEPT
1466 {1483 {
1467#if _LIBCPP_DEBUG_LEVEL >= 21484#if _LIBCPP_DEBUG_LEVEL == 2
1468 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),1485 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
1469 "Attempted to dereference a non-dereferenceable iterator");1486 "Attempted to dereference a non-dereferenceable iterator");
1470#endif1487#endif
...@@ -1472,7 +1489,7 @@ public:...@@ -1472,7 +1489,7 @@ public:
1472 }1489 }
1473 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator++() _NOEXCEPT1490 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator++() _NOEXCEPT
1474 {1491 {
1475#if _LIBCPP_DEBUG_LEVEL >= 21492#if _LIBCPP_DEBUG_LEVEL == 2
1476 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),1493 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
1477 "Attempted to increment non-incrementable iterator");1494 "Attempted to increment non-incrementable iterator");
1478#endif1495#endif
...@@ -1484,7 +1501,7 @@ public:...@@ -1484,7 +1501,7 @@ public:
14841501
1485 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator--() _NOEXCEPT1502 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator--() _NOEXCEPT
1486 {1503 {
1487#if _LIBCPP_DEBUG_LEVEL >= 21504#if _LIBCPP_DEBUG_LEVEL == 2
1488 _LIBCPP_ASSERT(__get_const_db()->__decrementable(this),1505 _LIBCPP_ASSERT(__get_const_db()->__decrementable(this),
1489 "Attempted to decrement non-decrementable iterator");1506 "Attempted to decrement non-decrementable iterator");
1490#endif1507#endif
...@@ -1497,7 +1514,7 @@ public:...@@ -1497,7 +1514,7 @@ public:
1497 {__wrap_iter __w(*this); __w += __n; return __w;}1514 {__wrap_iter __w(*this); __w += __n; return __w;}
1498 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator+=(difference_type __n) _NOEXCEPT1515 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator+=(difference_type __n) _NOEXCEPT
1499 {1516 {
1500#if _LIBCPP_DEBUG_LEVEL >= 21517#if _LIBCPP_DEBUG_LEVEL == 2
1501 _LIBCPP_ASSERT(__get_const_db()->__addable(this, __n),1518 _LIBCPP_ASSERT(__get_const_db()->__addable(this, __n),
1502 "Attempted to add/subtract iterator outside of valid range");1519 "Attempted to add/subtract iterator outside of valid range");
1503#endif1520#endif
...@@ -1510,7 +1527,7 @@ public:...@@ -1510,7 +1527,7 @@ public:
1510 {*this += -__n; return *this;}1527 {*this += -__n; return *this;}
1511 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG reference operator[](difference_type __n) const _NOEXCEPT1528 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG reference operator[](difference_type __n) const _NOEXCEPT
1512 {1529 {
1513#if _LIBCPP_DEBUG_LEVEL >= 21530#if _LIBCPP_DEBUG_LEVEL == 2
1514 _LIBCPP_ASSERT(__get_const_db()->__subscriptable(this, __n),1531 _LIBCPP_ASSERT(__get_const_db()->__subscriptable(this, __n),
1515 "Attempted to subscript iterator outside of valid range");1532 "Attempted to subscript iterator outside of valid range");
1516#endif1533#endif
...@@ -1520,7 +1537,7 @@ public:...@@ -1520,7 +1537,7 @@ public:
1520 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG iterator_type base() const _NOEXCEPT {return __i;}1537 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG iterator_type base() const _NOEXCEPT {return __i;}
15211538
1522private:1539private:
1523#if _LIBCPP_DEBUG_LEVEL >= 21540#if _LIBCPP_DEBUG_LEVEL == 2
1524 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(const void* __p, iterator_type __x) : __i(__x)1541 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(const void* __p, iterator_type __x) : __i(__x)
1525 {1542 {
1526 __get_db()->__insert_ic(this, __p);1543 __get_db()->__insert_ic(this, __p);
...@@ -1584,12 +1601,12 @@ private:...@@ -1584,12 +1601,12 @@ private:
15841601
1585 template <class _Ip, class _Op> friend _LIBCPP_CONSTEXPR_AFTER_CXX17 _Op copy(_Ip, _Ip, _Op);1602 template <class _Ip, class _Op> friend _LIBCPP_CONSTEXPR_AFTER_CXX17 _Op copy(_Ip, _Ip, _Op);
1586 template <class _B1, class _B2> friend _LIBCPP_CONSTEXPR_AFTER_CXX17 _B2 copy_backward(_B1, _B1, _B2);1603 template <class _B1, class _B2> friend _LIBCPP_CONSTEXPR_AFTER_CXX17 _B2 copy_backward(_B1, _B1, _B2);
1587 template <class _Ip, class _Op> friend _Op move(_Ip, _Ip, _Op);1604 template <class _Ip, class _Op> friend _LIBCPP_CONSTEXPR_AFTER_CXX17 _Op move(_Ip, _Ip, _Op);
1588 template <class _B1, class _B2> friend _B2 move_backward(_B1, _B1, _B2);1605 template <class _B1, class _B2> friend _LIBCPP_CONSTEXPR_AFTER_CXX17 _B2 move_backward(_B1, _B1, _B2);
15891606
1590#if _LIBCPP_DEBUG_LEVEL < 21607#if _LIBCPP_DEBUG_LEVEL < 2
1591 template <class _Tp>1608 template <class _Tp>
1592 _LIBCPP_CONSTEXPR_IF_NODEBUG friend1609 _LIBCPP_CONSTEXPR friend
1593 typename enable_if1610 typename enable_if
1594 <1611 <
1595 is_trivially_copy_assignable<_Tp>::value,1612 is_trivially_copy_assignable<_Tp>::value,
...@@ -1598,7 +1615,7 @@ private:...@@ -1598,7 +1615,7 @@ private:
1598 __unwrap_iter(__wrap_iter<_Tp*>);1615 __unwrap_iter(__wrap_iter<_Tp*>);
1599#else1616#else
1600 template <class _Tp>1617 template <class _Tp>
1601 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG1618 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR friend
1602 typename enable_if1619 typename enable_if
1603 <1620 <
1604 is_trivially_copy_assignable<_Tp>::value,1621 is_trivially_copy_assignable<_Tp>::value,
...@@ -1621,7 +1638,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG...@@ -1621,7 +1638,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1621bool1638bool
1622operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT1639operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
1623{1640{
1624#if _LIBCPP_DEBUG_LEVEL >= 21641#if _LIBCPP_DEBUG_LEVEL == 2
1625 _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y),1642 _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y),
1626 "Attempted to compare incomparable iterators");1643 "Attempted to compare incomparable iterators");
1627#endif1644#endif
...@@ -1699,7 +1716,7 @@ auto...@@ -1699,7 +1716,7 @@ auto
1699operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT1716operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
1700-> decltype(__x.base() - __y.base())1717-> decltype(__x.base() - __y.base())
1701{1718{
1702#if _LIBCPP_DEBUG_LEVEL >= 21719#if _LIBCPP_DEBUG_LEVEL == 2
1703 _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y),1720 _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y),
1704 "Attempted to subtract incompatible iterators");1721 "Attempted to subtract incompatible iterators");
1705#endif1722#endif
...@@ -1711,7 +1728,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG...@@ -1711,7 +1728,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1711typename __wrap_iter<_Iter1>::difference_type1728typename __wrap_iter<_Iter1>::difference_type
1712operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT1729operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
1713{1730{
1714#if _LIBCPP_DEBUG_LEVEL >= 21731#if _LIBCPP_DEBUG_LEVEL == 2
1715 _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y),1732 _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y),
1716 "Attempted to subtract incompatible iterators");1733 "Attempted to subtract incompatible iterators");
1717#endif1734#endif
lib/libcxx/include/latch+8
...@@ -19,6 +19,8 @@ namespace std...@@ -19,6 +19,8 @@ namespace std
19 class latch19 class latch
20 {20 {
21 public:21 public:
22 static constexpr ptrdiff_t max() noexcept;
23
22 constexpr explicit latch(ptrdiff_t __expected);24 constexpr explicit latch(ptrdiff_t __expected);
23 ~latch();25 ~latch();
2426
...@@ -39,6 +41,7 @@ namespace std...@@ -39,6 +41,7 @@ namespace std
39*/41*/
4042
41#include <__config>43#include <__config>
44#include <__availability>
42#include <atomic>45#include <atomic>
4346
44#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)47#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -49,6 +52,9 @@ namespace std...@@ -49,6 +52,9 @@ namespace std
49# error <latch> is not supported on this single threaded system52# error <latch> is not supported on this single threaded system
50#endif53#endif
5154
55_LIBCPP_PUSH_MACROS
56#include <__undef_macros>
57
52#if _LIBCPP_STD_VER >= 1458#if _LIBCPP_STD_VER >= 14
5359
54_LIBCPP_BEGIN_NAMESPACE_STD60_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -101,4 +107,6 @@ _LIBCPP_END_NAMESPACE_STD...@@ -101,4 +107,6 @@ _LIBCPP_END_NAMESPACE_STD
101107
102#endif // _LIBCPP_STD_VER >= 14108#endif // _LIBCPP_STD_VER >= 14
103109
110_LIBCPP_POP_MACROS
111
104#endif //_LIBCPP_LATCH112#endif //_LIBCPP_LATCH
lib/libcxx/include/list+93-93
...@@ -293,7 +293,7 @@ class _LIBCPP_TEMPLATE_VIS __list_iterator...@@ -293,7 +293,7 @@ class _LIBCPP_TEMPLATE_VIS __list_iterator
293293
294 __link_pointer __ptr_;294 __link_pointer __ptr_;
295295
296#if _LIBCPP_DEBUG_LEVEL >= 2296#if _LIBCPP_DEBUG_LEVEL == 2
297 _LIBCPP_INLINE_VISIBILITY297 _LIBCPP_INLINE_VISIBILITY
298 explicit __list_iterator(__link_pointer __p, const void* __c) _NOEXCEPT298 explicit __list_iterator(__link_pointer __p, const void* __c) _NOEXCEPT
299 : __ptr_(__p)299 : __ptr_(__p)
...@@ -320,12 +320,12 @@ public:...@@ -320,12 +320,12 @@ public:
320 _LIBCPP_INLINE_VISIBILITY320 _LIBCPP_INLINE_VISIBILITY
321 __list_iterator() _NOEXCEPT : __ptr_(nullptr)321 __list_iterator() _NOEXCEPT : __ptr_(nullptr)
322 {322 {
323#if _LIBCPP_DEBUG_LEVEL >= 2323#if _LIBCPP_DEBUG_LEVEL == 2
324 __get_db()->__insert_i(this);324 __get_db()->__insert_i(this);
325#endif325#endif
326 }326 }
327327
328#if _LIBCPP_DEBUG_LEVEL >= 2328#if _LIBCPP_DEBUG_LEVEL == 2
329329
330 _LIBCPP_INLINE_VISIBILITY330 _LIBCPP_INLINE_VISIBILITY
331 __list_iterator(const __list_iterator& __p)331 __list_iterator(const __list_iterator& __p)
...@@ -351,12 +351,12 @@ public:...@@ -351,12 +351,12 @@ public:
351 return *this;351 return *this;
352 }352 }
353353
354#endif // _LIBCPP_DEBUG_LEVEL >= 2354#endif // _LIBCPP_DEBUG_LEVEL == 2
355355
356 _LIBCPP_INLINE_VISIBILITY356 _LIBCPP_INLINE_VISIBILITY
357 reference operator*() const357 reference operator*() const
358 {358 {
359#if _LIBCPP_DEBUG_LEVEL >= 2359#if _LIBCPP_DEBUG_LEVEL == 2
360 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),360 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
361 "Attempted to dereference a non-dereferenceable list::iterator");361 "Attempted to dereference a non-dereferenceable list::iterator");
362#endif362#endif
...@@ -365,7 +365,7 @@ public:...@@ -365,7 +365,7 @@ public:
365 _LIBCPP_INLINE_VISIBILITY365 _LIBCPP_INLINE_VISIBILITY
366 pointer operator->() const366 pointer operator->() const
367 {367 {
368#if _LIBCPP_DEBUG_LEVEL >= 2368#if _LIBCPP_DEBUG_LEVEL == 2
369 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),369 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
370 "Attempted to dereference a non-dereferenceable list::iterator");370 "Attempted to dereference a non-dereferenceable list::iterator");
371#endif371#endif
...@@ -375,7 +375,7 @@ public:...@@ -375,7 +375,7 @@ public:
375 _LIBCPP_INLINE_VISIBILITY375 _LIBCPP_INLINE_VISIBILITY
376 __list_iterator& operator++()376 __list_iterator& operator++()
377 {377 {
378#if _LIBCPP_DEBUG_LEVEL >= 2378#if _LIBCPP_DEBUG_LEVEL == 2
379 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),379 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
380 "Attempted to increment non-incrementable list::iterator");380 "Attempted to increment non-incrementable list::iterator");
381#endif381#endif
...@@ -388,7 +388,7 @@ public:...@@ -388,7 +388,7 @@ public:
388 _LIBCPP_INLINE_VISIBILITY388 _LIBCPP_INLINE_VISIBILITY
389 __list_iterator& operator--()389 __list_iterator& operator--()
390 {390 {
391#if _LIBCPP_DEBUG_LEVEL >= 2391#if _LIBCPP_DEBUG_LEVEL == 2
392 _LIBCPP_ASSERT(__get_const_db()->__decrementable(this),392 _LIBCPP_ASSERT(__get_const_db()->__decrementable(this),
393 "Attempted to decrement non-decrementable list::iterator");393 "Attempted to decrement non-decrementable list::iterator");
394#endif394#endif
...@@ -416,7 +416,7 @@ class _LIBCPP_TEMPLATE_VIS __list_const_iterator...@@ -416,7 +416,7 @@ class _LIBCPP_TEMPLATE_VIS __list_const_iterator
416416
417 __link_pointer __ptr_;417 __link_pointer __ptr_;
418418
419#if _LIBCPP_DEBUG_LEVEL >= 2419#if _LIBCPP_DEBUG_LEVEL == 2
420 _LIBCPP_INLINE_VISIBILITY420 _LIBCPP_INLINE_VISIBILITY
421 explicit __list_const_iterator(__link_pointer __p, const void* __c) _NOEXCEPT421 explicit __list_const_iterator(__link_pointer __p, const void* __c) _NOEXCEPT
422 : __ptr_(__p)422 : __ptr_(__p)
...@@ -440,7 +440,7 @@ public:...@@ -440,7 +440,7 @@ public:
440 _LIBCPP_INLINE_VISIBILITY440 _LIBCPP_INLINE_VISIBILITY
441 __list_const_iterator() _NOEXCEPT : __ptr_(nullptr)441 __list_const_iterator() _NOEXCEPT : __ptr_(nullptr)
442 {442 {
443#if _LIBCPP_DEBUG_LEVEL >= 2443#if _LIBCPP_DEBUG_LEVEL == 2
444 __get_db()->__insert_i(this);444 __get_db()->__insert_i(this);
445#endif445#endif
446 }446 }
...@@ -448,12 +448,12 @@ public:...@@ -448,12 +448,12 @@ public:
448 __list_const_iterator(const __list_iterator<_Tp, _VoidPtr>& __p) _NOEXCEPT448 __list_const_iterator(const __list_iterator<_Tp, _VoidPtr>& __p) _NOEXCEPT
449 : __ptr_(__p.__ptr_)449 : __ptr_(__p.__ptr_)
450 {450 {
451#if _LIBCPP_DEBUG_LEVEL >= 2451#if _LIBCPP_DEBUG_LEVEL == 2
452 __get_db()->__iterator_copy(this, &__p);452 __get_db()->__iterator_copy(this, &__p);
453#endif453#endif
454 }454 }
455455
456#if _LIBCPP_DEBUG_LEVEL >= 2456#if _LIBCPP_DEBUG_LEVEL == 2
457457
458 _LIBCPP_INLINE_VISIBILITY458 _LIBCPP_INLINE_VISIBILITY
459 __list_const_iterator(const __list_const_iterator& __p)459 __list_const_iterator(const __list_const_iterator& __p)
...@@ -479,11 +479,11 @@ public:...@@ -479,11 +479,11 @@ public:
479 return *this;479 return *this;
480 }480 }
481481
482#endif // _LIBCPP_DEBUG_LEVEL >= 2482#endif // _LIBCPP_DEBUG_LEVEL == 2
483 _LIBCPP_INLINE_VISIBILITY483 _LIBCPP_INLINE_VISIBILITY
484 reference operator*() const484 reference operator*() const
485 {485 {
486#if _LIBCPP_DEBUG_LEVEL >= 2486#if _LIBCPP_DEBUG_LEVEL == 2
487 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),487 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
488 "Attempted to dereference a non-dereferenceable list::const_iterator");488 "Attempted to dereference a non-dereferenceable list::const_iterator");
489#endif489#endif
...@@ -492,7 +492,7 @@ public:...@@ -492,7 +492,7 @@ public:
492 _LIBCPP_INLINE_VISIBILITY492 _LIBCPP_INLINE_VISIBILITY
493 pointer operator->() const493 pointer operator->() const
494 {494 {
495#if _LIBCPP_DEBUG_LEVEL >= 2495#if _LIBCPP_DEBUG_LEVEL == 2
496 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),496 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
497 "Attempted to dereference a non-dereferenceable list::const_iterator");497 "Attempted to dereference a non-dereferenceable list::const_iterator");
498#endif498#endif
...@@ -502,7 +502,7 @@ public:...@@ -502,7 +502,7 @@ public:
502 _LIBCPP_INLINE_VISIBILITY502 _LIBCPP_INLINE_VISIBILITY
503 __list_const_iterator& operator++()503 __list_const_iterator& operator++()
504 {504 {
505#if _LIBCPP_DEBUG_LEVEL >= 2505#if _LIBCPP_DEBUG_LEVEL == 2
506 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),506 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
507 "Attempted to increment non-incrementable list::const_iterator");507 "Attempted to increment non-incrementable list::const_iterator");
508#endif508#endif
...@@ -515,7 +515,7 @@ public:...@@ -515,7 +515,7 @@ public:
515 _LIBCPP_INLINE_VISIBILITY515 _LIBCPP_INLINE_VISIBILITY
516 __list_const_iterator& operator--()516 __list_const_iterator& operator--()
517 {517 {
518#if _LIBCPP_DEBUG_LEVEL >= 2518#if _LIBCPP_DEBUG_LEVEL == 2
519 _LIBCPP_ASSERT(__get_const_db()->__decrementable(this),519 _LIBCPP_ASSERT(__get_const_db()->__decrementable(this),
520 "Attempted to decrement non-decrementable list::const_iterator");520 "Attempted to decrement non-decrementable list::const_iterator");
521#endif521#endif
...@@ -614,7 +614,7 @@ protected:...@@ -614,7 +614,7 @@ protected:
614 _LIBCPP_INLINE_VISIBILITY614 _LIBCPP_INLINE_VISIBILITY
615 iterator begin() _NOEXCEPT615 iterator begin() _NOEXCEPT
616 {616 {
617#if _LIBCPP_DEBUG_LEVEL >= 2617#if _LIBCPP_DEBUG_LEVEL == 2
618 return iterator(__end_.__next_, this);618 return iterator(__end_.__next_, this);
619#else619#else
620 return iterator(__end_.__next_);620 return iterator(__end_.__next_);
...@@ -623,7 +623,7 @@ protected:...@@ -623,7 +623,7 @@ protected:
623 _LIBCPP_INLINE_VISIBILITY623 _LIBCPP_INLINE_VISIBILITY
624 const_iterator begin() const _NOEXCEPT624 const_iterator begin() const _NOEXCEPT
625 {625 {
626#if _LIBCPP_DEBUG_LEVEL >= 2626#if _LIBCPP_DEBUG_LEVEL == 2
627 return const_iterator(__end_.__next_, this);627 return const_iterator(__end_.__next_, this);
628#else628#else
629 return const_iterator(__end_.__next_);629 return const_iterator(__end_.__next_);
...@@ -632,7 +632,7 @@ protected:...@@ -632,7 +632,7 @@ protected:
632 _LIBCPP_INLINE_VISIBILITY632 _LIBCPP_INLINE_VISIBILITY
633 iterator end() _NOEXCEPT633 iterator end() _NOEXCEPT
634 {634 {
635#if _LIBCPP_DEBUG_LEVEL >= 2635#if _LIBCPP_DEBUG_LEVEL == 2
636 return iterator(__end_as_link(), this);636 return iterator(__end_as_link(), this);
637#else637#else
638 return iterator(__end_as_link());638 return iterator(__end_as_link());
...@@ -641,7 +641,7 @@ protected:...@@ -641,7 +641,7 @@ protected:
641 _LIBCPP_INLINE_VISIBILITY641 _LIBCPP_INLINE_VISIBILITY
642 const_iterator end() const _NOEXCEPT642 const_iterator end() const _NOEXCEPT
643 {643 {
644#if _LIBCPP_DEBUG_LEVEL >= 2644#if _LIBCPP_DEBUG_LEVEL == 2
645 return const_iterator(__end_as_link(), this);645 return const_iterator(__end_as_link(), this);
646#else646#else
647 return const_iterator(__end_as_link());647 return const_iterator(__end_as_link());
...@@ -696,7 +696,7 @@ private:...@@ -696,7 +696,7 @@ private:
696696
697 _LIBCPP_INLINE_VISIBILITY697 _LIBCPP_INLINE_VISIBILITY
698 void __invalidate_all_iterators() {698 void __invalidate_all_iterators() {
699#if _LIBCPP_DEBUG_LEVEL >= 2699#if _LIBCPP_DEBUG_LEVEL == 2
700 __get_db()->__invalidate_all(this);700 __get_db()->__invalidate_all(this);
701#endif701#endif
702 }702 }
...@@ -735,13 +735,13 @@ inline __list_imp<_Tp, _Alloc>::__list_imp(const __node_allocator& __a)...@@ -735,13 +735,13 @@ inline __list_imp<_Tp, _Alloc>::__list_imp(const __node_allocator& __a)
735#ifndef _LIBCPP_CXX03_LANG735#ifndef _LIBCPP_CXX03_LANG
736template <class _Tp, class _Alloc>736template <class _Tp, class _Alloc>
737inline __list_imp<_Tp, _Alloc>::__list_imp(__node_allocator&& __a) _NOEXCEPT737inline __list_imp<_Tp, _Alloc>::__list_imp(__node_allocator&& __a) _NOEXCEPT
738 : __size_alloc_(0, std::move(__a)) {}738 : __size_alloc_(0, _VSTD::move(__a)) {}
739#endif739#endif
740740
741template <class _Tp, class _Alloc>741template <class _Tp, class _Alloc>
742__list_imp<_Tp, _Alloc>::~__list_imp() {742__list_imp<_Tp, _Alloc>::~__list_imp() {
743 clear();743 clear();
744#if _LIBCPP_DEBUG_LEVEL >= 2744#if _LIBCPP_DEBUG_LEVEL == 2
745 __get_db()->__erase_c(this);745 __get_db()->__erase_c(this);
746#endif746#endif
747}747}
...@@ -783,7 +783,7 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)...@@ -783,7 +783,7 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
783 "list::swap: Either propagate_on_container_swap must be true"783 "list::swap: Either propagate_on_container_swap must be true"
784 " or the allocators must compare equal");784 " or the allocators must compare equal");
785 using _VSTD::swap;785 using _VSTD::swap;
786 __swap_allocator(__node_alloc(), __c.__node_alloc());786 _VSTD::__swap_allocator(__node_alloc(), __c.__node_alloc());
787 swap(__sz(), __c.__sz());787 swap(__sz(), __c.__sz());
788 swap(__end_, __c.__end_);788 swap(__end_, __c.__end_);
789 if (__sz() == 0)789 if (__sz() == 0)
...@@ -795,13 +795,13 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)...@@ -795,13 +795,13 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
795 else795 else
796 __c.__end_.__prev_->__next_ = __c.__end_.__next_->__prev_ = __c.__end_as_link();796 __c.__end_.__prev_->__next_ = __c.__end_.__next_->__prev_ = __c.__end_as_link();
797797
798#if _LIBCPP_DEBUG_LEVEL >= 2798#if _LIBCPP_DEBUG_LEVEL == 2
799 __libcpp_db* __db = __get_db();799 __libcpp_db* __db = __get_db();
800 __c_node* __cn1 = __db->__find_c_and_lock(this);800 __c_node* __cn1 = __db->__find_c_and_lock(this);
801 __c_node* __cn2 = __db->__find_c(&__c);801 __c_node* __cn2 = __db->__find_c(&__c);
802 std::swap(__cn1->beg_, __cn2->beg_);802 _VSTD::swap(__cn1->beg_, __cn2->beg_);
803 std::swap(__cn1->end_, __cn2->end_);803 _VSTD::swap(__cn1->end_, __cn2->end_);
804 std::swap(__cn1->cap_, __cn2->cap_);804 _VSTD::swap(__cn1->cap_, __cn2->cap_);
805 for (__i_node** __p = __cn1->end_; __p != __cn1->beg_;)805 for (__i_node** __p = __cn1->end_; __p != __cn1->beg_;)
806 {806 {
807 --__p;807 --__p;
...@@ -810,7 +810,7 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)...@@ -810,7 +810,7 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
810 {810 {
811 __cn2->__add(*__p);811 __cn2->__add(*__p);
812 if (--__cn1->end_ != __p)812 if (--__cn1->end_ != __p)
813 memmove(__p, __p+1, (__cn1->end_ - __p)*sizeof(__i_node*));813 _VSTD::memmove(__p, __p+1, (__cn1->end_ - __p)*sizeof(__i_node*));
814 }814 }
815 else815 else
816 (*__p)->__c_ = __cn1;816 (*__p)->__c_ = __cn1;
...@@ -823,7 +823,7 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)...@@ -823,7 +823,7 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
823 {823 {
824 __cn1->__add(*__p);824 __cn1->__add(*__p);
825 if (--__cn2->end_ != __p)825 if (--__cn2->end_ != __p)
826 memmove(__p, __p+1, (__cn2->end_ - __p)*sizeof(__i_node*));826 _VSTD::memmove(__p, __p+1, (__cn2->end_ - __p)*sizeof(__i_node*));
827 }827 }
828 else828 else
829 (*__p)->__c_ = __cn2;829 (*__p)->__c_ = __cn2;
...@@ -870,14 +870,14 @@ public:...@@ -870,14 +870,14 @@ public:
870 list()870 list()
871 _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)871 _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)
872 {872 {
873#if _LIBCPP_DEBUG_LEVEL >= 2873#if _LIBCPP_DEBUG_LEVEL == 2
874 __get_db()->__insert_c(this);874 __get_db()->__insert_c(this);
875#endif875#endif
876 }876 }
877 _LIBCPP_INLINE_VISIBILITY877 _LIBCPP_INLINE_VISIBILITY
878 explicit list(const allocator_type& __a) : base(__a)878 explicit list(const allocator_type& __a) : base(__a)
879 {879 {
880#if _LIBCPP_DEBUG_LEVEL >= 2880#if _LIBCPP_DEBUG_LEVEL == 2
881 __get_db()->__insert_c(this);881 __get_db()->__insert_c(this);
882#endif882#endif
883 }883 }
...@@ -937,7 +937,7 @@ public:...@@ -937,7 +937,7 @@ public:
937 _LIBCPP_INLINE_VISIBILITY937 _LIBCPP_INLINE_VISIBILITY
938 size_type max_size() const _NOEXCEPT938 size_type max_size() const _NOEXCEPT
939 {939 {
940 return std::min<size_type>(940 return _VSTD::min<size_type>(
941 base::__node_alloc_max_size(),941 base::__node_alloc_max_size(),
942 numeric_limits<difference_type >::max());942 numeric_limits<difference_type >::max());
943 }943 }
...@@ -1117,14 +1117,14 @@ public:...@@ -1117,14 +1117,14 @@ public:
1117 return __hold_pointer(__p, __node_destructor(__na, 1));1117 return __hold_pointer(__p, __node_destructor(__na, 1));
1118 }1118 }
11191119
1120#if _LIBCPP_DEBUG_LEVEL >= 21120#if _LIBCPP_DEBUG_LEVEL == 2
11211121
1122 bool __dereferenceable(const const_iterator* __i) const;1122 bool __dereferenceable(const const_iterator* __i) const;
1123 bool __decrementable(const const_iterator* __i) const;1123 bool __decrementable(const const_iterator* __i) const;
1124 bool __addable(const const_iterator* __i, ptrdiff_t __n) const;1124 bool __addable(const const_iterator* __i, ptrdiff_t __n) const;
1125 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;1125 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;
11261126
1127#endif // _LIBCPP_DEBUG_LEVEL >= 21127#endif // _LIBCPP_DEBUG_LEVEL == 2
11281128
1129private:1129private:
1130 _LIBCPP_INLINE_VISIBILITY1130 _LIBCPP_INLINE_VISIBILITY
...@@ -1144,7 +1144,7 @@ private:...@@ -1144,7 +1144,7 @@ private:
11441144
1145#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES1145#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
1146template<class _InputIterator,1146template<class _InputIterator,
1147 class _Alloc = typename std::allocator<typename iterator_traits<_InputIterator>::value_type>,1147 class _Alloc = allocator<typename iterator_traits<_InputIterator>::value_type>,
1148 class = typename enable_if<__is_allocator<_Alloc>::value, void>::type1148 class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
1149 >1149 >
1150list(_InputIterator, _InputIterator)1150list(_InputIterator, _InputIterator)
...@@ -1207,7 +1207,7 @@ list<_Tp, _Alloc>::__iterator(size_type __n)...@@ -1207,7 +1207,7 @@ list<_Tp, _Alloc>::__iterator(size_type __n)
1207template <class _Tp, class _Alloc>1207template <class _Tp, class _Alloc>
1208list<_Tp, _Alloc>::list(size_type __n)1208list<_Tp, _Alloc>::list(size_type __n)
1209{1209{
1210#if _LIBCPP_DEBUG_LEVEL >= 21210#if _LIBCPP_DEBUG_LEVEL == 2
1211 __get_db()->__insert_c(this);1211 __get_db()->__insert_c(this);
1212#endif1212#endif
1213 for (; __n > 0; --__n)1213 for (; __n > 0; --__n)
...@@ -1222,7 +1222,7 @@ list<_Tp, _Alloc>::list(size_type __n)...@@ -1222,7 +1222,7 @@ list<_Tp, _Alloc>::list(size_type __n)
1222template <class _Tp, class _Alloc>1222template <class _Tp, class _Alloc>
1223list<_Tp, _Alloc>::list(size_type __n, const allocator_type& __a) : base(__a)1223list<_Tp, _Alloc>::list(size_type __n, const allocator_type& __a) : base(__a)
1224{1224{
1225#if _LIBCPP_DEBUG_LEVEL >= 21225#if _LIBCPP_DEBUG_LEVEL == 2
1226 __get_db()->__insert_c(this);1226 __get_db()->__insert_c(this);
1227#endif1227#endif
1228 for (; __n > 0; --__n)1228 for (; __n > 0; --__n)
...@@ -1233,7 +1233,7 @@ list<_Tp, _Alloc>::list(size_type __n, const allocator_type& __a) : base(__a)...@@ -1233,7 +1233,7 @@ list<_Tp, _Alloc>::list(size_type __n, const allocator_type& __a) : base(__a)
1233template <class _Tp, class _Alloc>1233template <class _Tp, class _Alloc>
1234list<_Tp, _Alloc>::list(size_type __n, const value_type& __x)1234list<_Tp, _Alloc>::list(size_type __n, const value_type& __x)
1235{1235{
1236#if _LIBCPP_DEBUG_LEVEL >= 21236#if _LIBCPP_DEBUG_LEVEL == 2
1237 __get_db()->__insert_c(this);1237 __get_db()->__insert_c(this);
1238#endif1238#endif
1239 for (; __n > 0; --__n)1239 for (; __n > 0; --__n)
...@@ -1244,7 +1244,7 @@ template <class _Tp, class _Alloc>...@@ -1244,7 +1244,7 @@ template <class _Tp, class _Alloc>
1244list<_Tp, _Alloc>::list(size_type __n, const value_type& __x, const allocator_type& __a)1244list<_Tp, _Alloc>::list(size_type __n, const value_type& __x, const allocator_type& __a)
1245 : base(__a)1245 : base(__a)
1246{1246{
1247#if _LIBCPP_DEBUG_LEVEL >= 21247#if _LIBCPP_DEBUG_LEVEL == 2
1248 __get_db()->__insert_c(this);1248 __get_db()->__insert_c(this);
1249#endif1249#endif
1250 for (; __n > 0; --__n)1250 for (; __n > 0; --__n)
...@@ -1256,7 +1256,7 @@ template <class _InpIter>...@@ -1256,7 +1256,7 @@ template <class _InpIter>
1256list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l,1256list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l,
1257 typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type*)1257 typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type*)
1258{1258{
1259#if _LIBCPP_DEBUG_LEVEL >= 21259#if _LIBCPP_DEBUG_LEVEL == 2
1260 __get_db()->__insert_c(this);1260 __get_db()->__insert_c(this);
1261#endif1261#endif
1262 for (; __f != __l; ++__f)1262 for (; __f != __l; ++__f)
...@@ -1269,7 +1269,7 @@ list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l, const allocator_type& __a,...@@ -1269,7 +1269,7 @@ list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l, const allocator_type& __a,
1269 typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type*)1269 typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type*)
1270 : base(__a)1270 : base(__a)
1271{1271{
1272#if _LIBCPP_DEBUG_LEVEL >= 21272#if _LIBCPP_DEBUG_LEVEL == 2
1273 __get_db()->__insert_c(this);1273 __get_db()->__insert_c(this);
1274#endif1274#endif
1275 for (; __f != __l; ++__f)1275 for (; __f != __l; ++__f)
...@@ -1280,7 +1280,7 @@ template <class _Tp, class _Alloc>...@@ -1280,7 +1280,7 @@ template <class _Tp, class _Alloc>
1280list<_Tp, _Alloc>::list(const list& __c)1280list<_Tp, _Alloc>::list(const list& __c)
1281 : base(__node_alloc_traits::select_on_container_copy_construction(1281 : base(__node_alloc_traits::select_on_container_copy_construction(
1282 __c.__node_alloc())) {1282 __c.__node_alloc())) {
1283#if _LIBCPP_DEBUG_LEVEL >= 21283#if _LIBCPP_DEBUG_LEVEL == 2
1284 __get_db()->__insert_c(this);1284 __get_db()->__insert_c(this);
1285#endif1285#endif
1286 for (const_iterator __i = __c.begin(), __e = __c.end(); __i != __e; ++__i)1286 for (const_iterator __i = __c.begin(), __e = __c.end(); __i != __e; ++__i)
...@@ -1291,7 +1291,7 @@ template <class _Tp, class _Alloc>...@@ -1291,7 +1291,7 @@ template <class _Tp, class _Alloc>
1291list<_Tp, _Alloc>::list(const list& __c, const allocator_type& __a)1291list<_Tp, _Alloc>::list(const list& __c, const allocator_type& __a)
1292 : base(__a)1292 : base(__a)
1293{1293{
1294#if _LIBCPP_DEBUG_LEVEL >= 21294#if _LIBCPP_DEBUG_LEVEL == 2
1295 __get_db()->__insert_c(this);1295 __get_db()->__insert_c(this);
1296#endif1296#endif
1297 for (const_iterator __i = __c.begin(), __e = __c.end(); __i != __e; ++__i)1297 for (const_iterator __i = __c.begin(), __e = __c.end(); __i != __e; ++__i)
...@@ -1304,7 +1304,7 @@ template <class _Tp, class _Alloc>...@@ -1304,7 +1304,7 @@ template <class _Tp, class _Alloc>
1304list<_Tp, _Alloc>::list(initializer_list<value_type> __il, const allocator_type& __a)1304list<_Tp, _Alloc>::list(initializer_list<value_type> __il, const allocator_type& __a)
1305 : base(__a)1305 : base(__a)
1306{1306{
1307#if _LIBCPP_DEBUG_LEVEL >= 21307#if _LIBCPP_DEBUG_LEVEL == 2
1308 __get_db()->__insert_c(this);1308 __get_db()->__insert_c(this);
1309#endif1309#endif
1310 for (typename initializer_list<value_type>::const_iterator __i = __il.begin(),1310 for (typename initializer_list<value_type>::const_iterator __i = __il.begin(),
...@@ -1315,7 +1315,7 @@ list<_Tp, _Alloc>::list(initializer_list<value_type> __il, const allocator_type&...@@ -1315,7 +1315,7 @@ list<_Tp, _Alloc>::list(initializer_list<value_type> __il, const allocator_type&
1315template <class _Tp, class _Alloc>1315template <class _Tp, class _Alloc>
1316list<_Tp, _Alloc>::list(initializer_list<value_type> __il)1316list<_Tp, _Alloc>::list(initializer_list<value_type> __il)
1317{1317{
1318#if _LIBCPP_DEBUG_LEVEL >= 21318#if _LIBCPP_DEBUG_LEVEL == 2
1319 __get_db()->__insert_c(this);1319 __get_db()->__insert_c(this);
1320#endif1320#endif
1321 for (typename initializer_list<value_type>::const_iterator __i = __il.begin(),1321 for (typename initializer_list<value_type>::const_iterator __i = __il.begin(),
...@@ -1327,7 +1327,7 @@ template <class _Tp, class _Alloc>...@@ -1327,7 +1327,7 @@ template <class _Tp, class _Alloc>
1327inline list<_Tp, _Alloc>::list(list&& __c)1327inline list<_Tp, _Alloc>::list(list&& __c)
1328 _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value)1328 _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value)
1329 : base(_VSTD::move(__c.__node_alloc())) {1329 : base(_VSTD::move(__c.__node_alloc())) {
1330#if _LIBCPP_DEBUG_LEVEL >= 21330#if _LIBCPP_DEBUG_LEVEL == 2
1331 __get_db()->__insert_c(this);1331 __get_db()->__insert_c(this);
1332#endif1332#endif
1333 splice(end(), __c);1333 splice(end(), __c);
...@@ -1338,7 +1338,7 @@ inline...@@ -1338,7 +1338,7 @@ inline
1338list<_Tp, _Alloc>::list(list&& __c, const allocator_type& __a)1338list<_Tp, _Alloc>::list(list&& __c, const allocator_type& __a)
1339 : base(__a)1339 : base(__a)
1340{1340{
1341#if _LIBCPP_DEBUG_LEVEL >= 21341#if _LIBCPP_DEBUG_LEVEL == 2
1342 __get_db()->__insert_c(this);1342 __get_db()->__insert_c(this);
1343#endif1343#endif
1344 if (__a == __c.get_allocator())1344 if (__a == __c.get_allocator())
...@@ -1415,7 +1415,7 @@ list<_Tp, _Alloc>::assign(_InpIter __f, _InpIter __l,...@@ -1415,7 +1415,7 @@ list<_Tp, _Alloc>::assign(_InpIter __f, _InpIter __l,
1415 insert(__e, __f, __l);1415 insert(__e, __f, __l);
1416 else1416 else
1417 erase(__i, __e);1417 erase(__i, __e);
1418#if _LIBCPP_DEBUG_LEVEL >= 21418#if _LIBCPP_DEBUG_LEVEL == 2
1419 __get_db()->__invalidate_all(this);1419 __get_db()->__invalidate_all(this);
1420#endif1420#endif
1421}1421}
...@@ -1432,7 +1432,7 @@ list<_Tp, _Alloc>::assign(size_type __n, const value_type& __x)...@@ -1432,7 +1432,7 @@ list<_Tp, _Alloc>::assign(size_type __n, const value_type& __x)
1432 insert(__e, __n, __x);1432 insert(__e, __n, __x);
1433 else1433 else
1434 erase(__i, __e);1434 erase(__i, __e);
1435#if _LIBCPP_DEBUG_LEVEL >= 21435#if _LIBCPP_DEBUG_LEVEL == 2
1436 __get_db()->__invalidate_all(this);1436 __get_db()->__invalidate_all(this);
1437#endif1437#endif
1438}1438}
...@@ -1449,7 +1449,7 @@ template <class _Tp, class _Alloc>...@@ -1449,7 +1449,7 @@ template <class _Tp, class _Alloc>
1449typename list<_Tp, _Alloc>::iterator1449typename list<_Tp, _Alloc>::iterator
1450list<_Tp, _Alloc>::insert(const_iterator __p, const value_type& __x)1450list<_Tp, _Alloc>::insert(const_iterator __p, const value_type& __x)
1451{1451{
1452#if _LIBCPP_DEBUG_LEVEL >= 21452#if _LIBCPP_DEBUG_LEVEL == 2
1453 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,1453 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
1454 "list::insert(iterator, x) called with an iterator not"1454 "list::insert(iterator, x) called with an iterator not"
1455 " referring to this list");1455 " referring to this list");
...@@ -1459,7 +1459,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, const value_type& __x)...@@ -1459,7 +1459,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, const value_type& __x)
1459 __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);1459 __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
1460 __link_nodes(__p.__ptr_, __hold->__as_link(), __hold->__as_link());1460 __link_nodes(__p.__ptr_, __hold->__as_link(), __hold->__as_link());
1461 ++base::__sz();1461 ++base::__sz();
1462#if _LIBCPP_DEBUG_LEVEL >= 21462#if _LIBCPP_DEBUG_LEVEL == 2
1463 return iterator(__hold.release()->__as_link(), this);1463 return iterator(__hold.release()->__as_link(), this);
1464#else1464#else
1465 return iterator(__hold.release()->__as_link());1465 return iterator(__hold.release()->__as_link());
...@@ -1470,7 +1470,7 @@ template <class _Tp, class _Alloc>...@@ -1470,7 +1470,7 @@ template <class _Tp, class _Alloc>
1470typename list<_Tp, _Alloc>::iterator1470typename list<_Tp, _Alloc>::iterator
1471list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& __x)1471list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& __x)
1472{1472{
1473#if _LIBCPP_DEBUG_LEVEL >= 21473#if _LIBCPP_DEBUG_LEVEL == 2
1474 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,1474 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
1475 "list::insert(iterator, n, x) called with an iterator not"1475 "list::insert(iterator, n, x) called with an iterator not"
1476 " referring to this list");1476 " referring to this list");
...@@ -1485,7 +1485,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _...@@ -1485,7 +1485,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _
1485 __hold_pointer __hold = __allocate_node(__na);1485 __hold_pointer __hold = __allocate_node(__na);
1486 __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);1486 __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
1487 ++__ds;1487 ++__ds;
1488#if _LIBCPP_DEBUG_LEVEL >= 21488#if _LIBCPP_DEBUG_LEVEL == 2
1489 __r = iterator(__hold->__as_link(), this);1489 __r = iterator(__hold->__as_link(), this);
1490#else1490#else
1491 __r = iterator(__hold->__as_link());1491 __r = iterator(__hold->__as_link());
...@@ -1515,7 +1515,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _...@@ -1515,7 +1515,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _
1515 __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);1515 __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);
1516 if (__prev == 0)1516 if (__prev == 0)
1517 break;1517 break;
1518#if _LIBCPP_DEBUG_LEVEL >= 21518#if _LIBCPP_DEBUG_LEVEL == 2
1519 __e = iterator(__prev, this);1519 __e = iterator(__prev, this);
1520#else1520#else
1521 __e = iterator(__prev);1521 __e = iterator(__prev);
...@@ -1536,7 +1536,7 @@ typename list<_Tp, _Alloc>::iterator...@@ -1536,7 +1536,7 @@ typename list<_Tp, _Alloc>::iterator
1536list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l,1536list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l,
1537 typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type*)1537 typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type*)
1538{1538{
1539#if _LIBCPP_DEBUG_LEVEL >= 21539#if _LIBCPP_DEBUG_LEVEL == 2
1540 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,1540 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
1541 "list::insert(iterator, range) called with an iterator not"1541 "list::insert(iterator, range) called with an iterator not"
1542 " referring to this list");1542 " referring to this list");
...@@ -1551,7 +1551,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l,...@@ -1551,7 +1551,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l,
1551 __hold_pointer __hold = __allocate_node(__na);1551 __hold_pointer __hold = __allocate_node(__na);
1552 __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), *__f);1552 __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), *__f);
1553 ++__ds;1553 ++__ds;
1554#if _LIBCPP_DEBUG_LEVEL >= 21554#if _LIBCPP_DEBUG_LEVEL == 2
1555 __r = iterator(__hold.get()->__as_link(), this);1555 __r = iterator(__hold.get()->__as_link(), this);
1556#else1556#else
1557 __r = iterator(__hold.get()->__as_link());1557 __r = iterator(__hold.get()->__as_link());
...@@ -1581,7 +1581,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l,...@@ -1581,7 +1581,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l,
1581 __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);1581 __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);
1582 if (__prev == 0)1582 if (__prev == 0)
1583 break;1583 break;
1584#if _LIBCPP_DEBUG_LEVEL >= 21584#if _LIBCPP_DEBUG_LEVEL == 2
1585 __e = iterator(__prev, this);1585 __e = iterator(__prev, this);
1586#else1586#else
1587 __e = iterator(__prev);1587 __e = iterator(__prev);
...@@ -1695,7 +1695,7 @@ template <class... _Args>...@@ -1695,7 +1695,7 @@ template <class... _Args>
1695typename list<_Tp, _Alloc>::iterator1695typename list<_Tp, _Alloc>::iterator
1696list<_Tp, _Alloc>::emplace(const_iterator __p, _Args&&... __args)1696list<_Tp, _Alloc>::emplace(const_iterator __p, _Args&&... __args)
1697{1697{
1698#if _LIBCPP_DEBUG_LEVEL >= 21698#if _LIBCPP_DEBUG_LEVEL == 2
1699 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,1699 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
1700 "list::emplace(iterator, args...) called with an iterator not"1700 "list::emplace(iterator, args...) called with an iterator not"
1701 " referring to this list");1701 " referring to this list");
...@@ -1707,7 +1707,7 @@ list<_Tp, _Alloc>::emplace(const_iterator __p, _Args&&... __args)...@@ -1707,7 +1707,7 @@ list<_Tp, _Alloc>::emplace(const_iterator __p, _Args&&... __args)
1707 __link_nodes(__p.__ptr_, __nl, __nl);1707 __link_nodes(__p.__ptr_, __nl, __nl);
1708 ++base::__sz();1708 ++base::__sz();
1709 __hold.release();1709 __hold.release();
1710#if _LIBCPP_DEBUG_LEVEL >= 21710#if _LIBCPP_DEBUG_LEVEL == 2
1711 return iterator(__nl, this);1711 return iterator(__nl, this);
1712#else1712#else
1713 return iterator(__nl);1713 return iterator(__nl);
...@@ -1718,7 +1718,7 @@ template <class _Tp, class _Alloc>...@@ -1718,7 +1718,7 @@ template <class _Tp, class _Alloc>
1718typename list<_Tp, _Alloc>::iterator1718typename list<_Tp, _Alloc>::iterator
1719list<_Tp, _Alloc>::insert(const_iterator __p, value_type&& __x)1719list<_Tp, _Alloc>::insert(const_iterator __p, value_type&& __x)
1720{1720{
1721#if _LIBCPP_DEBUG_LEVEL >= 21721#if _LIBCPP_DEBUG_LEVEL == 2
1722 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,1722 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
1723 "list::insert(iterator, x) called with an iterator not"1723 "list::insert(iterator, x) called with an iterator not"
1724 " referring to this list");1724 " referring to this list");
...@@ -1730,7 +1730,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, value_type&& __x)...@@ -1730,7 +1730,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, value_type&& __x)
1730 __link_nodes(__p.__ptr_, __nl, __nl);1730 __link_nodes(__p.__ptr_, __nl, __nl);
1731 ++base::__sz();1731 ++base::__sz();
1732 __hold.release();1732 __hold.release();
1733#if _LIBCPP_DEBUG_LEVEL >= 21733#if _LIBCPP_DEBUG_LEVEL == 2
1734 return iterator(__nl, this);1734 return iterator(__nl, this);
1735#else1735#else
1736 return iterator(__nl);1736 return iterator(__nl);
...@@ -1748,7 +1748,7 @@ list<_Tp, _Alloc>::pop_front()...@@ -1748,7 +1748,7 @@ list<_Tp, _Alloc>::pop_front()
1748 __link_pointer __n = base::__end_.__next_;1748 __link_pointer __n = base::__end_.__next_;
1749 base::__unlink_nodes(__n, __n);1749 base::__unlink_nodes(__n, __n);
1750 --base::__sz();1750 --base::__sz();
1751#if _LIBCPP_DEBUG_LEVEL >= 21751#if _LIBCPP_DEBUG_LEVEL == 2
1752 __c_node* __c = __get_db()->__find_c_and_lock(this);1752 __c_node* __c = __get_db()->__find_c_and_lock(this);
1753 for (__i_node** __p = __c->end_; __p != __c->beg_; )1753 for (__i_node** __p = __c->end_; __p != __c->beg_; )
1754 {1754 {
...@@ -1758,7 +1758,7 @@ list<_Tp, _Alloc>::pop_front()...@@ -1758,7 +1758,7 @@ list<_Tp, _Alloc>::pop_front()
1758 {1758 {
1759 (*__p)->__c_ = nullptr;1759 (*__p)->__c_ = nullptr;
1760 if (--__c->end_ != __p)1760 if (--__c->end_ != __p)
1761 memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));1761 _VSTD::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
1762 }1762 }
1763 }1763 }
1764 __get_db()->unlock();1764 __get_db()->unlock();
...@@ -1777,7 +1777,7 @@ list<_Tp, _Alloc>::pop_back()...@@ -1777,7 +1777,7 @@ list<_Tp, _Alloc>::pop_back()
1777 __link_pointer __n = base::__end_.__prev_;1777 __link_pointer __n = base::__end_.__prev_;
1778 base::__unlink_nodes(__n, __n);1778 base::__unlink_nodes(__n, __n);
1779 --base::__sz();1779 --base::__sz();
1780#if _LIBCPP_DEBUG_LEVEL >= 21780#if _LIBCPP_DEBUG_LEVEL == 2
1781 __c_node* __c = __get_db()->__find_c_and_lock(this);1781 __c_node* __c = __get_db()->__find_c_and_lock(this);
1782 for (__i_node** __p = __c->end_; __p != __c->beg_; )1782 for (__i_node** __p = __c->end_; __p != __c->beg_; )
1783 {1783 {
...@@ -1787,7 +1787,7 @@ list<_Tp, _Alloc>::pop_back()...@@ -1787,7 +1787,7 @@ list<_Tp, _Alloc>::pop_back()
1787 {1787 {
1788 (*__p)->__c_ = nullptr;1788 (*__p)->__c_ = nullptr;
1789 if (--__c->end_ != __p)1789 if (--__c->end_ != __p)
1790 memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));1790 _VSTD::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
1791 }1791 }
1792 }1792 }
1793 __get_db()->unlock();1793 __get_db()->unlock();
...@@ -1801,7 +1801,7 @@ template <class _Tp, class _Alloc>...@@ -1801,7 +1801,7 @@ template <class _Tp, class _Alloc>
1801typename list<_Tp, _Alloc>::iterator1801typename list<_Tp, _Alloc>::iterator
1802list<_Tp, _Alloc>::erase(const_iterator __p)1802list<_Tp, _Alloc>::erase(const_iterator __p)
1803{1803{
1804#if _LIBCPP_DEBUG_LEVEL >= 21804#if _LIBCPP_DEBUG_LEVEL == 2
1805 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,1805 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
1806 "list::erase(iterator) called with an iterator not"1806 "list::erase(iterator) called with an iterator not"
1807 " referring to this list");1807 " referring to this list");
...@@ -1813,7 +1813,7 @@ list<_Tp, _Alloc>::erase(const_iterator __p)...@@ -1813,7 +1813,7 @@ list<_Tp, _Alloc>::erase(const_iterator __p)
1813 __link_pointer __r = __n->__next_;1813 __link_pointer __r = __n->__next_;
1814 base::__unlink_nodes(__n, __n);1814 base::__unlink_nodes(__n, __n);
1815 --base::__sz();1815 --base::__sz();
1816#if _LIBCPP_DEBUG_LEVEL >= 21816#if _LIBCPP_DEBUG_LEVEL == 2
1817 __c_node* __c = __get_db()->__find_c_and_lock(this);1817 __c_node* __c = __get_db()->__find_c_and_lock(this);
1818 for (__i_node** __ip = __c->end_; __ip != __c->beg_; )1818 for (__i_node** __ip = __c->end_; __ip != __c->beg_; )
1819 {1819 {
...@@ -1823,7 +1823,7 @@ list<_Tp, _Alloc>::erase(const_iterator __p)...@@ -1823,7 +1823,7 @@ list<_Tp, _Alloc>::erase(const_iterator __p)
1823 {1823 {
1824 (*__ip)->__c_ = nullptr;1824 (*__ip)->__c_ = nullptr;
1825 if (--__c->end_ != __ip)1825 if (--__c->end_ != __ip)
1826 memmove(__ip, __ip+1, (__c->end_ - __ip)*sizeof(__i_node*));1826 _VSTD::memmove(__ip, __ip+1, (__c->end_ - __ip)*sizeof(__i_node*));
1827 }1827 }
1828 }1828 }
1829 __get_db()->unlock();1829 __get_db()->unlock();
...@@ -1831,7 +1831,7 @@ list<_Tp, _Alloc>::erase(const_iterator __p)...@@ -1831,7 +1831,7 @@ list<_Tp, _Alloc>::erase(const_iterator __p)
1831 __node_pointer __np = __n->__as_node();1831 __node_pointer __np = __n->__as_node();
1832 __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_));1832 __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_));
1833 __node_alloc_traits::deallocate(__na, __np, 1);1833 __node_alloc_traits::deallocate(__na, __np, 1);
1834#if _LIBCPP_DEBUG_LEVEL >= 21834#if _LIBCPP_DEBUG_LEVEL == 2
1835 return iterator(__r, this);1835 return iterator(__r, this);
1836#else1836#else
1837 return iterator(__r);1837 return iterator(__r);
...@@ -1842,7 +1842,7 @@ template <class _Tp, class _Alloc>...@@ -1842,7 +1842,7 @@ template <class _Tp, class _Alloc>
1842typename list<_Tp, _Alloc>::iterator1842typename list<_Tp, _Alloc>::iterator
1843list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l)1843list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l)
1844{1844{
1845#if _LIBCPP_DEBUG_LEVEL >= 21845#if _LIBCPP_DEBUG_LEVEL == 2
1846 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__f) == this,1846 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__f) == this,
1847 "list::erase(iterator, iterator) called with an iterator not"1847 "list::erase(iterator, iterator) called with an iterator not"
1848 " referring to this list");1848 " referring to this list");
...@@ -1859,7 +1859,7 @@ list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l)...@@ -1859,7 +1859,7 @@ list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l)
1859 __link_pointer __n = __f.__ptr_;1859 __link_pointer __n = __f.__ptr_;
1860 ++__f;1860 ++__f;
1861 --base::__sz();1861 --base::__sz();
1862#if _LIBCPP_DEBUG_LEVEL >= 21862#if _LIBCPP_DEBUG_LEVEL == 2
1863 __c_node* __c = __get_db()->__find_c_and_lock(this);1863 __c_node* __c = __get_db()->__find_c_and_lock(this);
1864 for (__i_node** __p = __c->end_; __p != __c->beg_; )1864 for (__i_node** __p = __c->end_; __p != __c->beg_; )
1865 {1865 {
...@@ -1869,7 +1869,7 @@ list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l)...@@ -1869,7 +1869,7 @@ list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l)
1869 {1869 {
1870 (*__p)->__c_ = nullptr;1870 (*__p)->__c_ = nullptr;
1871 if (--__c->end_ != __p)1871 if (--__c->end_ != __p)
1872 memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));1872 _VSTD::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
1873 }1873 }
1874 }1874 }
1875 __get_db()->unlock();1875 __get_db()->unlock();
...@@ -1879,7 +1879,7 @@ list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l)...@@ -1879,7 +1879,7 @@ list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l)
1879 __node_alloc_traits::deallocate(__na, __np, 1);1879 __node_alloc_traits::deallocate(__na, __np, 1);
1880 }1880 }
1881 }1881 }
1882#if _LIBCPP_DEBUG_LEVEL >= 21882#if _LIBCPP_DEBUG_LEVEL == 2
1883 return iterator(__l.__ptr_, this);1883 return iterator(__l.__ptr_, this);
1884#else1884#else
1885 return iterator(__l.__ptr_);1885 return iterator(__l.__ptr_);
...@@ -1900,7 +1900,7 @@ list<_Tp, _Alloc>::resize(size_type __n)...@@ -1900,7 +1900,7 @@ list<_Tp, _Alloc>::resize(size_type __n)
1900 __hold_pointer __hold = __allocate_node(__na);1900 __hold_pointer __hold = __allocate_node(__na);
1901 __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_));1901 __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_));
1902 ++__ds;1902 ++__ds;
1903#if _LIBCPP_DEBUG_LEVEL >= 21903#if _LIBCPP_DEBUG_LEVEL == 2
1904 iterator __r = iterator(__hold.release()->__as_link(), this);1904 iterator __r = iterator(__hold.release()->__as_link(), this);
1905#else1905#else
1906 iterator __r = iterator(__hold.release()->__as_link());1906 iterator __r = iterator(__hold.release()->__as_link());
...@@ -1929,7 +1929,7 @@ list<_Tp, _Alloc>::resize(size_type __n)...@@ -1929,7 +1929,7 @@ list<_Tp, _Alloc>::resize(size_type __n)
1929 __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);1929 __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);
1930 if (__prev == 0)1930 if (__prev == 0)
1931 break;1931 break;
1932#if _LIBCPP_DEBUG_LEVEL >= 21932#if _LIBCPP_DEBUG_LEVEL == 2
1933 __e = iterator(__prev, this);1933 __e = iterator(__prev, this);
1934#else1934#else
1935 __e = iterator(__prev);1935 __e = iterator(__prev);
...@@ -1958,7 +1958,7 @@ list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x)...@@ -1958,7 +1958,7 @@ list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x)
1958 __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);1958 __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
1959 ++__ds;1959 ++__ds;
1960 __link_pointer __nl = __hold.release()->__as_link();1960 __link_pointer __nl = __hold.release()->__as_link();
1961#if _LIBCPP_DEBUG_LEVEL >= 21961#if _LIBCPP_DEBUG_LEVEL == 2
1962 iterator __r = iterator(__nl, this);1962 iterator __r = iterator(__nl, this);
1963#else1963#else
1964 iterator __r = iterator(__nl);1964 iterator __r = iterator(__nl);
...@@ -1987,7 +1987,7 @@ list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x)...@@ -1987,7 +1987,7 @@ list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x)
1987 __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);1987 __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);
1988 if (__prev == 0)1988 if (__prev == 0)
1989 break;1989 break;
1990#if _LIBCPP_DEBUG_LEVEL >= 21990#if _LIBCPP_DEBUG_LEVEL == 2
1991 __e = iterator(__prev, this);1991 __e = iterator(__prev, this);
1992#else1992#else
1993 __e = iterator(__prev);1993 __e = iterator(__prev);
...@@ -2007,7 +2007,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c)...@@ -2007,7 +2007,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c)
2007{2007{
2008 _LIBCPP_ASSERT(this != &__c,2008 _LIBCPP_ASSERT(this != &__c,
2009 "list::splice(iterator, list) called with this == &list");2009 "list::splice(iterator, list) called with this == &list");
2010#if _LIBCPP_DEBUG_LEVEL >= 22010#if _LIBCPP_DEBUG_LEVEL == 2
2011 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,2011 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
2012 "list::splice(iterator, list) called with an iterator not"2012 "list::splice(iterator, list) called with an iterator not"
2013 " referring to this list");2013 " referring to this list");
...@@ -2020,7 +2020,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c)...@@ -2020,7 +2020,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c)
2020 __link_nodes(__p.__ptr_, __f, __l);2020 __link_nodes(__p.__ptr_, __f, __l);
2021 base::__sz() += __c.__sz();2021 base::__sz() += __c.__sz();
2022 __c.__sz() = 0;2022 __c.__sz() = 0;
2023#if _LIBCPP_DEBUG_LEVEL >= 22023#if _LIBCPP_DEBUG_LEVEL == 2
2024 if (&__c != this) {2024 if (&__c != this) {
2025 __libcpp_db* __db = __get_db();2025 __libcpp_db* __db = __get_db();
2026 __c_node* __cn1 = __db->__find_c_and_lock(this);2026 __c_node* __cn1 = __db->__find_c_and_lock(this);
...@@ -2034,7 +2034,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c)...@@ -2034,7 +2034,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c)
2034 __cn1->__add(*__ip);2034 __cn1->__add(*__ip);
2035 (*__ip)->__c_ = __cn1;2035 (*__ip)->__c_ = __cn1;
2036 if (--__cn2->end_ != __ip)2036 if (--__cn2->end_ != __ip)
2037 memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*));2037 _VSTD::memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*));
2038 }2038 }
2039 }2039 }
2040 __db->unlock();2040 __db->unlock();
...@@ -2047,7 +2047,7 @@ template <class _Tp, class _Alloc>...@@ -2047,7 +2047,7 @@ template <class _Tp, class _Alloc>
2047void2047void
2048list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i)2048list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i)
2049{2049{
2050#if _LIBCPP_DEBUG_LEVEL >= 22050#if _LIBCPP_DEBUG_LEVEL == 2
2051 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,2051 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
2052 "list::splice(iterator, list, iterator) called with first iterator not"2052 "list::splice(iterator, list, iterator) called with first iterator not"
2053 " referring to this list");2053 " referring to this list");
...@@ -2056,7 +2056,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i)...@@ -2056,7 +2056,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i)
2056 " referring to list argument");2056 " referring to list argument");
2057 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(&__i),2057 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(&__i),
2058 "list::splice(iterator, list, iterator) called with second iterator not"2058 "list::splice(iterator, list, iterator) called with second iterator not"
2059 " derefereceable");2059 " dereferenceable");
2060#endif2060#endif
2061 if (__p.__ptr_ != __i.__ptr_ && __p.__ptr_ != __i.__ptr_->__next_)2061 if (__p.__ptr_ != __i.__ptr_ && __p.__ptr_ != __i.__ptr_->__next_)
2062 {2062 {
...@@ -2065,7 +2065,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i)...@@ -2065,7 +2065,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i)
2065 __link_nodes(__p.__ptr_, __f, __f);2065 __link_nodes(__p.__ptr_, __f, __f);
2066 --__c.__sz();2066 --__c.__sz();
2067 ++base::__sz();2067 ++base::__sz();
2068#if _LIBCPP_DEBUG_LEVEL >= 22068#if _LIBCPP_DEBUG_LEVEL == 2
2069 if (&__c != this) {2069 if (&__c != this) {
2070 __libcpp_db* __db = __get_db();2070 __libcpp_db* __db = __get_db();
2071 __c_node* __cn1 = __db->__find_c_and_lock(this);2071 __c_node* __cn1 = __db->__find_c_and_lock(this);
...@@ -2079,7 +2079,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i)...@@ -2079,7 +2079,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i)
2079 __cn1->__add(*__ip);2079 __cn1->__add(*__ip);
2080 (*__ip)->__c_ = __cn1;2080 (*__ip)->__c_ = __cn1;
2081 if (--__cn2->end_ != __ip)2081 if (--__cn2->end_ != __ip)
2082 memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*));2082 _VSTD::memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*));
2083 }2083 }
2084 }2084 }
2085 __db->unlock();2085 __db->unlock();
...@@ -2092,7 +2092,7 @@ template <class _Tp, class _Alloc>...@@ -2092,7 +2092,7 @@ template <class _Tp, class _Alloc>
2092void2092void
2093list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l)2093list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l)
2094{2094{
2095#if _LIBCPP_DEBUG_LEVEL >= 22095#if _LIBCPP_DEBUG_LEVEL == 2
2096 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,2096 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
2097 "list::splice(iterator, list, iterator, iterator) called with first iterator not"2097 "list::splice(iterator, list, iterator, iterator) called with first iterator not"
2098 " referring to this list");2098 " referring to this list");
...@@ -2121,7 +2121,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, con...@@ -2121,7 +2121,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, con
2121 }2121 }
2122 base::__unlink_nodes(__first, __last);2122 base::__unlink_nodes(__first, __last);
2123 __link_nodes(__p.__ptr_, __first, __last);2123 __link_nodes(__p.__ptr_, __first, __last);
2124#if _LIBCPP_DEBUG_LEVEL >= 22124#if _LIBCPP_DEBUG_LEVEL == 2
2125 if (&__c != this) {2125 if (&__c != this) {
2126 __libcpp_db* __db = __get_db();2126 __libcpp_db* __db = __get_db();
2127 __c_node* __cn1 = __db->__find_c_and_lock(this);2127 __c_node* __cn1 = __db->__find_c_and_lock(this);
...@@ -2138,7 +2138,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, con...@@ -2138,7 +2138,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, con
2138 __cn1->__add(*__ip);2138 __cn1->__add(*__ip);
2139 (*__ip)->__c_ = __cn1;2139 (*__ip)->__c_ = __cn1;
2140 if (--__cn2->end_ != __ip)2140 if (--__cn2->end_ != __ip)
2141 memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*));2141 _VSTD::memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*));
2142 }2142 }
2143 }2143 }
2144 }2144 }
...@@ -2258,7 +2258,7 @@ list<_Tp, _Alloc>::merge(list& __c, _Comp __comp)...@@ -2258,7 +2258,7 @@ list<_Tp, _Alloc>::merge(list& __c, _Comp __comp)
2258 ++__f1;2258 ++__f1;
2259 }2259 }
2260 splice(__e1, __c);2260 splice(__e1, __c);
2261#if _LIBCPP_DEBUG_LEVEL >= 22261#if _LIBCPP_DEBUG_LEVEL == 2
2262 __libcpp_db* __db = __get_db();2262 __libcpp_db* __db = __get_db();
2263 __c_node* __cn1 = __db->__find_c_and_lock(this);2263 __c_node* __cn1 = __db->__find_c_and_lock(this);
2264 __c_node* __cn2 = __db->__find_c(&__c);2264 __c_node* __cn2 = __db->__find_c(&__c);
...@@ -2271,7 +2271,7 @@ list<_Tp, _Alloc>::merge(list& __c, _Comp __comp)...@@ -2271,7 +2271,7 @@ list<_Tp, _Alloc>::merge(list& __c, _Comp __comp)
2271 __cn1->__add(*__p);2271 __cn1->__add(*__p);
2272 (*__p)->__c_ = __cn1;2272 (*__p)->__c_ = __cn1;
2273 if (--__cn2->end_ != __p)2273 if (--__cn2->end_ != __p)
2274 memmove(__p, __p+1, (__cn2->end_ - __p)*sizeof(__i_node*));2274 _VSTD::memmove(__p, __p+1, (__cn2->end_ - __p)*sizeof(__i_node*));
2275 }2275 }
2276 }2276 }
2277 __db->unlock();2277 __db->unlock();
...@@ -2382,7 +2382,7 @@ list<_Tp, _Alloc>::__invariants() const...@@ -2382,7 +2382,7 @@ list<_Tp, _Alloc>::__invariants() const
2382 return size() == _VSTD::distance(begin(), end());2382 return size() == _VSTD::distance(begin(), end());
2383}2383}
23842384
2385#if _LIBCPP_DEBUG_LEVEL >= 22385#if _LIBCPP_DEBUG_LEVEL == 2
23862386
2387template <class _Tp, class _Alloc>2387template <class _Tp, class _Alloc>
2388bool2388bool
...@@ -2412,7 +2412,7 @@ list<_Tp, _Alloc>::__subscriptable(const const_iterator*, ptrdiff_t) const...@@ -2412,7 +2412,7 @@ list<_Tp, _Alloc>::__subscriptable(const const_iterator*, ptrdiff_t) const
2412 return false;2412 return false;
2413}2413}
24142414
2415#endif // _LIBCPP_DEBUG_LEVEL >= 22415#endif // _LIBCPP_DEBUG_LEVEL == 2
24162416
2417template <class _Tp, class _Alloc>2417template <class _Tp, class _Alloc>
2418inline _LIBCPP_INLINE_VISIBILITY2418inline _LIBCPP_INLINE_VISIBILITY
lib/libcxx/include/locale+63-67
...@@ -197,10 +197,6 @@ template <class charT> class messages_byname;...@@ -197,10 +197,6 @@ template <class charT> class messages_byname;
197#include <nl_types.h>197#include <nl_types.h>
198#endif198#endif
199199
200#ifdef __APPLE__
201#include <Availability.h>
202#endif
203
204#ifdef _LIBCPP_LOCALE__L_EXTENSIONS200#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
205#include <__bsd_locale_defaults.h>201#include <__bsd_locale_defaults.h>
206#else202#else
...@@ -261,11 +257,11 @@ __scan_keyword(_InputIterator& __b, _InputIterator __e,...@@ -261,11 +257,11 @@ __scan_keyword(_InputIterator& __b, _InputIterator __e,
261 const unsigned char __does_match = '\2';257 const unsigned char __does_match = '\2';
262 unsigned char __statbuf[100];258 unsigned char __statbuf[100];
263 unsigned char* __status = __statbuf;259 unsigned char* __status = __statbuf;
264 unique_ptr<unsigned char, void(*)(void*)> __stat_hold(0, free);260 unique_ptr<unsigned char, void(*)(void*)> __stat_hold(nullptr, free);
265 if (__nkw > sizeof(__statbuf))261 if (__nkw > sizeof(__statbuf))
266 {262 {
267 __status = (unsigned char*)malloc(__nkw);263 __status = (unsigned char*)malloc(__nkw);
268 if (__status == 0)264 if (__status == nullptr)
269 __throw_bad_alloc();265 __throw_bad_alloc();
270 __stat_hold.reset(__status);266 __stat_hold.reset(__status);
271 }267 }
...@@ -561,8 +557,8 @@ __num_get<_CharT>::__stage2_float_loop(_CharT __ct, bool& __in_units, char& __ex...@@ -561,8 +557,8 @@ __num_get<_CharT>::__stage2_float_loop(_CharT __ct, bool& __in_units, char& __ex
561 return 0;557 return 0;
562}558}
563559
564_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<char>)560_LIBCPP_EXTERN_TEMPLATE(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<char>)
565_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<wchar_t>)561_LIBCPP_EXTERN_TEMPLATE(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<wchar_t>)
566562
567template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >563template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
568class _LIBCPP_TEMPLATE_VIS num_get564class _LIBCPP_TEMPLATE_VIS num_get
...@@ -877,8 +873,8 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,...@@ -877,8 +873,8 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
877 const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__iob.getloc());873 const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__iob.getloc());
878 typedef typename numpunct<_CharT>::string_type string_type;874 typedef typename numpunct<_CharT>::string_type string_type;
879 const string_type __names[2] = {__np.truename(), __np.falsename()};875 const string_type __names[2] = {__np.truename(), __np.falsename()};
880 const string_type* __i = __scan_keyword(__b, __e, __names, __names+2,876 const string_type* __i = _VSTD::__scan_keyword(__b, __e, __names, __names+2,
881 __ct, __err);877 __ct, __err);
882 __v = __i == __names;878 __v = __i == __names;
883 return __b;879 return __b;
884}880}
...@@ -1099,8 +1095,8 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,...@@ -1099,8 +1095,8 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
1099 return __b;1095 return __b;
1100}1096}
11011097
1102_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<char>)1098_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<char>)
1103_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<wchar_t>)1099_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<wchar_t>)
11041100
1105struct _LIBCPP_TYPE_VIS __num_put_base1101struct _LIBCPP_TYPE_VIS __num_put_base
1106{1102{
...@@ -1249,8 +1245,8 @@ __num_put<_CharT>::__widen_and_group_float(char* __nb, char* __np, char* __ne,...@@ -1249,8 +1245,8 @@ __num_put<_CharT>::__widen_and_group_float(char* __nb, char* __np, char* __ne,
1249 __op = __ob + (__np - __nb);1245 __op = __ob + (__np - __nb);
1250}1246}
12511247
1252_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<char>)1248_LIBCPP_EXTERN_TEMPLATE(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<char>)
1253_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<wchar_t>)1249_LIBCPP_EXTERN_TEMPLATE(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<wchar_t>)
12541250
1255template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >1251template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
1256class _LIBCPP_TEMPLATE_VIS num_put1252class _LIBCPP_TEMPLATE_VIS num_put
...@@ -1427,7 +1423,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,...@@ -1427,7 +1423,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
1427 return do_put(__s, __iob, __fl, (unsigned long)__v);1423 return do_put(__s, __iob, __fl, (unsigned long)__v);
1428 const numpunct<char_type>& __np = use_facet<numpunct<char_type> >(__iob.getloc());1424 const numpunct<char_type>& __np = use_facet<numpunct<char_type> >(__iob.getloc());
1429 typedef typename numpunct<char_type>::string_type string_type;1425 typedef typename numpunct<char_type>::string_type string_type;
1430#if _LIBCPP_DEBUG_LEVEL >= 21426#if _LIBCPP_DEBUG_LEVEL == 2
1431 string_type __tmp(__v ? __np.truename() : __np.falsename());1427 string_type __tmp(__v ? __np.truename() : __np.falsename());
1432 string_type __nm = _VSTD::move(__tmp);1428 string_type __nm = _VSTD::move(__tmp);
1433#else1429#else
...@@ -1564,14 +1560,14 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,...@@ -1564,14 +1560,14 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
1564 (int)__iob.precision(), __v);1560 (int)__iob.precision(), __v);
1565 else1561 else
1566 __nc = __libcpp_snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v);1562 __nc = __libcpp_snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v);
1567 unique_ptr<char, void(*)(void*)> __nbh(0, free);1563 unique_ptr<char, void(*)(void*)> __nbh(nullptr, free);
1568 if (__nc > static_cast<int>(__nbuf-1))1564 if (__nc > static_cast<int>(__nbuf-1))
1569 {1565 {
1570 if (__specify_precision)1566 if (__specify_precision)
1571 __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);1567 __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);
1572 else1568 else
1573 __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v);1569 __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v);
1574 if (__nb == 0)1570 if (__nb == nullptr)
1575 __throw_bad_alloc();1571 __throw_bad_alloc();
1576 __nbh.reset(__nb);1572 __nbh.reset(__nb);
1577 }1573 }
...@@ -1615,14 +1611,14 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,...@@ -1615,14 +1611,14 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
1615 (int)__iob.precision(), __v);1611 (int)__iob.precision(), __v);
1616 else1612 else
1617 __nc = __libcpp_snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v);1613 __nc = __libcpp_snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v);
1618 unique_ptr<char, void(*)(void*)> __nbh(0, free);1614 unique_ptr<char, void(*)(void*)> __nbh(nullptr, free);
1619 if (__nc > static_cast<int>(__nbuf-1))1615 if (__nc > static_cast<int>(__nbuf-1))
1620 {1616 {
1621 if (__specify_precision)1617 if (__specify_precision)
1622 __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);1618 __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);
1623 else1619 else
1624 __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v);1620 __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v);
1625 if (__nb == 0)1621 if (__nb == nullptr)
1626 __throw_bad_alloc();1622 __throw_bad_alloc();
1627 __nbh.reset(__nb);1623 __nbh.reset(__nb);
1628 }1624 }
...@@ -1676,8 +1672,8 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,...@@ -1676,8 +1672,8 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
1676 return __pad_and_output(__s, __o, __op, __oe, __iob, __fl);1672 return __pad_and_output(__s, __o, __op, __oe, __iob, __fl);
1677}1673}
16781674
1679_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<char>)1675_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<char>)
1680_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<wchar_t>)1676_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<wchar_t>)
16811677
1682template <class _CharT, class _InputIterator>1678template <class _CharT, class _InputIterator>
1683_LIBCPP_HIDDEN1679_LIBCPP_HIDDEN
...@@ -1916,7 +1912,7 @@ time_get<_CharT, _InputIterator>::__get_weekdayname(int& __w,...@@ -1916,7 +1912,7 @@ time_get<_CharT, _InputIterator>::__get_weekdayname(int& __w,
1916{1912{
1917 // Note: ignoring case comes from the POSIX strptime spec1913 // Note: ignoring case comes from the POSIX strptime spec
1918 const string_type* __wk = this->__weeks();1914 const string_type* __wk = this->__weeks();
1919 ptrdiff_t __i = __scan_keyword(__b, __e, __wk, __wk+14, __ct, __err, false) - __wk;1915 ptrdiff_t __i = _VSTD::__scan_keyword(__b, __e, __wk, __wk+14, __ct, __err, false) - __wk;
1920 if (__i < 14)1916 if (__i < 14)
1921 __w = __i % 7;1917 __w = __i % 7;
1922}1918}
...@@ -1930,7 +1926,7 @@ time_get<_CharT, _InputIterator>::__get_monthname(int& __m,...@@ -1930,7 +1926,7 @@ time_get<_CharT, _InputIterator>::__get_monthname(int& __m,
1930{1926{
1931 // Note: ignoring case comes from the POSIX strptime spec1927 // Note: ignoring case comes from the POSIX strptime spec
1932 const string_type* __month = this->__months();1928 const string_type* __month = this->__months();
1933 ptrdiff_t __i = __scan_keyword(__b, __e, __month, __month+24, __ct, __err, false) - __month;1929 ptrdiff_t __i = _VSTD::__scan_keyword(__b, __e, __month, __month+24, __ct, __err, false) - __month;
1934 if (__i < 24)1930 if (__i < 24)
1935 __m = __i % 12;1931 __m = __i % 12;
1936}1932}
...@@ -1942,7 +1938,7 @@ time_get<_CharT, _InputIterator>::__get_day(int& __d,...@@ -1942,7 +1938,7 @@ time_get<_CharT, _InputIterator>::__get_day(int& __d,
1942 ios_base::iostate& __err,1938 ios_base::iostate& __err,
1943 const ctype<char_type>& __ct) const1939 const ctype<char_type>& __ct) const
1944{1940{
1945 int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 2);1941 int __t = _VSTD::__get_up_to_n_digits(__b, __e, __err, __ct, 2);
1946 if (!(__err & ios_base::failbit) && 1 <= __t && __t <= 31)1942 if (!(__err & ios_base::failbit) && 1 <= __t && __t <= 31)
1947 __d = __t;1943 __d = __t;
1948 else1944 else
...@@ -2102,7 +2098,7 @@ time_get<_CharT, _InputIterator>::__get_am_pm(int& __h,...@@ -2102,7 +2098,7 @@ time_get<_CharT, _InputIterator>::__get_am_pm(int& __h,
2102 __err |= ios_base::failbit;2098 __err |= ios_base::failbit;
2103 return;2099 return;
2104 }2100 }
2105 ptrdiff_t __i = __scan_keyword(__b, __e, __ap, __ap+2, __ct, __err, false) - __ap;2101 ptrdiff_t __i = _VSTD::__scan_keyword(__b, __e, __ap, __ap+2, __ct, __err, false) - __ap;
2106 if (__i == 0 && __h == 12)2102 if (__i == 0 && __h == 12)
2107 __h = 0;2103 __h = 0;
2108 else if (__i == 1 && __h < 12)2104 else if (__i == 1 && __h < 12)
...@@ -2362,8 +2358,8 @@ time_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,...@@ -2362,8 +2358,8 @@ time_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
2362 return __b;2358 return __b;
2363}2359}
23642360
2365_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<char>)2361_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<char>)
2366_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<wchar_t>)2362_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<wchar_t>)
23672363
2368class _LIBCPP_TYPE_VIS __time_get2364class _LIBCPP_TYPE_VIS __time_get
2369{2365{
...@@ -2462,8 +2458,8 @@ private:...@@ -2462,8 +2458,8 @@ private:
2462 virtual const string_type& __X() const {return this->__X_;}2458 virtual const string_type& __X() const {return this->__X_;}
2463};2459};
24642460
2465_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<char>)2461_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<char>)
2466_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<wchar_t>)2462_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<wchar_t>)
24672463
2468class _LIBCPP_TYPE_VIS __time_put2464class _LIBCPP_TYPE_VIS __time_put
2469{2465{
...@@ -2575,8 +2571,8 @@ time_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base&,...@@ -2575,8 +2571,8 @@ time_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base&,
2575 return _VSTD::copy(__nb, __ne, __s);2571 return _VSTD::copy(__nb, __ne, __s);
2576}2572}
25772573
2578_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<char>)2574_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<char>)
2579_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<wchar_t>)2575_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<wchar_t>)
25802576
2581template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >2577template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
2582class _LIBCPP_TEMPLATE_VIS time_put_byname2578class _LIBCPP_TEMPLATE_VIS time_put_byname
...@@ -2596,8 +2592,8 @@ protected:...@@ -2596,8 +2592,8 @@ protected:
2596 ~time_put_byname() {}2592 ~time_put_byname() {}
2597};2593};
25982594
2599_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<char>)2595_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<char>)
2600_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<wchar_t>)2596_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<wchar_t>)
26012597
2602// money_base2598// money_base
26032599
...@@ -2663,10 +2659,10 @@ template <class _CharT, bool _International>...@@ -2663,10 +2659,10 @@ template <class _CharT, bool _International>
2663const bool2659const bool
2664moneypunct<_CharT, _International>::intl;2660moneypunct<_CharT, _International>::intl;
26652661
2666_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, false>)2662_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, false>)
2667_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, true>)2663_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, true>)
2668_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, false>)2664_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, false>)
2669_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, true>)2665_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, true>)
26702666
2671// moneypunct_byname2667// moneypunct_byname
26722668
...@@ -2720,10 +2716,10 @@ template<> _LIBCPP_FUNC_VIS void moneypunct_byname<char, true>::init(const char*...@@ -2720,10 +2716,10 @@ template<> _LIBCPP_FUNC_VIS void moneypunct_byname<char, true>::init(const char*
2720template<> _LIBCPP_FUNC_VIS void moneypunct_byname<wchar_t, false>::init(const char*);2716template<> _LIBCPP_FUNC_VIS void moneypunct_byname<wchar_t, false>::init(const char*);
2721template<> _LIBCPP_FUNC_VIS void moneypunct_byname<wchar_t, true>::init(const char*);2717template<> _LIBCPP_FUNC_VIS void moneypunct_byname<wchar_t, true>::init(const char*);
27222718
2723_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, false>)2719_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, false>)
2724_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, true>)2720_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, true>)
2725_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, false>)2721_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, false>)
2726_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, true>)2722_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, true>)
27272723
2728// money_get2724// money_get
27292725
...@@ -2779,8 +2775,8 @@ __money_get<_CharT>::__gather_info(bool __intl, const locale& __loc,...@@ -2779,8 +2775,8 @@ __money_get<_CharT>::__gather_info(bool __intl, const locale& __loc,
2779 }2775 }
2780}2776}
27812777
2782_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<char>)2778_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<char>)
2783_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<wchar_t>)2779_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<wchar_t>)
27842780
2785template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >2781template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
2786class _LIBCPP_TEMPLATE_VIS money_get2782class _LIBCPP_TEMPLATE_VIS money_get
...@@ -3108,11 +3104,11 @@ money_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,...@@ -3108,11 +3104,11 @@ money_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
3108 __ct.widen(__src, __src + (sizeof(__src)-1), __atoms);3104 __ct.widen(__src, __src + (sizeof(__src)-1), __atoms);
3109 char __nbuf[__bz];3105 char __nbuf[__bz];
3110 char* __nc = __nbuf;3106 char* __nc = __nbuf;
3111 unique_ptr<char, void(*)(void*)> __h(0, free);3107 unique_ptr<char, void(*)(void*)> __h(nullptr, free);
3112 if (__wn - __wb.get() > __bz-2)3108 if (__wn - __wb.get() > __bz-2)
3113 {3109 {
3114 __h.reset((char*)malloc(static_cast<size_t>(__wn - __wb.get() + 2)));3110 __h.reset((char*)malloc(static_cast<size_t>(__wn - __wb.get() + 2)));
3115 if (__h.get() == 0)3111 if (__h.get() == nullptr)
3116 __throw_bad_alloc();3112 __throw_bad_alloc();
3117 __nc = __h.get();3113 __nc = __h.get();
3118 }3114 }
...@@ -3162,8 +3158,8 @@ money_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,...@@ -3162,8 +3158,8 @@ money_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
3162 return __b;3158 return __b;
3163}3159}
31643160
3165_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<char>)3161_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<char>)
3166_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<wchar_t>)3162_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<wchar_t>)
31673163
3168// money_put3164// money_put
31693165
...@@ -3337,8 +3333,8 @@ __money_put<_CharT>::__format(char_type* __mb, char_type*& __mi, char_type*& __m...@@ -3337,8 +3333,8 @@ __money_put<_CharT>::__format(char_type* __mb, char_type*& __mi, char_type*& __m
3337 __mi = __mb;3333 __mi = __mb;
3338}3334}
33393335
3340_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<char>)3336_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<char>)
3341_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<wchar_t>)3337_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<wchar_t>)
33423338
3343template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >3339template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
3344class _LIBCPP_TEMPLATE_VIS money_put3340class _LIBCPP_TEMPLATE_VIS money_put
...@@ -3397,13 +3393,13 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,...@@ -3397,13 +3393,13 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,
3397 char_type __digits[__bs];3393 char_type __digits[__bs];
3398 char_type* __db = __digits;3394 char_type* __db = __digits;
3399 size_t __n = static_cast<size_t>(snprintf(__bb, __bs, "%.0Lf", __units));3395 size_t __n = static_cast<size_t>(snprintf(__bb, __bs, "%.0Lf", __units));
3400 unique_ptr<char, void(*)(void*)> __hn(0, free);3396 unique_ptr<char, void(*)(void*)> __hn(nullptr, free);
3401 unique_ptr<char_type, void(*)(void*)> __hd(0, free);3397 unique_ptr<char_type, void(*)(void*)> __hd(0, free);
3402 // secure memory for digit storage3398 // secure memory for digit storage
3403 if (__n > __bs-1)3399 if (__n > __bs-1)
3404 {3400 {
3405 __n = static_cast<size_t>(__libcpp_asprintf_l(&__bb, _LIBCPP_GET_C_LOCALE, "%.0Lf", __units));3401 __n = static_cast<size_t>(__libcpp_asprintf_l(&__bb, _LIBCPP_GET_C_LOCALE, "%.0Lf", __units));
3406 if (__bb == 0)3402 if (__bb == nullptr)
3407 __throw_bad_alloc();3403 __throw_bad_alloc();
3408 __hn.reset(__bb);3404 __hn.reset(__bb);
3409 __hd.reset((char_type*)malloc(__n * sizeof(char_type)));3405 __hd.reset((char_type*)malloc(__n * sizeof(char_type)));
...@@ -3490,8 +3486,8 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,...@@ -3490,8 +3486,8 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,
3490 return __pad_and_output(__s, __mb, __mi, __me, __iob, __fl);3486 return __pad_and_output(__s, __mb, __mi, __me, __iob, __fl);
3491}3487}
34923488
3493_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<char>)3489_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<char>)
3494_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<wchar_t>)3490_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<wchar_t>)
34953491
3496// messages3492// messages
34973493
...@@ -3582,7 +3578,7 @@ messages<_CharT>::do_get(catalog __c, int __set, int __msgid,...@@ -3582,7 +3578,7 @@ messages<_CharT>::do_get(catalog __c, int __set, int __msgid,
3582 char* __n = catgets(__cat, __set, __msgid, __ndflt.c_str());3578 char* __n = catgets(__cat, __set, __msgid, __ndflt.c_str());
3583 string_type __w;3579 string_type __w;
3584 __widen_from_utf8<sizeof(char_type)*__CHAR_BIT__>()(back_inserter(__w),3580 __widen_from_utf8<sizeof(char_type)*__CHAR_BIT__>()(back_inserter(__w),
3585 __n, __n + strlen(__n));3581 __n, __n + _VSTD::strlen(__n));
3586 return __w;3582 return __w;
3587#else // !_LIBCPP_HAS_CATOPEN3583#else // !_LIBCPP_HAS_CATOPEN
3588 _LIBCPP_UNUSED_VAR(__c);3584 _LIBCPP_UNUSED_VAR(__c);
...@@ -3606,8 +3602,8 @@ messages<_CharT>::do_close(catalog __c) const...@@ -3606,8 +3602,8 @@ messages<_CharT>::do_close(catalog __c) const
3606#endif // _LIBCPP_HAS_CATOPEN3602#endif // _LIBCPP_HAS_CATOPEN
3607}3603}
36083604
3609_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<char>)3605_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<char>)
3610_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<wchar_t>)3606_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<wchar_t>)
36113607
3612template <class _CharT>3608template <class _CharT>
3613class _LIBCPP_TEMPLATE_VIS messages_byname3609class _LIBCPP_TEMPLATE_VIS messages_byname
...@@ -3630,8 +3626,8 @@ protected:...@@ -3630,8 +3626,8 @@ protected:
3630 ~messages_byname() {}3626 ~messages_byname() {}
3631};3627};
36323628
3633_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<char>)3629_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<char>)
3634_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<wchar_t>)3630_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<wchar_t>)
36353631
3636template<class _Codecvt, class _Elem = wchar_t,3632template<class _Codecvt, class _Elem = wchar_t,
3637 class _Wide_alloc = allocator<_Elem>,3633 class _Wide_alloc = allocator<_Elem>,
...@@ -3923,7 +3919,7 @@ private:...@@ -3923,7 +3919,7 @@ private:
3923 wbuffer_convert(const wbuffer_convert&);3919 wbuffer_convert(const wbuffer_convert&);
3924 wbuffer_convert& operator=(const wbuffer_convert&);3920 wbuffer_convert& operator=(const wbuffer_convert&);
3925public:3921public:
3926 _LIBCPP_EXPLICIT_AFTER_CXX11 wbuffer_convert(streambuf* __bytebuf = 0,3922 _LIBCPP_EXPLICIT_AFTER_CXX11 wbuffer_convert(streambuf* __bytebuf = nullptr,
3927 _Codecvt* __pcvt = new _Codecvt, state_type __state = state_type());3923 _Codecvt* __pcvt = new _Codecvt, state_type __state = state_type());
3928 ~wbuffer_convert();3924 ~wbuffer_convert();
39293925
...@@ -3961,9 +3957,9 @@ private:...@@ -3961,9 +3957,9 @@ private:
3961template <class _Codecvt, class _Elem, class _Tr>3957template <class _Codecvt, class _Elem, class _Tr>
3962wbuffer_convert<_Codecvt, _Elem, _Tr>::3958wbuffer_convert<_Codecvt, _Elem, _Tr>::
3963 wbuffer_convert(streambuf* __bytebuf, _Codecvt* __pcvt, state_type __state)3959 wbuffer_convert(streambuf* __bytebuf, _Codecvt* __pcvt, state_type __state)
3964 : __extbuf_(0),3960 : __extbuf_(nullptr),
3965 __extbufnext_(0),3961 __extbufnext_(nullptr),
3966 __extbufend_(0),3962 __extbufend_(nullptr),
3967 __ebs_(0),3963 __ebs_(0),
3968 __intbuf_(0),3964 __intbuf_(0),
3969 __ibs_(0),3965 __ibs_(0),
...@@ -4003,7 +3999,7 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::underflow()...@@ -4003,7 +3999,7 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::underflow()
4003 int_type __c = traits_type::eof();3999 int_type __c = traits_type::eof();
4004 if (this->gptr() == this->egptr())4000 if (this->gptr() == this->egptr())
4005 {4001 {
4006 memmove(this->eback(), this->egptr() - __unget_sz, __unget_sz * sizeof(char_type));4002 _VSTD::memmove(this->eback(), this->egptr() - __unget_sz, __unget_sz * sizeof(char_type));
4007 if (__always_noconv_)4003 if (__always_noconv_)
4008 {4004 {
4009 streamsize __nmemb = static_cast<streamsize>(this->egptr() - this->eback() - __unget_sz);4005 streamsize __nmemb = static_cast<streamsize>(this->egptr() - this->eback() - __unget_sz);
...@@ -4020,7 +4016,7 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::underflow()...@@ -4020,7 +4016,7 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::underflow()
4020 {4016 {
4021 _LIBCPP_ASSERT(!(__extbufnext_ == NULL && (__extbufend_ != __extbufnext_)), "underflow moving from NULL" );4017 _LIBCPP_ASSERT(!(__extbufnext_ == NULL && (__extbufend_ != __extbufnext_)), "underflow moving from NULL" );
4022 if (__extbufend_ != __extbufnext_)4018 if (__extbufend_ != __extbufnext_)
4023 memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);4019 _VSTD::memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);
4024 __extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_);4020 __extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_);
4025 __extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? sizeof(__extbuf_min_) : __ebs_);4021 __extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? sizeof(__extbuf_min_) : __ebs_);
4026 streamsize __nmemb = _VSTD::min(static_cast<streamsize>(this->egptr() - this->eback() - __unget_sz),4022 streamsize __nmemb = _VSTD::min(static_cast<streamsize>(this->egptr() - this->eback() - __unget_sz),
...@@ -4336,12 +4332,12 @@ template <class _Codecvt, class _Elem, class _Tr>...@@ -4336,12 +4332,12 @@ template <class _Codecvt, class _Elem, class _Tr>
4336wbuffer_convert<_Codecvt, _Elem, _Tr>*4332wbuffer_convert<_Codecvt, _Elem, _Tr>*
4337wbuffer_convert<_Codecvt, _Elem, _Tr>::__close()4333wbuffer_convert<_Codecvt, _Elem, _Tr>::__close()
4338{4334{
4339 wbuffer_convert* __rt = 0;4335 wbuffer_convert* __rt = nullptr;
4340 if (__cv_ != 0 && __bufptr_ != 0)4336 if (__cv_ != nullptr && __bufptr_ != nullptr)
4341 {4337 {
4342 __rt = this;4338 __rt = this;
4343 if ((__cm_ & ios_base::out) && sync())4339 if ((__cm_ & ios_base::out) && sync())
4344 __rt = 0;4340 __rt = nullptr;
4345 }4341 }
4346 return __rt;4342 return __rt;
4347}4343}
lib/libcxx/include/locale.h+5-1
...@@ -35,8 +35,12 @@ Functions:...@@ -35,8 +35,12 @@ Functions:
3535
36#include <__config>36#include <__config>
3737
38#if defined(_LIBCPP_HAS_NO_LOCALIZATION)
39# error "Localization is not supported by this configuration of libc++"
40#endif
41
38#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)42#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
39#pragma GCC system_header43# pragma GCC system_header
40#endif44#endif
4145
42#include_next <locale.h>46#include_next <locale.h>
lib/libcxx/include/map+25-25
...@@ -1230,7 +1230,7 @@ public:...@@ -1230,7 +1230,7 @@ public:
1230 return __tree_.__emplace_hint_unique_key_args(__h.__i_, __k,1230 return __tree_.__emplace_hint_unique_key_args(__h.__i_, __k,
1231 _VSTD::piecewise_construct,1231 _VSTD::piecewise_construct,
1232 _VSTD::forward_as_tuple(__k),1232 _VSTD::forward_as_tuple(__k),
1233 _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));1233 _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)).first;
1234 }1234 }
12351235
1236 template <class... _Args>1236 template <class... _Args>
...@@ -1240,7 +1240,7 @@ public:...@@ -1240,7 +1240,7 @@ public:
1240 return __tree_.__emplace_hint_unique_key_args(__h.__i_, __k,1240 return __tree_.__emplace_hint_unique_key_args(__h.__i_, __k,
1241 _VSTD::piecewise_construct,1241 _VSTD::piecewise_construct,
1242 _VSTD::forward_as_tuple(_VSTD::move(__k)),1242 _VSTD::forward_as_tuple(_VSTD::move(__k)),
1243 _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));1243 _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)).first;
1244 }1244 }
12451245
1246 template <class _Vp>1246 template <class _Vp>
...@@ -1270,30 +1270,30 @@ public:...@@ -1270,30 +1270,30 @@ public:
1270 }1270 }
12711271
1272 template <class _Vp>1272 template <class _Vp>
1273 _LIBCPP_INLINE_VISIBILITY1273 _LIBCPP_INLINE_VISIBILITY iterator insert_or_assign(const_iterator __h,
1274 iterator insert_or_assign(const_iterator __h, const key_type& __k, _Vp&& __v)1274 const key_type& __k,
1275 {1275 _Vp&& __v) {
1276 iterator __p = lower_bound(__k);1276 auto [__r, __inserted] = __tree_.__emplace_hint_unique_key_args(
1277 if ( __p != end() && !key_comp()(__k, __p->first))1277 __h.__i_, __k, __k, _VSTD::forward<_Vp>(__v));
1278 {1278
1279 __p->second = _VSTD::forward<_Vp>(__v);1279 if (!__inserted)
1280 return __p;1280 __r->__get_value().second = _VSTD::forward<_Vp>(__v);
1281 }1281
1282 return emplace_hint(__h, __k, _VSTD::forward<_Vp>(__v));1282 return __r;
1283 }1283 }
12841284
1285 template <class _Vp>1285 template <class _Vp>
1286 _LIBCPP_INLINE_VISIBILITY1286 _LIBCPP_INLINE_VISIBILITY iterator insert_or_assign(const_iterator __h,
1287 iterator insert_or_assign(const_iterator __h, key_type&& __k, _Vp&& __v)1287 key_type&& __k,
1288 {1288 _Vp&& __v) {
1289 iterator __p = lower_bound(__k);1289 auto [__r, __inserted] = __tree_.__emplace_hint_unique_key_args(
1290 if ( __p != end() && !key_comp()(__k, __p->first))1290 __h.__i_, __k, _VSTD::move(__k), _VSTD::forward<_Vp>(__v));
1291 {1291
1292 __p->second = _VSTD::forward<_Vp>(__v);1292 if (!__inserted)
1293 return __p;1293 __r->__get_value().second = _VSTD::forward<_Vp>(__v);
1294 }1294
1295 return emplace_hint(__h, _VSTD::move(__k), _VSTD::forward<_Vp>(__v));1295 return __r;
1296 }1296 }
12971297
1298#endif // _LIBCPP_STD_VER > 141298#endif // _LIBCPP_STD_VER > 14
12991299
...@@ -1546,7 +1546,7 @@ map<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(const key_type&...@@ -1546,7 +1546,7 @@ map<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(const key_type&
1546 __h.get_deleter().__first_constructed = true;1546 __h.get_deleter().__first_constructed = true;
1547 __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__get_value().second));1547 __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__get_value().second));
1548 __h.get_deleter().__second_constructed = true;1548 __h.get_deleter().__second_constructed = true;
1549 return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++031549 return __h;
1550}1550}
15511551
1552template <class _Key, class _Tp, class _Compare, class _Allocator>1552template <class _Key, class _Tp, class _Compare, class _Allocator>
lib/libcxx/include/memory+365-1377
...@@ -46,7 +46,7 @@ struct pointer_traits<T*>...@@ -46,7 +46,7 @@ struct pointer_traits<T*>
46};46};
4747
48template <class T> constexpr T* to_address(T* p) noexcept; // C++2048template <class T> constexpr T* to_address(T* p) noexcept; // C++20
49template <class Ptr> auto to_address(const Ptr& p) noexcept; // C++2049template <class Ptr> constexpr auto to_address(const Ptr& p) noexcept; // C++20
5050
51template <class Alloc>51template <class Alloc>
52struct allocator_traits52struct allocator_traits
...@@ -83,21 +83,19 @@ struct allocator_traits...@@ -83,21 +83,19 @@ struct allocator_traits
83 template <class T> using rebind_alloc = Alloc::rebind<T>::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); // constexpr and [[nodiscard]] in C++20
87 static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint); // [[nodiscard]] in C++2087 static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint); // constexpr and [[nodiscard]] in C++20
8888
89 static void deallocate(allocator_type& a, pointer p, size_type n) noexcept;89 static void deallocate(allocator_type& a, pointer p, size_type n) noexcept; // constexpr in C++20
9090
91 template <class T, class... Args>91 template <class T, class... Args>
92 static void construct(allocator_type& a, T* p, Args&&... args);92 static void construct(allocator_type& a, T* p, Args&&... args); // constexpr in C++20
9393
94 template <class T>94 template <class T>
95 static void destroy(allocator_type& a, T* p);95 static void destroy(allocator_type& a, T* p); // constexpr in C++20
9696
97 static size_type max_size(const allocator_type& a); // noexcept in C++1497 static size_type max_size(const allocator_type& a); // noexcept in C++14, constexpr in C++20
9898 static allocator_type select_on_container_copy_construction(const allocator_type& a); // constexpr in C++20
99 static allocator_type
100 select_on_container_copy_construction(const allocator_type& a);
101};99};
102100
103template <>101template <>
...@@ -115,8 +113,8 @@ template <class T>...@@ -115,8 +113,8 @@ template <class T>
115class allocator113class allocator
116{114{
117public:115public:
118 typedef size_t size_type; // deprecated in C++17, removed in C++20116 typedef size_t size_type;
119 typedef ptrdiff_t difference_type; // deprecated in C++17, removed in C++20117 typedef ptrdiff_t difference_type;
120 typedef T* pointer; // deprecated in C++17, removed in C++20118 typedef T* pointer; // deprecated in C++17, removed in C++20
121 typedef const T* const_pointer; // deprecated in C++17, removed in C++20119 typedef const T* const_pointer; // deprecated in C++17, removed in C++20
122 typedef typename add_lvalue_reference<T>::type120 typedef typename add_lvalue_reference<T>::type
...@@ -135,12 +133,12 @@ public:...@@ -135,12 +133,12 @@ public:
135 constexpr allocator(const allocator&) noexcept; // constexpr in C++20133 constexpr allocator(const allocator&) noexcept; // constexpr in C++20
136 template <class U>134 template <class U>
137 constexpr allocator(const allocator<U>&) noexcept; // constexpr in C++20135 constexpr allocator(const allocator<U>&) noexcept; // constexpr in C++20
138 ~allocator();136 ~allocator(); // constexpr in C++20
139 pointer address(reference x) const noexcept; // deprecated in C++17, removed in C++20137 pointer address(reference x) const noexcept; // deprecated in C++17, removed in C++20
140 const_pointer address(const_reference x) const noexcept; // deprecated in C++17, removed in C++20138 const_pointer address(const_reference x) const noexcept; // deprecated in C++17, removed in C++20
141 T* allocate(size_t n, const void* hint); // deprecated in C++17, removed in C++20139 T* allocate(size_t n, const void* hint); // deprecated in C++17, removed in C++20
142 T* allocate(size_t n);140 T* allocate(size_t n); // constexpr in C++20
143 void deallocate(T* p, size_t n) noexcept;141 void deallocate(T* p, size_t n) noexcept; // constexpr in C++20
144 size_type max_size() const noexcept; // deprecated in C++17, removed in C++20142 size_type max_size() const noexcept; // deprecated in C++17, removed in C++20
145 template<class U, class... Args>143 template<class U, class... Args>
146 void construct(U* p, Args&&... args); // deprecated in C++17, removed in C++20144 void construct(U* p, Args&&... args); // deprecated in C++17, removed in C++20
...@@ -149,10 +147,10 @@ public:...@@ -149,10 +147,10 @@ public:
149};147};
150148
151template <class T, class U>149template <class T, class U>
152bool operator==(const allocator<T>&, const allocator<U>&) noexcept;150bool operator==(const allocator<T>&, const allocator<U>&) noexcept; // constexpr in C++20
153151
154template <class T, class U>152template <class T, class U>
155bool operator!=(const allocator<T>&, const allocator<U>&) noexcept;153bool operator!=(const allocator<T>&, const allocator<U>&) noexcept; // constexpr in C++20
156154
157template <class OutputIterator, class T>155template <class OutputIterator, class T>
158class raw_storage_iterator156class raw_storage_iterator
...@@ -191,14 +189,17 @@ template <class ForwardIterator, class Size, class T>...@@ -191,14 +189,17 @@ template <class ForwardIterator, class Size, class T>
191ForwardIterator189ForwardIterator
192uninitialized_fill_n(ForwardIterator first, Size n, const T& x);190uninitialized_fill_n(ForwardIterator first, Size n, const T& x);
193191
192template <class T, class ...Args>
193constexpr T* construct_at(T* location, Args&& ...args); // since C++20
194
194template <class T>195template <class T>
195void destroy_at(T* location);196void destroy_at(T* location); // constexpr in C++20
196197
197template <class ForwardIterator>198template <class ForwardIterator>
198 void destroy(ForwardIterator first, ForwardIterator last);199void destroy(ForwardIterator first, ForwardIterator last); // constexpr in C++20
199200
200template <class ForwardIterator, class Size>201template <class ForwardIterator, class Size>
201 ForwardIterator destroy_n(ForwardIterator first, Size n);202ForwardIterator destroy_n(ForwardIterator first, Size n); // constexpr in C++20
202203
203template <class InputIterator, class ForwardIterator>204template <class InputIterator, class ForwardIterator>
204 ForwardIterator uninitialized_move(InputIterator first, InputIterator last, ForwardIterator result);205 ForwardIterator uninitialized_move(InputIterator first, InputIterator last, ForwardIterator result);
...@@ -338,7 +339,7 @@ public:...@@ -338,7 +339,7 @@ public:
338 pointer release() noexcept;339 pointer release() noexcept;
339 void reset(pointer p = pointer()) noexcept;340 void reset(pointer p = pointer()) noexcept;
340 void reset(nullptr_t) noexcept;341 void reset(nullptr_t) noexcept;
341 template <class U> void reset(U) = delete;342 template <class U> void reset(U) = delete;
342 void swap(unique_ptr& u) noexcept;343 void swap(unique_ptr& u) noexcept;
343};344};
344345
...@@ -664,6 +665,7 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space);...@@ -664,6 +665,7 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
664*/665*/
665666
666#include <__config>667#include <__config>
668#include <__availability>
667#include <type_traits>669#include <type_traits>
668#include <typeinfo>670#include <typeinfo>
669#include <cstddef>671#include <cstddef>
...@@ -677,6 +679,10 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space);...@@ -677,6 +679,10 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
677#include <tuple>679#include <tuple>
678#include <stdexcept>680#include <stdexcept>
679#include <cstring>681#include <cstring>
682#include <__memory/allocator_traits.h>
683#include <__memory/base.h>
684#include <__memory/pointer_traits.h>
685#include <__memory/utilities.h>
680#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)686#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
681# include <atomic>687# include <atomic>
682#endif688#endif
...@@ -716,413 +722,11 @@ _ValueType __libcpp_acquire_load(_ValueType const* __value) {...@@ -716,413 +722,11 @@ _ValueType __libcpp_acquire_load(_ValueType const* __value) {
716#endif722#endif
717}723}
718724
719// addressof moved to <type_traits>
720
721template <class _Tp> class allocator;
722
723#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
724template <>
725class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 allocator<void>
726{
727public:
728 typedef void* pointer;
729 typedef const void* const_pointer;
730 typedef void value_type;
731
732 template <class _Up> struct rebind {typedef allocator<_Up> other;};
733};
734
735template <>
736class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 allocator<const void>
737{
738public:
739 typedef const void* pointer;
740 typedef const void* const_pointer;
741 typedef const void value_type;
742
743 template <class _Up> struct rebind {typedef allocator<_Up> other;};
744};
745#endif
746
747// pointer_traits
748
749template <class _Tp, class = void>
750struct __has_element_type : false_type {};
751
752template <class _Tp>
753struct __has_element_type<_Tp,
754 typename __void_t<typename _Tp::element_type>::type> : true_type {};
755
756template <class _Ptr, bool = __has_element_type<_Ptr>::value>
757struct __pointer_traits_element_type;
758
759template <class _Ptr>
760struct __pointer_traits_element_type<_Ptr, true>
761{
762 typedef _LIBCPP_NODEBUG_TYPE typename _Ptr::element_type type;
763};
764
765#ifndef _LIBCPP_HAS_NO_VARIADICS
766
767template <template <class, class...> class _Sp, class _Tp, class ..._Args>
768struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, true>
769{
770 typedef _LIBCPP_NODEBUG_TYPE typename _Sp<_Tp, _Args...>::element_type type;
771};
772
773template <template <class, class...> class _Sp, class _Tp, class ..._Args>
774struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, false>
775{
776 typedef _LIBCPP_NODEBUG_TYPE _Tp type;
777};
778
779#else // _LIBCPP_HAS_NO_VARIADICS
780
781template <template <class> class _Sp, class _Tp>
782struct __pointer_traits_element_type<_Sp<_Tp>, true>
783{
784 typedef typename _Sp<_Tp>::element_type type;
785};
786
787template <template <class> class _Sp, class _Tp>
788struct __pointer_traits_element_type<_Sp<_Tp>, false>
789{
790 typedef _Tp type;
791};
792
793template <template <class, class> class _Sp, class _Tp, class _A0>
794struct __pointer_traits_element_type<_Sp<_Tp, _A0>, true>
795{
796 typedef typename _Sp<_Tp, _A0>::element_type type;
797};
798
799template <template <class, class> class _Sp, class _Tp, class _A0>
800struct __pointer_traits_element_type<_Sp<_Tp, _A0>, false>
801{
802 typedef _Tp type;
803};
804
805template <template <class, class, class> class _Sp, class _Tp, class _A0, class _A1>
806struct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1>, true>
807{
808 typedef typename _Sp<_Tp, _A0, _A1>::element_type type;
809};
810
811template <template <class, class, class> class _Sp, class _Tp, class _A0, class _A1>
812struct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1>, false>
813{
814 typedef _Tp type;
815};
816
817template <template <class, class, class, class> class _Sp, class _Tp, class _A0,
818 class _A1, class _A2>
819struct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1, _A2>, true>
820{
821 typedef typename _Sp<_Tp, _A0, _A1, _A2>::element_type type;
822};
823
824template <template <class, class, class, class> class _Sp, class _Tp, class _A0,
825 class _A1, class _A2>
826struct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1, _A2>, false>
827{
828 typedef _Tp type;
829};
830
831#endif // _LIBCPP_HAS_NO_VARIADICS
832
833template <class _Tp, class = void>
834struct __has_difference_type : false_type {};
835
836template <class _Tp>
837struct __has_difference_type<_Tp,
838 typename __void_t<typename _Tp::difference_type>::type> : true_type {};
839
840template <class _Ptr, bool = __has_difference_type<_Ptr>::value>
841struct __pointer_traits_difference_type
842{
843 typedef _LIBCPP_NODEBUG_TYPE ptrdiff_t type;
844};
845
846template <class _Ptr>
847struct __pointer_traits_difference_type<_Ptr, true>
848{
849 typedef _LIBCPP_NODEBUG_TYPE typename _Ptr::difference_type type;
850};
851
852template <class _Tp, class _Up>
853struct __has_rebind
854{
855private:
856 struct __two {char __lx; char __lxx;};
857 template <class _Xp> static __two __test(...);
858 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
859 template <class _Xp> static char __test(typename _Xp::template rebind<_Up>* = 0);
860 _LIBCPP_SUPPRESS_DEPRECATED_POP
861public:
862 static const bool value = sizeof(__test<_Tp>(0)) == 1;
863};
864
865template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value>
866struct __pointer_traits_rebind
867{
868#ifndef _LIBCPP_CXX03_LANG
869 typedef _LIBCPP_NODEBUG_TYPE typename _Tp::template rebind<_Up> type;
870#else
871 typedef _LIBCPP_NODEBUG_TYPE typename _Tp::template rebind<_Up>::other type;
872#endif
873};
874
875#ifndef _LIBCPP_HAS_NO_VARIADICS
876
877template <template <class, class...> class _Sp, class _Tp, class ..._Args, class _Up>
878struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, true>
879{
880#ifndef _LIBCPP_CXX03_LANG
881 typedef _LIBCPP_NODEBUG_TYPE typename _Sp<_Tp, _Args...>::template rebind<_Up> type;
882#else
883 typedef _LIBCPP_NODEBUG_TYPE typename _Sp<_Tp, _Args...>::template rebind<_Up>::other type;
884#endif
885};
886
887template <template <class, class...> class _Sp, class _Tp, class ..._Args, class _Up>
888struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, false>
889{
890 typedef _Sp<_Up, _Args...> type;
891};
892
893#else // _LIBCPP_HAS_NO_VARIADICS
894
895template <template <class> class _Sp, class _Tp, class _Up>
896struct __pointer_traits_rebind<_Sp<_Tp>, _Up, true>
897{
898#ifndef _LIBCPP_CXX03_LANG
899 typedef typename _Sp<_Tp>::template rebind<_Up> type;
900#else
901 typedef typename _Sp<_Tp>::template rebind<_Up>::other type;
902#endif
903};
904
905template <template <class> class _Sp, class _Tp, class _Up>
906struct __pointer_traits_rebind<_Sp<_Tp>, _Up, false>
907{
908 typedef _Sp<_Up> type;
909};
910
911template <template <class, class> class _Sp, class _Tp, class _A0, class _Up>
912struct __pointer_traits_rebind<_Sp<_Tp, _A0>, _Up, true>
913{
914#ifndef _LIBCPP_CXX03_LANG
915 typedef typename _Sp<_Tp, _A0>::template rebind<_Up> type;
916#else
917 typedef typename _Sp<_Tp, _A0>::template rebind<_Up>::other type;
918#endif
919};
920
921template <template <class, class> class _Sp, class _Tp, class _A0, class _Up>
922struct __pointer_traits_rebind<_Sp<_Tp, _A0>, _Up, false>
923{
924 typedef _Sp<_Up, _A0> type;
925};
926
927template <template <class, class, class> class _Sp, class _Tp, class _A0,
928 class _A1, class _Up>
929struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1>, _Up, true>
930{
931#ifndef _LIBCPP_CXX03_LANG
932 typedef typename _Sp<_Tp, _A0, _A1>::template rebind<_Up> type;
933#else
934 typedef typename _Sp<_Tp, _A0, _A1>::template rebind<_Up>::other type;
935#endif
936};
937
938template <template <class, class, class> class _Sp, class _Tp, class _A0,
939 class _A1, class _Up>
940struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1>, _Up, false>
941{
942 typedef _Sp<_Up, _A0, _A1> type;
943};
944
945template <template <class, class, class, class> class _Sp, class _Tp, class _A0,
946 class _A1, class _A2, class _Up>
947struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1, _A2>, _Up, true>
948{
949#ifndef _LIBCPP_CXX03_LANG
950 typedef typename _Sp<_Tp, _A0, _A1, _A2>::template rebind<_Up> type;
951#else
952 typedef typename _Sp<_Tp, _A0, _A1, _A2>::template rebind<_Up>::other type;
953#endif
954};
955
956template <template <class, class, class, class> class _Sp, class _Tp, class _A0,
957 class _A1, class _A2, class _Up>
958struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1, _A2>, _Up, false>
959{
960 typedef _Sp<_Up, _A0, _A1, _A2> type;
961};
962
963#endif // _LIBCPP_HAS_NO_VARIADICS
964
965template <class _Ptr>
966struct _LIBCPP_TEMPLATE_VIS pointer_traits
967{
968 typedef _Ptr pointer;
969 typedef typename __pointer_traits_element_type<pointer>::type element_type;
970 typedef typename __pointer_traits_difference_type<pointer>::type difference_type;
971
972#ifndef _LIBCPP_CXX03_LANG
973 template <class _Up> using rebind = typename __pointer_traits_rebind<pointer, _Up>::type;
974#else
975 template <class _Up> struct rebind
976 {typedef typename __pointer_traits_rebind<pointer, _Up>::type other;};
977#endif // _LIBCPP_CXX03_LANG
978
979private:
980 struct __nat {};
981public:
982 _LIBCPP_INLINE_VISIBILITY
983 static pointer pointer_to(typename conditional<is_void<element_type>::value,
984 __nat, element_type>::type& __r)
985 {return pointer::pointer_to(__r);}
986};
987
988template <class _Tp>
989struct _LIBCPP_TEMPLATE_VIS pointer_traits<_Tp*>
990{
991 typedef _Tp* pointer;
992 typedef _Tp element_type;
993 typedef ptrdiff_t difference_type;
994
995#ifndef _LIBCPP_CXX03_LANG
996 template <class _Up> using rebind = _Up*;
997#else
998 template <class _Up> struct rebind {typedef _Up* other;};
999#endif
1000
1001private:
1002 struct __nat {};
1003public:
1004 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1005 static pointer pointer_to(typename conditional<is_void<element_type>::value,
1006 __nat, element_type>::type& __r) _NOEXCEPT
1007 {return _VSTD::addressof(__r);}
1008};
1009
1010template <class _From, class _To>
1011struct __rebind_pointer {
1012#ifndef _LIBCPP_CXX03_LANG
1013 typedef typename pointer_traits<_From>::template rebind<_To> type;
1014#else
1015 typedef typename pointer_traits<_From>::template rebind<_To>::other type;
1016#endif
1017};
1018
1019// allocator_traits
1020
1021template <class _Tp, class = void>
1022struct __has_pointer_type : false_type {};
1023
1024template <class _Tp>
1025struct __has_pointer_type<_Tp,
1026 typename __void_t<typename _Tp::pointer>::type> : true_type {};
1027
1028namespace __pointer_type_imp
1029{
1030
1031template <class _Tp, class _Dp, bool = __has_pointer_type<_Dp>::value>
1032struct __pointer_type
1033{
1034 typedef _LIBCPP_NODEBUG_TYPE typename _Dp::pointer type;
1035};
1036
1037template <class _Tp, class _Dp>
1038struct __pointer_type<_Tp, _Dp, false>
1039{
1040 typedef _LIBCPP_NODEBUG_TYPE _Tp* type;
1041};
1042
1043} // __pointer_type_imp
1044
1045template <class _Tp, class _Dp>
1046struct __pointer_type
1047{
1048 typedef _LIBCPP_NODEBUG_TYPE typename __pointer_type_imp::__pointer_type<_Tp, typename remove_reference<_Dp>::type>::type type;
1049};
1050
1051template <class _Tp, class = void>
1052struct __has_const_pointer : false_type {};
1053
1054template <class _Tp>
1055struct __has_const_pointer<_Tp,
1056 typename __void_t<typename _Tp::const_pointer>::type> : true_type {};
1057
1058template <class _Tp, class _Ptr, class _Alloc, bool = __has_const_pointer<_Alloc>::value>
1059struct __const_pointer
1060{
1061 typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::const_pointer type;
1062};
1063
1064template <class _Tp, class _Ptr, class _Alloc>
1065struct __const_pointer<_Tp, _Ptr, _Alloc, false>
1066{
1067#ifndef _LIBCPP_CXX03_LANG
1068 typedef _LIBCPP_NODEBUG_TYPE typename pointer_traits<_Ptr>::template rebind<const _Tp> type;
1069#else
1070 typedef typename pointer_traits<_Ptr>::template rebind<const _Tp>::other type;
1071#endif
1072};
1073
1074template <class _Tp, class = void>
1075struct __has_void_pointer : false_type {};
1076
1077template <class _Tp>
1078struct __has_void_pointer<_Tp,
1079 typename __void_t<typename _Tp::void_pointer>::type> : true_type {};
1080
1081template <class _Ptr, class _Alloc, bool = __has_void_pointer<_Alloc>::value>
1082struct __void_pointer
1083{
1084 typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::void_pointer type;
1085};
1086
1087template <class _Ptr, class _Alloc>
1088struct __void_pointer<_Ptr, _Alloc, false>
1089{
1090#ifndef _LIBCPP_CXX03_LANG
1091 typedef _LIBCPP_NODEBUG_TYPE typename pointer_traits<_Ptr>::template rebind<void> type;
1092#else
1093 typedef _LIBCPP_NODEBUG_TYPE typename pointer_traits<_Ptr>::template rebind<void>::other type;
1094#endif
1095};
1096
1097template <class _Tp, class = void>
1098struct __has_const_void_pointer : false_type {};
1099
1100template <class _Tp>
1101struct __has_const_void_pointer<_Tp,
1102 typename __void_t<typename _Tp::const_void_pointer>::type> : true_type {};
1103
1104template <class _Ptr, class _Alloc, bool = __has_const_void_pointer<_Alloc>::value>
1105struct __const_void_pointer
1106{
1107 typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::const_void_pointer type;
1108};
1109
1110template <class _Ptr, class _Alloc>
1111struct __const_void_pointer<_Ptr, _Alloc, false>
1112{
1113#ifndef _LIBCPP_CXX03_LANG
1114 typedef _LIBCPP_NODEBUG_TYPE typename pointer_traits<_Ptr>::template rebind<const void> type;
1115#else
1116 typedef _LIBCPP_NODEBUG_TYPE typename pointer_traits<_Ptr>::template rebind<const void>::other type;
1117#endif
1118};
1119
1120
1121template <bool _UsePointerTraits> struct __to_address_helper;725template <bool _UsePointerTraits> struct __to_address_helper;
1122726
1123template <> struct __to_address_helper<true> {727template <> struct __to_address_helper<true> {
1124 template <class _Pointer>728 template <class _Pointer>
1125 using __return_type = decltype(pointer_traits<_Pointer>::to_address(std::declval<const _Pointer&>()));729 using __return_type = decltype(pointer_traits<_Pointer>::to_address(_VSTD::declval<const _Pointer&>()));
1126730
1127 template <class _Pointer>731 template <class _Pointer>
1128 _LIBCPP_CONSTEXPR732 _LIBCPP_CONSTEXPR
...@@ -1157,7 +761,7 @@ template <> struct __to_address_helper<false> {...@@ -1157,7 +761,7 @@ template <> struct __to_address_helper<false> {
1157 template <class _Pointer>761 template <class _Pointer>
1158 _LIBCPP_CONSTEXPR762 _LIBCPP_CONSTEXPR
1159 static __return_type<_Pointer>763 static __return_type<_Pointer>
1160 __do_it(const _Pointer &__p) _NOEXCEPT { return std::__to_address(__p.operator->()); }764 __do_it(const _Pointer &__p) _NOEXCEPT { return _VSTD::__to_address(__p.operator->()); }
1161};765};
1162766
1163767
...@@ -1172,7 +776,7 @@ to_address(_Tp* __p) _NOEXCEPT...@@ -1172,7 +776,7 @@ to_address(_Tp* __p) _NOEXCEPT
1172}776}
1173777
1174template <class _Pointer>778template <class _Pointer>
1175inline _LIBCPP_INLINE_VISIBILITY779inline _LIBCPP_INLINE_VISIBILITY constexpr
1176auto780auto
1177to_address(const _Pointer& __p) _NOEXCEPT781to_address(const _Pointer& __p) _NOEXCEPT
1178{782{
...@@ -1180,635 +784,112 @@ to_address(const _Pointer& __p) _NOEXCEPT...@@ -1180,635 +784,112 @@ to_address(const _Pointer& __p) _NOEXCEPT
1180}784}
1181#endif785#endif
1182786
1183template <class _Tp, class = void>787template <class _Tp> class allocator;
1184struct __has_size_type : false_type {};
1185
1186template <class _Tp>
1187struct __has_size_type<_Tp,
1188 typename __void_t<typename _Tp::size_type>::type> : true_type {};
1189788
1190template <class _Alloc, class _DiffType, bool = __has_size_type<_Alloc>::value>789#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
1191struct __size_type790template <>
791class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 allocator<void>
1192{792{
1193 typedef _LIBCPP_NODEBUG_TYPE typename make_unsigned<_DiffType>::type type;793public:
1194};794 typedef void* pointer;
795 typedef const void* const_pointer;
796 typedef void value_type;
1195797
1196template <class _Alloc, class _DiffType>798 template <class _Up> struct rebind {typedef allocator<_Up> other;};
1197struct __size_type<_Alloc, _DiffType, true>
1198{
1199 typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::size_type type;
1200};799};
1201800
1202template <class _Tp, class = void>801template <>
1203struct __has_propagate_on_container_copy_assignment : false_type {};802class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 allocator<const void>
1204
1205template <class _Tp>
1206struct __has_propagate_on_container_copy_assignment<_Tp,
1207 typename __void_t<typename _Tp::propagate_on_container_copy_assignment>::type>
1208 : true_type {};
1209
1210template <class _Alloc, bool = __has_propagate_on_container_copy_assignment<_Alloc>::value>
1211struct __propagate_on_container_copy_assignment
1212{803{
1213 typedef _LIBCPP_NODEBUG_TYPE false_type type;804public:
1214};805 typedef const void* pointer;
806 typedef const void* const_pointer;
807 typedef const void value_type;
1215808
1216template <class _Alloc>809 template <class _Up> struct rebind {typedef allocator<_Up> other;};
1217struct __propagate_on_container_copy_assignment<_Alloc, true>
1218{
1219 typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::propagate_on_container_copy_assignment type;
1220};810};
811#endif
1221812
1222template <class _Tp, class = void>813// allocator
1223struct __has_propagate_on_container_move_assignment : false_type {};
1224814
1225template <class _Tp>815template <class _Tp>
1226struct __has_propagate_on_container_move_assignment<_Tp,816class _LIBCPP_TEMPLATE_VIS allocator
1227 typename __void_t<typename _Tp::propagate_on_container_move_assignment>::type>
1228 : true_type {};
1229
1230template <class _Alloc, bool = __has_propagate_on_container_move_assignment<_Alloc>::value>
1231struct __propagate_on_container_move_assignment
1232{817{
1233 typedef false_type type;
1234};
1235
1236template <class _Alloc>
1237struct __propagate_on_container_move_assignment<_Alloc, true>
1238{
1239 typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::propagate_on_container_move_assignment type;
1240};
1241
1242template <class _Tp, class = void>
1243struct __has_propagate_on_container_swap : false_type {};
1244
1245template <class _Tp>
1246struct __has_propagate_on_container_swap<_Tp,
1247 typename __void_t<typename _Tp::propagate_on_container_swap>::type>
1248 : true_type {};
1249
1250template <class _Alloc, bool = __has_propagate_on_container_swap<_Alloc>::value>
1251struct __propagate_on_container_swap
1252{
1253 typedef false_type type;
1254};
1255
1256template <class _Alloc>
1257struct __propagate_on_container_swap<_Alloc, true>
1258{
1259 typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::propagate_on_container_swap type;
1260};
1261
1262template <class _Tp, class = void>
1263struct __has_is_always_equal : false_type {};
1264
1265template <class _Tp>
1266struct __has_is_always_equal<_Tp,
1267 typename __void_t<typename _Tp::is_always_equal>::type>
1268 : true_type {};
1269
1270template <class _Alloc, bool = __has_is_always_equal<_Alloc>::value>
1271struct __is_always_equal
1272{
1273 typedef _LIBCPP_NODEBUG_TYPE typename _VSTD::is_empty<_Alloc>::type type;
1274};
1275
1276template <class _Alloc>
1277struct __is_always_equal<_Alloc, true>
1278{
1279 typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::is_always_equal type;
1280};
1281
1282template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value>
1283struct __has_rebind_other
1284{
1285private:
1286 struct __two {char __lx; char __lxx;};
1287 template <class _Xp> static __two __test(...);
1288 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
1289 template <class _Xp> static char __test(typename _Xp::template rebind<_Up>::other* = 0);
1290 _LIBCPP_SUPPRESS_DEPRECATED_POP
1291public:818public:
1292 static const bool value = sizeof(__test<_Tp>(0)) == 1;819 typedef size_t size_type;
1293};820 typedef ptrdiff_t difference_type;
1294821 typedef _Tp value_type;
1295template <class _Tp, class _Up>822 typedef true_type propagate_on_container_move_assignment;
1296struct __has_rebind_other<_Tp, _Up, false>823 typedef true_type is_always_equal;
1297{
1298 static const bool value = false;
1299};
1300
1301template <class _Tp, class _Up, bool = __has_rebind_other<_Tp, _Up>::value>
1302struct __allocator_traits_rebind
1303{
1304 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
1305 typedef _LIBCPP_NODEBUG_TYPE typename _Tp::template rebind<_Up>::other type;
1306 _LIBCPP_SUPPRESS_DEPRECATED_POP
1307};
1308
1309template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up>
1310struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, true>
1311{
1312 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
1313 typedef _LIBCPP_NODEBUG_TYPE typename _Alloc<_Tp, _Args...>::template rebind<_Up>::other type;
1314 _LIBCPP_SUPPRESS_DEPRECATED_POP
1315};
1316
1317template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up>
1318struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, false>
1319{
1320 typedef _LIBCPP_NODEBUG_TYPE _Alloc<_Up, _Args...> type;
1321};
1322
1323#ifndef _LIBCPP_CXX03_LANG
1324
1325_LIBCPP_SUPPRESS_DEPRECATED_PUSH
1326template <class _Alloc, class _SizeType, class _ConstVoidPtr>
1327auto
1328__has_allocate_hint_test(_Alloc&& __a, _SizeType&& __sz, _ConstVoidPtr&& __p)
1329 -> decltype((void)__a.allocate(__sz, __p), true_type());
1330_LIBCPP_SUPPRESS_DEPRECATED_POP
1331
1332template <class _Alloc, class _SizeType, class _ConstVoidPtr>
1333auto
1334__has_allocate_hint_test(const _Alloc& __a, _SizeType&& __sz, _ConstVoidPtr&& __p)
1335 -> false_type;
1336
1337template <class _Alloc, class _SizeType, class _ConstVoidPtr>
1338struct __has_allocate_hint
1339 : decltype(_VSTD::__has_allocate_hint_test(declval<_Alloc>(),
1340 declval<_SizeType>(),
1341 declval<_ConstVoidPtr>()))
1342{
1343};
1344
1345#else // _LIBCPP_CXX03_LANG
1346
1347template <class _Alloc, class _SizeType, class _ConstVoidPtr>
1348struct __has_allocate_hint
1349 : true_type
1350{
1351};
1352
1353#endif // _LIBCPP_CXX03_LANG
1354
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
1360
1361template <class _Alloc, class...>
1362static false_type __test_has_construct(...);
1363
1364template <class _Alloc, class ..._Args>
1365struct __has_construct : decltype(__test_has_construct<_Alloc, _Args...>(0)) {};
1366
1367#if !defined(_LIBCPP_CXX03_LANG)
1368
1369_LIBCPP_SUPPRESS_DEPRECATED_PUSH
1370template <class _Alloc, class _Pointer>
1371auto
1372__has_destroy_test(_Alloc&& __a, _Pointer&& __p)
1373 -> decltype(__a.destroy(__p), true_type());
1374_LIBCPP_SUPPRESS_DEPRECATED_POP
1375
1376template <class _Alloc, class _Pointer>
1377auto
1378__has_destroy_test(const _Alloc& __a, _Pointer&& __p)
1379 -> false_type;
1380
1381template <class _Alloc, class _Pointer>
1382struct __has_destroy
1383 : decltype(_VSTD::__has_destroy_test(declval<_Alloc>(),
1384 declval<_Pointer>()))
1385{
1386};
1387
1388_LIBCPP_SUPPRESS_DEPRECATED_PUSH
1389template <class _Alloc>
1390auto
1391__has_max_size_test(_Alloc&& __a)
1392 -> decltype(__a.max_size(), true_type());
1393_LIBCPP_SUPPRESS_DEPRECATED_POP
1394
1395template <class _Alloc>
1396auto
1397__has_max_size_test(const volatile _Alloc& __a)
1398 -> false_type;
1399
1400template <class _Alloc>
1401struct __has_max_size
1402 : decltype(_VSTD::__has_max_size_test(declval<_Alloc&>()))
1403{
1404};
1405
1406template <class _Alloc>
1407auto
1408__has_select_on_container_copy_construction_test(_Alloc&& __a)
1409 -> decltype(__a.select_on_container_copy_construction(), true_type());
1410
1411template <class _Alloc>
1412auto
1413__has_select_on_container_copy_construction_test(const volatile _Alloc& __a)
1414 -> false_type;
1415
1416template <class _Alloc>
1417struct __has_select_on_container_copy_construction
1418 : decltype(_VSTD::__has_select_on_container_copy_construction_test(declval<_Alloc&>()))
1419{
1420};
1421
1422#else // _LIBCPP_CXX03_LANG
1423
1424template <class _Alloc, class _Pointer, class = void>
1425struct __has_destroy : false_type {};
1426
1427template <class _Alloc, class _Pointer>
1428struct __has_destroy<_Alloc, _Pointer, typename __void_t<
1429 decltype(_VSTD::declval<_Alloc>().destroy(_VSTD::declval<_Pointer>()))
1430>::type> : std::true_type {};
1431
1432template <class _Alloc>
1433struct __has_max_size
1434 : true_type
1435{
1436};
1437
1438template <class _Alloc>
1439struct __has_select_on_container_copy_construction
1440 : false_type
1441{
1442};
1443
1444#endif // _LIBCPP_CXX03_LANG
1445
1446template <class _Alloc, class _Ptr, bool = __has_difference_type<_Alloc>::value>
1447struct __alloc_traits_difference_type
1448{
1449 typedef _LIBCPP_NODEBUG_TYPE typename pointer_traits<_Ptr>::difference_type type;
1450};
1451824
1452template <class _Alloc, class _Ptr>825 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1453struct __alloc_traits_difference_type<_Alloc, _Ptr, true>826 allocator() _NOEXCEPT { }
1454{
1455 typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::difference_type type;
1456};
1457
1458template <class _Tp>
1459struct __is_default_allocator : false_type {};
1460
1461template <class _Tp>
1462struct __is_default_allocator<_VSTD::allocator<_Tp> > : true_type {};
1463
1464
1465
1466template <class _Alloc,
1467 bool = __has_construct<_Alloc, typename _Alloc::value_type*, typename _Alloc::value_type&&>::value && !__is_default_allocator<_Alloc>::value
1468 >
1469struct __is_cpp17_move_insertable;
1470template <class _Alloc>
1471struct __is_cpp17_move_insertable<_Alloc, true> : std::true_type {};
1472template <class _Alloc>
1473struct __is_cpp17_move_insertable<_Alloc, false> : std::is_move_constructible<typename _Alloc::value_type> {};
1474
1475template <class _Alloc,
1476 bool = __has_construct<_Alloc, typename _Alloc::value_type*, const typename _Alloc::value_type&>::value && !__is_default_allocator<_Alloc>::value
1477 >
1478struct __is_cpp17_copy_insertable;
1479template <class _Alloc>
1480struct __is_cpp17_copy_insertable<_Alloc, true> : __is_cpp17_move_insertable<_Alloc> {};
1481template <class _Alloc>
1482struct __is_cpp17_copy_insertable<_Alloc, false> : integral_constant<bool,
1483 std::is_copy_constructible<typename _Alloc::value_type>::value &&
1484 __is_cpp17_move_insertable<_Alloc>::value>
1485 {};
1486
1487
1488
1489template <class _Alloc>
1490struct _LIBCPP_TEMPLATE_VIS allocator_traits
1491{
1492 typedef _Alloc allocator_type;
1493 typedef typename allocator_type::value_type value_type;
1494
1495 typedef typename __pointer_type<value_type, allocator_type>::type pointer;
1496 typedef typename __const_pointer<value_type, pointer, allocator_type>::type const_pointer;
1497 typedef typename __void_pointer<pointer, allocator_type>::type void_pointer;
1498 typedef typename __const_void_pointer<pointer, allocator_type>::type const_void_pointer;
1499
1500 typedef typename __alloc_traits_difference_type<allocator_type, pointer>::type difference_type;
1501 typedef typename __size_type<allocator_type, difference_type>::type size_type;
1502
1503 typedef typename __propagate_on_container_copy_assignment<allocator_type>::type
1504 propagate_on_container_copy_assignment;
1505 typedef typename __propagate_on_container_move_assignment<allocator_type>::type
1506 propagate_on_container_move_assignment;
1507 typedef typename __propagate_on_container_swap<allocator_type>::type
1508 propagate_on_container_swap;
1509 typedef typename __is_always_equal<allocator_type>::type
1510 is_always_equal;
1511
1512#ifndef _LIBCPP_CXX03_LANG
1513 template <class _Tp> using rebind_alloc =
1514 typename __allocator_traits_rebind<allocator_type, _Tp>::type;
1515 template <class _Tp> using rebind_traits = allocator_traits<rebind_alloc<_Tp> >;
1516#else // _LIBCPP_CXX03_LANG
1517 template <class _Tp> struct rebind_alloc
1518 {typedef typename __allocator_traits_rebind<allocator_type, _Tp>::type other;};
1519 template <class _Tp> struct rebind_traits
1520 {typedef allocator_traits<typename rebind_alloc<_Tp>::other> other;};
1521#endif // _LIBCPP_CXX03_LANG
1522
1523 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
1524 static pointer allocate(allocator_type& __a, size_type __n)
1525 {return __a.allocate(__n);}
1526 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
1527 static pointer allocate(allocator_type& __a, size_type __n, const_void_pointer __hint)
1528 {return __allocate(__a, __n, __hint,
1529 __has_allocate_hint<allocator_type, size_type, const_void_pointer>());}
1530
1531 _LIBCPP_INLINE_VISIBILITY
1532 static void deallocate(allocator_type& __a, pointer __p, size_type __n) _NOEXCEPT
1533 {__a.deallocate(__p, __n);}
1534
1535 template <class _Tp, class... _Args>
1536 _LIBCPP_INLINE_VISIBILITY
1537 static void construct(allocator_type& __a, _Tp* __p, _Args&&... __args)
1538 {__construct(__has_construct<allocator_type, _Tp*, _Args...>(),
1539 __a, __p, _VSTD::forward<_Args>(__args)...);}
1540
1541 template <class _Tp>
1542 _LIBCPP_INLINE_VISIBILITY
1543 static void destroy(allocator_type& __a, _Tp* __p)
1544 {__destroy(__has_destroy<allocator_type, _Tp*>(), __a, __p);}
1545
1546 _LIBCPP_INLINE_VISIBILITY
1547 static size_type max_size(const allocator_type& __a) _NOEXCEPT
1548 {return __max_size(__has_max_size<const allocator_type>(), __a);}
1549
1550 _LIBCPP_INLINE_VISIBILITY
1551 static allocator_type
1552 select_on_container_copy_construction(const allocator_type& __a)
1553 {return __select_on_container_copy_construction(
1554 __has_select_on_container_copy_construction<const allocator_type>(),
1555 __a);}
1556
1557 template <class _Ptr>
1558 _LIBCPP_INLINE_VISIBILITY
1559 static
1560 void
1561 __construct_forward_with_exception_guarantees(allocator_type& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __begin2)
1562 {
1563 static_assert(__is_cpp17_move_insertable<allocator_type>::value,
1564 "The specified type does not meet the requirements of Cpp17MoveInsertible");
1565 for (; __begin1 != __end1; ++__begin1, (void) ++__begin2)
1566 construct(__a, _VSTD::__to_address(__begin2),
1567#ifdef _LIBCPP_NO_EXCEPTIONS
1568 _VSTD::move(*__begin1)
1569#else
1570 _VSTD::move_if_noexcept(*__begin1)
1571#endif
1572 );
1573 }
1574
1575 template <class _Tp>
1576 _LIBCPP_INLINE_VISIBILITY
1577 static
1578 typename enable_if
1579 <
1580 (__is_default_allocator<allocator_type>::value
1581 || !__has_construct<allocator_type, _Tp*, _Tp>::value) &&
1582 is_trivially_move_constructible<_Tp>::value,
1583 void
1584 >::type
1585 __construct_forward_with_exception_guarantees(allocator_type&, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2)
1586 {
1587 ptrdiff_t _Np = __end1 - __begin1;
1588 if (_Np > 0)
1589 {
1590 _VSTD::memcpy(__begin2, __begin1, _Np * sizeof(_Tp));
1591 __begin2 += _Np;
1592 }
1593 }
1594
1595 template <class _Iter, class _Ptr>
1596 _LIBCPP_INLINE_VISIBILITY
1597 static
1598 void
1599 __construct_range_forward(allocator_type& __a, _Iter __begin1, _Iter __end1, _Ptr& __begin2)
1600 {
1601 for (; __begin1 != __end1; ++__begin1, (void) ++__begin2)
1602 construct(__a, _VSTD::__to_address(__begin2), *__begin1);
1603 }
1604
1605 template <class _SourceTp, class _DestTp,
1606 class _RawSourceTp = typename remove_const<_SourceTp>::type,
1607 class _RawDestTp = typename remove_const<_DestTp>::type>
1608 _LIBCPP_INLINE_VISIBILITY
1609 static
1610 typename enable_if
1611 <
1612 is_trivially_copy_constructible<_DestTp>::value &&
1613 is_same<_RawSourceTp, _RawDestTp>::value &&
1614 (__is_default_allocator<allocator_type>::value ||
1615 !__has_construct<allocator_type, _DestTp*, _SourceTp&>::value),
1616 void
1617 >::type
1618 __construct_range_forward(allocator_type&, _SourceTp* __begin1, _SourceTp* __end1, _DestTp*& __begin2)
1619 {
1620 ptrdiff_t _Np = __end1 - __begin1;
1621 if (_Np > 0)
1622 {
1623 _VSTD::memcpy(const_cast<_RawDestTp*>(__begin2), __begin1, _Np * sizeof(_DestTp));
1624 __begin2 += _Np;
1625 }
1626 }
1627827
1628 template <class _Ptr>828 template <class _Up>
1629 _LIBCPP_INLINE_VISIBILITY829 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1630 static830 allocator(const allocator<_Up>&) _NOEXCEPT { }
1631 void
1632 __construct_backward_with_exception_guarantees(allocator_type& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __end2)
1633 {
1634 static_assert(__is_cpp17_move_insertable<allocator_type>::value,
1635 "The specified type does not meet the requirements of Cpp17MoveInsertable");
1636 while (__end1 != __begin1)
1637 {
1638 construct(__a, _VSTD::__to_address(__end2 - 1),
1639#ifdef _LIBCPP_NO_EXCEPTIONS
1640 _VSTD::move(*--__end1)
1641#else
1642 _VSTD::move_if_noexcept(*--__end1)
1643#endif
1644 );
1645 --__end2;
1646 }
1647 }
1648831
1649 template <class _Tp>832 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1650 _LIBCPP_INLINE_VISIBILITY833 _Tp* allocate(size_t __n) {
1651 static834 if (__n > allocator_traits<allocator>::max_size(*this))
1652 typename enable_if835 __throw_length_error("allocator<T>::allocate(size_t n)"
1653 <836 " 'n' exceeds maximum supported size");
1654 (__is_default_allocator<allocator_type>::value837 if (__libcpp_is_constant_evaluated()) {
1655 || !__has_construct<allocator_type, _Tp*, _Tp>::value) &&838 return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp)));
1656 is_trivially_move_constructible<_Tp>::value,839 } else {
1657 void840 return static_cast<_Tp*>(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)));
1658 >::type
1659 __construct_backward_with_exception_guarantees(allocator_type&, _Tp* __begin1, _Tp* __end1, _Tp*& __end2)
1660 {
1661 ptrdiff_t _Np = __end1 - __begin1;
1662 __end2 -= _Np;
1663 if (_Np > 0)
1664 _VSTD::memcpy(__end2, __begin1, _Np * sizeof(_Tp));
1665 }841 }
842 }
1666843
1667private:844 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1668845 void deallocate(_Tp* __p, size_t __n) _NOEXCEPT {
1669 _LIBCPP_INLINE_VISIBILITY846 if (__libcpp_is_constant_evaluated()) {
1670 static pointer __allocate(allocator_type& __a, size_type __n,847 ::operator delete(__p);
1671 const_void_pointer __hint, true_type)848 } else {
1672 {849 _VSTD::__libcpp_deallocate((void*)__p, __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));
1673 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
1674 return __a.allocate(__n, __hint);
1675 _LIBCPP_SUPPRESS_DEPRECATED_POP
1676 }850 }
1677 _LIBCPP_INLINE_VISIBILITY851 }
1678 static pointer __allocate(allocator_type& __a, size_type __n,
1679 const_void_pointer, false_type)
1680 {return __a.allocate(__n);}
1681
1682 template <class _Tp, class... _Args>
1683 _LIBCPP_INLINE_VISIBILITY
1684 static void __construct(true_type, allocator_type& __a, _Tp* __p, _Args&&... __args)
1685 {
1686 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
1687 __a.construct(__p, _VSTD::forward<_Args>(__args)...);
1688 _LIBCPP_SUPPRESS_DEPRECATED_POP
1689 }
1690
1691 template <class _Tp, class... _Args>
1692 _LIBCPP_INLINE_VISIBILITY
1693 static void __construct(false_type, allocator_type&, _Tp* __p, _Args&&... __args)
1694 {
1695 ::new ((void*)__p) _Tp(_VSTD::forward<_Args>(__args)...);
1696 }
1697
1698 template <class _Tp>
1699 _LIBCPP_INLINE_VISIBILITY
1700 static void __destroy(true_type, allocator_type& __a, _Tp* __p)
1701 {
1702 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
1703 __a.destroy(__p);
1704 _LIBCPP_SUPPRESS_DEPRECATED_POP
1705 }
1706 template <class _Tp>
1707 _LIBCPP_INLINE_VISIBILITY
1708 static void __destroy(false_type, allocator_type&, _Tp* __p)
1709 {
1710 __p->~_Tp();
1711 }
1712
1713 _LIBCPP_INLINE_VISIBILITY
1714 static size_type __max_size(true_type, const allocator_type& __a) _NOEXCEPT
1715 {
1716 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
1717 return __a.max_size();
1718 _LIBCPP_SUPPRESS_DEPRECATED_POP
1719 }
1720
1721 _LIBCPP_INLINE_VISIBILITY
1722 static size_type __max_size(false_type, const allocator_type&) _NOEXCEPT
1723 {return numeric_limits<size_type>::max() / sizeof(value_type);}
1724
1725 _LIBCPP_INLINE_VISIBILITY
1726 static allocator_type
1727 __select_on_container_copy_construction(true_type, const allocator_type& __a)
1728 {return __a.select_on_container_copy_construction();}
1729 _LIBCPP_INLINE_VISIBILITY
1730 static allocator_type
1731 __select_on_container_copy_construction(false_type, const allocator_type& __a)
1732 {return __a;}
1733};
1734
1735template <class _Traits, class _Tp>
1736struct __rebind_alloc_helper
1737{
1738#ifndef _LIBCPP_CXX03_LANG
1739 typedef _LIBCPP_NODEBUG_TYPE typename _Traits::template rebind_alloc<_Tp> type;
1740#else
1741 typedef typename _Traits::template rebind_alloc<_Tp>::other type;
1742#endif
1743};
1744
1745// allocator
1746852
1747template <class _Tp>853 // C++20 Removed members
1748class _LIBCPP_TEMPLATE_VIS allocator
1749{
1750public:
1751#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)854#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
1752 _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t size_type;
1753 _LIBCPP_DEPRECATED_IN_CXX17 typedef ptrdiff_t difference_type;
1754 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp* pointer;855 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp* pointer;
1755 _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* const_pointer;856 _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* const_pointer;
1756 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp& reference;857 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp& reference;
1757 _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& const_reference;858 _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& const_reference;
1758859
1759 template <class _Up> struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {typedef allocator<_Up> other;};
1760#endif
1761
1762 typedef _Tp value_type;
1763
1764 typedef true_type propagate_on_container_move_assignment;
1765 typedef true_type is_always_equal;
1766
1767 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1768 allocator() _NOEXCEPT {}
1769
1770 template <class _Up>860 template <class _Up>
1771 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17861 struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {
1772 allocator(const allocator<_Up>&) _NOEXCEPT {}862 typedef allocator<_Up> other;
863 };
1773864
1774#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
1775 _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY865 _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
1776 pointer address(reference __x) const _NOEXCEPT866 pointer address(reference __x) const _NOEXCEPT {
1777 {return _VSTD::addressof(__x);}867 return _VSTD::addressof(__x);
868 }
1778 _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY869 _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
1779 const_pointer address(const_reference __x) const _NOEXCEPT870 const_pointer address(const_reference __x) const _NOEXCEPT {
1780 {return _VSTD::addressof(__x);}871 return _VSTD::addressof(__x);
1781#endif872 }
1782
1783 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _Tp* allocate(size_t __n)
1784 {
1785 // TODO(mpark): Replace with `allocator_traits<allocator>::max_size(*this)`.
1786 if (__n > (size_t(~0) / sizeof(_Tp)))
1787 __throw_length_error("allocator<T>::allocate(size_t n)"
1788 " 'n' exceeds maximum supported size");
1789 return static_cast<_Tp*>(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)));
1790 }
1791873
1792#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
1793 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_IN_CXX17874 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_IN_CXX17
1794 _Tp* allocate(size_t __n, const void*) { return allocate(__n); }875 _Tp* allocate(size_t __n, const void*) {
1795#endif876 return allocate(__n);
1796877 }
1797 _LIBCPP_INLINE_VISIBILITY void deallocate(_Tp* __p, size_t __n) _NOEXCEPT
1798 {_VSTD::__libcpp_deallocate((void*)__p, __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));}
1799878
1800#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)879 _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT {
1801 _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT880 return size_type(~0) / sizeof(_Tp);
1802 {return size_type(~0) / sizeof(_Tp);}881 }
1803882
1804 template <class _Up, class... _Args>883 template <class _Up, class... _Args>
1805 _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY884 _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
1806 void885 void construct(_Up* __p, _Args&&... __args) {
1807 construct(_Up* __p, _Args&&... __args)886 ::new ((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
1808 {887 }
1809 ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);888
1810 }889 _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
1811 _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();}890 void destroy(pointer __p) {
891 __p->~_Tp();
892 }
1812#endif893#endif
1813};894};
1814895
...@@ -1816,129 +897,174 @@ template <class _Tp>...@@ -1816,129 +897,174 @@ template <class _Tp>
1816class _LIBCPP_TEMPLATE_VIS allocator<const _Tp>897class _LIBCPP_TEMPLATE_VIS allocator<const _Tp>
1817{898{
1818public:899public:
1819#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)900 typedef size_t size_type;
1820 _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t size_type;901 typedef ptrdiff_t difference_type;
1821 _LIBCPP_DEPRECATED_IN_CXX17 typedef ptrdiff_t difference_type;902 typedef const _Tp value_type;
1822 _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* pointer;903 typedef true_type propagate_on_container_move_assignment;
1823 _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* const_pointer;904 typedef true_type is_always_equal;
1824 _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& reference;
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;
1831
1832 typedef true_type propagate_on_container_move_assignment;
1833 typedef true_type is_always_equal;
1834905
1835 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17906 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1836 allocator() _NOEXCEPT {}907 allocator() _NOEXCEPT { }
1837908
1838 template <class _Up>909 template <class _Up>
1839 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17910 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1840 allocator(const allocator<_Up>&) _NOEXCEPT {}911 allocator(const allocator<_Up>&) _NOEXCEPT { }
1841
1842#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
1843 _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
1844 const_pointer address(const_reference __x) const _NOEXCEPT
1845 {return _VSTD::addressof(__x);}
1846#endif
1847912
1848 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const _Tp* allocate(size_t __n)913 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1849 {914 const _Tp* allocate(size_t __n) {
1850 // TODO(mpark): Replace with `allocator_traits<allocator>::max_size(*this)`.915 if (__n > allocator_traits<allocator>::max_size(*this))
1851 if (__n > (size_t(~0) / sizeof(_Tp)))
1852 __throw_length_error("allocator<const T>::allocate(size_t n)"916 __throw_length_error("allocator<const T>::allocate(size_t n)"
1853 " 'n' exceeds maximum supported size");917 " 'n' exceeds maximum supported size");
1854 return static_cast<const _Tp*>(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)));918 if (__libcpp_is_constant_evaluated()) {
919 return static_cast<const _Tp*>(::operator new(__n * sizeof(_Tp)));
920 } else {
921 return static_cast<const _Tp*>(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)));
922 }
923 }
924
925 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
926 void deallocate(const _Tp* __p, size_t __n) {
927 if (__libcpp_is_constant_evaluated()) {
928 ::operator delete(const_cast<_Tp*>(__p));
929 } else {
930 _VSTD::__libcpp_deallocate((void*) const_cast<_Tp *>(__p), __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));
931 }
1855 }932 }
1856933
934 // C++20 Removed members
1857#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)935#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
1858 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_IN_CXX17936 _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* pointer;
1859 const _Tp* allocate(size_t __n, const void*) { return allocate(__n); }937 _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* const_pointer;
1860#endif938 _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& reference;
939 _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& const_reference;
1861940
1862 _LIBCPP_INLINE_VISIBILITY void deallocate(const _Tp* __p, size_t __n)941 template <class _Up>
1863 {_VSTD::__libcpp_deallocate((void*) const_cast<_Tp *>(__p), __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));}942 struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {
943 typedef allocator<_Up> other;
944 };
1864945
1865#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)946 _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
1866 _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT947 const_pointer address(const_reference __x) const _NOEXCEPT {
1867 {return size_type(~0) / sizeof(_Tp);}948 return _VSTD::addressof(__x);
949 }
950
951 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_IN_CXX17
952 const _Tp* allocate(size_t __n, const void*) {
953 return allocate(__n);
954 }
955
956 _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT {
957 return size_type(~0) / sizeof(_Tp);
958 }
1868959
1869#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
1870 template <class _Up, class... _Args>960 template <class _Up, class... _Args>
1871 _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY961 _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
1872 void962 void construct(_Up* __p, _Args&&... __args) {
1873 construct(_Up* __p, _Args&&... __args)963 ::new ((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
1874 {964 }
1875 ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
1876 }
1877#else // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
1878 _LIBCPP_INLINE_VISIBILITY
1879 void
1880 construct(pointer __p)
1881 {
1882 ::new((void*) const_cast<_Tp *>(__p)) _Tp();
1883 }
1884# if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
1885965
1886 template <class _A0>966 _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
1887 _LIBCPP_INLINE_VISIBILITY967 void destroy(pointer __p) {
1888 void968 __p->~_Tp();
1889 construct(pointer __p, _A0& __a0)969 }
1890 {
1891 ::new((void*) const_cast<_Tp *>(__p)) _Tp(__a0);
1892 }
1893 template <class _A0>
1894 _LIBCPP_INLINE_VISIBILITY
1895 void
1896 construct(pointer __p, const _A0& __a0)
1897 {
1898 ::new((void*) const_cast<_Tp *>(__p)) _Tp(__a0);
1899 }
1900# endif // defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
1901 template <class _A0, class _A1>
1902 _LIBCPP_INLINE_VISIBILITY
1903 void
1904 construct(pointer __p, _A0& __a0, _A1& __a1)
1905 {
1906 ::new((void*) const_cast<_Tp *>(__p)) _Tp(__a0, __a1);
1907 }
1908 template <class _A0, class _A1>
1909 _LIBCPP_INLINE_VISIBILITY
1910 void
1911 construct(pointer __p, const _A0& __a0, _A1& __a1)
1912 {
1913 ::new((void*) const_cast<_Tp *>(__p)) _Tp(__a0, __a1);
1914 }
1915 template <class _A0, class _A1>
1916 _LIBCPP_INLINE_VISIBILITY
1917 void
1918 construct(pointer __p, _A0& __a0, const _A1& __a1)
1919 {
1920 ::new((void*) const_cast<_Tp *>(__p)) _Tp(__a0, __a1);
1921 }
1922 template <class _A0, class _A1>
1923 _LIBCPP_INLINE_VISIBILITY
1924 void
1925 construct(pointer __p, const _A0& __a0, const _A1& __a1)
1926 {
1927 ::new((void*) const_cast<_Tp *>(__p)) _Tp(__a0, __a1);
1928 }
1929#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
1930 _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();}
1931#endif970#endif
1932};971};
1933972
1934template <class _Tp, class _Up>973template <class _Tp, class _Up>
1935inline _LIBCPP_INLINE_VISIBILITY974inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1936bool operator==(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return true;}975bool operator==(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return true;}
1937976
1938template <class _Tp, class _Up>977template <class _Tp, class _Up>
1939inline _LIBCPP_INLINE_VISIBILITY978inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1940bool operator!=(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return false;}979bool operator!=(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return false;}
1941980
981template <class _Alloc, class _Ptr>
982_LIBCPP_INLINE_VISIBILITY
983void __construct_forward_with_exception_guarantees(_Alloc& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __begin2) {
984 static_assert(__is_cpp17_move_insertable<_Alloc>::value,
985 "The specified type does not meet the requirements of Cpp17MoveInsertable");
986 typedef allocator_traits<_Alloc> _Traits;
987 for (; __begin1 != __end1; ++__begin1, (void)++__begin2) {
988 _Traits::construct(__a, _VSTD::__to_address(__begin2),
989#ifdef _LIBCPP_NO_EXCEPTIONS
990 _VSTD::move(*__begin1)
991#else
992 _VSTD::move_if_noexcept(*__begin1)
993#endif
994 );
995 }
996}
997
998template <class _Alloc, class _Tp, typename enable_if<
999 (__is_default_allocator<_Alloc>::value || !__has_construct<_Alloc, _Tp*, _Tp>::value) &&
1000 is_trivially_move_constructible<_Tp>::value
1001>::type>
1002_LIBCPP_INLINE_VISIBILITY
1003void __construct_forward_with_exception_guarantees(_Alloc&, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2) {
1004 ptrdiff_t _Np = __end1 - __begin1;
1005 if (_Np > 0) {
1006 _VSTD::memcpy(__begin2, __begin1, _Np * sizeof(_Tp));
1007 __begin2 += _Np;
1008 }
1009}
1010
1011template <class _Alloc, class _Iter, class _Ptr>
1012_LIBCPP_INLINE_VISIBILITY
1013void __construct_range_forward(_Alloc& __a, _Iter __begin1, _Iter __end1, _Ptr& __begin2) {
1014 typedef allocator_traits<_Alloc> _Traits;
1015 for (; __begin1 != __end1; ++__begin1, (void) ++__begin2) {
1016 _Traits::construct(__a, _VSTD::__to_address(__begin2), *__begin1);
1017 }
1018}
1019
1020template <class _Alloc, class _Source, class _Dest,
1021 class _RawSource = typename remove_const<_Source>::type,
1022 class _RawDest = typename remove_const<_Dest>::type,
1023 class =
1024 typename enable_if<
1025 is_trivially_copy_constructible<_Dest>::value &&
1026 is_same<_RawSource, _RawDest>::value &&
1027 (__is_default_allocator<_Alloc>::value || !__has_construct<_Alloc, _Dest*, _Source&>::value)
1028 >::type>
1029_LIBCPP_INLINE_VISIBILITY
1030void __construct_range_forward(_Alloc&, _Source* __begin1, _Source* __end1, _Dest*& __begin2) {
1031 ptrdiff_t _Np = __end1 - __begin1;
1032 if (_Np > 0) {
1033 _VSTD::memcpy(const_cast<_RawDest*>(__begin2), __begin1, _Np * sizeof(_Dest));
1034 __begin2 += _Np;
1035 }
1036}
1037
1038template <class _Alloc, class _Ptr>
1039_LIBCPP_INLINE_VISIBILITY
1040void __construct_backward_with_exception_guarantees(_Alloc& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __end2) {
1041 static_assert(__is_cpp17_move_insertable<_Alloc>::value,
1042 "The specified type does not meet the requirements of Cpp17MoveInsertable");
1043 typedef allocator_traits<_Alloc> _Traits;
1044 while (__end1 != __begin1) {
1045 _Traits::construct(__a, _VSTD::__to_address(__end2 - 1),
1046#ifdef _LIBCPP_NO_EXCEPTIONS
1047 _VSTD::move(*--__end1)
1048#else
1049 _VSTD::move_if_noexcept(*--__end1)
1050#endif
1051 );
1052 --__end2;
1053 }
1054}
1055
1056template <class _Alloc, class _Tp, class = typename enable_if<
1057 (__is_default_allocator<_Alloc>::value || !__has_construct<_Alloc, _Tp*, _Tp>::value) &&
1058 is_trivially_move_constructible<_Tp>::value
1059>::type>
1060_LIBCPP_INLINE_VISIBILITY
1061void __construct_backward_with_exception_guarantees(_Alloc&, _Tp* __begin1, _Tp* __end1, _Tp*& __end2) {
1062 ptrdiff_t _Np = __end1 - __begin1;
1063 __end2 -= _Np;
1064 if (_Np > 0)
1065 _VSTD::memcpy(__end2, __begin1, _Np * sizeof(_Tp));
1066}
1067
1942template <class _OutputIterator, class _Tp>1068template <class _OutputIterator, class _Tp>
1943class _LIBCPP_TEMPLATE_VIS raw_storage_iterator1069class _LIBCPP_TEMPLATE_VIS raw_storage_iterator
1944 : public iterator<output_iterator_tag,1070 : public iterator<output_iterator_tag,
...@@ -1953,10 +1079,10 @@ public:...@@ -1953,10 +1079,10 @@ public:
1953 _LIBCPP_INLINE_VISIBILITY explicit raw_storage_iterator(_OutputIterator __x) : __x_(__x) {}1079 _LIBCPP_INLINE_VISIBILITY explicit raw_storage_iterator(_OutputIterator __x) : __x_(__x) {}
1954 _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator*() {return *this;}1080 _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator*() {return *this;}
1955 _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator=(const _Tp& __element)1081 _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator=(const _Tp& __element)
1956 {::new(_VSTD::addressof(*__x_)) _Tp(__element); return *this;}1082 {::new ((void*)_VSTD::addressof(*__x_)) _Tp(__element); return *this;}
1957#if _LIBCPP_STD_VER >= 141083#if _LIBCPP_STD_VER >= 14
1958 _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator=(_Tp&& __element)1084 _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator=(_Tp&& __element)
1959 {::new(_VSTD::addressof(*__x_)) _Tp(_VSTD::move(__element)); return *this;}1085 {::new ((void*)_VSTD::addressof(*__x_)) _Tp(_VSTD::move(__element)); return *this;}
1960#endif1086#endif
1961 _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator++() {++__x_; return *this;}1087 _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator++() {++__x_; return *this;}
1962 _LIBCPP_INLINE_VISIBILITY raw_storage_iterator operator++(int)1088 _LIBCPP_INLINE_VISIBILITY raw_storage_iterator operator++(int)
...@@ -1982,8 +1108,8 @@ get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT...@@ -1982,8 +1108,8 @@ get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT
1982#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION)1108#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION)
1983 if (__is_overaligned_for_new(_LIBCPP_ALIGNOF(_Tp)))1109 if (__is_overaligned_for_new(_LIBCPP_ALIGNOF(_Tp)))
1984 {1110 {
1985 std::align_val_t __al =1111 align_val_t __al =
1986 std::align_val_t(std::alignment_of<_Tp>::value);1112 align_val_t(alignment_of<_Tp>::value);
1987 __r.first = static_cast<_Tp*>(::operator new(1113 __r.first = static_cast<_Tp*>(::operator new(
1988 __n * sizeof(_Tp), __al, nothrow));1114 __n * sizeof(_Tp), __al, nothrow));
1989 } else {1115 } else {
...@@ -2052,7 +1178,7 @@ public:...@@ -2052,7 +1178,7 @@ public:
2052 _LIBCPP_INLINE_VISIBILITY _Tp* release() _NOEXCEPT1178 _LIBCPP_INLINE_VISIBILITY _Tp* release() _NOEXCEPT
2053 {1179 {
2054 _Tp* __t = __ptr_;1180 _Tp* __t = __ptr_;
2055 __ptr_ = 0;1181 __ptr_ = nullptr;
2056 return __t;1182 return __t;
2057 }1183 }
2058 _LIBCPP_INLINE_VISIBILITY void reset(_Tp* __p = 0) _NOEXCEPT1184 _LIBCPP_INLINE_VISIBILITY void reset(_Tp* __p = 0) _NOEXCEPT
...@@ -2168,7 +1294,7 @@ class __compressed_pair : private __compressed_pair_elem<_T1, 0>,...@@ -2168,7 +1294,7 @@ class __compressed_pair : private __compressed_pair_elem<_T1, 0>,
2168 // (The exception is std::function where it is possible that the function1294 // (The exception is std::function where it is possible that the function
2169 // object and the allocator have the same type).1295 // object and the allocator have the same type).
2170 static_assert((!is_same<_T1, _T2>::value),1296 static_assert((!is_same<_T1, _T2>::value),
2171 "__compressed_pair cannot be instantated when T1 and T2 are the same type; "1297 "__compressed_pair cannot be instantiated when T1 and T2 are the same type; "
2172 "The current implementation is NOT ABI-compatible with the previous "1298 "The current implementation is NOT ABI-compatible with the previous "
2173 "implementation for this configuration");1299 "implementation for this configuration");
21741300
...@@ -2185,7 +1311,7 @@ public:...@@ -2185,7 +1311,7 @@ public:
2185 template <class _U1, class _U2>1311 template <class _U1, class _U2>
2186 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR1312 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2187 __compressed_pair(_U1&& __t1, _U2&& __t2)1313 __compressed_pair(_U1&& __t1, _U2&& __t2)
2188 : _Base1(std::forward<_U1>(__t1)), _Base2(std::forward<_U2>(__t2)) {}1314 : _Base1(_VSTD::forward<_U1>(__t1)), _Base2(_VSTD::forward<_U2>(__t2)) {}
21891315
2190#ifndef _LIBCPP_CXX03_LANG1316#ifndef _LIBCPP_CXX03_LANG
2191 template <class... _Args1, class... _Args2>1317 template <class... _Args1, class... _Args2>
...@@ -2223,7 +1349,7 @@ public:...@@ -2223,7 +1349,7 @@ public:
2223 _NOEXCEPT_(__is_nothrow_swappable<_T1>::value &&1349 _NOEXCEPT_(__is_nothrow_swappable<_T1>::value &&
2224 __is_nothrow_swappable<_T2>::value)1350 __is_nothrow_swappable<_T2>::value)
2225 {1351 {
2226 using std::swap;1352 using _VSTD::swap;
2227 swap(first(), __x.first());1353 swap(first(), __x.first());
2228 swap(second(), __x.second());1354 swap(second(), __x.second());
2229 }1355 }
...@@ -2316,8 +1442,14 @@ struct __unique_ptr_deleter_sfinae<_Deleter&> {...@@ -2316,8 +1442,14 @@ struct __unique_ptr_deleter_sfinae<_Deleter&> {
2316 typedef false_type __enable_rval_overload;1442 typedef false_type __enable_rval_overload;
2317};1443};
23181444
1445#if defined(_LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI)
1446# define _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI __attribute__((trivial_abi))
1447#else
1448# define _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI
1449#endif
1450
2319template <class _Tp, class _Dp = default_delete<_Tp> >1451template <class _Tp, class _Dp = default_delete<_Tp> >
2320class _LIBCPP_TEMPLATE_VIS unique_ptr {1452class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr {
2321public:1453public:
2322 typedef _Tp element_type;1454 typedef _Tp element_type;
2323 typedef _Dp deleter_type;1455 typedef _Dp deleter_type;
...@@ -2525,7 +1657,7 @@ public:...@@ -2525,7 +1657,7 @@ public:
25251657
25261658
2527template <class _Tp, class _Dp>1659template <class _Tp, class _Dp>
2528class _LIBCPP_TEMPLATE_VIS unique_ptr<_Tp[], _Dp> {1660class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr<_Tp[], _Dp> {
2529public:1661public:
2530 typedef _Tp element_type;1662 typedef _Tp element_type;
2531 typedef _Dp deleter_type;1663 typedef _Dp deleter_type;
...@@ -2987,7 +2119,7 @@ public:...@@ -2987,7 +2119,7 @@ public:
2987 : __size_(__s) {}2119 : __size_(__s) {}
29882120
2989 template <class _Tp>2121 template <class _Tp>
2990 _LIBCPP_INLINE_VISIBILITY void __incr(_Tp*) _NOEXCEPT2122 _LIBCPP_INLINE_VISIBILITY void __incr() _NOEXCEPT
2991 {__incr(integral_constant<bool, is_trivially_destructible<_Tp>::value>());}2123 {__incr(integral_constant<bool, is_trivially_destructible<_Tp>::value>());}
29922124
2993 template <class _Tp>2125 template <class _Tp>
...@@ -3029,7 +2161,7 @@ uninitialized_copy(_InputIterator __f, _InputIterator __l, _ForwardIterator __r)...@@ -3029,7 +2161,7 @@ uninitialized_copy(_InputIterator __f, _InputIterator __l, _ForwardIterator __r)
3029 {2161 {
3030#endif2162#endif
3031 for (; __f != __l; ++__f, (void) ++__r)2163 for (; __f != __l; ++__f, (void) ++__r)
3032 ::new (static_cast<void*>(_VSTD::addressof(*__r))) value_type(*__f);2164 ::new ((void*)_VSTD::addressof(*__r)) value_type(*__f);
3033#ifndef _LIBCPP_NO_EXCEPTIONS2165#ifndef _LIBCPP_NO_EXCEPTIONS
3034 }2166 }
3035 catch (...)2167 catch (...)
...@@ -3053,7 +2185,7 @@ uninitialized_copy_n(_InputIterator __f, _Size __n, _ForwardIterator __r)...@@ -3053,7 +2185,7 @@ uninitialized_copy_n(_InputIterator __f, _Size __n, _ForwardIterator __r)
3053 {2185 {
3054#endif2186#endif
3055 for (; __n > 0; ++__f, (void) ++__r, (void) --__n)2187 for (; __n > 0; ++__f, (void) ++__r, (void) --__n)
3056 ::new (static_cast<void*>(_VSTD::addressof(*__r))) value_type(*__f);2188 ::new ((void*)_VSTD::addressof(*__r)) value_type(*__f);
3057#ifndef _LIBCPP_NO_EXCEPTIONS2189#ifndef _LIBCPP_NO_EXCEPTIONS
3058 }2190 }
3059 catch (...)2191 catch (...)
...@@ -3077,7 +2209,7 @@ uninitialized_fill(_ForwardIterator __f, _ForwardIterator __l, const _Tp& __x)...@@ -3077,7 +2209,7 @@ uninitialized_fill(_ForwardIterator __f, _ForwardIterator __l, const _Tp& __x)
3077 {2209 {
3078#endif2210#endif
3079 for (; __f != __l; ++__f)2211 for (; __f != __l; ++__f)
3080 ::new (static_cast<void*>(_VSTD::addressof(*__f))) value_type(__x);2212 ::new ((void*)_VSTD::addressof(*__f)) value_type(__x);
3081#ifndef _LIBCPP_NO_EXCEPTIONS2213#ifndef _LIBCPP_NO_EXCEPTIONS
3082 }2214 }
3083 catch (...)2215 catch (...)
...@@ -3100,7 +2232,7 @@ uninitialized_fill_n(_ForwardIterator __f, _Size __n, const _Tp& __x)...@@ -3100,7 +2232,7 @@ uninitialized_fill_n(_ForwardIterator __f, _Size __n, const _Tp& __x)
3100 {2232 {
3101#endif2233#endif
3102 for (; __n > 0; ++__f, (void) --__n)2234 for (; __n > 0; ++__f, (void) --__n)
3103 ::new (static_cast<void*>(_VSTD::addressof(*__f))) value_type(__x);2235 ::new ((void*)_VSTD::addressof(*__f)) value_type(__x);
3104#ifndef _LIBCPP_NO_EXCEPTIONS2236#ifndef _LIBCPP_NO_EXCEPTIONS
3105 }2237 }
3106 catch (...)2238 catch (...)
...@@ -3115,22 +2247,15 @@ uninitialized_fill_n(_ForwardIterator __f, _Size __n, const _Tp& __x)...@@ -3115,22 +2247,15 @@ uninitialized_fill_n(_ForwardIterator __f, _Size __n, const _Tp& __x)
31152247
3116#if _LIBCPP_STD_VER > 142248#if _LIBCPP_STD_VER > 14
31172249
3118template <class _Tp>
3119inline _LIBCPP_INLINE_VISIBILITY
3120void destroy_at(_Tp* __loc) {
3121 _LIBCPP_ASSERT(__loc, "null pointer given to destroy_at");
3122 __loc->~_Tp();
3123}
3124
3125template <class _ForwardIterator>2250template <class _ForwardIterator>
3126inline _LIBCPP_INLINE_VISIBILITY2251inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
3127void destroy(_ForwardIterator __first, _ForwardIterator __last) {2252void destroy(_ForwardIterator __first, _ForwardIterator __last) {
3128 for (; __first != __last; ++__first)2253 for (; __first != __last; ++__first)
3129 _VSTD::destroy_at(_VSTD::addressof(*__first));2254 _VSTD::destroy_at(_VSTD::addressof(*__first));
3130}2255}
31312256
3132template <class _ForwardIterator, class _Size>2257template <class _ForwardIterator, class _Size>
3133inline _LIBCPP_INLINE_VISIBILITY2258inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
3134_ForwardIterator destroy_n(_ForwardIterator __first, _Size __n) {2259_ForwardIterator destroy_n(_ForwardIterator __first, _Size __n) {
3135 for (; __n > 0; (void)++__first, --__n)2260 for (; __n > 0; (void)++__first, --__n)
3136 _VSTD::destroy_at(_VSTD::addressof(*__first));2261 _VSTD::destroy_at(_VSTD::addressof(*__first));
...@@ -3146,7 +2271,7 @@ void uninitialized_default_construct(_ForwardIterator __first, _ForwardIterator...@@ -3146,7 +2271,7 @@ void uninitialized_default_construct(_ForwardIterator __first, _ForwardIterator
3146 try {2271 try {
3147#endif2272#endif
3148 for (; __idx != __last; ++__idx)2273 for (; __idx != __last; ++__idx)
3149 ::new((void*)_VSTD::addressof(*__idx)) _Vt;2274 ::new ((void*)_VSTD::addressof(*__idx)) _Vt;
3150#ifndef _LIBCPP_NO_EXCEPTIONS2275#ifndef _LIBCPP_NO_EXCEPTIONS
3151 } catch (...) {2276 } catch (...) {
3152 _VSTD::destroy(__first, __idx);2277 _VSTD::destroy(__first, __idx);
...@@ -3164,7 +2289,7 @@ _ForwardIterator uninitialized_default_construct_n(_ForwardIterator __first, _Si...@@ -3164,7 +2289,7 @@ _ForwardIterator uninitialized_default_construct_n(_ForwardIterator __first, _Si
3164 try {2289 try {
3165#endif2290#endif
3166 for (; __n > 0; (void)++__idx, --__n)2291 for (; __n > 0; (void)++__idx, --__n)
3167 ::new((void*)_VSTD::addressof(*__idx)) _Vt;2292 ::new ((void*)_VSTD::addressof(*__idx)) _Vt;
3168 return __idx;2293 return __idx;
3169#ifndef _LIBCPP_NO_EXCEPTIONS2294#ifndef _LIBCPP_NO_EXCEPTIONS
3170 } catch (...) {2295 } catch (...) {
...@@ -3184,7 +2309,7 @@ void uninitialized_value_construct(_ForwardIterator __first, _ForwardIterator __...@@ -3184,7 +2309,7 @@ void uninitialized_value_construct(_ForwardIterator __first, _ForwardIterator __
3184 try {2309 try {
3185#endif2310#endif
3186 for (; __idx != __last; ++__idx)2311 for (; __idx != __last; ++__idx)
3187 ::new((void*)_VSTD::addressof(*__idx)) _Vt();2312 ::new ((void*)_VSTD::addressof(*__idx)) _Vt();
3188#ifndef _LIBCPP_NO_EXCEPTIONS2313#ifndef _LIBCPP_NO_EXCEPTIONS
3189 } catch (...) {2314 } catch (...) {
3190 _VSTD::destroy(__first, __idx);2315 _VSTD::destroy(__first, __idx);
...@@ -3202,7 +2327,7 @@ _ForwardIterator uninitialized_value_construct_n(_ForwardIterator __first, _Size...@@ -3202,7 +2327,7 @@ _ForwardIterator uninitialized_value_construct_n(_ForwardIterator __first, _Size
3202 try {2327 try {
3203#endif2328#endif
3204 for (; __n > 0; (void)++__idx, --__n)2329 for (; __n > 0; (void)++__idx, --__n)
3205 ::new((void*)_VSTD::addressof(*__idx)) _Vt();2330 ::new ((void*)_VSTD::addressof(*__idx)) _Vt();
3206 return __idx;2331 return __idx;
3207#ifndef _LIBCPP_NO_EXCEPTIONS2332#ifndef _LIBCPP_NO_EXCEPTIONS
3208 } catch (...) {2333 } catch (...) {
...@@ -3222,7 +2347,7 @@ _ForwardIt uninitialized_move(_InputIt __first, _InputIt __last, _ForwardIt __fi...@@ -3222,7 +2347,7 @@ _ForwardIt uninitialized_move(_InputIt __first, _InputIt __last, _ForwardIt __fi
3222 try {2347 try {
3223#endif2348#endif
3224 for (; __first != __last; (void)++__idx, ++__first)2349 for (; __first != __last; (void)++__idx, ++__first)
3225 ::new((void*)_VSTD::addressof(*__idx)) _Vt(std::move(*__first));2350 ::new ((void*)_VSTD::addressof(*__idx)) _Vt(_VSTD::move(*__first));
3226 return __idx;2351 return __idx;
3227#ifndef _LIBCPP_NO_EXCEPTIONS2352#ifndef _LIBCPP_NO_EXCEPTIONS
3228 } catch (...) {2353 } catch (...) {
...@@ -3242,7 +2367,7 @@ uninitialized_move_n(_InputIt __first, _Size __n, _ForwardIt __first_res) {...@@ -3242,7 +2367,7 @@ uninitialized_move_n(_InputIt __first, _Size __n, _ForwardIt __first_res) {
3242 try {2367 try {
3243#endif2368#endif
3244 for (; __n > 0; ++__idx, (void)++__first, --__n)2369 for (; __n > 0; ++__idx, (void)++__first, --__n)
3245 ::new((void*)_VSTD::addressof(*__idx)) _Vt(std::move(*__first));2370 ::new ((void*)_VSTD::addressof(*__idx)) _Vt(_VSTD::move(*__first));
3246 return {__first, __idx};2371 return {__first, __idx};
3247#ifndef _LIBCPP_NO_EXCEPTIONS2372#ifndef _LIBCPP_NO_EXCEPTIONS
3248 } catch (...) {2373 } catch (...) {
...@@ -3389,13 +2514,7 @@ public:...@@ -3389,13 +2514,7 @@ public:
3389 long use_count() const _NOEXCEPT {return __shared_count::use_count();}2514 long use_count() const _NOEXCEPT {return __shared_count::use_count();}
3390 __shared_weak_count* lock() _NOEXCEPT;2515 __shared_weak_count* lock() _NOEXCEPT;
33912516
3392 // Define the function out only if we build static libc++ without RTTI.
3393 // Otherwise we may break clients who need to compile their projects with
3394 // -fno-rtti and yet link against a libc++.dylib compiled
3395 // without -fno-rtti.
3396#if !defined(_LIBCPP_NO_RTTI) || !defined(_LIBCPP_BUILD_STATIC)
3397 virtual const void* __get_deleter(const type_info&) const _NOEXCEPT;2517 virtual const void* __get_deleter(const type_info&) const _NOEXCEPT;
3398#endif
3399private:2518private:
3400 virtual void __on_zero_shared_weak() _NOEXCEPT = 0;2519 virtual void __on_zero_shared_weak() _NOEXCEPT = 0;
3401};2520};
...@@ -3452,68 +2571,47 @@ __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT...@@ -3452,68 +2571,47 @@ __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT
3452}2571}
34532572
3454template <class _Tp, class _Alloc>2573template <class _Tp, class _Alloc>
3455class __shared_ptr_emplace2574struct __shared_ptr_emplace
3456 : public __shared_weak_count2575 : __shared_weak_count
3457{2576{
3458 __compressed_pair<_Alloc, _Tp> __data_;2577 _LIBCPP_HIDE_FROM_ABI
3459public:2578 explicit __shared_ptr_emplace(_Alloc __a)
2579 : __data_(_VSTD::move(__a), __value_init_tag())
2580 { }
34602581
3461 _LIBCPP_INLINE_VISIBILITY
3462 __shared_ptr_emplace(_Alloc __a)
3463 : __data_(_VSTD::move(__a), __value_init_tag()) {}
3464
3465
3466#ifndef _LIBCPP_HAS_NO_VARIADICS
3467 template <class ..._Args>2582 template <class ..._Args>
3468 _LIBCPP_INLINE_VISIBILITY2583 _LIBCPP_HIDE_FROM_ABI
3469 __shared_ptr_emplace(_Alloc __a, _Args&& ...__args)2584 explicit __shared_ptr_emplace(_Alloc __a, _Args&& ...__args)
3470 : __data_(piecewise_construct, _VSTD::forward_as_tuple(__a),2585#ifndef _LIBCPP_CXX03_LANG
3471 _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)) {}2586 : __data_(piecewise_construct, _VSTD::forward_as_tuple(__a),
3472#else // _LIBCPP_HAS_NO_VARIADICS2587 _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...))
34732588#else
3474 template <class _A0>2589 : __data_(__a, _Tp(_VSTD::forward<_Args>(__args)...))
3475 _LIBCPP_INLINE_VISIBILITY2590#endif
3476 __shared_ptr_emplace(_Alloc __a, _A0& __a0)2591 { }
3477 : __data_(__a, _Tp(__a0)) {}
3478
3479 template <class _A0, class _A1>
3480 _LIBCPP_INLINE_VISIBILITY
3481 __shared_ptr_emplace(_Alloc __a, _A0& __a0, _A1& __a1)
3482 : __data_(__a, _Tp(__a0, __a1)) {}
34832592
3484 template <class _A0, class _A1, class _A2>2593 _LIBCPP_HIDE_FROM_ABI
3485 _LIBCPP_INLINE_VISIBILITY2594 _Tp* __get_elem() _NOEXCEPT { return _VSTD::addressof(__data_.second()); }
3486 __shared_ptr_emplace(_Alloc __a, _A0& __a0, _A1& __a1, _A2& __a2)
3487 : __data_(__a, _Tp(__a0, __a1, __a2)) {}
34882595
3489#endif // _LIBCPP_HAS_NO_VARIADICS2596 _LIBCPP_HIDE_FROM_ABI
2597 _Alloc* __get_alloc() _NOEXCEPT { return _VSTD::addressof(__data_.first()); }
34902598
3491private:2599private:
3492 virtual void __on_zero_shared() _NOEXCEPT;2600 virtual void __on_zero_shared() _NOEXCEPT {
3493 virtual void __on_zero_shared_weak() _NOEXCEPT;2601 __get_elem()->~_Tp();
3494public:2602 }
3495 _LIBCPP_INLINE_VISIBILITY
3496 _Tp* get() _NOEXCEPT {return _VSTD::addressof(__data_.second());}
3497};
34982603
3499template <class _Tp, class _Alloc>2604 virtual void __on_zero_shared_weak() _NOEXCEPT {
3500void2605 using _ControlBlockAlloc = typename __allocator_traits_rebind<_Alloc, __shared_ptr_emplace>::type;
3501__shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared() _NOEXCEPT2606 using _ControlBlockPointer = typename allocator_traits<_ControlBlockAlloc>::pointer;
3502{2607 _ControlBlockAlloc __tmp(*__get_alloc());
3503 __data_.second().~_Tp();2608 __get_alloc()->~_Alloc();
3504}2609 allocator_traits<_ControlBlockAlloc>::deallocate(__tmp,
2610 pointer_traits<_ControlBlockPointer>::pointer_to(*this), 1);
2611 }
35052612
3506template <class _Tp, class _Alloc>2613 __compressed_pair<_Alloc, _Tp> __data_;
3507void2614};
3508__shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT
3509{
3510 typedef typename __allocator_traits_rebind<_Alloc, __shared_ptr_emplace>::type _Al;
3511 typedef allocator_traits<_Al> _ATraits;
3512 typedef pointer_traits<typename _ATraits::pointer> _PTraits;
3513 _Al __a(__data_.first());
3514 __data_.first().~_Alloc();
3515 __a.deallocate(_PTraits::pointer_to(*this), 1);
3516}
35172615
3518struct __shared_ptr_dummy_rebind_allocator_type;2616struct __shared_ptr_dummy_rebind_allocator_type;
3519template <>2617template <>
...@@ -3537,8 +2635,14 @@ struct __compatible_with...@@ -3537,8 +2635,14 @@ struct __compatible_with
3537 : is_convertible<_Tp*, _Up*> {};2635 : is_convertible<_Tp*, _Up*> {};
3538#endif // _LIBCPP_STD_VER > 142636#endif // _LIBCPP_STD_VER > 14
35392637
2638#if defined(_LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI)
2639# define _LIBCPP_SHARED_PTR_TRIVIAL_ABI __attribute__((trivial_abi))
2640#else
2641# define _LIBCPP_SHARED_PTR_TRIVIAL_ABI
2642#endif
2643
3540template<class _Tp>2644template<class _Tp>
3541class _LIBCPP_TEMPLATE_VIS shared_ptr2645class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS shared_ptr
3542{2646{
3543public:2647public:
3544#if _LIBCPP_STD_VER > 142648#if _LIBCPP_STD_VER > 14
...@@ -3577,25 +2681,17 @@ public:...@@ -3577,25 +2681,17 @@ public:
3577 shared_ptr(const shared_ptr<_Yp>& __r,2681 shared_ptr(const shared_ptr<_Yp>& __r,
3578 typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type = __nat())2682 typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type = __nat())
3579 _NOEXCEPT;2683 _NOEXCEPT;
3580#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3581 _LIBCPP_INLINE_VISIBILITY2684 _LIBCPP_INLINE_VISIBILITY
3582 shared_ptr(shared_ptr&& __r) _NOEXCEPT;2685 shared_ptr(shared_ptr&& __r) _NOEXCEPT;
3583 template<class _Yp> _LIBCPP_INLINE_VISIBILITY shared_ptr(shared_ptr<_Yp>&& __r,2686 template<class _Yp> _LIBCPP_INLINE_VISIBILITY shared_ptr(shared_ptr<_Yp>&& __r,
3584 typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type = __nat())2687 typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type = __nat())
3585 _NOEXCEPT;2688 _NOEXCEPT;
3586#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3587 template<class _Yp> explicit shared_ptr(const weak_ptr<_Yp>& __r,2689 template<class _Yp> explicit shared_ptr(const weak_ptr<_Yp>& __r,
3588 typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type= __nat());2690 typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type= __nat());
3589#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)2691#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
3590#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3591 template<class _Yp>2692 template<class _Yp>
3592 shared_ptr(auto_ptr<_Yp>&& __r,2693 shared_ptr(auto_ptr<_Yp>&& __r,
3593 typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat());2694 typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat());
3594#else
3595 template<class _Yp>
3596 shared_ptr(auto_ptr<_Yp> __r,
3597 typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat());
3598#endif
3599#endif2695#endif
3600 template <class _Yp, class _Dp>2696 template <class _Yp, class _Dp>
3601 shared_ptr(unique_ptr<_Yp, _Dp>&&,2697 shared_ptr(unique_ptr<_Yp, _Dp>&&,
...@@ -3628,7 +2724,6 @@ public:...@@ -3628,7 +2724,6 @@ public:
3628 >::type2724 >::type
3629 _LIBCPP_INLINE_VISIBILITY2725 _LIBCPP_INLINE_VISIBILITY
3630 operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT;2726 operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT;
3631#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3632 _LIBCPP_INLINE_VISIBILITY2727 _LIBCPP_INLINE_VISIBILITY
3633 shared_ptr& operator=(shared_ptr&& __r) _NOEXCEPT;2728 shared_ptr& operator=(shared_ptr&& __r) _NOEXCEPT;
3634 template<class _Yp>2729 template<class _Yp>
...@@ -3649,19 +2744,6 @@ public:...@@ -3649,19 +2744,6 @@ public:
3649 shared_ptr2744 shared_ptr
3650 >::type&2745 >::type&
3651 operator=(auto_ptr<_Yp>&& __r);2746 operator=(auto_ptr<_Yp>&& __r);
3652#endif
3653#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3654#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
3655 template<class _Yp>
3656 _LIBCPP_INLINE_VISIBILITY
3657 typename enable_if
3658 <
3659 !is_array<_Yp>::value &&
3660 is_convertible<_Yp*, element_type*>::value,
3661 shared_ptr&
3662 >::type
3663 operator=(auto_ptr<_Yp> __r);
3664#endif
3665#endif2747#endif
3666 template <class _Yp, class _Dp>2748 template <class _Yp, class _Dp>
3667 typename enable_if2749 typename enable_if
...@@ -3670,13 +2752,8 @@ public:...@@ -3670,13 +2752,8 @@ public:
3670 is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,2752 is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
3671 shared_ptr&2753 shared_ptr&
3672 >::type2754 >::type
3673#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3674 _LIBCPP_INLINE_VISIBILITY2755 _LIBCPP_INLINE_VISIBILITY
3675 operator=(unique_ptr<_Yp, _Dp>&& __r);2756 operator=(unique_ptr<_Yp, _Dp>&& __r);
3676#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3677 _LIBCPP_INLINE_VISIBILITY
3678 operator=(unique_ptr<_Yp, _Dp> __r);
3679#endif
36802757
3681 _LIBCPP_INLINE_VISIBILITY2758 _LIBCPP_INLINE_VISIBILITY
3682 void swap(shared_ptr& __r) _NOEXCEPT;2759 void swap(shared_ptr& __r) _NOEXCEPT;
...@@ -3724,7 +2801,7 @@ public:...@@ -3724,7 +2801,7 @@ public:
3724 _LIBCPP_INLINE_VISIBILITY2801 _LIBCPP_INLINE_VISIBILITY
3725 bool unique() const _NOEXCEPT {return use_count() == 1;}2802 bool unique() const _NOEXCEPT {return use_count() == 1;}
3726 _LIBCPP_INLINE_VISIBILITY2803 _LIBCPP_INLINE_VISIBILITY
3727 _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return get() != 0;}2804 _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return get() != nullptr;}
3728 template <class _Up>2805 template <class _Up>
3729 _LIBCPP_INLINE_VISIBILITY2806 _LIBCPP_INLINE_VISIBILITY
3730 bool owner_before(shared_ptr<_Up> const& __p) const _NOEXCEPT2807 bool owner_before(shared_ptr<_Up> const& __p) const _NOEXCEPT
...@@ -3828,8 +2905,8 @@ template<class _Tp>...@@ -3828,8 +2905,8 @@ template<class _Tp>
3828inline2905inline
3829_LIBCPP_CONSTEXPR2906_LIBCPP_CONSTEXPR
3830shared_ptr<_Tp>::shared_ptr() _NOEXCEPT2907shared_ptr<_Tp>::shared_ptr() _NOEXCEPT
3831 : __ptr_(0),2908 : __ptr_(nullptr),
3832 __cntrl_(0)2909 __cntrl_(nullptr)
3833{2910{
3834}2911}
38352912
...@@ -3837,8 +2914,8 @@ template<class _Tp>...@@ -3837,8 +2914,8 @@ template<class _Tp>
3837inline2914inline
3838_LIBCPP_CONSTEXPR2915_LIBCPP_CONSTEXPR
3839shared_ptr<_Tp>::shared_ptr(nullptr_t) _NOEXCEPT2916shared_ptr<_Tp>::shared_ptr(nullptr_t) _NOEXCEPT
3840 : __ptr_(0),2917 : __ptr_(nullptr),
3841 __cntrl_(0)2918 __cntrl_(nullptr)
3842{2919{
3843}2920}
38442921
...@@ -3883,7 +2960,7 @@ shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d,...@@ -3883,7 +2960,7 @@ shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d,
3883template<class _Tp>2960template<class _Tp>
3884template<class _Dp>2961template<class _Dp>
3885shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d)2962shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d)
3886 : __ptr_(0)2963 : __ptr_(nullptr)
3887{2964{
3888#ifndef _LIBCPP_NO_EXCEPTIONS2965#ifndef _LIBCPP_NO_EXCEPTIONS
3889 try2966 try
...@@ -3917,8 +2994,7 @@ shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a,...@@ -3917,8 +2994,7 @@ shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a,
3917 typedef __allocator_destructor<_A2> _D2;2994 typedef __allocator_destructor<_A2> _D2;
3918 _A2 __a2(__a);2995 _A2 __a2(__a);
3919 unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));2996 unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
3920 ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))2997 ::new ((void*)_VSTD::addressof(*__hold2.get())) _CntrlBlk(__p, __d, __a);
3921 _CntrlBlk(__p, __d, __a);
3922 __cntrl_ = _VSTD::addressof(*__hold2.release());2998 __cntrl_ = _VSTD::addressof(*__hold2.release());
3923 __enable_weak_this(__p, __p);2999 __enable_weak_this(__p, __p);
3924#ifndef _LIBCPP_NO_EXCEPTIONS3000#ifndef _LIBCPP_NO_EXCEPTIONS
...@@ -3934,7 +3010,7 @@ shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a,...@@ -3934,7 +3010,7 @@ shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a,
3934template<class _Tp>3010template<class _Tp>
3935template<class _Dp, class _Alloc>3011template<class _Dp, class _Alloc>
3936shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a)3012shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a)
3937 : __ptr_(0)3013 : __ptr_(nullptr)
3938{3014{
3939#ifndef _LIBCPP_NO_EXCEPTIONS3015#ifndef _LIBCPP_NO_EXCEPTIONS
3940 try3016 try
...@@ -3945,8 +3021,7 @@ shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a)...@@ -3945,8 +3021,7 @@ shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a)
3945 typedef __allocator_destructor<_A2> _D2;3021 typedef __allocator_destructor<_A2> _D2;
3946 _A2 __a2(__a);3022 _A2 __a2(__a);
3947 unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));3023 unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
3948 ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))3024 ::new ((void*)_VSTD::addressof(*__hold2.get())) _CntrlBlk(__p, __d, __a);
3949 _CntrlBlk(__p, __d, __a);
3950 __cntrl_ = _VSTD::addressof(*__hold2.release());3025 __cntrl_ = _VSTD::addressof(*__hold2.release());
3951#ifndef _LIBCPP_NO_EXCEPTIONS3026#ifndef _LIBCPP_NO_EXCEPTIONS
3952 }3027 }
...@@ -3992,16 +3067,14 @@ shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r,...@@ -3992,16 +3067,14 @@ shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r,
3992 __cntrl_->__add_shared();3067 __cntrl_->__add_shared();
3993}3068}
39943069
3995#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3996
3997template<class _Tp>3070template<class _Tp>
3998inline3071inline
3999shared_ptr<_Tp>::shared_ptr(shared_ptr&& __r) _NOEXCEPT3072shared_ptr<_Tp>::shared_ptr(shared_ptr&& __r) _NOEXCEPT
4000 : __ptr_(__r.__ptr_),3073 : __ptr_(__r.__ptr_),
4001 __cntrl_(__r.__cntrl_)3074 __cntrl_(__r.__cntrl_)
4002{3075{
4003 __r.__ptr_ = 0;3076 __r.__ptr_ = nullptr;
4004 __r.__cntrl_ = 0;3077 __r.__cntrl_ = nullptr;
4005}3078}
40063079
4007template<class _Tp>3080template<class _Tp>
...@@ -4013,20 +3086,14 @@ shared_ptr<_Tp>::shared_ptr(shared_ptr<_Yp>&& __r,...@@ -4013,20 +3086,14 @@ shared_ptr<_Tp>::shared_ptr(shared_ptr<_Yp>&& __r,
4013 : __ptr_(__r.__ptr_),3086 : __ptr_(__r.__ptr_),
4014 __cntrl_(__r.__cntrl_)3087 __cntrl_(__r.__cntrl_)
4015{3088{
4016 __r.__ptr_ = 0;3089 __r.__ptr_ = nullptr;
4017 __r.__cntrl_ = 0;3090 __r.__cntrl_ = nullptr;
4018}3091}
40193092
4020#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
4021
4022#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)3093#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
4023template<class _Tp>3094template<class _Tp>
4024template<class _Yp>3095template<class _Yp>
4025#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
4026shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp>&& __r,3096shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp>&& __r,
4027#else
4028shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp> __r,
4029#endif
4030 typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type)3097 typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type)
4031 : __ptr_(__r.get())3098 : __ptr_(__r.get())
4032{3099{
...@@ -4121,8 +3188,6 @@ shared_ptr<_Tp>::operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT...@@ -4121,8 +3188,6 @@ shared_ptr<_Tp>::operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT
4121 return *this;3188 return *this;
4122}3189}
41233190
4124#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
4125
4126template<class _Tp>3191template<class _Tp>
4127inline3192inline
4128shared_ptr<_Tp>&3193shared_ptr<_Tp>&
...@@ -4179,43 +3244,6 @@ shared_ptr<_Tp>::operator=(unique_ptr<_Yp, _Dp>&& __r)...@@ -4179,43 +3244,6 @@ shared_ptr<_Tp>::operator=(unique_ptr<_Yp, _Dp>&& __r)
4179 return *this;3244 return *this;
4180}3245}
41813246
4182#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
4183
4184#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
4185template<class _Tp>
4186template<class _Yp>
4187inline _LIBCPP_INLINE_VISIBILITY
4188typename enable_if
4189<
4190 !is_array<_Yp>::value &&
4191 is_convertible<_Yp*, typename shared_ptr<_Tp>::element_type*>::value,
4192 shared_ptr<_Tp>&
4193>::type
4194shared_ptr<_Tp>::operator=(auto_ptr<_Yp> __r)
4195{
4196 shared_ptr(__r).swap(*this);
4197 return *this;
4198}
4199#endif
4200
4201template<class _Tp>
4202template <class _Yp, class _Dp>
4203inline _LIBCPP_INLINE_VISIBILITY
4204typename enable_if
4205<
4206 !is_array<_Yp>::value &&
4207 is_convertible<typename unique_ptr<_Yp, _Dp>::pointer,
4208 typename shared_ptr<_Tp>::element_type*>::value,
4209 shared_ptr<_Tp>&
4210>::type
4211shared_ptr<_Tp>::operator=(unique_ptr<_Yp, _Dp> __r)
4212{
4213 shared_ptr(_VSTD::move(__r)).swap(*this);
4214 return *this;
4215}
4216
4217#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
4218
4219template<class _Tp>3247template<class _Tp>
4220inline3248inline
4221void3249void
...@@ -4272,50 +3300,26 @@ shared_ptr<_Tp>::reset(_Yp* __p, _Dp __d, _Alloc __a)...@@ -4272,50 +3300,26 @@ shared_ptr<_Tp>::reset(_Yp* __p, _Dp __d, _Alloc __a)
4272 shared_ptr(__p, __d, __a).swap(*this);3300 shared_ptr(__p, __d, __a).swap(*this);
4273}3301}
42743302
4275template<class _Tp, class ..._Args>3303//
4276inline _LIBCPP_INLINE_VISIBILITY3304// std::allocate_shared and std::make_shared
4277typename enable_if3305//
4278<3306template<class _Tp, class _Alloc, class ..._Args, class = _EnableIf<!is_array<_Tp>::value> >
4279 !is_array<_Tp>::value,3307_LIBCPP_HIDE_FROM_ABI
4280 shared_ptr<_Tp>3308shared_ptr<_Tp> allocate_shared(const _Alloc& __a, _Args&& ...__args)
4281>::type
4282make_shared(_Args&& ...__args)
4283{3309{
4284 static_assert(is_constructible<_Tp, _Args...>::value, "Can't construct object in make_shared");3310 using _ControlBlock = __shared_ptr_emplace<_Tp, _Alloc>;
4285 typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk;3311 using _ControlBlockAllocator = typename __allocator_traits_rebind<_Alloc, _ControlBlock>::type;
4286 typedef allocator<_CntrlBlk> _A2;3312 __allocation_guard<_ControlBlockAllocator> __guard(__a, 1);
4287 typedef __allocator_destructor<_A2> _D2;3313 ::new ((void*)_VSTD::addressof(*__guard.__get())) _ControlBlock(__a, _VSTD::forward<_Args>(__args)...);
42883314 auto __control_block = __guard.__release_ptr();
4289 _A2 __a2;3315 return shared_ptr<_Tp>::__create_with_control_block((*__control_block).__get_elem(), _VSTD::addressof(*__control_block));
4290 unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
4291 ::new(__hold2.get()) _CntrlBlk(__a2, _VSTD::forward<_Args>(__args)...);
4292
4293 _Tp *__ptr = __hold2.get()->get();
4294 return shared_ptr<_Tp>::__create_with_control_block(__ptr, __hold2.release());
4295}3316}
42963317
4297template<class _Tp, class _Alloc, class ..._Args>3318template<class _Tp, class ..._Args, class = _EnableIf<!is_array<_Tp>::value> >
4298inline _LIBCPP_INLINE_VISIBILITY3319_LIBCPP_HIDE_FROM_ABI
4299typename enable_if3320shared_ptr<_Tp> make_shared(_Args&& ...__args)
4300<
4301 !is_array<_Tp>::value,
4302 shared_ptr<_Tp>
4303>::type
4304allocate_shared(const _Alloc& __a, _Args&& ...__args)
4305{3321{
4306 static_assert( is_constructible<_Tp, _Args...>::value, "Can't construct object in allocate_shared");3322 return _VSTD::allocate_shared<_Tp>(allocator<_Tp>(), _VSTD::forward<_Args>(__args)...);
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()));
4319}3323}
43203324
4321template<class _Tp, class _Up>3325template<class _Tp, class _Up>
...@@ -4526,7 +3530,7 @@ get_deleter(const shared_ptr<_Tp>& __p) _NOEXCEPT...@@ -4526,7 +3530,7 @@ get_deleter(const shared_ptr<_Tp>& __p) _NOEXCEPT
4526#endif // _LIBCPP_NO_RTTI3530#endif // _LIBCPP_NO_RTTI
45273531
4528template<class _Tp>3532template<class _Tp>
4529class _LIBCPP_TEMPLATE_VIS weak_ptr3533class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS weak_ptr
4530{3534{
4531public:3535public:
4532 typedef _Tp element_type;3536 typedef _Tp element_type;
...@@ -4546,13 +3550,11 @@ public:...@@ -4546,13 +3550,11 @@ public:
4546 typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0)3550 typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0)
4547 _NOEXCEPT;3551 _NOEXCEPT;
45483552
4549#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
4550 _LIBCPP_INLINE_VISIBILITY3553 _LIBCPP_INLINE_VISIBILITY
4551 weak_ptr(weak_ptr&& __r) _NOEXCEPT;3554 weak_ptr(weak_ptr&& __r) _NOEXCEPT;
4552 template<class _Yp> _LIBCPP_INLINE_VISIBILITY weak_ptr(weak_ptr<_Yp>&& __r,3555 template<class _Yp> _LIBCPP_INLINE_VISIBILITY weak_ptr(weak_ptr<_Yp>&& __r,
4553 typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0)3556 typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0)
4554 _NOEXCEPT;3557 _NOEXCEPT;
4555#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
4556 ~weak_ptr();3558 ~weak_ptr();
45573559
4558 _LIBCPP_INLINE_VISIBILITY3560 _LIBCPP_INLINE_VISIBILITY
...@@ -4566,8 +3568,6 @@ public:...@@ -4566,8 +3568,6 @@ public:
4566 _LIBCPP_INLINE_VISIBILITY3568 _LIBCPP_INLINE_VISIBILITY
4567 operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT;3569 operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT;
45683570
4569#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
4570
4571 _LIBCPP_INLINE_VISIBILITY3571 _LIBCPP_INLINE_VISIBILITY
4572 weak_ptr& operator=(weak_ptr&& __r) _NOEXCEPT;3572 weak_ptr& operator=(weak_ptr&& __r) _NOEXCEPT;
4573 template<class _Yp>3573 template<class _Yp>
...@@ -4579,8 +3579,6 @@ public:...@@ -4579,8 +3579,6 @@ public:
4579 _LIBCPP_INLINE_VISIBILITY3579 _LIBCPP_INLINE_VISIBILITY
4580 operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT;3580 operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT;
45813581
4582#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
4583
4584 template<class _Yp>3582 template<class _Yp>
4585 typename enable_if3583 typename enable_if
4586 <3584 <
...@@ -4600,7 +3598,7 @@ public:...@@ -4600,7 +3598,7 @@ public:
4600 {return __cntrl_ ? __cntrl_->use_count() : 0;}3598 {return __cntrl_ ? __cntrl_->use_count() : 0;}
4601 _LIBCPP_INLINE_VISIBILITY3599 _LIBCPP_INLINE_VISIBILITY
4602 bool expired() const _NOEXCEPT3600 bool expired() const _NOEXCEPT
4603 {return __cntrl_ == 0 || __cntrl_->use_count() == 0;}3601 {return __cntrl_ == nullptr || __cntrl_->use_count() == 0;}
4604 shared_ptr<_Tp> lock() const _NOEXCEPT;3602 shared_ptr<_Tp> lock() const _NOEXCEPT;
4605 template<class _Up>3603 template<class _Up>
4606 _LIBCPP_INLINE_VISIBILITY3604 _LIBCPP_INLINE_VISIBILITY
...@@ -4624,8 +3622,8 @@ template<class _Tp>...@@ -4624,8 +3622,8 @@ template<class _Tp>
4624inline3622inline
4625_LIBCPP_CONSTEXPR3623_LIBCPP_CONSTEXPR
4626weak_ptr<_Tp>::weak_ptr() _NOEXCEPT3624weak_ptr<_Tp>::weak_ptr() _NOEXCEPT
4627 : __ptr_(0),3625 : __ptr_(nullptr),
4628 __cntrl_(0)3626 __cntrl_(nullptr)
4629{3627{
4630}3628}
46313629
...@@ -4665,16 +3663,14 @@ weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp> const& __r,...@@ -4665,16 +3663,14 @@ weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp> const& __r,
4665 __cntrl_->__add_weak();3663 __cntrl_->__add_weak();
4666}3664}
46673665
4668#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
4669
4670template<class _Tp>3666template<class _Tp>
4671inline3667inline
4672weak_ptr<_Tp>::weak_ptr(weak_ptr&& __r) _NOEXCEPT3668weak_ptr<_Tp>::weak_ptr(weak_ptr&& __r) _NOEXCEPT
4673 : __ptr_(__r.__ptr_),3669 : __ptr_(__r.__ptr_),
4674 __cntrl_(__r.__cntrl_)3670 __cntrl_(__r.__cntrl_)
4675{3671{
4676 __r.__ptr_ = 0;3672 __r.__ptr_ = nullptr;
4677 __r.__cntrl_ = 0;3673 __r.__cntrl_ = nullptr;
4678}3674}
46793675
4680template<class _Tp>3676template<class _Tp>
...@@ -4686,12 +3682,10 @@ weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp>&& __r,...@@ -4686,12 +3682,10 @@ weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp>&& __r,
4686 : __ptr_(__r.__ptr_),3682 : __ptr_(__r.__ptr_),
4687 __cntrl_(__r.__cntrl_)3683 __cntrl_(__r.__cntrl_)
4688{3684{
4689 __r.__ptr_ = 0;3685 __r.__ptr_ = nullptr;
4690 __r.__cntrl_ = 0;3686 __r.__cntrl_ = nullptr;
4691}3687}
46923688
4693#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
4694
4695template<class _Tp>3689template<class _Tp>
4696weak_ptr<_Tp>::~weak_ptr()3690weak_ptr<_Tp>::~weak_ptr()
4697{3691{
...@@ -4722,8 +3716,6 @@ weak_ptr<_Tp>::operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT...@@ -4722,8 +3716,6 @@ weak_ptr<_Tp>::operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT
4722 return *this;3716 return *this;
4723}3717}
47243718
4725#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
4726
4727template<class _Tp>3719template<class _Tp>
4728inline3720inline
4729weak_ptr<_Tp>&3721weak_ptr<_Tp>&
...@@ -4747,8 +3739,6 @@ weak_ptr<_Tp>::operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT...@@ -4747,8 +3739,6 @@ weak_ptr<_Tp>::operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT
4747 return *this;3739 return *this;
4748}3740}
47493741
4750#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
4751
4752template<class _Tp>3742template<class _Tp>
4753template<class _Yp>3743template<class _Yp>
4754inline3744inline
...@@ -4795,7 +3785,7 @@ shared_ptr<_Tp>::shared_ptr(const weak_ptr<_Yp>& __r,...@@ -4795,7 +3785,7 @@ shared_ptr<_Tp>::shared_ptr(const weak_ptr<_Yp>& __r,
4795 : __ptr_(__r.__ptr_),3785 : __ptr_(__r.__ptr_),
4796 __cntrl_(__r.__cntrl_ ? __r.__cntrl_->lock() : __r.__cntrl_)3786 __cntrl_(__r.__cntrl_ ? __r.__cntrl_->lock() : __r.__cntrl_)
4797{3787{
4798 if (__cntrl_ == 0)3788 if (__cntrl_ == nullptr)
4799 __throw_bad_weak_ptr();3789 __throw_bad_weak_ptr();
4800}3790}
48013791
...@@ -5130,35 +4120,35 @@ _LIBCPP_FUNC_VIS void* align(size_t __align, size_t __sz, void*& __ptr, size_t&...@@ -5130,35 +4120,35 @@ _LIBCPP_FUNC_VIS void* align(size_t __align, size_t __sz, void*& __ptr, size_t&
51304120
5131// --- Helper for container swap --4121// --- Helper for container swap --
5132template <typename _Alloc>4122template <typename _Alloc>
5133inline _LIBCPP_INLINE_VISIBILITY4123_LIBCPP_INLINE_VISIBILITY
5134void __swap_allocator(_Alloc & __a1, _Alloc & __a2)4124void __swap_allocator(_Alloc & __a1, _Alloc & __a2, true_type)
5135#if _LIBCPP_STD_VER >= 144125#if _LIBCPP_STD_VER >= 14
5136 _NOEXCEPT4126 _NOEXCEPT
5137#else4127#else
5138 _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value)4128 _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value)
5139#endif4129#endif
5140{4130{
5141 __swap_allocator(__a1, __a2,4131 using _VSTD::swap;
5142 integral_constant<bool, _VSTD::allocator_traits<_Alloc>::propagate_on_container_swap::value>());4132 swap(__a1, __a2);
5143}4133}
51444134
5145template <typename _Alloc>4135template <typename _Alloc>
5146_LIBCPP_INLINE_VISIBILITY4136inline _LIBCPP_INLINE_VISIBILITY
5147void __swap_allocator(_Alloc & __a1, _Alloc & __a2, true_type)4137void __swap_allocator(_Alloc &, _Alloc &, false_type) _NOEXCEPT {}
4138
4139template <typename _Alloc>
4140inline _LIBCPP_INLINE_VISIBILITY
4141void __swap_allocator(_Alloc & __a1, _Alloc & __a2)
5148#if _LIBCPP_STD_VER >= 144142#if _LIBCPP_STD_VER >= 14
5149 _NOEXCEPT4143 _NOEXCEPT
5150#else4144#else
5151 _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value)4145 _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value)
5152#endif4146#endif
5153{4147{
5154 using _VSTD::swap;4148 _VSTD::__swap_allocator(__a1, __a2,
5155 swap(__a1, __a2);4149 integral_constant<bool, _VSTD::allocator_traits<_Alloc>::propagate_on_container_swap::value>());
5156}4150}
51574151
5158template <typename _Alloc>
5159inline _LIBCPP_INLINE_VISIBILITY
5160void __swap_allocator(_Alloc &, _Alloc &, false_type) _NOEXCEPT {}
5161
5162template <typename _Alloc, typename _Traits=allocator_traits<_Alloc> >4152template <typename _Alloc, typename _Traits=allocator_traits<_Alloc> >
5163struct __noexcept_move_assign_container : public integral_constant<bool,4153struct __noexcept_move_assign_container : public integral_constant<bool,
5164 _Traits::propagate_on_container_move_assignment::value4154 _Traits::propagate_on_container_move_assignment::value
...@@ -5170,7 +4160,6 @@ struct __noexcept_move_assign_container : public integral_constant<bool,...@@ -5170,7 +4160,6 @@ struct __noexcept_move_assign_container : public integral_constant<bool,
5170 > {};4160 > {};
51714161
51724162
5173#ifndef _LIBCPP_HAS_NO_VARIADICS
5174template <class _Tp, class _Alloc>4163template <class _Tp, class _Alloc>
5175struct __temp_value {4164struct __temp_value {
5176 typedef allocator_traits<_Alloc> _Traits;4165 typedef allocator_traits<_Alloc> _Traits;
...@@ -5190,7 +4179,6 @@ struct __temp_value {...@@ -5190,7 +4179,6 @@ struct __temp_value {
51904179
5191 ~__temp_value() { _Traits::destroy(__a, __addr()); }4180 ~__temp_value() { _Traits::destroy(__a, __addr()); }
5192 };4181 };
5193#endif
51944182
5195template<typename _Alloc, typename = void, typename = void>4183template<typename _Alloc, typename = void, typename = void>
5196struct __is_allocator : false_type {};4184struct __is_allocator : false_type {};
...@@ -5214,7 +4202,7 @@ struct __builtin_new_allocator {...@@ -5214,7 +4202,7 @@ struct __builtin_new_allocator {
5214 : __size_(__size), __align_(__align) {}4202 : __size_(__size), __align_(__align) {}
52154203
5216 void operator()(void* p) const _NOEXCEPT {4204 void operator()(void* p) const _NOEXCEPT {
5217 std::__libcpp_deallocate(p, __size_, __align_);4205 _VSTD::__libcpp_deallocate(p, __size_, __align_);
5218 }4206 }
52194207
5220 private:4208 private:
...@@ -5225,13 +4213,13 @@ struct __builtin_new_allocator {...@@ -5225,13 +4213,13 @@ struct __builtin_new_allocator {
5225 typedef unique_ptr<void, __builtin_new_deleter> __holder_t;4213 typedef unique_ptr<void, __builtin_new_deleter> __holder_t;
52264214
5227 static __holder_t __allocate_bytes(size_t __s, size_t __align) {4215 static __holder_t __allocate_bytes(size_t __s, size_t __align) {
5228 return __holder_t(std::__libcpp_allocate(__s, __align),4216 return __holder_t(_VSTD::__libcpp_allocate(__s, __align),
5229 __builtin_new_deleter(__s, __align));4217 __builtin_new_deleter(__s, __align));
5230 }4218 }
52314219
5232 static void __deallocate_bytes(void* __p, size_t __s,4220 static void __deallocate_bytes(void* __p, size_t __s,
5233 size_t __align) _NOEXCEPT {4221 size_t __align) _NOEXCEPT {
5234 std::__libcpp_deallocate(__p, __s, __align);4222 _VSTD::__libcpp_deallocate(__p, __s, __align);
5235 }4223 }
52364224
5237 template <class _Tp>4225 template <class _Tp>
lib/libcxx/include/new+70-83
...@@ -87,13 +87,12 @@ void operator delete[](void* ptr, void*) noexcept;...@@ -87,13 +87,12 @@ void operator delete[](void* ptr, void*) noexcept;
87*/87*/
8888
89#include <__config>89#include <__config>
90#include <__availability>
91#include <cstddef>
92#include <cstdlib>
90#include <exception>93#include <exception>
91#include <type_traits>94#include <type_traits>
92#include <cstddef>
93#include <version>95#include <version>
94#ifdef _LIBCPP_NO_EXCEPTIONS
95#include <cstdlib>
96#endif
9796
98#if defined(_LIBCPP_ABI_VCRUNTIME)97#if defined(_LIBCPP_ABI_VCRUNTIME)
99#include <new.h>98#include <new.h>
...@@ -117,11 +116,6 @@ void operator delete[](void* ptr, void*) noexcept;...@@ -117,11 +116,6 @@ void operator delete[](void* ptr, void*) noexcept;
117# define _LIBCPP_HAS_NO_SIZED_DEALLOCATION116# define _LIBCPP_HAS_NO_SIZED_DEALLOCATION
118#endif117#endif
119118
120#if !__has_builtin(__builtin_operator_new) || \
121 __has_builtin(__builtin_operator_new) < 201802L
122#define _LIBCPP_HAS_NO_BUILTIN_OVERLOADED_OPERATOR_NEW_DELETE
123#endif
124
125namespace std // purposefully not using versioning namespace119namespace std // purposefully not using versioning namespace
126{120{
127121
...@@ -234,31 +228,54 @@ _LIBCPP_CONSTEXPR inline _LIBCPP_INLINE_VISIBILITY bool __is_overaligned_for_new...@@ -234,31 +228,54 @@ _LIBCPP_CONSTEXPR inline _LIBCPP_INLINE_VISIBILITY bool __is_overaligned_for_new
234#endif228#endif
235}229}
236230
237inline _LIBCPP_INLINE_VISIBILITY void *__libcpp_allocate(size_t __size, size_t __align) {231template <class ..._Args>
232_LIBCPP_INLINE_VISIBILITY
233void* __libcpp_operator_new(_Args ...__args) {
234#if __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete)
235 return __builtin_operator_new(__args...);
236#else
237 return ::operator new(__args...);
238#endif
239}
240
241template <class ..._Args>
242_LIBCPP_INLINE_VISIBILITY
243void __libcpp_operator_delete(_Args ...__args) {
244#if __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete)
245 __builtin_operator_delete(__args...);
246#else
247 ::operator delete(__args...);
248#endif
249}
250
251inline _LIBCPP_INLINE_VISIBILITY
252void *__libcpp_allocate(size_t __size, size_t __align) {
238#ifndef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION253#ifndef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
239 if (__is_overaligned_for_new(__align)) {254 if (__is_overaligned_for_new(__align)) {
240 const align_val_t __align_val = static_cast<align_val_t>(__align);255 const align_val_t __align_val = static_cast<align_val_t>(__align);
241# ifdef _LIBCPP_HAS_NO_BUILTIN_OVERLOADED_OPERATOR_NEW_DELETE256 return __libcpp_operator_new(__size, __align_val);
242 return ::operator new(__size, __align_val);
243# else
244 return __builtin_operator_new(__size, __align_val);
245# endif
246 }257 }
247#else
248 ((void)__align);
249#endif258#endif
250#ifdef _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE259
251 return ::operator new(__size);260 (void)__align;
261 return __libcpp_operator_new(__size);
262}
263
264template <class ..._Args>
265_LIBCPP_INLINE_VISIBILITY
266void __do_deallocate_handle_size(void *__ptr, size_t __size, _Args ...__args) {
267#ifdef _LIBCPP_HAS_NO_SIZED_DEALLOCATION
268 (void)__size;
269 return __libcpp_operator_delete(__ptr, __args...);
252#else270#else
253 return __builtin_operator_new(__size);271 return __libcpp_operator_delete(__ptr, __size, __args...);
254#endif272#endif
255}273}
256274
257struct _DeallocateCaller {275inline _LIBCPP_INLINE_VISIBILITY
258 static inline _LIBCPP_INLINE_VISIBILITY276void __libcpp_deallocate(void* __ptr, size_t __size, size_t __align) {
259 void __do_deallocate_handle_size_align(void *__ptr, size_t __size, size_t __align) {
260#if defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION)277#if defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION)
261 ((void)__align);278 (void)__align;
262 return __do_deallocate_handle_size(__ptr, __size);279 return __do_deallocate_handle_size(__ptr, __size);
263#else280#else
264 if (__is_overaligned_for_new(__align)) {281 if (__is_overaligned_for_new(__align)) {
...@@ -268,81 +285,51 @@ struct _DeallocateCaller {...@@ -268,81 +285,51 @@ struct _DeallocateCaller {
268 return __do_deallocate_handle_size(__ptr, __size);285 return __do_deallocate_handle_size(__ptr, __size);
269 }286 }
270#endif287#endif
271 }288}
272289
273 static inline _LIBCPP_INLINE_VISIBILITY290inline _LIBCPP_INLINE_VISIBILITY void __libcpp_deallocate_unsized(void* __ptr, size_t __align) {
274 void __do_deallocate_handle_align(void *__ptr, size_t __align) {
275#if defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION)291#if defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION)
276 ((void)__align);292 (void)__align;
277 return __do_call(__ptr);293 return __libcpp_operator_delete(__ptr);
278#else294#else
279 if (__is_overaligned_for_new(__align)) {295 if (__is_overaligned_for_new(__align)) {
280 const align_val_t __align_val = static_cast<align_val_t>(__align);296 const align_val_t __align_val = static_cast<align_val_t>(__align);
281 return __do_call(__ptr, __align_val);297 return __libcpp_operator_delete(__ptr, __align_val);
282 } else {298 } else {
283 return __do_call(__ptr);299 return __libcpp_operator_delete(__ptr);
284 }300 }
285#endif301#endif
286 }302}
287
288 private:
289 static inline void __do_deallocate_handle_size(void *__ptr, size_t __size) {
290#ifdef _LIBCPP_HAS_NO_SIZED_DEALLOCATION
291 ((void)__size);
292 return __do_call(__ptr);
293#else
294 return __do_call(__ptr, __size);
295#endif
296 }
297
298#ifndef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
299 static inline void __do_deallocate_handle_size(void *__ptr, size_t __size, align_val_t __align) {
300#ifdef _LIBCPP_HAS_NO_SIZED_DEALLOCATION
301 ((void)__size);
302 return __do_call(__ptr, __align);
303#else
304 return __do_call(__ptr, __size, __align);
305#endif
306 }
307#endif
308
309private:
310 template <class _A1, class _A2>
311 static inline void __do_call(void *__ptr, _A1 __a1, _A2 __a2) {
312#if defined(_LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE) || \
313 defined(_LIBCPP_HAS_NO_BUILTIN_OVERLOADED_OPERATOR_NEW_DELETE)
314 return ::operator delete(__ptr, __a1, __a2);
315#else
316 return __builtin_operator_delete(__ptr, __a1, __a2);
317#endif
318 }
319303
320 template <class _A1>304#if !defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION)
321 static inline void __do_call(void *__ptr, _A1 __a1) {305// Low-level helpers to call the aligned allocation and deallocation functions
322#if defined(_LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE) || \306// on the target platform. This is used to implement libc++'s own memory
323 defined(_LIBCPP_HAS_NO_BUILTIN_OVERLOADED_OPERATOR_NEW_DELETE)307// allocation routines -- if you need to allocate memory inside the library,
324 return ::operator delete(__ptr, __a1);308// chances are that you want to use `__libcpp_allocate` instead.
309//
310// Returns the allocated memory, or `nullptr` on failure.
311inline _LIBCPP_INLINE_VISIBILITY
312void* __libcpp_aligned_alloc(std::size_t __alignment, std::size_t __size) {
313#if defined(_LIBCPP_MSVCRT_LIKE)
314 return ::_aligned_malloc(__size, __alignment);
325#else315#else
326 return __builtin_operator_delete(__ptr, __a1);316 void* __result = nullptr;
317 ::posix_memalign(&__result, __alignment, __size);
318 // If posix_memalign fails, __result is unmodified so we still return `nullptr`.
319 return __result;
327#endif320#endif
328 }321}
329322
330 static inline void __do_call(void *__ptr) {323inline _LIBCPP_INLINE_VISIBILITY
331#ifdef _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE324void __libcpp_aligned_free(void* __ptr) {
332 return ::operator delete(__ptr);325#if defined(_LIBCPP_MSVCRT_LIKE)
326 ::_aligned_free(__ptr);
333#else327#else
334 return __builtin_operator_delete(__ptr);328 ::free(__ptr);
335#endif329#endif
336 }
337};
338
339inline _LIBCPP_INLINE_VISIBILITY void __libcpp_deallocate(void* __ptr, size_t __size, size_t __align) {
340 _DeallocateCaller::__do_deallocate_handle_size_align(__ptr, __size, __align);
341}330}
331#endif // !_LIBCPP_HAS_NO_ALIGNED_ALLOCATION
342332
343inline _LIBCPP_INLINE_VISIBILITY void __libcpp_deallocate_unsized(void* __ptr, size_t __align) {
344 _DeallocateCaller::__do_deallocate_handle_align(__ptr, __align);
345}
346333
347template <class _Tp>334template <class _Tp>
348_LIBCPP_NODISCARD_AFTER_CXX17 inline335_LIBCPP_NODISCARD_AFTER_CXX17 inline
lib/libcxx/include/numbers+1-1
...@@ -100,7 +100,7 @@ template <class T> inline constexpr T egamma_v = __illformed<T>{};...@@ -100,7 +100,7 @@ template <class T> inline constexpr T egamma_v = __illformed<T>{};
100template <class T> inline constexpr T phi_v = __illformed<T>{};100template <class T> inline constexpr T phi_v = __illformed<T>{};
101101
102template <class T>102template <class T>
103concept __floating_point = std::is_floating_point_v<T>;103concept __floating_point = is_floating_point_v<T>;
104104
105template <__floating_point T> inline constexpr T e_v<T> = 2.718281828459045235360287471352662;105template <__floating_point T> inline constexpr T e_v<T> = 2.718281828459045235360287471352662;
106template <__floating_point T> inline constexpr T log2e_v<T> = 1.442695040888963407359924681001892;106template <__floating_point T> inline constexpr T log2e_v<T> = 1.442695040888963407359924681001892;
lib/libcxx/include/numeric+118-73
...@@ -17,115 +17,116 @@ namespace std...@@ -17,115 +17,116 @@ namespace std
17{17{
1818
19template <class InputIterator, class T>19template <class InputIterator, class T>
20 T20 constexpr T // constexpr since C++20
21 accumulate(InputIterator first, InputIterator last, T init);21 accumulate(InputIterator first, InputIterator last, T init);
2222
23template <class InputIterator, class T, class BinaryOperation>23template <class InputIterator, class T, class BinaryOperation>
24 T24 constexpr T // constexpr since C++20
25 accumulate(InputIterator first, InputIterator last, T init, BinaryOperation binary_op);25 accumulate(InputIterator first, InputIterator last, T init, BinaryOperation binary_op);
2626
27template<class InputIterator>27template<class InputIterator>
28 typename iterator_traits<InputIterator>::value_type28 constexpr typename iterator_traits<InputIterator>::value_type // constexpr since C++20
29 reduce(InputIterator first, InputIterator last); // C++1729 reduce(InputIterator first, InputIterator last); // C++17
3030
31template<class InputIterator, class T>31template<class InputIterator, class T>
32 T32 constexpr T // constexpr since C++20
33 reduce(InputIterator first, InputIterator last, T init); // C++1733 reduce(InputIterator first, InputIterator last, T init); // C++17
3434
35template<class InputIterator, class T, class BinaryOperation>35template<class InputIterator, class T, class BinaryOperation>
36 T36 constexpr T // constexpr since C++20
37 reduce(InputIterator first, InputIterator last, T init, BinaryOperation binary_op); // C++1737 reduce(InputIterator first, InputIterator last, T init, BinaryOperation binary_op); // C++17
3838
39template <class InputIterator1, class InputIterator2, class T>39template <class InputIterator1, class InputIterator2, class T>
40 T40 constexpr T // constexpr since C++20
41 inner_product(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, T init);41 inner_product(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, T init);
4242
43template <class InputIterator1, class InputIterator2, class T, class BinaryOperation1, class BinaryOperation2>43template <class InputIterator1, class InputIterator2, class T, class BinaryOperation1, class BinaryOperation2>
44 T44 constexpr T // constexpr since C++20
45 inner_product(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,45 inner_product(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
46 T init, BinaryOperation1 binary_op1, BinaryOperation2 binary_op2);46 T init, BinaryOperation1 binary_op1, BinaryOperation2 binary_op2);
4747
4848
49template<class InputIterator1, class InputIterator2, class T>49template<class InputIterator1, class InputIterator2, class T>
50 T50 constexpr T // constexpr since C++20
51 transform_reduce(InputIterator1 first1, InputIterator1 last1,51 transform_reduce(InputIterator1 first1, InputIterator1 last1,
52 InputIterator2 first2, T init); // C++1752 InputIterator2 first2, T init); // C++17
5353
54template<class InputIterator1, class InputIterator2, class T, class BinaryOperation1, class BinaryOperation2>54template<class InputIterator1, class InputIterator2, class T, class BinaryOperation1, class BinaryOperation2>
55 T55 constexpr T // constexpr since C++20
56 transform_reduce(InputIterator1 first1, InputIterator1 last1,56 transform_reduce(InputIterator1 first1, InputIterator1 last1,
57 InputIterator2 first2, T init,57 InputIterator2 first2, T init,
58 BinaryOperation1 binary_op1, BinaryOperation2 binary_op2); // C++1758 BinaryOperation1 binary_op1, BinaryOperation2 binary_op2); // C++17
5959
60template<class InputIterator, class T, class BinaryOperation, class UnaryOperation>60template<class InputIterator, class T, class BinaryOperation, class UnaryOperation>
61 T61 constexpr T // constexpr since C++20
62 transform_reduce(InputIterator first, InputIterator last, T init,62 transform_reduce(InputIterator first, InputIterator last, T init,
63 BinaryOperation binary_op, UnaryOperation unary_op); // C++1763 BinaryOperation binary_op, UnaryOperation unary_op); // C++17
6464
65template <class InputIterator, class OutputIterator>65template <class InputIterator, class OutputIterator>
66 OutputIterator66 constexpr OutputIterator // constexpr since C++20
67 partial_sum(InputIterator first, InputIterator last, OutputIterator result);67 partial_sum(InputIterator first, InputIterator last, OutputIterator result);
6868
69template <class InputIterator, class OutputIterator, class BinaryOperation>69template <class InputIterator, class OutputIterator, class BinaryOperation>
70 OutputIterator70 constexpr OutputIterator // constexpr since C++20
71 partial_sum(InputIterator first, InputIterator last, OutputIterator result, BinaryOperation binary_op);71 partial_sum(InputIterator first, InputIterator last, OutputIterator result, BinaryOperation binary_op);
7272
73template<class InputIterator, class OutputIterator, class T>73template<class InputIterator, class OutputIterator, class T>
74 OutputIterator74 constexpr OutputIterator // constexpr since C++20
75 exclusive_scan(InputIterator first, InputIterator last,75 exclusive_scan(InputIterator first, InputIterator last,
76 OutputIterator result, T init); // C++1776 OutputIterator result, T init); // C++17
7777
78template<class InputIterator, class OutputIterator, class T, class BinaryOperation>78template<class InputIterator, class OutputIterator, class T, class BinaryOperation>
79 OutputIterator79 constexpr OutputIterator // constexpr since C++20
80 exclusive_scan(InputIterator first, InputIterator last,80 exclusive_scan(InputIterator first, InputIterator last,
81 OutputIterator result, T init, BinaryOperation binary_op); // C++1781 OutputIterator result, T init, BinaryOperation binary_op); // C++17
8282
83template<class InputIterator, class OutputIterator>83template<class InputIterator, class OutputIterator>
84 OutputIterator84 constexpr OutputIterator // constexpr since C++20
85 inclusive_scan(InputIterator first, InputIterator last, OutputIterator result); // C++1785 inclusive_scan(InputIterator first, InputIterator last, OutputIterator result); // C++17
8686
87template<class InputIterator, class OutputIterator, class BinaryOperation>87template<class InputIterator, class OutputIterator, class BinaryOperation>
88 OutputIterator88 constexpr OutputIterator // constexpr since C++20
89 inclusive_scan(InputIterator first, InputIterator last,89 inclusive_scan(InputIterator first, InputIterator last,
90 OutputIterator result, BinaryOperation binary_op); // C++1790 OutputIterator result, BinaryOperation binary_op); // C++17
9191
92template<class InputIterator, class OutputIterator, class BinaryOperation, class T>92template<class InputIterator, class OutputIterator, class BinaryOperation, class T>
93 OutputIterator93 constexpr OutputIterator // constexpr since C++20
94 inclusive_scan(InputIterator first, InputIterator last,94 inclusive_scan(InputIterator first, InputIterator last,
95 OutputIterator result, BinaryOperation binary_op, T init); // C++1795 OutputIterator result, BinaryOperation binary_op, T init); // C++17
9696
97template<class InputIterator, class OutputIterator, class T,97template<class InputIterator, class OutputIterator, class T,
98 class BinaryOperation, class UnaryOperation>98 class BinaryOperation, class UnaryOperation>
99 OutputIterator99 constexpr OutputIterator // constexpr since C++20
100 transform_exclusive_scan(InputIterator first, InputIterator last,100 transform_exclusive_scan(InputIterator first, InputIterator last,
101 OutputIterator result, T init,101 OutputIterator result, T init,
102 BinaryOperation binary_op, UnaryOperation unary_op); // C++17102 BinaryOperation binary_op, UnaryOperation unary_op); // C++17
103103
104template<class InputIterator, class OutputIterator,104template<class InputIterator, class OutputIterator,
105 class BinaryOperation, class UnaryOperation>105 class BinaryOperation, class UnaryOperation>
106 OutputIterator106 constexpr OutputIterator // constexpr since C++20
107 transform_inclusive_scan(InputIterator first, InputIterator last,107 transform_inclusive_scan(InputIterator first, InputIterator last,
108 OutputIterator result,108 OutputIterator result,
109 BinaryOperation binary_op, UnaryOperation unary_op); // C++17109 BinaryOperation binary_op, UnaryOperation unary_op); // C++17
110110
111template<class InputIterator, class OutputIterator,111template<class InputIterator, class OutputIterator,
112 class BinaryOperation, class UnaryOperation, class T>112 class BinaryOperation, class UnaryOperation, class T>
113 OutputIterator113 constexpr OutputIterator // constexpr since C++20
114 transform_inclusive_scan(InputIterator first, InputIterator last,114 transform_inclusive_scan(InputIterator first, InputIterator last,
115 OutputIterator result,115 OutputIterator result,
116 BinaryOperation binary_op, UnaryOperation unary_op,116 BinaryOperation binary_op, UnaryOperation unary_op,
117 T init); // C++17117 T init); // C++17
118118
119template <class InputIterator, class OutputIterator>119template <class InputIterator, class OutputIterator>
120 OutputIterator120 constexpr OutputIterator // constexpr since C++20
121 adjacent_difference(InputIterator first, InputIterator last, OutputIterator result);121 adjacent_difference(InputIterator first, InputIterator last, OutputIterator result);
122122
123template <class InputIterator, class OutputIterator, class BinaryOperation>123template <class InputIterator, class OutputIterator, class BinaryOperation>
124 OutputIterator124 constexpr OutputIterator // constexpr since C++20
125 adjacent_difference(InputIterator first, InputIterator last, OutputIterator result, BinaryOperation binary_op);125 adjacent_difference(InputIterator first, InputIterator last, OutputIterator result, BinaryOperation binary_op);
126126
127template <class ForwardIterator, class T>127template <class ForwardIterator, class T>
128 void iota(ForwardIterator first, ForwardIterator last, T value);128 constexpr void // constexpr since C++20
129 iota(ForwardIterator first, ForwardIterator last, T value);
129130
130template <class M, class N>131template <class M, class N>
131 constexpr common_type_t<M,N> gcd(M m, N n); // C++17132 constexpr common_type_t<M,N> gcd(M m, N n); // C++17
...@@ -133,9 +134,11 @@ template <class M, class N>...@@ -133,9 +134,11 @@ template <class M, class N>
133template <class M, class N>134template <class M, class N>
134 constexpr common_type_t<M,N> lcm(M m, N n); // C++17135 constexpr common_type_t<M,N> lcm(M m, N n); // C++17
135136
136integer midpoint(integer a, integer b); // C++20137template<class T>
137pointer midpoint(pointer a, pointer b); // C++20138 constexpr T midpoint(T a, T b) noexcept; // C++20
138floating_point midpoint(floating_point a, floating_point b); // C++20139
140template<class T>
141 constexpr T* midpoint(T* a, T* b); // C++20
139142
140} // std143} // std
141144
...@@ -158,28 +161,36 @@ _LIBCPP_PUSH_MACROS...@@ -158,28 +161,36 @@ _LIBCPP_PUSH_MACROS
158_LIBCPP_BEGIN_NAMESPACE_STD161_LIBCPP_BEGIN_NAMESPACE_STD
159162
160template <class _InputIterator, class _Tp>163template <class _InputIterator, class _Tp>
161inline _LIBCPP_INLINE_VISIBILITY164_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
162_Tp165_Tp
163accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)166accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
164{167{
165 for (; __first != __last; ++__first)168 for (; __first != __last; ++__first)
169#if _LIBCPP_STD_VER > 17
170 __init = _VSTD::move(__init) + *__first;
171#else
166 __init = __init + *__first;172 __init = __init + *__first;
173#endif
167 return __init;174 return __init;
168}175}
169176
170template <class _InputIterator, class _Tp, class _BinaryOperation>177template <class _InputIterator, class _Tp, class _BinaryOperation>
171inline _LIBCPP_INLINE_VISIBILITY178_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
172_Tp179_Tp
173accumulate(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOperation __binary_op)180accumulate(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOperation __binary_op)
174{181{
175 for (; __first != __last; ++__first)182 for (; __first != __last; ++__first)
183#if _LIBCPP_STD_VER > 17
184 __init = __binary_op(_VSTD::move(__init), *__first);
185#else
176 __init = __binary_op(__init, *__first);186 __init = __binary_op(__init, *__first);
187#endif
177 return __init;188 return __init;
178}189}
179190
180#if _LIBCPP_STD_VER > 14191#if _LIBCPP_STD_VER > 14
181template <class _InputIterator, class _Tp, class _BinaryOp>192template <class _InputIterator, class _Tp, class _BinaryOp>
182inline _LIBCPP_INLINE_VISIBILITY193_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
183_Tp194_Tp
184reduce(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOp __b)195reduce(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOp __b)
185{196{
...@@ -189,7 +200,7 @@ reduce(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOp __b)...@@ -189,7 +200,7 @@ reduce(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOp __b)
189}200}
190201
191template <class _InputIterator, class _Tp>202template <class _InputIterator, class _Tp>
192inline _LIBCPP_INLINE_VISIBILITY203_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
193_Tp204_Tp
194reduce(_InputIterator __first, _InputIterator __last, _Tp __init)205reduce(_InputIterator __first, _InputIterator __last, _Tp __init)
195{206{
...@@ -197,7 +208,7 @@ reduce(_InputIterator __first, _InputIterator __last, _Tp __init)...@@ -197,7 +208,7 @@ reduce(_InputIterator __first, _InputIterator __last, _Tp __init)
197}208}
198209
199template <class _InputIterator>210template <class _InputIterator>
200inline _LIBCPP_INLINE_VISIBILITY211_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
201typename iterator_traits<_InputIterator>::value_type212typename iterator_traits<_InputIterator>::value_type
202reduce(_InputIterator __first, _InputIterator __last)213reduce(_InputIterator __first, _InputIterator __last)
203{214{
...@@ -207,29 +218,37 @@ reduce(_InputIterator __first, _InputIterator __last)...@@ -207,29 +218,37 @@ reduce(_InputIterator __first, _InputIterator __last)
207#endif218#endif
208219
209template <class _InputIterator1, class _InputIterator2, class _Tp>220template <class _InputIterator1, class _InputIterator2, class _Tp>
210inline _LIBCPP_INLINE_VISIBILITY221_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
211_Tp222_Tp
212inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _Tp __init)223inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _Tp __init)
213{224{
214 for (; __first1 != __last1; ++__first1, (void) ++__first2)225 for (; __first1 != __last1; ++__first1, (void) ++__first2)
226#if _LIBCPP_STD_VER > 17
227 __init = _VSTD::move(__init) + *__first1 * *__first2;
228#else
215 __init = __init + *__first1 * *__first2;229 __init = __init + *__first1 * *__first2;
230#endif
216 return __init;231 return __init;
217}232}
218233
219template <class _InputIterator1, class _InputIterator2, class _Tp, class _BinaryOperation1, class _BinaryOperation2>234template <class _InputIterator1, class _InputIterator2, class _Tp, class _BinaryOperation1, class _BinaryOperation2>
220inline _LIBCPP_INLINE_VISIBILITY235_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
221_Tp236_Tp
222inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2,237inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2,
223 _Tp __init, _BinaryOperation1 __binary_op1, _BinaryOperation2 __binary_op2)238 _Tp __init, _BinaryOperation1 __binary_op1, _BinaryOperation2 __binary_op2)
224{239{
225 for (; __first1 != __last1; ++__first1, (void) ++__first2)240 for (; __first1 != __last1; ++__first1, (void) ++__first2)
241#if _LIBCPP_STD_VER > 17
242 __init = __binary_op1(_VSTD::move(__init), __binary_op2(*__first1, *__first2));
243#else
226 __init = __binary_op1(__init, __binary_op2(*__first1, *__first2));244 __init = __binary_op1(__init, __binary_op2(*__first1, *__first2));
245#endif
227 return __init;246 return __init;
228}247}
229248
230#if _LIBCPP_STD_VER > 14249#if _LIBCPP_STD_VER > 14
231template <class _InputIterator, class _Tp, class _BinaryOp, class _UnaryOp>250template <class _InputIterator, class _Tp, class _BinaryOp, class _UnaryOp>
232inline _LIBCPP_INLINE_VISIBILITY251_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
233_Tp252_Tp
234transform_reduce(_InputIterator __first, _InputIterator __last,253transform_reduce(_InputIterator __first, _InputIterator __last,
235 _Tp __init, _BinaryOp __b, _UnaryOp __u)254 _Tp __init, _BinaryOp __b, _UnaryOp __u)
...@@ -241,7 +260,7 @@ transform_reduce(_InputIterator __first, _InputIterator __last,...@@ -241,7 +260,7 @@ transform_reduce(_InputIterator __first, _InputIterator __last,
241260
242template <class _InputIterator1, class _InputIterator2,261template <class _InputIterator1, class _InputIterator2,
243 class _Tp, class _BinaryOp1, class _BinaryOp2>262 class _Tp, class _BinaryOp1, class _BinaryOp2>
244inline _LIBCPP_INLINE_VISIBILITY263_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
245_Tp264_Tp
246transform_reduce(_InputIterator1 __first1, _InputIterator1 __last1,265transform_reduce(_InputIterator1 __first1, _InputIterator1 __last1,
247 _InputIterator2 __first2, _Tp __init, _BinaryOp1 __b1, _BinaryOp2 __b2)266 _InputIterator2 __first2, _Tp __init, _BinaryOp1 __b1, _BinaryOp2 __b2)
...@@ -252,7 +271,7 @@ transform_reduce(_InputIterator1 __first1, _InputIterator1 __last1,...@@ -252,7 +271,7 @@ transform_reduce(_InputIterator1 __first1, _InputIterator1 __last1,
252}271}
253272
254template <class _InputIterator1, class _InputIterator2, class _Tp>273template <class _InputIterator1, class _InputIterator2, class _Tp>
255inline _LIBCPP_INLINE_VISIBILITY274_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
256_Tp275_Tp
257transform_reduce(_InputIterator1 __first1, _InputIterator1 __last1,276transform_reduce(_InputIterator1 __first1, _InputIterator1 __last1,
258 _InputIterator2 __first2, _Tp __init)277 _InputIterator2 __first2, _Tp __init)
...@@ -263,7 +282,7 @@ transform_reduce(_InputIterator1 __first1, _InputIterator1 __last1,...@@ -263,7 +282,7 @@ transform_reduce(_InputIterator1 __first1, _InputIterator1 __last1,
263#endif282#endif
264283
265template <class _InputIterator, class _OutputIterator>284template <class _InputIterator, class _OutputIterator>
266inline _LIBCPP_INLINE_VISIBILITY285_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
267_OutputIterator286_OutputIterator
268partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __result)287partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
269{288{
...@@ -273,7 +292,11 @@ partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __res...@@ -273,7 +292,11 @@ partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __res
273 *__result = __t;292 *__result = __t;
274 for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result)293 for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result)
275 {294 {
295#if _LIBCPP_STD_VER > 17
296 __t = _VSTD::move(__t) + *__first;
297#else
276 __t = __t + *__first;298 __t = __t + *__first;
299#endif
277 *__result = __t;300 *__result = __t;
278 }301 }
279 }302 }
...@@ -281,7 +304,7 @@ partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __res...@@ -281,7 +304,7 @@ partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __res
281}304}
282305
283template <class _InputIterator, class _OutputIterator, class _BinaryOperation>306template <class _InputIterator, class _OutputIterator, class _BinaryOperation>
284inline _LIBCPP_INLINE_VISIBILITY307_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
285_OutputIterator308_OutputIterator
286partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __result,309partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
287 _BinaryOperation __binary_op)310 _BinaryOperation __binary_op)
...@@ -292,7 +315,11 @@ partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __res...@@ -292,7 +315,11 @@ partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __res
292 *__result = __t;315 *__result = __t;
293 for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result)316 for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result)
294 {317 {
318#if _LIBCPP_STD_VER > 17
319 __t = __binary_op(_VSTD::move(__t), *__first);
320#else
295 __t = __binary_op(__t, *__first);321 __t = __binary_op(__t, *__first);
322#endif
296 *__result = __t;323 *__result = __t;
297 }324 }
298 }325 }
...@@ -301,27 +328,30 @@ partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __res...@@ -301,27 +328,30 @@ partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __res
301328
302#if _LIBCPP_STD_VER > 14329#if _LIBCPP_STD_VER > 14
303template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp>330template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp>
304inline _LIBCPP_INLINE_VISIBILITY331_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
305_OutputIterator332_OutputIterator
306exclusive_scan(_InputIterator __first, _InputIterator __last,333exclusive_scan(_InputIterator __first, _InputIterator __last,
307 _OutputIterator __result, _Tp __init, _BinaryOp __b)334 _OutputIterator __result, _Tp __init, _BinaryOp __b)
308{335{
309 if (__first != __last)336 if (__first != __last)
310 {337 {
311 _Tp __saved = __init;338 _Tp __tmp(__b(__init, *__first));
312 do339 while (true)
313 {340 {
314 __init = __b(__init, *__first);341 *__result = _VSTD::move(__init);
315 *__result = __saved;
316 __saved = __init;
317 ++__result;342 ++__result;
318 } while (++__first != __last);343 ++__first;
344 if (__first == __last)
345 break;
346 __init = _VSTD::move(__tmp);
347 __tmp = __b(__init, *__first);
348 }
319 }349 }
320 return __result;350 return __result;
321}351}
322352
323template <class _InputIterator, class _OutputIterator, class _Tp>353template <class _InputIterator, class _OutputIterator, class _Tp>
324inline _LIBCPP_INLINE_VISIBILITY354_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
325_OutputIterator355_OutputIterator
326exclusive_scan(_InputIterator __first, _InputIterator __last,356exclusive_scan(_InputIterator __first, _InputIterator __last,
327 _OutputIterator __result, _Tp __init)357 _OutputIterator __result, _Tp __init)
...@@ -330,40 +360,43 @@ exclusive_scan(_InputIterator __first, _InputIterator __last,...@@ -330,40 +360,43 @@ exclusive_scan(_InputIterator __first, _InputIterator __last,
330}360}
331361
332template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp>362template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp>
363_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
333_OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last,364_OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last,
334 _OutputIterator __result, _BinaryOp __b, _Tp __init)365 _OutputIterator __result, _BinaryOp __b, _Tp __init)
335{366{
336 for (; __first != __last; ++__first, (void) ++__result) {367 for (; __first != __last; ++__first, (void) ++__result) {
337 __init = __b(__init, *__first);368 __init = __b(__init, *__first);
338 *__result = __init;369 *__result = __init;
339 }370 }
340 return __result;371 return __result;
341}372}
342373
343template <class _InputIterator, class _OutputIterator, class _BinaryOp>374template <class _InputIterator, class _OutputIterator, class _BinaryOp>
375_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
344_OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last,376_OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last,
345 _OutputIterator __result, _BinaryOp __b)377 _OutputIterator __result, _BinaryOp __b)
346{378{
347 if (__first != __last) {379 if (__first != __last) {
348 typename std::iterator_traits<_InputIterator>::value_type __init = *__first;380 typename iterator_traits<_InputIterator>::value_type __init = *__first;
349 *__result++ = __init;381 *__result++ = __init;
350 if (++__first != __last)382 if (++__first != __last)
351 return _VSTD::inclusive_scan(__first, __last, __result, __b, __init);383 return _VSTD::inclusive_scan(__first, __last, __result, __b, __init);
352 }384 }
353385
354 return __result;386 return __result;
355}387}
356388
357template <class _InputIterator, class _OutputIterator>389template <class _InputIterator, class _OutputIterator>
390_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
358_OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last,391_OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last,
359 _OutputIterator __result)392 _OutputIterator __result)
360{393{
361 return _VSTD::inclusive_scan(__first, __last, __result, std::plus<>());394 return _VSTD::inclusive_scan(__first, __last, __result, _VSTD::plus<>());
362}395}
363396
364template <class _InputIterator, class _OutputIterator, class _Tp,397template <class _InputIterator, class _OutputIterator, class _Tp,
365 class _BinaryOp, class _UnaryOp>398 class _BinaryOp, class _UnaryOp>
366inline _LIBCPP_INLINE_VISIBILITY399_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
367_OutputIterator400_OutputIterator
368transform_exclusive_scan(_InputIterator __first, _InputIterator __last,401transform_exclusive_scan(_InputIterator __first, _InputIterator __last,
369 _OutputIterator __result, _Tp __init,402 _OutputIterator __result, _Tp __init,
...@@ -384,7 +417,9 @@ transform_exclusive_scan(_InputIterator __first, _InputIterator __last,...@@ -384,7 +417,9 @@ transform_exclusive_scan(_InputIterator __first, _InputIterator __last,
384}417}
385418
386template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp, class _UnaryOp>419template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp, class _UnaryOp>
387_OutputIterator transform_inclusive_scan(_InputIterator __first, _InputIterator __last,420_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
421_OutputIterator
422transform_inclusive_scan(_InputIterator __first, _InputIterator __last,
388 _OutputIterator __result, _BinaryOp __b, _UnaryOp __u, _Tp __init)423 _OutputIterator __result, _BinaryOp __b, _UnaryOp __u, _Tp __init)
389{424{
390 for (; __first != __last; ++__first, (void) ++__result) {425 for (; __first != __last; ++__first, (void) ++__result) {
...@@ -396,61 +431,71 @@ _OutputIterator transform_inclusive_scan(_InputIterator __first, _InputIterator...@@ -396,61 +431,71 @@ _OutputIterator transform_inclusive_scan(_InputIterator __first, _InputIterator
396}431}
397432
398template <class _InputIterator, class _OutputIterator, class _BinaryOp, class _UnaryOp>433template <class _InputIterator, class _OutputIterator, class _BinaryOp, class _UnaryOp>
399_OutputIterator transform_inclusive_scan(_InputIterator __first, _InputIterator __last,434_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
435_OutputIterator
436transform_inclusive_scan(_InputIterator __first, _InputIterator __last,
400 _OutputIterator __result, _BinaryOp __b, _UnaryOp __u)437 _OutputIterator __result, _BinaryOp __b, _UnaryOp __u)
401{438{
402 if (__first != __last) {439 if (__first != __last) {
403 typename std::iterator_traits<_InputIterator>::value_type __init = __u(*__first);440 typename iterator_traits<_InputIterator>::value_type __init = __u(*__first);
404 *__result++ = __init;441 *__result++ = __init;
405 if (++__first != __last)442 if (++__first != __last)
406 return _VSTD::transform_inclusive_scan(__first, __last, __result, __b, __u, __init);443 return _VSTD::transform_inclusive_scan(__first, __last, __result, __b, __u, __init);
407 }444 }
408445
409 return __result;446 return __result;
410}447}
411#endif448#endif
412449
413template <class _InputIterator, class _OutputIterator>450template <class _InputIterator, class _OutputIterator>
414inline _LIBCPP_INLINE_VISIBILITY451_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
415_OutputIterator452_OutputIterator
416adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterator __result)453adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
417{454{
418 if (__first != __last)455 if (__first != __last)
419 {456 {
420 typename iterator_traits<_InputIterator>::value_type __t1(*__first);457 typename iterator_traits<_InputIterator>::value_type __acc(*__first);
421 *__result = __t1;458 *__result = __acc;
422 for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result)459 for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result)
423 {460 {
424 typename iterator_traits<_InputIterator>::value_type __t2(*__first);461 typename iterator_traits<_InputIterator>::value_type __val(*__first);
425 *__result = __t2 - __t1;462#if _LIBCPP_STD_VER > 17
426 __t1 = _VSTD::move(__t2);463 *__result = __val - _VSTD::move(__acc);
464#else
465 *__result = __val - __acc;
466#endif
467 __acc = _VSTD::move(__val);
427 }468 }
428 }469 }
429 return __result;470 return __result;
430}471}
431472
432template <class _InputIterator, class _OutputIterator, class _BinaryOperation>473template <class _InputIterator, class _OutputIterator, class _BinaryOperation>
433inline _LIBCPP_INLINE_VISIBILITY474_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
434_OutputIterator475_OutputIterator
435adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterator __result,476adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
436 _BinaryOperation __binary_op)477 _BinaryOperation __binary_op)
437{478{
438 if (__first != __last)479 if (__first != __last)
439 {480 {
440 typename iterator_traits<_InputIterator>::value_type __t1(*__first);481 typename iterator_traits<_InputIterator>::value_type __acc(*__first);
441 *__result = __t1;482 *__result = __acc;
442 for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result)483 for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result)
443 {484 {
444 typename iterator_traits<_InputIterator>::value_type __t2(*__first);485 typename iterator_traits<_InputIterator>::value_type __val(*__first);
445 *__result = __binary_op(__t2, __t1);486#if _LIBCPP_STD_VER > 17
446 __t1 = _VSTD::move(__t2);487 *__result = __binary_op(__val, _VSTD::move(__acc));
488#else
489 *__result = __binary_op(__val, __acc);
490#endif
491 __acc = _VSTD::move(__val);
447 }492 }
448 }493 }
449 return __result;494 return __result;
450}495}
451496
452template <class _ForwardIterator, class _Tp>497template <class _ForwardIterator, class _Tp>
453inline _LIBCPP_INLINE_VISIBILITY498_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
454void499void
455iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value_)500iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value_)
456{501{
...@@ -467,9 +512,9 @@ struct __ct_abs<_Result, _Source, true> {...@@ -467,9 +512,9 @@ struct __ct_abs<_Result, _Source, true> {
467 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY512 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
468 _Result operator()(_Source __t) const noexcept513 _Result operator()(_Source __t) const noexcept
469 {514 {
470 if (__t >= 0) return __t;515 if (__t >= 0) return __t;
471 if (__t == numeric_limits<_Source>::min()) return -static_cast<_Result>(__t);516 if (__t == numeric_limits<_Source>::min()) return -static_cast<_Result>(__t);
472 return -__t;517 return -__t;
473 }518 }
474};519};
475520
...@@ -531,8 +576,8 @@ enable_if_t<is_integral_v<_Tp> && !is_same_v<bool, _Tp> && !is_null_pointer_v<_T...@@ -531,8 +576,8 @@ enable_if_t<is_integral_v<_Tp> && !is_same_v<bool, _Tp> && !is_null_pointer_v<_T
531midpoint(_Tp __a, _Tp __b) noexcept576midpoint(_Tp __a, _Tp __b) noexcept
532_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK577_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
533{578{
534 using _Up = std::make_unsigned_t<_Tp>;579 using _Up = make_unsigned_t<_Tp>;
535 constexpr _Up __bitshift = std::numeric_limits<_Up>::digits - 1;580 constexpr _Up __bitshift = numeric_limits<_Up>::digits - 1;
536581
537 _Up __diff = _Up(__b) - _Up(__a);582 _Up __diff = _Up(__b) - _Up(__a);
538 _Up __sign_bit = __b < __a;583 _Up __sign_bit = __b < __a;
lib/libcxx/include/optional+3-2
...@@ -147,6 +147,7 @@ template<class T>...@@ -147,6 +147,7 @@ template<class T>
147*/147*/
148148
149#include <__config>149#include <__config>
150#include <__availability>
150#include <__debug>151#include <__debug>
151#include <__functional_base>152#include <__functional_base>
152#include <functional>153#include <functional>
...@@ -320,7 +321,7 @@ struct __optional_storage_base : __optional_destruct_base<_Tp>...@@ -320,7 +321,7 @@ struct __optional_storage_base : __optional_destruct_base<_Tp>
320 void __construct(_Args&&... __args)321 void __construct(_Args&&... __args)
321 {322 {
322 _LIBCPP_ASSERT(!has_value(), "__construct called for engaged __optional_storage");323 _LIBCPP_ASSERT(!has_value(), "__construct called for engaged __optional_storage");
323 ::new((void*)_VSTD::addressof(this->__val_)) value_type(_VSTD::forward<_Args>(__args)...);324 ::new ((void*)_VSTD::addressof(this->__val_)) value_type(_VSTD::forward<_Args>(__args)...);
324 this->__engaged_ = true;325 this->__engaged_ = true;
325 }326 }
326327
...@@ -656,7 +657,7 @@ private:...@@ -656,7 +657,7 @@ private:
656 }657 }
657 template <class _Up, class _QUp = _QualUp>658 template <class _Up, class _QUp = _QualUp>
658 static constexpr bool __enable_assign() {659 static constexpr bool __enable_assign() {
659 // Construction and assignability of _Qup to _Tp has already been660 // Construction and assignability of _QUp to _Tp has already been
660 // checked.661 // checked.
661 return !__check_constructible_from_opt<_Up>::value &&662 return !__check_constructible_from_opt<_Up>::value &&
662 !__check_assignable_from_opt<_Up>::value;663 !__check_assignable_from_opt<_Up>::value;
lib/libcxx/include/ostream+15-13
...@@ -126,9 +126,8 @@ template <class charT, class traits>...@@ -126,9 +126,8 @@ template <class charT, class traits>
126 basic_ostream<charT,traits>& flush(basic_ostream<charT,traits>& os);126 basic_ostream<charT,traits>& flush(basic_ostream<charT,traits>& os);
127127
128// rvalue stream insertion128// rvalue stream insertion
129template <class charT, class traits, class T>129template <class Stream, class T>
130 basic_ostream<charT, traits>&130 Stream&& operator<<(Stream&& os, const T& x);
131 operator<<(basic_ostream<charT, traits>&& os, const T& x);
132131
133} // std132} // std
134133
...@@ -1028,15 +1027,20 @@ flush(basic_ostream<_CharT, _Traits>& __os)...@@ -1028,15 +1027,20 @@ flush(basic_ostream<_CharT, _Traits>& __os)
10281027
1029#ifndef _LIBCPP_CXX03_LANG1028#ifndef _LIBCPP_CXX03_LANG
10301029
1030template <class _Stream, class _Tp, class = void>
1031struct __is_ostreamable : false_type { };
1032
1031template <class _Stream, class _Tp>1033template <class _Stream, class _Tp>
1032inline _LIBCPP_INLINE_VISIBILITY1034struct __is_ostreamable<_Stream, _Tp, decltype(
1033typename enable_if1035 _VSTD::declval<_Stream>() << _VSTD::declval<_Tp>(), void()
1034<1036)> : true_type { };
1035 !is_lvalue_reference<_Stream>::value &&1037
1036 is_base_of<ios_base, _Stream>::value,1038template <class _Stream, class _Tp, class = typename enable_if<
1037 _Stream&&1039 _And<is_base_of<ios_base, _Stream>,
1038>::type1040 __is_ostreamable<_Stream&, const _Tp&>>::value
1039operator<<(_Stream&& __os, const _Tp& __x)1041>::type>
1042_LIBCPP_INLINE_VISIBILITY
1043_Stream&& operator<<(_Stream&& __os, const _Tp& __x)
1040{1044{
1041 __os << __x;1045 __os << __x;
1042 return _VSTD::move(__os);1046 return _VSTD::move(__os);
...@@ -1097,10 +1101,8 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x)...@@ -1097,10 +1101,8 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x)
1097 use_facet<ctype<_CharT> >(__os.getloc()).widen('1'));1101 use_facet<ctype<_CharT> >(__os.getloc()).widen('1'));
1098}1102}
10991103
1100#ifndef _LIBCPP_DO_NOT_ASSUME_STREAMS_EXPLICIT_INSTANTIATION_IN_DYLIB
1101_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<char>)1104_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<char>)
1102_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<wchar_t>)1105_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<wchar_t>)
1103#endif
11041106
1105_LIBCPP_END_NAMESPACE_STD1107_LIBCPP_END_NAMESPACE_STD
11061108
lib/libcxx/include/random+145-77
...@@ -1642,8 +1642,7 @@ class piecewise_linear_distribution...@@ -1642,8 +1642,7 @@ class piecewise_linear_distribution
1642#include <numeric>1642#include <numeric>
1643#include <vector>1643#include <vector>
1644#include <string>1644#include <string>
1645#include <istream>1645#include <iosfwd>
1646#include <ostream>
16471646
1648#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)1647#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1649#pragma GCC system_header1648#pragma GCC system_header
...@@ -1669,7 +1668,23 @@ struct __is_seed_sequence...@@ -1669,7 +1668,23 @@ struct __is_seed_sequence
16691668
1670template <unsigned long long __a, unsigned long long __c,1669template <unsigned long long __a, unsigned long long __c,
1671 unsigned long long __m, unsigned long long _Mp,1670 unsigned long long __m, unsigned long long _Mp,
1672 bool _MightOverflow = (__a != 0 && __m != 0 && __m-1 > (_Mp-__c)/__a)>1671 bool _MightOverflow = (__a != 0 && __m != 0 && __m-1 > (_Mp-__c)/__a),
1672 bool _OverflowOK = ((__m|__m-1) > __m), // m = 2^n
1673 bool _SchrageOK = (__a != 0 && __m != 0 && __m % __a <= __m / __a)> // r <= q
1674struct __lce_alg_picker
1675{
1676 static_assert(__a != 0 || __m != 0 || !_MightOverflow || _OverflowOK || _SchrageOK,
1677 "The current values of a, c, and m cannot generate a number "
1678 "within bounds of linear_congruential_engine.");
1679
1680 static _LIBCPP_CONSTEXPR const bool __use_schrage = _MightOverflow &&
1681 !_OverflowOK &&
1682 _SchrageOK;
1683};
1684
1685template <unsigned long long __a, unsigned long long __c,
1686 unsigned long long __m, unsigned long long _Mp,
1687 bool _UseSchrage = __lce_alg_picker<__a, __c, __m, _Mp>::__use_schrage>
1673struct __lce_ta;1688struct __lce_ta;
16741689
1675// 641690// 64
...@@ -1843,6 +1858,7 @@ private:...@@ -1843,6 +1858,7 @@ private:
18431858
1844 static_assert(__m == 0 || __a < __m, "linear_congruential_engine invalid parameters");1859 static_assert(__m == 0 || __a < __m, "linear_congruential_engine invalid parameters");
1845 static_assert(__m == 0 || __c < __m, "linear_congruential_engine invalid parameters");1860 static_assert(__m == 0 || __c < __m, "linear_congruential_engine invalid parameters");
1861 static_assert(_VSTD::is_unsigned<_UIntType>::value, "_UIntType must be unsigned type");
1846public:1862public:
1847 static _LIBCPP_CONSTEXPR const result_type _Min = __c == 0u ? 1u: 0u;1863 static _LIBCPP_CONSTEXPR const result_type _Min = __c == 0u ? 1u: 0u;
1848 static _LIBCPP_CONSTEXPR const result_type _Max = __m - 1u;1864 static _LIBCPP_CONSTEXPR const result_type _Max = __m - 1u;
...@@ -1982,7 +1998,8 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -1982,7 +1998,8 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
1982 const linear_congruential_engine<_UIntType, __a, __c, __m>& __x)1998 const linear_congruential_engine<_UIntType, __a, __c, __m>& __x)
1983{1999{
1984 __save_flags<_CharT, _Traits> __lx(__os);2000 __save_flags<_CharT, _Traits> __lx(__os);
1985 __os.flags(ios_base::dec | ios_base::left);2001 typedef basic_ostream<_CharT, _Traits> _Ostream;
2002 __os.flags(_Ostream::dec | _Ostream::left);
1986 __os.fill(__os.widen(' '));2003 __os.fill(__os.widen(' '));
1987 return __os << __x.__x_;2004 return __os << __x.__x_;
1988}2005}
...@@ -1994,7 +2011,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,...@@ -1994,7 +2011,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
1994 linear_congruential_engine<_UIntType, __a, __c, __m>& __x)2011 linear_congruential_engine<_UIntType, __a, __c, __m>& __x)
1995{2012{
1996 __save_flags<_CharT, _Traits> __lx(__is);2013 __save_flags<_CharT, _Traits> __lx(__is);
1997 __is.flags(ios_base::dec | ios_base::skipws);2014 typedef basic_istream<_CharT, _Traits> _Istream;
2015 __is.flags(_Istream::dec | _Istream::skipws);
1998 _UIntType __t;2016 _UIntType __t;
1999 __is >> __t;2017 __is >> __t;
2000 if (!__is.fail())2018 if (!__is.fail())
...@@ -2453,7 +2471,8 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -2453,7 +2471,8 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
2453 _Bp, _Tp, _Cp, _Lp, _Fp>& __x)2471 _Bp, _Tp, _Cp, _Lp, _Fp>& __x)
2454{2472{
2455 __save_flags<_CharT, _Traits> __lx(__os);2473 __save_flags<_CharT, _Traits> __lx(__os);
2456 __os.flags(ios_base::dec | ios_base::left);2474 typedef basic_ostream<_CharT, _Traits> _Ostream;
2475 __os.flags(_Ostream::dec | _Ostream::left);
2457 _CharT __sp = __os.widen(' ');2476 _CharT __sp = __os.widen(' ');
2458 __os.fill(__sp);2477 __os.fill(__sp);
2459 __os << __x.__x_[__x.__i_];2478 __os << __x.__x_[__x.__i_];
...@@ -2474,7 +2493,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,...@@ -2474,7 +2493,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
2474 _Bp, _Tp, _Cp, _Lp, _Fp>& __x)2493 _Bp, _Tp, _Cp, _Lp, _Fp>& __x)
2475{2494{
2476 __save_flags<_CharT, _Traits> __lx(__is);2495 __save_flags<_CharT, _Traits> __lx(__is);
2477 __is.flags(ios_base::dec | ios_base::skipws);2496 typedef basic_istream<_CharT, _Traits> _Istream;
2497 __is.flags(_Istream::dec | _Istream::skipws);
2478 _UInt __t[_Np];2498 _UInt __t[_Np];
2479 for (size_t __i = 0; __i < _Np; ++__i)2499 for (size_t __i = 0; __i < _Np; ++__i)
2480 __is >> __t[__i];2500 __is >> __t[__i];
...@@ -2773,7 +2793,8 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -2773,7 +2793,8 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
2773 const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x)2793 const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x)
2774{2794{
2775 __save_flags<_CharT, _Traits> __lx(__os);2795 __save_flags<_CharT, _Traits> __lx(__os);
2776 __os.flags(ios_base::dec | ios_base::left);2796 typedef basic_ostream<_CharT, _Traits> _Ostream;
2797 __os.flags(_Ostream::dec | _Ostream::left);
2777 _CharT __sp = __os.widen(' ');2798 _CharT __sp = __os.widen(' ');
2778 __os.fill(__sp);2799 __os.fill(__sp);
2779 __os << __x.__x_[__x.__i_];2800 __os << __x.__x_[__x.__i_];
...@@ -2792,7 +2813,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,...@@ -2792,7 +2813,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
2792 subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x)2813 subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x)
2793{2814{
2794 __save_flags<_CharT, _Traits> __lx(__is);2815 __save_flags<_CharT, _Traits> __lx(__is);
2795 __is.flags(ios_base::dec | ios_base::skipws);2816 typedef basic_istream<_CharT, _Traits> _Istream;
2817 __is.flags(_Istream::dec | _Istream::skipws);
2796 _UInt __t[_Rp+1];2818 _UInt __t[_Rp+1];
2797 for (size_t __i = 0; __i < _Rp+1; ++__i)2819 for (size_t __i = 0; __i < _Rp+1; ++__i)
2798 __is >> __t[__i];2820 __is >> __t[__i];
...@@ -2955,7 +2977,8 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -2955,7 +2977,8 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
2955 const discard_block_engine<_Eng, _Pp, _Rp>& __x)2977 const discard_block_engine<_Eng, _Pp, _Rp>& __x)
2956{2978{
2957 __save_flags<_CharT, _Traits> __lx(__os);2979 __save_flags<_CharT, _Traits> __lx(__os);
2958 __os.flags(ios_base::dec | ios_base::left);2980 typedef basic_ostream<_CharT, _Traits> _Ostream;
2981 __os.flags(_Ostream::dec | _Ostream::left);
2959 _CharT __sp = __os.widen(' ');2982 _CharT __sp = __os.widen(' ');
2960 __os.fill(__sp);2983 __os.fill(__sp);
2961 return __os << __x.__e_ << __sp << __x.__n_;2984 return __os << __x.__e_ << __sp << __x.__n_;
...@@ -2968,7 +2991,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,...@@ -2968,7 +2991,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
2968 discard_block_engine<_Eng, _Pp, _Rp>& __x)2991 discard_block_engine<_Eng, _Pp, _Rp>& __x)
2969{2992{
2970 __save_flags<_CharT, _Traits> __lx(__is);2993 __save_flags<_CharT, _Traits> __lx(__is);
2971 __is.flags(ios_base::dec | ios_base::skipws);2994 typedef basic_istream<_CharT, _Traits> _Istream;
2995 __is.flags(_Istream::dec | _Istream::skipws);
2972 _Eng __e;2996 _Eng __e;
2973 int __n;2997 int __n;
2974 __is >> __e >> __n;2998 __is >> __e >> __n;
...@@ -3440,7 +3464,8 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -3440,7 +3464,8 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
3440 const shuffle_order_engine<_Eng, _Kp>& __x)3464 const shuffle_order_engine<_Eng, _Kp>& __x)
3441{3465{
3442 __save_flags<_CharT, _Traits> __lx(__os);3466 __save_flags<_CharT, _Traits> __lx(__os);
3443 __os.flags(ios_base::dec | ios_base::left);3467 typedef basic_ostream<_CharT, _Traits> _Ostream;
3468 __os.flags(_Ostream::dec | _Ostream::left);
3444 _CharT __sp = __os.widen(' ');3469 _CharT __sp = __os.widen(' ');
3445 __os.fill(__sp);3470 __os.fill(__sp);
3446 __os << __x.__e_ << __sp << __x._V_[0];3471 __os << __x.__e_ << __sp << __x._V_[0];
...@@ -3457,7 +3482,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,...@@ -3457,7 +3482,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
3457{3482{
3458 typedef typename shuffle_order_engine<_Eng, _Kp>::result_type result_type;3483 typedef typename shuffle_order_engine<_Eng, _Kp>::result_type result_type;
3459 __save_flags<_CharT, _Traits> __lx(__is);3484 __save_flags<_CharT, _Traits> __lx(__is);
3460 __is.flags(ios_base::dec | ios_base::skipws);3485 typedef basic_istream<_CharT, _Traits> _Istream;
3486 __is.flags(_Istream::dec | _Istream::skipws);
3461 _Eng __e;3487 _Eng __e;
3462 result_type _Vp[_Kp+1];3488 result_type _Vp[_Kp+1];
3463 __is >> __e;3489 __is >> __e;
...@@ -3477,6 +3503,8 @@ typedef shuffle_order_engine<minstd_rand0, 256> knuth_b;...@@ -3477,6 +3503,8 @@ typedef shuffle_order_engine<minstd_rand0, 256> knuth_b;
34773503
3478// random_device3504// random_device
34793505
3506#if !defined(_LIBCPP_HAS_NO_RANDOM_DEVICE)
3507
3480class _LIBCPP_TYPE_VIS random_device3508class _LIBCPP_TYPE_VIS random_device
3481{3509{
3482#ifdef _LIBCPP_USING_DEV_RANDOM3510#ifdef _LIBCPP_USING_DEV_RANDOM
...@@ -3511,6 +3539,8 @@ private:...@@ -3511,6 +3539,8 @@ private:
3511 random_device& operator=(const random_device&); // = delete;3539 random_device& operator=(const random_device&); // = delete;
3512};3540};
35133541
3542#endif // !_LIBCPP_HAS_NO_RANDOM_DEVICE
3543
3514// seed_seq3544// seed_seq
35153545
3516class _LIBCPP_TEMPLATE_VIS seed_seq3546class _LIBCPP_TEMPLATE_VIS seed_seq
...@@ -3663,7 +3693,8 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -3663,7 +3693,8 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
3663 const uniform_int_distribution<_IT>& __x)3693 const uniform_int_distribution<_IT>& __x)
3664{3694{
3665 __save_flags<_CharT, _Traits> __lx(__os);3695 __save_flags<_CharT, _Traits> __lx(__os);
3666 __os.flags(ios_base::dec | ios_base::left);3696 typedef basic_ostream<_CharT, _Traits> _Ostream;
3697 __os.flags(_Ostream::dec | _Ostream::left);
3667 _CharT __sp = __os.widen(' ');3698 _CharT __sp = __os.widen(' ');
3668 __os.fill(__sp);3699 __os.fill(__sp);
3669 return __os << __x.a() << __sp << __x.b();3700 return __os << __x.a() << __sp << __x.b();
...@@ -3678,7 +3709,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,...@@ -3678,7 +3709,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
3678 typedef typename _Eng::result_type result_type;3709 typedef typename _Eng::result_type result_type;
3679 typedef typename _Eng::param_type param_type;3710 typedef typename _Eng::param_type param_type;
3680 __save_flags<_CharT, _Traits> __lx(__is);3711 __save_flags<_CharT, _Traits> __lx(__is);
3681 __is.flags(ios_base::dec | ios_base::skipws);3712 typedef basic_istream<_CharT, _Traits> _Istream;
3713 __is.flags(_Istream::dec | _Istream::skipws);
3682 result_type __a;3714 result_type __a;
3683 result_type __b;3715 result_type __b;
3684 __is >> __a >> __b;3716 __is >> __a >> __b;
...@@ -3784,8 +3816,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -3784,8 +3816,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
3784 const uniform_real_distribution<_RT>& __x)3816 const uniform_real_distribution<_RT>& __x)
3785{3817{
3786 __save_flags<_CharT, _Traits> __lx(__os);3818 __save_flags<_CharT, _Traits> __lx(__os);
3787 __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |3819 typedef basic_ostream<_CharT, _Traits> _OStream;
3788 ios_base::scientific);3820 __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
3821 _OStream::scientific);
3789 _CharT __sp = __os.widen(' ');3822 _CharT __sp = __os.widen(' ');
3790 __os.fill(__sp);3823 __os.fill(__sp);
3791 return __os << __x.a() << __sp << __x.b();3824 return __os << __x.a() << __sp << __x.b();
...@@ -3800,7 +3833,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,...@@ -3800,7 +3833,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
3800 typedef typename _Eng::result_type result_type;3833 typedef typename _Eng::result_type result_type;
3801 typedef typename _Eng::param_type param_type;3834 typedef typename _Eng::param_type param_type;
3802 __save_flags<_CharT, _Traits> __lx(__is);3835 __save_flags<_CharT, _Traits> __lx(__is);
3803 __is.flags(ios_base::dec | ios_base::skipws);3836 typedef basic_istream<_CharT, _Traits> _Istream;
3837 __is.flags(_Istream::dec | _Istream::skipws);
3804 result_type __a;3838 result_type __a;
3805 result_type __b;3839 result_type __b;
3806 __is >> __a >> __b;3840 __is >> __a >> __b;
...@@ -3895,8 +3929,9 @@ basic_ostream<_CharT, _Traits>&...@@ -3895,8 +3929,9 @@ basic_ostream<_CharT, _Traits>&
3895operator<<(basic_ostream<_CharT, _Traits>& __os, const bernoulli_distribution& __x)3929operator<<(basic_ostream<_CharT, _Traits>& __os, const bernoulli_distribution& __x)
3896{3930{
3897 __save_flags<_CharT, _Traits> __lx(__os);3931 __save_flags<_CharT, _Traits> __lx(__os);
3898 __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |3932 typedef basic_ostream<_CharT, _Traits> _OStream;
3899 ios_base::scientific);3933 __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
3934 _OStream::scientific);
3900 _CharT __sp = __os.widen(' ');3935 _CharT __sp = __os.widen(' ');
3901 __os.fill(__sp);3936 __os.fill(__sp);
3902 return __os << __x.p();3937 return __os << __x.p();
...@@ -3909,7 +3944,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bernoulli_distribution& __x)...@@ -3909,7 +3944,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bernoulli_distribution& __x)
3909 typedef bernoulli_distribution _Eng;3944 typedef bernoulli_distribution _Eng;
3910 typedef typename _Eng::param_type param_type;3945 typedef typename _Eng::param_type param_type;
3911 __save_flags<_CharT, _Traits> __lx(__is);3946 __save_flags<_CharT, _Traits> __lx(__is);
3912 __is.flags(ios_base::dec | ios_base::skipws);3947 typedef basic_istream<_CharT, _Traits> _Istream;
3948 __is.flags(_Istream::dec | _Istream::skipws);
3913 double __p;3949 double __p;
3914 __is >> __p;3950 __is >> __p;
3915 if (!__is.fail())3951 if (!__is.fail())
...@@ -3999,12 +4035,12 @@ public:...@@ -3999,12 +4035,12 @@ public:
3999 {return !(__x == __y);}4035 {return !(__x == __y);}
4000};4036};
40014037
4002#ifndef _LIBCPP_MSVCRT4038#ifndef _LIBCPP_MSVCRT_LIKE
4003extern "C" double lgamma_r(double, int *);4039extern "C" double lgamma_r(double, int *);
4004#endif4040#endif
40054041
4006inline _LIBCPP_INLINE_VISIBILITY double __libcpp_lgamma(double __d) {4042inline _LIBCPP_INLINE_VISIBILITY double __libcpp_lgamma(double __d) {
4007#if defined(_LIBCPP_MSVCRT)4043#if defined(_LIBCPP_MSVCRT_LIKE)
4008 return lgamma(__d);4044 return lgamma(__d);
4009#else4045#else
4010 int __sign;4046 int __sign;
...@@ -4079,8 +4115,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -4079,8 +4115,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
4079 const binomial_distribution<_IntType>& __x)4115 const binomial_distribution<_IntType>& __x)
4080{4116{
4081 __save_flags<_CharT, _Traits> __lx(__os);4117 __save_flags<_CharT, _Traits> __lx(__os);
4082 __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |4118 typedef basic_ostream<_CharT, _Traits> _OStream;
4083 ios_base::scientific);4119 __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
4120 _OStream::scientific);
4084 _CharT __sp = __os.widen(' ');4121 _CharT __sp = __os.widen(' ');
4085 __os.fill(__sp);4122 __os.fill(__sp);
4086 return __os << __x.t() << __sp << __x.p();4123 return __os << __x.t() << __sp << __x.p();
...@@ -4095,7 +4132,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,...@@ -4095,7 +4132,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
4095 typedef typename _Eng::result_type result_type;4132 typedef typename _Eng::result_type result_type;
4096 typedef typename _Eng::param_type param_type;4133 typedef typename _Eng::param_type param_type;
4097 __save_flags<_CharT, _Traits> __lx(__is);4134 __save_flags<_CharT, _Traits> __lx(__is);
4098 __is.flags(ios_base::dec | ios_base::skipws);4135 typedef basic_istream<_CharT, _Traits> _Istream;
4136 __is.flags(_Istream::dec | _Istream::skipws);
4099 result_type __t;4137 result_type __t;
4100 double __p;4138 double __p;
4101 __is >> __t >> __p;4139 __is >> __t >> __p;
...@@ -4197,8 +4235,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -4197,8 +4235,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
4197 const exponential_distribution<_RealType>& __x)4235 const exponential_distribution<_RealType>& __x)
4198{4236{
4199 __save_flags<_CharT, _Traits> __lx(__os);4237 __save_flags<_CharT, _Traits> __lx(__os);
4200 __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |4238 typedef basic_ostream<_CharT, _Traits> _OStream;
4201 ios_base::scientific);4239 __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
4240 _OStream::scientific);
4202 return __os << __x.lambda();4241 return __os << __x.lambda();
4203}4242}
42044243
...@@ -4211,7 +4250,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,...@@ -4211,7 +4250,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
4211 typedef typename _Eng::result_type result_type;4250 typedef typename _Eng::result_type result_type;
4212 typedef typename _Eng::param_type param_type;4251 typedef typename _Eng::param_type param_type;
4213 __save_flags<_CharT, _Traits> __lx(__is);4252 __save_flags<_CharT, _Traits> __lx(__is);
4214 __is.flags(ios_base::dec | ios_base::skipws);4253 typedef basic_istream<_CharT, _Traits> _Istream;
4254 __is.flags(_Istream::dec | _Istream::skipws);
4215 result_type __lambda;4255 result_type __lambda;
4216 __is >> __lambda;4256 __is >> __lambda;
4217 if (!__is.fail())4257 if (!__is.fail())
...@@ -4351,8 +4391,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -4351,8 +4391,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
4351 const normal_distribution<_RT>& __x)4391 const normal_distribution<_RT>& __x)
4352{4392{
4353 __save_flags<_CharT, _Traits> __lx(__os);4393 __save_flags<_CharT, _Traits> __lx(__os);
4354 __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |4394 typedef basic_ostream<_CharT, _Traits> _OStream;
4355 ios_base::scientific);4395 __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
4396 _OStream::scientific);
4356 _CharT __sp = __os.widen(' ');4397 _CharT __sp = __os.widen(' ');
4357 __os.fill(__sp);4398 __os.fill(__sp);
4358 __os << __x.mean() << __sp << __x.stddev() << __sp << __x._V_hot_;4399 __os << __x.mean() << __sp << __x.stddev() << __sp << __x._V_hot_;
...@@ -4370,7 +4411,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,...@@ -4370,7 +4411,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
4370 typedef typename _Eng::result_type result_type;4411 typedef typename _Eng::result_type result_type;
4371 typedef typename _Eng::param_type param_type;4412 typedef typename _Eng::param_type param_type;
4372 __save_flags<_CharT, _Traits> __lx(__is);4413 __save_flags<_CharT, _Traits> __lx(__is);
4373 __is.flags(ios_base::dec | ios_base::skipws);4414 typedef basic_istream<_CharT, _Traits> _Istream;
4415 __is.flags(_Istream::dec | _Istream::skipws);
4374 result_type __mean;4416 result_type __mean;
4375 result_type __stddev;4417 result_type __stddev;
4376 result_type _Vp = 0;4418 result_type _Vp = 0;
...@@ -4618,7 +4660,7 @@ poisson_distribution<_IntType>::param_type::param_type(double __mean)...@@ -4618,7 +4660,7 @@ poisson_distribution<_IntType>::param_type::param_type(double __mean)
4618 {4660 {
4619 __s_ = _VSTD::sqrt(__mean_);4661 __s_ = _VSTD::sqrt(__mean_);
4620 __d_ = 6 * __mean_ * __mean_;4662 __d_ = 6 * __mean_ * __mean_;
4621 __l_ = std::trunc(__mean_ - 1.1484);4663 __l_ = _VSTD::trunc(__mean_ - 1.1484);
4622 __omega_ = .3989423 / __s_;4664 __omega_ = .3989423 / __s_;
4623 double __b1_ = .4166667E-1 / __mean_;4665 double __b1_ = .4166667E-1 / __mean_;
4624 double __b2_ = .3 * __b1_ * __b1_;4666 double __b2_ = .3 * __b1_ * __b1_;
...@@ -4650,13 +4692,13 @@ poisson_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr...@@ -4650,13 +4692,13 @@ poisson_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr
4650 double __u;4692 double __u;
4651 if (__g > 0)4693 if (__g > 0)
4652 {4694 {
4653 __tx = std::trunc(__g);4695 __tx = _VSTD::trunc(__g);
4654 if (__tx >= __pr.__l_)4696 if (__tx >= __pr.__l_)
4655 return std::__clamp_to_integral<result_type>(__tx);4697 return _VSTD::__clamp_to_integral<result_type>(__tx);
4656 __difmuk = __pr.__mean_ - __tx;4698 __difmuk = __pr.__mean_ - __tx;
4657 __u = __urd(__urng);4699 __u = __urd(__urng);
4658 if (__pr.__d_ * __u >= __difmuk * __difmuk * __difmuk)4700 if (__pr.__d_ * __u >= __difmuk * __difmuk * __difmuk)
4659 return std::__clamp_to_integral<result_type>(__tx);4701 return _VSTD::__clamp_to_integral<result_type>(__tx);
4660 }4702 }
4661 exponential_distribution<double> __edist;4703 exponential_distribution<double> __edist;
4662 for (bool __using_exp_dist = false; true; __using_exp_dist = true)4704 for (bool __using_exp_dist = false; true; __using_exp_dist = true)
...@@ -4672,7 +4714,7 @@ poisson_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr...@@ -4672,7 +4714,7 @@ poisson_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr
4672 __u += __u - 1;4714 __u += __u - 1;
4673 __t = 1.8 + (__u < 0 ? -__e : __e);4715 __t = 1.8 + (__u < 0 ? -__e : __e);
4674 } while (__t <= -.6744);4716 } while (__t <= -.6744);
4675 __tx = std::trunc(__pr.__mean_ + __pr.__s_ * __t);4717 __tx = _VSTD::trunc(__pr.__mean_ + __pr.__s_ * __t);
4676 __difmuk = __pr.__mean_ - __tx;4718 __difmuk = __pr.__mean_ - __tx;
4677 __using_exp_dist = true;4719 __using_exp_dist = true;
4678 }4720 }
...@@ -4716,7 +4758,7 @@ poisson_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr...@@ -4716,7 +4758,7 @@ poisson_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr
4716 }4758 }
4717 }4759 }
4718 }4760 }
4719 return std::__clamp_to_integral<result_type>(__tx);4761 return _VSTD::__clamp_to_integral<result_type>(__tx);
4720}4762}
47214763
4722template <class _CharT, class _Traits, class _IntType>4764template <class _CharT, class _Traits, class _IntType>
...@@ -4725,8 +4767,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -4725,8 +4767,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
4725 const poisson_distribution<_IntType>& __x)4767 const poisson_distribution<_IntType>& __x)
4726{4768{
4727 __save_flags<_CharT, _Traits> __lx(__os);4769 __save_flags<_CharT, _Traits> __lx(__os);
4728 __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |4770 typedef basic_ostream<_CharT, _Traits> _OStream;
4729 ios_base::scientific);4771 __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
4772 _OStream::scientific);
4730 return __os << __x.mean();4773 return __os << __x.mean();
4731}4774}
47324775
...@@ -4738,7 +4781,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,...@@ -4738,7 +4781,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
4738 typedef poisson_distribution<_IntType> _Eng;4781 typedef poisson_distribution<_IntType> _Eng;
4739 typedef typename _Eng::param_type param_type;4782 typedef typename _Eng::param_type param_type;
4740 __save_flags<_CharT, _Traits> __lx(__is);4783 __save_flags<_CharT, _Traits> __lx(__is);
4741 __is.flags(ios_base::dec | ios_base::skipws);4784 typedef basic_istream<_CharT, _Traits> _Istream;
4785 __is.flags(_Istream::dec | _Istream::skipws);
4742 double __mean;4786 double __mean;
4743 __is >> __mean;4787 __is >> __mean;
4744 if (!__is.fail())4788 if (!__is.fail())
...@@ -4836,8 +4880,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -4836,8 +4880,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
4836 const weibull_distribution<_RT>& __x)4880 const weibull_distribution<_RT>& __x)
4837{4881{
4838 __save_flags<_CharT, _Traits> __lx(__os);4882 __save_flags<_CharT, _Traits> __lx(__os);
4839 __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |4883 typedef basic_ostream<_CharT, _Traits> _OStream;
4840 ios_base::scientific);4884 __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
4885 _OStream::scientific);
4841 _CharT __sp = __os.widen(' ');4886 _CharT __sp = __os.widen(' ');
4842 __os.fill(__sp);4887 __os.fill(__sp);
4843 __os << __x.a() << __sp << __x.b();4888 __os << __x.a() << __sp << __x.b();
...@@ -4853,7 +4898,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,...@@ -4853,7 +4898,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
4853 typedef typename _Eng::result_type result_type;4898 typedef typename _Eng::result_type result_type;
4854 typedef typename _Eng::param_type param_type;4899 typedef typename _Eng::param_type param_type;
4855 __save_flags<_CharT, _Traits> __lx(__is);4900 __save_flags<_CharT, _Traits> __lx(__is);
4856 __is.flags(ios_base::dec | ios_base::skipws);4901 typedef basic_istream<_CharT, _Traits> _Istream;
4902 __is.flags(_Istream::dec | _Istream::skipws);
4857 result_type __a;4903 result_type __a;
4858 result_type __b;4904 result_type __b;
4859 __is >> __a >> __b;4905 __is >> __a >> __b;
...@@ -4955,8 +5001,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -4955,8 +5001,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
4955 const extreme_value_distribution<_RT>& __x)5001 const extreme_value_distribution<_RT>& __x)
4956{5002{
4957 __save_flags<_CharT, _Traits> __lx(__os);5003 __save_flags<_CharT, _Traits> __lx(__os);
4958 __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |5004 typedef basic_ostream<_CharT, _Traits> _OStream;
4959 ios_base::scientific);5005 __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
5006 _OStream::scientific);
4960 _CharT __sp = __os.widen(' ');5007 _CharT __sp = __os.widen(' ');
4961 __os.fill(__sp);5008 __os.fill(__sp);
4962 __os << __x.a() << __sp << __x.b();5009 __os << __x.a() << __sp << __x.b();
...@@ -4972,7 +5019,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,...@@ -4972,7 +5019,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
4972 typedef typename _Eng::result_type result_type;5019 typedef typename _Eng::result_type result_type;
4973 typedef typename _Eng::param_type param_type;5020 typedef typename _Eng::param_type param_type;
4974 __save_flags<_CharT, _Traits> __lx(__is);5021 __save_flags<_CharT, _Traits> __lx(__is);
4975 __is.flags(ios_base::dec | ios_base::skipws);5022 typedef basic_istream<_CharT, _Traits> _Istream;
5023 __is.flags(_Istream::dec | _Istream::skipws);
4976 result_type __a;5024 result_type __a;
4977 result_type __b;5025 result_type __b;
4978 __is >> __a >> __b;5026 __is >> __a >> __b;
...@@ -5127,8 +5175,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -5127,8 +5175,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
5127 const gamma_distribution<_RT>& __x)5175 const gamma_distribution<_RT>& __x)
5128{5176{
5129 __save_flags<_CharT, _Traits> __lx(__os);5177 __save_flags<_CharT, _Traits> __lx(__os);
5130 __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |5178 typedef basic_ostream<_CharT, _Traits> _OStream;
5131 ios_base::scientific);5179 __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
5180 _OStream::scientific);
5132 _CharT __sp = __os.widen(' ');5181 _CharT __sp = __os.widen(' ');
5133 __os.fill(__sp);5182 __os.fill(__sp);
5134 __os << __x.alpha() << __sp << __x.beta();5183 __os << __x.alpha() << __sp << __x.beta();
...@@ -5144,7 +5193,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,...@@ -5144,7 +5193,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
5144 typedef typename _Eng::result_type result_type;5193 typedef typename _Eng::result_type result_type;
5145 typedef typename _Eng::param_type param_type;5194 typedef typename _Eng::param_type param_type;
5146 __save_flags<_CharT, _Traits> __lx(__is);5195 __save_flags<_CharT, _Traits> __lx(__is);
5147 __is.flags(ios_base::dec | ios_base::skipws);5196 typedef basic_istream<_CharT, _Traits> _Istream;
5197 __is.flags(_Istream::dec | _Istream::skipws);
5148 result_type __alpha;5198 result_type __alpha;
5149 result_type __beta;5199 result_type __beta;
5150 __is >> __alpha >> __beta;5200 __is >> __alpha >> __beta;
...@@ -5263,8 +5313,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -5263,8 +5313,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
5263 const negative_binomial_distribution<_IntType>& __x)5313 const negative_binomial_distribution<_IntType>& __x)
5264{5314{
5265 __save_flags<_CharT, _Traits> __lx(__os);5315 __save_flags<_CharT, _Traits> __lx(__os);
5266 __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |5316 typedef basic_ostream<_CharT, _Traits> _OStream;
5267 ios_base::scientific);5317 __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
5318 _OStream::scientific);
5268 _CharT __sp = __os.widen(' ');5319 _CharT __sp = __os.widen(' ');
5269 __os.fill(__sp);5320 __os.fill(__sp);
5270 return __os << __x.k() << __sp << __x.p();5321 return __os << __x.k() << __sp << __x.p();
...@@ -5279,7 +5330,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,...@@ -5279,7 +5330,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
5279 typedef typename _Eng::result_type result_type;5330 typedef typename _Eng::result_type result_type;
5280 typedef typename _Eng::param_type param_type;5331 typedef typename _Eng::param_type param_type;
5281 __save_flags<_CharT, _Traits> __lx(__is);5332 __save_flags<_CharT, _Traits> __lx(__is);
5282 __is.flags(ios_base::dec | ios_base::skipws);5333 typedef basic_istream<_CharT, _Traits> _Istream;
5334 __is.flags(_Istream::dec | _Istream::skipws);
5283 result_type __k;5335 result_type __k;
5284 double __p;5336 double __p;
5285 __is >> __k >> __p;5337 __is >> __k >> __p;
...@@ -5369,8 +5421,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -5369,8 +5421,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
5369 const geometric_distribution<_IntType>& __x)5421 const geometric_distribution<_IntType>& __x)
5370{5422{
5371 __save_flags<_CharT, _Traits> __lx(__os);5423 __save_flags<_CharT, _Traits> __lx(__os);
5372 __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |5424 typedef basic_ostream<_CharT, _Traits> _OStream;
5373 ios_base::scientific);5425 __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
5426 _OStream::scientific);
5374 return __os << __x.p();5427 return __os << __x.p();
5375}5428}
53765429
...@@ -5382,7 +5435,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,...@@ -5382,7 +5435,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
5382 typedef geometric_distribution<_IntType> _Eng;5435 typedef geometric_distribution<_IntType> _Eng;
5383 typedef typename _Eng::param_type param_type;5436 typedef typename _Eng::param_type param_type;
5384 __save_flags<_CharT, _Traits> __lx(__is);5437 __save_flags<_CharT, _Traits> __lx(__is);
5385 __is.flags(ios_base::dec | ios_base::skipws);5438 typedef basic_istream<_CharT, _Traits> _Istream;
5439 __is.flags(_Istream::dec | _Istream::skipws);
5386 double __p;5440 double __p;
5387 __is >> __p;5441 __is >> __p;
5388 if (!__is.fail())5442 if (!__is.fail())
...@@ -5473,8 +5527,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -5473,8 +5527,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
5473 const chi_squared_distribution<_RT>& __x)5527 const chi_squared_distribution<_RT>& __x)
5474{5528{
5475 __save_flags<_CharT, _Traits> __lx(__os);5529 __save_flags<_CharT, _Traits> __lx(__os);
5476 __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |5530 typedef basic_ostream<_CharT, _Traits> _OStream;
5477 ios_base::scientific);5531 __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
5532 _OStream::scientific);
5478 __os << __x.n();5533 __os << __x.n();
5479 return __os;5534 return __os;
5480}5535}
...@@ -5488,7 +5543,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,...@@ -5488,7 +5543,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
5488 typedef typename _Eng::result_type result_type;5543 typedef typename _Eng::result_type result_type;
5489 typedef typename _Eng::param_type param_type;5544 typedef typename _Eng::param_type param_type;
5490 __save_flags<_CharT, _Traits> __lx(__is);5545 __save_flags<_CharT, _Traits> __lx(__is);
5491 __is.flags(ios_base::dec | ios_base::skipws);5546 typedef basic_istream<_CharT, _Traits> _Istream;
5547 __is.flags(_Istream::dec | _Istream::skipws);
5492 result_type __n;5548 result_type __n;
5493 __is >> __n;5549 __is >> __n;
5494 if (!__is.fail())5550 if (!__is.fail())
...@@ -5593,8 +5649,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -5593,8 +5649,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
5593 const cauchy_distribution<_RT>& __x)5649 const cauchy_distribution<_RT>& __x)
5594{5650{
5595 __save_flags<_CharT, _Traits> __lx(__os);5651 __save_flags<_CharT, _Traits> __lx(__os);
5596 __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |5652 typedef basic_ostream<_CharT, _Traits> _OStream;
5597 ios_base::scientific);5653 __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
5654 _OStream::scientific);
5598 _CharT __sp = __os.widen(' ');5655 _CharT __sp = __os.widen(' ');
5599 __os.fill(__sp);5656 __os.fill(__sp);
5600 __os << __x.a() << __sp << __x.b();5657 __os << __x.a() << __sp << __x.b();
...@@ -5610,7 +5667,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,...@@ -5610,7 +5667,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
5610 typedef typename _Eng::result_type result_type;5667 typedef typename _Eng::result_type result_type;
5611 typedef typename _Eng::param_type param_type;5668 typedef typename _Eng::param_type param_type;
5612 __save_flags<_CharT, _Traits> __lx(__is);5669 __save_flags<_CharT, _Traits> __lx(__is);
5613 __is.flags(ios_base::dec | ios_base::skipws);5670 typedef basic_istream<_CharT, _Traits> _Istream;
5671 __is.flags(_Istream::dec | _Istream::skipws);
5614 result_type __a;5672 result_type __a;
5615 result_type __b;5673 result_type __b;
5616 __is >> __a >> __b;5674 __is >> __a >> __b;
...@@ -5715,8 +5773,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -5715,8 +5773,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
5715 const fisher_f_distribution<_RT>& __x)5773 const fisher_f_distribution<_RT>& __x)
5716{5774{
5717 __save_flags<_CharT, _Traits> __lx(__os);5775 __save_flags<_CharT, _Traits> __lx(__os);
5718 __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |5776 typedef basic_ostream<_CharT, _Traits> _OStream;
5719 ios_base::scientific);5777 __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
5778 _OStream::scientific);
5720 _CharT __sp = __os.widen(' ');5779 _CharT __sp = __os.widen(' ');
5721 __os.fill(__sp);5780 __os.fill(__sp);
5722 __os << __x.m() << __sp << __x.n();5781 __os << __x.m() << __sp << __x.n();
...@@ -5732,7 +5791,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,...@@ -5732,7 +5791,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
5732 typedef typename _Eng::result_type result_type;5791 typedef typename _Eng::result_type result_type;
5733 typedef typename _Eng::param_type param_type;5792 typedef typename _Eng::param_type param_type;
5734 __save_flags<_CharT, _Traits> __lx(__is);5793 __save_flags<_CharT, _Traits> __lx(__is);
5735 __is.flags(ios_base::dec | ios_base::skipws);5794 typedef basic_istream<_CharT, _Traits> _Istream;
5795 __is.flags(_Istream::dec | _Istream::skipws);
5736 result_type __m;5796 result_type __m;
5737 result_type __n;5797 result_type __n;
5738 __is >> __m >> __n;5798 __is >> __m >> __n;
...@@ -5831,8 +5891,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -5831,8 +5891,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
5831 const student_t_distribution<_RT>& __x)5891 const student_t_distribution<_RT>& __x)
5832{5892{
5833 __save_flags<_CharT, _Traits> __lx(__os);5893 __save_flags<_CharT, _Traits> __lx(__os);
5834 __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |5894 typedef basic_ostream<_CharT, _Traits> _OStream;
5835 ios_base::scientific);5895 __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
5896 _OStream::scientific);
5836 __os << __x.n();5897 __os << __x.n();
5837 return __os;5898 return __os;
5838}5899}
...@@ -5846,7 +5907,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,...@@ -5846,7 +5907,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
5846 typedef typename _Eng::result_type result_type;5907 typedef typename _Eng::result_type result_type;
5847 typedef typename _Eng::param_type param_type;5908 typedef typename _Eng::param_type param_type;
5848 __save_flags<_CharT, _Traits> __lx(__is);5909 __save_flags<_CharT, _Traits> __lx(__is);
5849 __is.flags(ios_base::dec | ios_base::skipws);5910 typedef basic_istream<_CharT, _Traits> _Istream;
5911 __is.flags(_Istream::dec | _Istream::skipws);
5850 result_type __n;5912 result_type __n;
5851 __is >> __n;5913 __is >> __n;
5852 if (!__is.fail())5914 if (!__is.fail())
...@@ -6054,8 +6116,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -6054,8 +6116,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
6054 const discrete_distribution<_IT>& __x)6116 const discrete_distribution<_IT>& __x)
6055{6117{
6056 __save_flags<_CharT, _Traits> __lx(__os);6118 __save_flags<_CharT, _Traits> __lx(__os);
6057 __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |6119 typedef basic_ostream<_CharT, _Traits> _OStream;
6058 ios_base::scientific);6120 __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
6121 _OStream::scientific);
6059 _CharT __sp = __os.widen(' ');6122 _CharT __sp = __os.widen(' ');
6060 __os.fill(__sp);6123 __os.fill(__sp);
6061 size_t __n = __x.__p_.__p_.size();6124 size_t __n = __x.__p_.__p_.size();
...@@ -6071,7 +6134,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,...@@ -6071,7 +6134,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
6071 discrete_distribution<_IT>& __x)6134 discrete_distribution<_IT>& __x)
6072{6135{
6073 __save_flags<_CharT, _Traits> __lx(__is);6136 __save_flags<_CharT, _Traits> __lx(__is);
6074 __is.flags(ios_base::dec | ios_base::skipws);6137 typedef basic_istream<_CharT, _Traits> _Istream;
6138 __is.flags(_Istream::dec | _Istream::skipws);
6075 size_t __n;6139 size_t __n;
6076 __is >> __n;6140 __is >> __n;
6077 vector<double> __p(__n);6141 vector<double> __p(__n);
...@@ -6356,8 +6420,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -6356,8 +6420,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
6356 const piecewise_constant_distribution<_RT>& __x)6420 const piecewise_constant_distribution<_RT>& __x)
6357{6421{
6358 __save_flags<_CharT, _Traits> __lx(__os);6422 __save_flags<_CharT, _Traits> __lx(__os);
6359 __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |6423 typedef basic_ostream<_CharT, _Traits> _OStream;
6360 ios_base::scientific);6424 __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
6425 _OStream::scientific);
6361 _CharT __sp = __os.widen(' ');6426 _CharT __sp = __os.widen(' ');
6362 __os.fill(__sp);6427 __os.fill(__sp);
6363 size_t __n = __x.__p_.__b_.size();6428 size_t __n = __x.__p_.__b_.size();
...@@ -6383,7 +6448,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,...@@ -6383,7 +6448,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
6383 typedef piecewise_constant_distribution<_RT> _Eng;6448 typedef piecewise_constant_distribution<_RT> _Eng;
6384 typedef typename _Eng::result_type result_type;6449 typedef typename _Eng::result_type result_type;
6385 __save_flags<_CharT, _Traits> __lx(__is);6450 __save_flags<_CharT, _Traits> __lx(__is);
6386 __is.flags(ios_base::dec | ios_base::skipws);6451 typedef basic_istream<_CharT, _Traits> _Istream;
6452 __is.flags(_Istream::dec | _Istream::skipws);
6387 size_t __n;6453 size_t __n;
6388 __is >> __n;6454 __is >> __n;
6389 vector<result_type> __b(__n);6455 vector<result_type> __b(__n);
...@@ -6696,8 +6762,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -6696,8 +6762,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
6696 const piecewise_linear_distribution<_RT>& __x)6762 const piecewise_linear_distribution<_RT>& __x)
6697{6763{
6698 __save_flags<_CharT, _Traits> __lx(__os);6764 __save_flags<_CharT, _Traits> __lx(__os);
6699 __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |6765 typedef basic_ostream<_CharT, _Traits> _OStream;
6700 ios_base::scientific);6766 __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
6767 _OStream::scientific);
6701 _CharT __sp = __os.widen(' ');6768 _CharT __sp = __os.widen(' ');
6702 __os.fill(__sp);6769 __os.fill(__sp);
6703 size_t __n = __x.__p_.__b_.size();6770 size_t __n = __x.__p_.__b_.size();
...@@ -6723,7 +6790,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,...@@ -6723,7 +6790,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
6723 typedef piecewise_linear_distribution<_RT> _Eng;6790 typedef piecewise_linear_distribution<_RT> _Eng;
6724 typedef typename _Eng::result_type result_type;6791 typedef typename _Eng::result_type result_type;
6725 __save_flags<_CharT, _Traits> __lx(__is);6792 __save_flags<_CharT, _Traits> __lx(__is);
6726 __is.flags(ios_base::dec | ios_base::skipws);6793 typedef basic_istream<_CharT, _Traits> _Istream;
6794 __is.flags(_Istream::dec | _Istream::skipws);
6727 size_t __n;6795 size_t __n;
6728 __is >> __n;6796 __is >> __n;
6729 vector<result_type> __b(__n);6797 vector<result_type> __b(__n);
lib/libcxx/include/regex+122-51
...@@ -32,7 +32,8 @@ enum syntax_option_type...@@ -32,7 +32,8 @@ enum syntax_option_type
32 extended = unspecified,32 extended = unspecified,
33 awk = unspecified,33 awk = unspecified,
34 grep = unspecified,34 grep = unspecified,
35 egrep = unspecified35 egrep = unspecified,
36 multiline = unspecified
36};37};
3738
38constexpr syntax_option_type operator~(syntax_option_type f);39constexpr syntax_option_type operator~(syntax_option_type f);
...@@ -142,6 +143,7 @@ public:...@@ -142,6 +143,7 @@ public:
142 static constexpr regex_constants::syntax_option_type awk = regex_constants::awk;143 static constexpr regex_constants::syntax_option_type awk = regex_constants::awk;
143 static constexpr regex_constants::syntax_option_type grep = regex_constants::grep;144 static constexpr regex_constants::syntax_option_type grep = regex_constants::grep;
144 static constexpr regex_constants::syntax_option_type egrep = regex_constants::egrep;145 static constexpr regex_constants::syntax_option_type egrep = regex_constants::egrep;
146 static constexpr regex_constants::syntax_option_type multiline = regex_constants::multiline;
145147
146 // construct/copy/destroy:148 // construct/copy/destroy:
147 basic_regex();149 basic_regex();
...@@ -802,7 +804,9 @@ enum syntax_option_type...@@ -802,7 +804,9 @@ enum syntax_option_type
802 extended = 1 << 5,804 extended = 1 << 5,
803 awk = 1 << 6,805 awk = 1 << 6,
804 grep = 1 << 7,806 grep = 1 << 7,
805 egrep = 1 << 8807 egrep = 1 << 8,
808 // 1 << 9 may be used by ECMAScript
809 multiline = 1 << 10
806};810};
807811
808inline _LIBCPP_CONSTEXPR812inline _LIBCPP_CONSTEXPR
...@@ -1982,24 +1986,33 @@ __word_boundary<_CharT, _Traits>::__exec(__state& __s) const...@@ -1982,24 +1986,33 @@ __word_boundary<_CharT, _Traits>::__exec(__state& __s) const
1982// __l_anchor1986// __l_anchor
19831987
1984template <class _CharT>1988template <class _CharT>
1985class __l_anchor1989_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
1990bool __is_eol(_CharT c)
1991{
1992 return c == '\r' || c == '\n';
1993}
1994
1995template <class _CharT>
1996class __l_anchor_multiline
1986 : public __owns_one_state<_CharT>1997 : public __owns_one_state<_CharT>
1987{1998{
1988 typedef __owns_one_state<_CharT> base;1999 typedef __owns_one_state<_CharT> base;
19892000
2001 bool __multiline;
2002
1990public:2003public:
1991 typedef _VSTD::__state<_CharT> __state;2004 typedef _VSTD::__state<_CharT> __state;
19922005
1993 _LIBCPP_INLINE_VISIBILITY2006 _LIBCPP_INLINE_VISIBILITY
1994 __l_anchor(__node<_CharT>* __s)2007 __l_anchor_multiline(bool __multiline, __node<_CharT>* __s)
1995 : base(__s) {}2008 : base(__s), __multiline(__multiline) {}
19962009
1997 virtual void __exec(__state&) const;2010 virtual void __exec(__state&) const;
1998};2011};
19992012
2000template <class _CharT>2013template <class _CharT>
2001void2014void
2002__l_anchor<_CharT>::__exec(__state& __s) const2015__l_anchor_multiline<_CharT>::__exec(__state& __s) const
2003{2016{
2004 if (__s.__at_first_ && __s.__current_ == __s.__first_ &&2017 if (__s.__at_first_ && __s.__current_ == __s.__first_ &&
2005 !(__s.__flags_ & regex_constants::match_not_bol))2018 !(__s.__flags_ & regex_constants::match_not_bol))
...@@ -2007,6 +2020,13 @@ __l_anchor<_CharT>::__exec(__state& __s) const...@@ -2007,6 +2020,13 @@ __l_anchor<_CharT>::__exec(__state& __s) const
2007 __s.__do_ = __state::__accept_but_not_consume;2020 __s.__do_ = __state::__accept_but_not_consume;
2008 __s.__node_ = this->first();2021 __s.__node_ = this->first();
2009 }2022 }
2023 else if (__multiline &&
2024 !__s.__at_first_ &&
2025 __is_eol(*_VSTD::prev(__s.__current_)))
2026 {
2027 __s.__do_ = __state::__accept_but_not_consume;
2028 __s.__node_ = this->first();
2029 }
2010 else2030 else
2011 {2031 {
2012 __s.__do_ = __state::__reject;2032 __s.__do_ = __state::__reject;
...@@ -2017,24 +2037,26 @@ __l_anchor<_CharT>::__exec(__state& __s) const...@@ -2017,24 +2037,26 @@ __l_anchor<_CharT>::__exec(__state& __s) const
2017// __r_anchor2037// __r_anchor
20182038
2019template <class _CharT>2039template <class _CharT>
2020class __r_anchor2040class __r_anchor_multiline
2021 : public __owns_one_state<_CharT>2041 : public __owns_one_state<_CharT>
2022{2042{
2023 typedef __owns_one_state<_CharT> base;2043 typedef __owns_one_state<_CharT> base;
20242044
2045 bool __multiline;
2046
2025public:2047public:
2026 typedef _VSTD::__state<_CharT> __state;2048 typedef _VSTD::__state<_CharT> __state;
20272049
2028 _LIBCPP_INLINE_VISIBILITY2050 _LIBCPP_INLINE_VISIBILITY
2029 __r_anchor(__node<_CharT>* __s)2051 __r_anchor_multiline(bool __multiline, __node<_CharT>* __s)
2030 : base(__s) {}2052 : base(__s), __multiline(__multiline) {}
20312053
2032 virtual void __exec(__state&) const;2054 virtual void __exec(__state&) const;
2033};2055};
20342056
2035template <class _CharT>2057template <class _CharT>
2036void2058void
2037__r_anchor<_CharT>::__exec(__state& __s) const2059__r_anchor_multiline<_CharT>::__exec(__state& __s) const
2038{2060{
2039 if (__s.__current_ == __s.__last_ &&2061 if (__s.__current_ == __s.__last_ &&
2040 !(__s.__flags_ & regex_constants::match_not_eol))2062 !(__s.__flags_ & regex_constants::match_not_eol))
...@@ -2042,6 +2064,11 @@ __r_anchor<_CharT>::__exec(__state& __s) const...@@ -2042,6 +2064,11 @@ __r_anchor<_CharT>::__exec(__state& __s) const
2042 __s.__do_ = __state::__accept_but_not_consume;2064 __s.__do_ = __state::__accept_but_not_consume;
2043 __s.__node_ = this->first();2065 __s.__node_ = this->first();
2044 }2066 }
2067 else if (__multiline && __is_eol(*__s.__current_))
2068 {
2069 __s.__do_ = __state::__accept_but_not_consume;
2070 __s.__node_ = this->first();
2071 }
2045 else2072 else
2046 {2073 {
2047 __s.__do_ = __state::__reject;2074 __s.__do_ = __state::__reject;
...@@ -2448,7 +2475,7 @@ __bracket_expression<_CharT, _Traits>::__exec(__state& __s) const...@@ -2448,7 +2475,7 @@ __bracket_expression<_CharT, _Traits>::__exec(__state& __s) const
2448 {2475 {
2449 const bool __in_neg_mask = __traits_.isctype(__ch, __neg_mask_);2476 const bool __in_neg_mask = __traits_.isctype(__ch, __neg_mask_);
2450 const bool __in_neg_chars =2477 const bool __in_neg_chars =
2451 std::find(__neg_chars_.begin(), __neg_chars_.end(), __ch) !=2478 _VSTD::find(__neg_chars_.begin(), __neg_chars_.end(), __ch) !=
2452 __neg_chars_.end();2479 __neg_chars_.end();
2453 if (!(__in_neg_mask || __in_neg_chars))2480 if (!(__in_neg_mask || __in_neg_chars))
2454 {2481 {
...@@ -2507,7 +2534,17 @@ __exit:...@@ -2507,7 +2534,17 @@ __exit:
2507template <class _CharT, class _Traits> class __lookahead;2534template <class _CharT, class _Traits> class __lookahead;
25082535
2509template <class _CharT, class _Traits = regex_traits<_CharT> >2536template <class _CharT, class _Traits = regex_traits<_CharT> >
2510class _LIBCPP_TEMPLATE_VIS basic_regex2537 class _LIBCPP_TEMPLATE_VIS basic_regex;
2538
2539typedef basic_regex<char> regex;
2540typedef basic_regex<wchar_t> wregex;
2541
2542template <class _CharT, class _Traits>
2543class
2544 _LIBCPP_TEMPLATE_VIS
2545 _LIBCPP_PREFERRED_NAME(regex)
2546 _LIBCPP_PREFERRED_NAME(wregex)
2547 basic_regex
2511{2548{
2512public:2549public:
2513 // types:2550 // types:
...@@ -2541,17 +2578,18 @@ public:...@@ -2541,17 +2578,18 @@ public:
2541 static const regex_constants::syntax_option_type awk = regex_constants::awk;2578 static const regex_constants::syntax_option_type awk = regex_constants::awk;
2542 static const regex_constants::syntax_option_type grep = regex_constants::grep;2579 static const regex_constants::syntax_option_type grep = regex_constants::grep;
2543 static const regex_constants::syntax_option_type egrep = regex_constants::egrep;2580 static const regex_constants::syntax_option_type egrep = regex_constants::egrep;
2581 static const regex_constants::syntax_option_type multiline = regex_constants::multiline;
25442582
2545 // construct/copy/destroy:2583 // construct/copy/destroy:
2546 _LIBCPP_INLINE_VISIBILITY2584 _LIBCPP_INLINE_VISIBILITY
2547 basic_regex()2585 basic_regex()
2548 : __flags_(regex_constants::ECMAScript), __marked_count_(0), __loop_count_(0), __open_count_(0),2586 : __flags_(regex_constants::ECMAScript), __marked_count_(0), __loop_count_(0), __open_count_(0),
2549 __end_(0)2587 __end_(nullptr)
2550 {}2588 {}
2551 _LIBCPP_INLINE_VISIBILITY2589 _LIBCPP_INLINE_VISIBILITY
2552 explicit basic_regex(const value_type* __p, flag_type __f = regex_constants::ECMAScript)2590 explicit basic_regex(const value_type* __p, flag_type __f = regex_constants::ECMAScript)
2553 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),2591 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
2554 __end_(0)2592 __end_(nullptr)
2555 {2593 {
2556 __init(__p, __p + __traits_.length(__p));2594 __init(__p, __p + __traits_.length(__p));
2557 }2595 }
...@@ -2559,7 +2597,7 @@ public:...@@ -2559,7 +2597,7 @@ public:
2559 _LIBCPP_INLINE_VISIBILITY2597 _LIBCPP_INLINE_VISIBILITY
2560 basic_regex(const value_type* __p, size_t __len, flag_type __f = regex_constants::ECMAScript)2598 basic_regex(const value_type* __p, size_t __len, flag_type __f = regex_constants::ECMAScript)
2561 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),2599 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
2562 __end_(0)2600 __end_(nullptr)
2563 {2601 {
2564 __init(__p, __p + __len);2602 __init(__p, __p + __len);
2565 }2603 }
...@@ -2571,7 +2609,7 @@ public:...@@ -2571,7 +2609,7 @@ public:
2571 explicit basic_regex(const basic_string<value_type, _ST, _SA>& __p,2609 explicit basic_regex(const basic_string<value_type, _ST, _SA>& __p,
2572 flag_type __f = regex_constants::ECMAScript)2610 flag_type __f = regex_constants::ECMAScript)
2573 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),2611 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
2574 __end_(0)2612 __end_(nullptr)
2575 {2613 {
2576 __init(__p.begin(), __p.end());2614 __init(__p.begin(), __p.end());
2577 }2615 }
...@@ -2581,7 +2619,7 @@ public:...@@ -2581,7 +2619,7 @@ public:
2581 basic_regex(_ForwardIterator __first, _ForwardIterator __last,2619 basic_regex(_ForwardIterator __first, _ForwardIterator __last,
2582 flag_type __f = regex_constants::ECMAScript)2620 flag_type __f = regex_constants::ECMAScript)
2583 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),2621 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
2584 __end_(0)2622 __end_(nullptr)
2585 {2623 {
2586 __init(__first, __last);2624 __init(__first, __last);
2587 }2625 }
...@@ -2590,7 +2628,7 @@ public:...@@ -2590,7 +2628,7 @@ public:
2590 basic_regex(initializer_list<value_type> __il,2628 basic_regex(initializer_list<value_type> __il,
2591 flag_type __f = regex_constants::ECMAScript)2629 flag_type __f = regex_constants::ECMAScript)
2592 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),2630 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
2593 __end_(0)2631 __end_(nullptr)
2594 {2632 {
2595 __init(__il.begin(), __il.end());2633 __init(__il.begin(), __il.end());
2596 }2634 }
...@@ -2707,6 +2745,12 @@ private:...@@ -2707,6 +2745,12 @@ private:
2707 _LIBCPP_INLINE_VISIBILITY2745 _LIBCPP_INLINE_VISIBILITY
2708 unsigned __loop_count() const {return __loop_count_;}2746 unsigned __loop_count() const {return __loop_count_;}
27092747
2748 _LIBCPP_INLINE_VISIBILITY
2749 bool __use_multiline() const
2750 {
2751 return __get_grammar(__flags_) == ECMAScript && (__flags_ & multiline);
2752 }
2753
2710 template <class _ForwardIterator>2754 template <class _ForwardIterator>
2711 void2755 void
2712 __init(_ForwardIterator __first, _ForwardIterator __last);2756 __init(_ForwardIterator __first, _ForwardIterator __last);
...@@ -4119,7 +4163,7 @@ basic_regex<_CharT, _Traits>::__parse_DUP_COUNT(_ForwardIterator __first,...@@ -4119,7 +4163,7 @@ basic_regex<_CharT, _Traits>::__parse_DUP_COUNT(_ForwardIterator __first,
4119 __first != __last && ( __val = __traits_.value(*__first, 10)) != -1;4163 __first != __last && ( __val = __traits_.value(*__first, 10)) != -1;
4120 ++__first)4164 ++__first)
4121 {4165 {
4122 if (__c >= std::numeric_limits<int>::max() / 10)4166 if (__c >= numeric_limits<int>::max() / 10)
4123 __throw_regex_error<regex_constants::error_badbrace>();4167 __throw_regex_error<regex_constants::error_badbrace>();
4124 __c *= 10;4168 __c *= 10;
4125 __c += __val;4169 __c += __val;
...@@ -4383,7 +4427,7 @@ basic_regex<_CharT, _Traits>::__parse_decimal_escape(_ForwardIterator __first,...@@ -4383,7 +4427,7 @@ basic_regex<_CharT, _Traits>::__parse_decimal_escape(_ForwardIterator __first,
4383 for (++__first;4427 for (++__first;
4384 __first != __last && '0' <= *__first && *__first <= '9'; ++__first)4428 __first != __last && '0' <= *__first && *__first <= '9'; ++__first)
4385 {4429 {
4386 if (__v >= std::numeric_limits<unsigned>::max() / 10)4430 if (__v >= numeric_limits<unsigned>::max() / 10)
4387 __throw_regex_error<regex_constants::error_backref>();4431 __throw_regex_error<regex_constants::error_backref>();
4388 __v = 10 * __v + *__first - '0';4432 __v = 10 * __v + *__first - '0';
4389 }4433 }
...@@ -4746,7 +4790,7 @@ template <class _CharT, class _Traits>...@@ -4746,7 +4790,7 @@ template <class _CharT, class _Traits>
4746void4790void
4747basic_regex<_CharT, _Traits>::__push_l_anchor()4791basic_regex<_CharT, _Traits>::__push_l_anchor()
4748{4792{
4749 __end_->first() = new __l_anchor<_CharT>(__end_->first());4793 __end_->first() = new __l_anchor_multiline<_CharT>(__use_multiline(), __end_->first());
4750 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());4794 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4751}4795}
47524796
...@@ -4754,7 +4798,7 @@ template <class _CharT, class _Traits>...@@ -4754,7 +4798,7 @@ template <class _CharT, class _Traits>
4754void4798void
4755basic_regex<_CharT, _Traits>::__push_r_anchor()4799basic_regex<_CharT, _Traits>::__push_r_anchor()
4756{4800{
4757 __end_->first() = new __r_anchor<_CharT>(__end_->first());4801 __end_->first() = new __r_anchor_multiline<_CharT>(__use_multiline(), __end_->first());
4758 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());4802 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4759}4803}
47604804
...@@ -4845,13 +4889,21 @@ basic_regex<_CharT, _Traits>::__push_lookahead(const basic_regex& __exp,...@@ -4845,13 +4889,21 @@ basic_regex<_CharT, _Traits>::__push_lookahead(const basic_regex& __exp,
4845 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());4889 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4846}4890}
48474891
4848typedef basic_regex<char> regex;
4849typedef basic_regex<wchar_t> wregex;
4850
4851// sub_match4892// sub_match
48524893
4894typedef sub_match<const char*> csub_match;
4895typedef sub_match<const wchar_t*> wcsub_match;
4896typedef sub_match<string::const_iterator> ssub_match;
4897typedef sub_match<wstring::const_iterator> wssub_match;
4898
4853template <class _BidirectionalIterator>4899template <class _BidirectionalIterator>
4854class _LIBCPP_TEMPLATE_VIS sub_match4900class
4901 _LIBCPP_TEMPLATE_VIS
4902 _LIBCPP_PREFERRED_NAME(csub_match)
4903 _LIBCPP_PREFERRED_NAME(wcsub_match)
4904 _LIBCPP_PREFERRED_NAME(ssub_match)
4905 _LIBCPP_PREFERRED_NAME(wssub_match)
4906 sub_match
4855 : public pair<_BidirectionalIterator, _BidirectionalIterator>4907 : public pair<_BidirectionalIterator, _BidirectionalIterator>
4856{4908{
4857public:4909public:
...@@ -4886,11 +4938,6 @@ public:...@@ -4886,11 +4938,6 @@ public:
4886 {return str().compare(__s);}4938 {return str().compare(__s);}
4887};4939};
48884940
4889typedef sub_match<const char*> csub_match;
4890typedef sub_match<const wchar_t*> wcsub_match;
4891typedef sub_match<string::const_iterator> ssub_match;
4892typedef sub_match<wstring::const_iterator> wssub_match;
4893
4894template <class _BiIter>4941template <class _BiIter>
4895inline _LIBCPP_INLINE_VISIBILITY4942inline _LIBCPP_INLINE_VISIBILITY
4896bool4943bool
...@@ -5273,8 +5320,19 @@ operator<<(basic_ostream<_CharT, _ST>& __os, const sub_match<_BiIter>& __m)...@@ -5273,8 +5320,19 @@ operator<<(basic_ostream<_CharT, _ST>& __os, const sub_match<_BiIter>& __m)
5273 return __os << __m.str();5320 return __os << __m.str();
5274}5321}
52755322
5323typedef match_results<const char*> cmatch;
5324typedef match_results<const wchar_t*> wcmatch;
5325typedef match_results<string::const_iterator> smatch;
5326typedef match_results<wstring::const_iterator> wsmatch;
5327
5276template <class _BidirectionalIterator, class _Allocator>5328template <class _BidirectionalIterator, class _Allocator>
5277class _LIBCPP_TEMPLATE_VIS match_results5329class
5330 _LIBCPP_TEMPLATE_VIS
5331 _LIBCPP_PREFERRED_NAME(cmatch)
5332 _LIBCPP_PREFERRED_NAME(wcmatch)
5333 _LIBCPP_PREFERRED_NAME(smatch)
5334 _LIBCPP_PREFERRED_NAME(wsmatch)
5335 match_results
5278{5336{
5279public:5337public:
5280 typedef _Allocator allocator_type;5338 typedef _Allocator allocator_type;
...@@ -5556,7 +5614,7 @@ match_results<_BidirectionalIterator, _Allocator>::format(_OutputIter __output_i...@@ -5556,7 +5614,7 @@ match_results<_BidirectionalIterator, _Allocator>::format(_OutputIter __output_i
5556 '0' <= __fmt_first[1] && __fmt_first[1] <= '9')5614 '0' <= __fmt_first[1] && __fmt_first[1] <= '9')
5557 {5615 {
5558 ++__fmt_first;5616 ++__fmt_first;
5559 if (__idx >= std::numeric_limits<size_t>::max() / 10)5617 if (__idx >= numeric_limits<size_t>::max() / 10)
5560 __throw_regex_error<regex_constants::error_escape>();5618 __throw_regex_error<regex_constants::error_escape>();
5561 __idx = 10 * __idx + *__fmt_first - '0';5619 __idx = 10 * __idx + *__fmt_first - '0';
5562 }5620 }
...@@ -5594,11 +5652,6 @@ match_results<_BidirectionalIterator, _Allocator>::swap(match_results& __m)...@@ -5594,11 +5652,6 @@ match_results<_BidirectionalIterator, _Allocator>::swap(match_results& __m)
5594 swap(__ready_, __m.__ready_);5652 swap(__ready_, __m.__ready_);
5595}5653}
55965654
5597typedef match_results<const char*> cmatch;
5598typedef match_results<const wchar_t*> wcmatch;
5599typedef match_results<string::const_iterator> smatch;
5600typedef match_results<wstring::const_iterator> wsmatch;
5601
5602template <class _BidirectionalIterator, class _Allocator>5655template <class _BidirectionalIterator, class _Allocator>
5603bool5656bool
5604operator==(const match_results<_BidirectionalIterator, _Allocator>& __x,5657operator==(const match_results<_BidirectionalIterator, _Allocator>& __x,
...@@ -6182,7 +6235,21 @@ regex_match(const basic_string<_CharT, _ST, _SA>& __s,...@@ -6182,7 +6235,21 @@ regex_match(const basic_string<_CharT, _ST, _SA>& __s,
6182template <class _BidirectionalIterator,6235template <class _BidirectionalIterator,
6183 class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type,6236 class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type,
6184 class _Traits = regex_traits<_CharT> >6237 class _Traits = regex_traits<_CharT> >
6185class _LIBCPP_TEMPLATE_VIS regex_iterator6238 class _LIBCPP_TEMPLATE_VIS regex_iterator;
6239
6240typedef regex_iterator<const char*> cregex_iterator;
6241typedef regex_iterator<const wchar_t*> wcregex_iterator;
6242typedef regex_iterator<string::const_iterator> sregex_iterator;
6243typedef regex_iterator<wstring::const_iterator> wsregex_iterator;
6244
6245template <class _BidirectionalIterator, class _CharT, class _Traits>
6246class
6247 _LIBCPP_TEMPLATE_VIS
6248 _LIBCPP_PREFERRED_NAME(cregex_iterator)
6249 _LIBCPP_PREFERRED_NAME(wcregex_iterator)
6250 _LIBCPP_PREFERRED_NAME(sregex_iterator)
6251 _LIBCPP_PREFERRED_NAME(wsregex_iterator)
6252 regex_iterator
6186{6253{
6187public:6254public:
6188 typedef basic_regex<_CharT, _Traits> regex_type;6255 typedef basic_regex<_CharT, _Traits> regex_type;
...@@ -6291,17 +6358,26 @@ regex_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++()...@@ -6291,17 +6358,26 @@ regex_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++()
6291 return *this;6358 return *this;
6292}6359}
62936360
6294typedef regex_iterator<const char*> cregex_iterator;
6295typedef regex_iterator<const wchar_t*> wcregex_iterator;
6296typedef regex_iterator<string::const_iterator> sregex_iterator;
6297typedef regex_iterator<wstring::const_iterator> wsregex_iterator;
6298
6299// regex_token_iterator6361// regex_token_iterator
63006362
6301template <class _BidirectionalIterator,6363template <class _BidirectionalIterator,
6302 class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type,6364 class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type,
6303 class _Traits = regex_traits<_CharT> >6365 class _Traits = regex_traits<_CharT> >
6304class _LIBCPP_TEMPLATE_VIS regex_token_iterator6366 class _LIBCPP_TEMPLATE_VIS regex_token_iterator;
6367
6368typedef regex_token_iterator<const char*> cregex_token_iterator;
6369typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator;
6370typedef regex_token_iterator<string::const_iterator> sregex_token_iterator;
6371typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
6372
6373template <class _BidirectionalIterator, class _CharT, class _Traits>
6374class
6375 _LIBCPP_TEMPLATE_VIS
6376 _LIBCPP_PREFERRED_NAME(cregex_token_iterator)
6377 _LIBCPP_PREFERRED_NAME(wcregex_token_iterator)
6378 _LIBCPP_PREFERRED_NAME(sregex_token_iterator)
6379 _LIBCPP_PREFERRED_NAME(wsregex_token_iterator)
6380 regex_token_iterator
6305{6381{
6306public:6382public:
6307 typedef basic_regex<_CharT, _Traits> regex_type;6383 typedef basic_regex<_CharT, _Traits> regex_type;
...@@ -6367,7 +6443,7 @@ public:...@@ -6367,7 +6443,7 @@ public:
6367 regex_constants::match_flag_type __m =6443 regex_constants::match_flag_type __m =
6368 regex_constants::match_default);6444 regex_constants::match_default);
6369#if _LIBCPP_STD_VER > 116445#if _LIBCPP_STD_VER > 11
6370 template <std::size_t _Np>6446 template <size_t _Np>
6371 regex_token_iterator(_BidirectionalIterator __a,6447 regex_token_iterator(_BidirectionalIterator __a,
6372 _BidirectionalIterator __b,6448 _BidirectionalIterator __b,
6373 const regex_type&& __re,6449 const regex_type&& __re,
...@@ -6579,11 +6655,6 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++()...@@ -6579,11 +6655,6 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++()
6579 return *this;6655 return *this;
6580}6656}
65816657
6582typedef regex_token_iterator<const char*> cregex_token_iterator;
6583typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator;
6584typedef regex_token_iterator<string::const_iterator> sregex_token_iterator;
6585typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
6586
6587// regex_replace6658// regex_replace
65886659
6589template <class _OutputIterator, class _BidirectionalIterator,6660template <class _OutputIterator, class _BidirectionalIterator,
lib/libcxx/include/semaphore+7-2
...@@ -46,9 +46,9 @@ using binary_semaphore = counting_semaphore<1>;...@@ -46,9 +46,9 @@ using binary_semaphore = counting_semaphore<1>;
46*/46*/
4747
48#include <__config>48#include <__config>
49#include <__availability>
49#include <__threading_support>50#include <__threading_support>
50#include <atomic>51#include <atomic>
51#include <cassert>
5252
53#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)53#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
54#pragma GCC system_header54#pragma GCC system_header
...@@ -58,6 +58,9 @@ using binary_semaphore = counting_semaphore<1>;...@@ -58,6 +58,9 @@ using binary_semaphore = counting_semaphore<1>;
58# error <semaphore> is not supported on this single threaded system58# error <semaphore> is not supported on this single threaded system
59#endif59#endif
6060
61_LIBCPP_PUSH_MACROS
62#include <__undef_macros>
63
61#if _LIBCPP_STD_VER >= 1464#if _LIBCPP_STD_VER >= 14
6265
63_LIBCPP_BEGIN_NAMESPACE_STD66_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -68,7 +71,7 @@ __atomic_semaphore_base is the general-case implementation, to be used for...@@ -68,7 +71,7 @@ __atomic_semaphore_base is the general-case implementation, to be used for
68user-requested least-max values that exceed the OS implementation support71user-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.72(incl. when the OS has no support of its own) and for binary semaphores.
7073
71It is a typical Dijsktra semaphore algorithm over atomics, wait and notify74It is a typical Dijkstra semaphore algorithm over atomics, wait and notify
72functions. It avoids contention against users' own use of those facilities.75functions. It avoids contention against users' own use of those facilities.
7376
74*/77*/
...@@ -232,4 +235,6 @@ _LIBCPP_END_NAMESPACE_STD...@@ -232,4 +235,6 @@ _LIBCPP_END_NAMESPACE_STD
232235
233#endif // _LIBCPP_STD_VER >= 14236#endif // _LIBCPP_STD_VER >= 14
234237
238_LIBCPP_POP_MACROS
239
235#endif //_LIBCPP_SEMAPHORE240#endif //_LIBCPP_SEMAPHORE
lib/libcxx/include/shared_mutex+1
...@@ -123,6 +123,7 @@ template <class Mutex>...@@ -123,6 +123,7 @@ template <class Mutex>
123*/123*/
124124
125#include <__config>125#include <__config>
126#include <__availability>
126#include <version>127#include <version>
127128
128_LIBCPP_PUSH_MACROS129_LIBCPP_PUSH_MACROS
lib/libcxx/include/span+6-1
...@@ -132,11 +132,14 @@ template<class Container>...@@ -132,11 +132,14 @@ template<class Container>
132#pragma GCC system_header132#pragma GCC system_header
133#endif133#endif
134134
135_LIBCPP_PUSH_MACROS
136#include <__undef_macros>
137
135_LIBCPP_BEGIN_NAMESPACE_STD138_LIBCPP_BEGIN_NAMESPACE_STD
136139
137#if _LIBCPP_STD_VER > 17140#if _LIBCPP_STD_VER > 17
138141
139inline constexpr size_t dynamic_extent = (numeric_limits<size_t>::max)();142inline constexpr size_t dynamic_extent = numeric_limits<size_t>::max();
140template <typename _Tp, size_t _Extent = dynamic_extent> class span;143template <typename _Tp, size_t _Extent = dynamic_extent> class span;
141144
142145
...@@ -546,4 +549,6 @@ template<class _Container>...@@ -546,4 +549,6 @@ template<class _Container>
546549
547_LIBCPP_END_NAMESPACE_STD550_LIBCPP_END_NAMESPACE_STD
548551
552_LIBCPP_POP_MACROS
553
549#endif // _LIBCPP_SPAN554#endif // _LIBCPP_SPAN
lib/libcxx/include/sstream+148-283
...@@ -208,17 +208,23 @@ private:...@@ -208,17 +208,23 @@ private:
208208
209public:209public:
210 // 27.8.1.1 Constructors:210 // 27.8.1.1 Constructors:
211 inline _LIBCPP_INLINE_VISIBILITY211 _LIBCPP_INLINE_VISIBILITY
212 explicit basic_stringbuf(ios_base::openmode __wch = ios_base::in | ios_base::out);212 explicit basic_stringbuf(ios_base::openmode __wch = ios_base::in | ios_base::out)
213 inline _LIBCPP_INLINE_VISIBILITY213 : __hm_(nullptr), __mode_(__wch)
214 { }
215
216 _LIBCPP_INLINE_VISIBILITY
214 explicit basic_stringbuf(const string_type& __s,217 explicit basic_stringbuf(const string_type& __s,
215 ios_base::openmode __wch = ios_base::in | ios_base::out);218 ios_base::openmode __wch = ios_base::in | ios_base::out)
216#ifndef _LIBCPP_CXX03_LANG219 : __str_(__s.get_allocator()), __hm_(nullptr), __mode_(__wch)
220 {
221 str(__s);
222 }
223
217 basic_stringbuf(basic_stringbuf&& __rhs);224 basic_stringbuf(basic_stringbuf&& __rhs);
218225
219 // 27.8.1.2 Assign and swap:226 // 27.8.1.2 Assign and swap:
220 basic_stringbuf& operator=(basic_stringbuf&& __rhs);227 basic_stringbuf& operator=(basic_stringbuf&& __rhs);
221#endif
222 void swap(basic_stringbuf& __rhs);228 void swap(basic_stringbuf& __rhs);
223229
224 // 27.8.1.3 Get and set:230 // 27.8.1.3 Get and set:
...@@ -232,30 +238,13 @@ protected:...@@ -232,30 +238,13 @@ protected:
232 virtual int_type overflow (int_type __c = traits_type::eof());238 virtual int_type overflow (int_type __c = traits_type::eof());
233 virtual pos_type seekoff(off_type __off, ios_base::seekdir __way,239 virtual pos_type seekoff(off_type __off, ios_base::seekdir __way,
234 ios_base::openmode __wch = ios_base::in | ios_base::out);240 ios_base::openmode __wch = ios_base::in | ios_base::out);
235 inline _LIBCPP_INLINE_VISIBILITY241 _LIBCPP_INLINE_VISIBILITY
236 virtual pos_type seekpos(pos_type __sp,242 virtual pos_type seekpos(pos_type __sp,
237 ios_base::openmode __wch = ios_base::in | ios_base::out);243 ios_base::openmode __wch = ios_base::in | ios_base::out) {
244 return seekoff(__sp, ios_base::beg, __wch);
245 }
238};246};
239247
240template <class _CharT, class _Traits, class _Allocator>
241basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(ios_base::openmode __wch)
242 : __hm_(0),
243 __mode_(__wch)
244{
245}
246
247template <class _CharT, class _Traits, class _Allocator>
248basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(const string_type& __s,
249 ios_base::openmode __wch)
250 : __str_(__s.get_allocator()),
251 __hm_(0),
252 __mode_(__wch)
253{
254 str(__s);
255}
256
257#ifndef _LIBCPP_CXX03_LANG
258
259template <class _CharT, class _Traits, class _Allocator>248template <class _CharT, class _Traits, class _Allocator>
260basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(basic_stringbuf&& __rhs)249basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(basic_stringbuf&& __rhs)
261 : __mode_(__rhs.__mode_)250 : __mode_(__rhs.__mode_)
...@@ -345,8 +334,6 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::operator=(basic_stringbuf&& __rhs)...@@ -345,8 +334,6 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::operator=(basic_stringbuf&& __rhs)
345 return *this;334 return *this;
346}335}
347336
348#endif // _LIBCPP_CXX03_LANG
349
350template <class _CharT, class _Traits, class _Allocator>337template <class _CharT, class _Traits, class _Allocator>
351void338void
352basic_stringbuf<_CharT, _Traits, _Allocator>::swap(basic_stringbuf& __rhs)339basic_stringbuf<_CharT, _Traits, _Allocator>::swap(basic_stringbuf& __rhs)
...@@ -453,7 +440,7 @@ void...@@ -453,7 +440,7 @@ void
453basic_stringbuf<_CharT, _Traits, _Allocator>::str(const string_type& __s)440basic_stringbuf<_CharT, _Traits, _Allocator>::str(const string_type& __s)
454{441{
455 __str_ = __s;442 __str_ = __s;
456 __hm_ = 0;443 __hm_ = nullptr;
457 if (__mode_ & ios_base::in)444 if (__mode_ & ios_base::in)
458 {445 {
459 __hm_ = const_cast<char_type*>(__str_.data()) + __str_.size();446 __hm_ = const_cast<char_type*>(__str_.data()) + __str_.size();
...@@ -600,9 +587,9 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::seekoff(off_type __off,...@@ -600,9 +587,9 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::seekoff(off_type __off,
600 return pos_type(-1);587 return pos_type(-1);
601 if (__noff != 0)588 if (__noff != 0)
602 {589 {
603 if ((__wch & ios_base::in) && this->gptr() == 0)590 if ((__wch & ios_base::in) && this->gptr() == nullptr)
604 return pos_type(-1);591 return pos_type(-1);
605 if ((__wch & ios_base::out) && this->pptr() == 0)592 if ((__wch & ios_base::out) && this->pptr() == nullptr)
606 return pos_type(-1);593 return pos_type(-1);
607 }594 }
608 if (__wch & ios_base::in)595 if (__wch & ios_base::in)
...@@ -615,14 +602,6 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::seekoff(off_type __off,...@@ -615,14 +602,6 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::seekoff(off_type __off,
615 return pos_type(__noff);602 return pos_type(__noff);
616}603}
617604
618template <class _CharT, class _Traits, class _Allocator>
619typename basic_stringbuf<_CharT, _Traits, _Allocator>::pos_type
620basic_stringbuf<_CharT, _Traits, _Allocator>::seekpos(pos_type __sp,
621 ios_base::openmode __wch)
622{
623 return seekoff(__sp, ios_base::beg, __wch);
624}
625
626// basic_istringstream605// basic_istringstream
627606
628template <class _CharT, class _Traits, class _Allocator>607template <class _CharT, class _Traits, class _Allocator>
...@@ -644,73 +623,53 @@ private:...@@ -644,73 +623,53 @@ private:
644623
645public:624public:
646 // 27.8.2.1 Constructors:625 // 27.8.2.1 Constructors:
647 inline _LIBCPP_INLINE_VISIBILITY626 _LIBCPP_INLINE_VISIBILITY
648 explicit basic_istringstream(ios_base::openmode __wch = ios_base::in);627 explicit basic_istringstream(ios_base::openmode __wch = ios_base::in)
649 inline _LIBCPP_INLINE_VISIBILITY628 : basic_istream<_CharT, _Traits>(&__sb_)
629 , __sb_(__wch | ios_base::in)
630 { }
631 _LIBCPP_INLINE_VISIBILITY
650 explicit basic_istringstream(const string_type& __s,632 explicit basic_istringstream(const string_type& __s,
651 ios_base::openmode __wch = ios_base::in);633 ios_base::openmode __wch = ios_base::in)
652#ifndef _LIBCPP_CXX03_LANG634 : basic_istream<_CharT, _Traits>(&__sb_)
653 inline _LIBCPP_INLINE_VISIBILITY635 , __sb_(__s, __wch | ios_base::in)
654 basic_istringstream(basic_istringstream&& __rhs);636 { }
637
638 _LIBCPP_INLINE_VISIBILITY
639 basic_istringstream(basic_istringstream&& __rhs)
640 : basic_istream<_CharT, _Traits>(_VSTD::move(__rhs))
641 , __sb_(_VSTD::move(__rhs.__sb_))
642 {
643 basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
644 }
655645
656 // 27.8.2.2 Assign and swap:646 // 27.8.2.2 Assign and swap:
657 basic_istringstream& operator=(basic_istringstream&& __rhs);647 basic_istringstream& operator=(basic_istringstream&& __rhs) {
658#endif // _LIBCPP_CXX03_LANG648 basic_istream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
659 inline _LIBCPP_INLINE_VISIBILITY649 __sb_ = _VSTD::move(__rhs.__sb_);
660 void swap(basic_istringstream& __rhs);650 return *this;
651 }
652 _LIBCPP_INLINE_VISIBILITY
653 void swap(basic_istringstream& __rhs) {
654 basic_istream<char_type, traits_type>::swap(__rhs);
655 __sb_.swap(__rhs.__sb_);
656 }
661657
662 // 27.8.2.3 Members:658 // 27.8.2.3 Members:
663 inline _LIBCPP_INLINE_VISIBILITY659 _LIBCPP_INLINE_VISIBILITY
664 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;660 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const {
665 inline _LIBCPP_INLINE_VISIBILITY661 return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
666 string_type str() const;662 }
667 inline _LIBCPP_INLINE_VISIBILITY663 _LIBCPP_INLINE_VISIBILITY
668 void str(const string_type& __s);664 string_type str() const {
665 return __sb_.str();
666 }
667 _LIBCPP_INLINE_VISIBILITY
668 void str(const string_type& __s) {
669 __sb_.str(__s);
670 }
669};671};
670672
671template <class _CharT, class _Traits, class _Allocator>
672basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(ios_base::openmode __wch)
673 : basic_istream<_CharT, _Traits>(&__sb_),
674 __sb_(__wch | ios_base::in)
675{
676}
677
678template <class _CharT, class _Traits, class _Allocator>
679basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(const string_type& __s,
680 ios_base::openmode __wch)
681 : basic_istream<_CharT, _Traits>(&__sb_),
682 __sb_(__s, __wch | ios_base::in)
683{
684}
685
686#ifndef _LIBCPP_CXX03_LANG
687
688template <class _CharT, class _Traits, class _Allocator>
689basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(basic_istringstream&& __rhs)
690 : basic_istream<_CharT, _Traits>(_VSTD::move(__rhs)),
691 __sb_(_VSTD::move(__rhs.__sb_))
692{
693 basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
694}
695
696template <class _CharT, class _Traits, class _Allocator>
697basic_istringstream<_CharT, _Traits, _Allocator>&
698basic_istringstream<_CharT, _Traits, _Allocator>::operator=(basic_istringstream&& __rhs)
699{
700 basic_istream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
701 __sb_ = _VSTD::move(__rhs.__sb_);
702 return *this;
703}
704
705#endif // _LIBCPP_CXX03_LANG
706
707template <class _CharT, class _Traits, class _Allocator>
708void basic_istringstream<_CharT, _Traits, _Allocator>::swap(basic_istringstream& __rhs)
709{
710 basic_istream<char_type, traits_type>::swap(__rhs);
711 __sb_.swap(__rhs.__sb_);
712}
713
714template <class _CharT, class _Traits, class _Allocator>673template <class _CharT, class _Traits, class _Allocator>
715inline _LIBCPP_INLINE_VISIBILITY674inline _LIBCPP_INLINE_VISIBILITY
716void675void
...@@ -720,26 +679,6 @@ swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x,...@@ -720,26 +679,6 @@ swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x,
720 __x.swap(__y);679 __x.swap(__y);
721}680}
722681
723template <class _CharT, class _Traits, class _Allocator>
724basic_stringbuf<_CharT, _Traits, _Allocator>*
725basic_istringstream<_CharT, _Traits, _Allocator>::rdbuf() const
726{
727 return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
728}
729
730template <class _CharT, class _Traits, class _Allocator>
731basic_string<_CharT, _Traits, _Allocator>
732basic_istringstream<_CharT, _Traits, _Allocator>::str() const
733{
734 return __sb_.str();
735}
736
737template <class _CharT, class _Traits, class _Allocator>
738void basic_istringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s)
739{
740 __sb_.str(__s);
741}
742
743// basic_ostringstream682// basic_ostringstream
744683
745template <class _CharT, class _Traits, class _Allocator>684template <class _CharT, class _Traits, class _Allocator>
...@@ -761,74 +700,55 @@ private:...@@ -761,74 +700,55 @@ private:
761700
762public:701public:
763 // 27.8.2.1 Constructors:702 // 27.8.2.1 Constructors:
764 inline _LIBCPP_INLINE_VISIBILITY703 _LIBCPP_INLINE_VISIBILITY
765 explicit basic_ostringstream(ios_base::openmode __wch = ios_base::out);704 explicit basic_ostringstream(ios_base::openmode __wch = ios_base::out)
766 inline _LIBCPP_INLINE_VISIBILITY705 : basic_ostream<_CharT, _Traits>(&__sb_)
706 , __sb_(__wch | ios_base::out)
707 { }
708
709 _LIBCPP_INLINE_VISIBILITY
767 explicit basic_ostringstream(const string_type& __s,710 explicit basic_ostringstream(const string_type& __s,
768 ios_base::openmode __wch = ios_base::out);711 ios_base::openmode __wch = ios_base::out)
769#ifndef _LIBCPP_CXX03_LANG712 : basic_ostream<_CharT, _Traits>(&__sb_)
770 inline _LIBCPP_INLINE_VISIBILITY713 , __sb_(__s, __wch | ios_base::out)
771 basic_ostringstream(basic_ostringstream&& __rhs);714 { }
715
716 _LIBCPP_INLINE_VISIBILITY
717 basic_ostringstream(basic_ostringstream&& __rhs)
718 : basic_ostream<_CharT, _Traits>(_VSTD::move(__rhs))
719 , __sb_(_VSTD::move(__rhs.__sb_))
720 {
721 basic_ostream<_CharT, _Traits>::set_rdbuf(&__sb_);
722 }
772723
773 // 27.8.2.2 Assign and swap:724 // 27.8.2.2 Assign and swap:
774 basic_ostringstream& operator=(basic_ostringstream&& __rhs);725 basic_ostringstream& operator=(basic_ostringstream&& __rhs) {
775#endif // _LIBCPP_CXX03_LANG726 basic_ostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
776 inline _LIBCPP_INLINE_VISIBILITY727 __sb_ = _VSTD::move(__rhs.__sb_);
777 void swap(basic_ostringstream& __rhs);728 return *this;
729 }
730
731 _LIBCPP_INLINE_VISIBILITY
732 void swap(basic_ostringstream& __rhs) {
733 basic_ostream<char_type, traits_type>::swap(__rhs);
734 __sb_.swap(__rhs.__sb_);
735 }
778736
779 // 27.8.2.3 Members:737 // 27.8.2.3 Members:
780 inline _LIBCPP_INLINE_VISIBILITY738 _LIBCPP_INLINE_VISIBILITY
781 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;739 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const {
782 inline _LIBCPP_INLINE_VISIBILITY740 return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
783 string_type str() const;741 }
784 inline _LIBCPP_INLINE_VISIBILITY742 _LIBCPP_INLINE_VISIBILITY
785 void str(const string_type& __s);743 string_type str() const {
744 return __sb_.str();
745 }
746 _LIBCPP_INLINE_VISIBILITY
747 void str(const string_type& __s) {
748 __sb_.str(__s);
749 }
786};750};
787751
788template <class _CharT, class _Traits, class _Allocator>
789basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(ios_base::openmode __wch)
790 : basic_ostream<_CharT, _Traits>(&__sb_),
791 __sb_(__wch | ios_base::out)
792{
793}
794
795template <class _CharT, class _Traits, class _Allocator>
796basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(const string_type& __s,
797 ios_base::openmode __wch)
798 : basic_ostream<_CharT, _Traits>(&__sb_),
799 __sb_(__s, __wch | ios_base::out)
800{
801}
802
803#ifndef _LIBCPP_CXX03_LANG
804
805template <class _CharT, class _Traits, class _Allocator>
806basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(basic_ostringstream&& __rhs)
807 : basic_ostream<_CharT, _Traits>(_VSTD::move(__rhs)),
808 __sb_(_VSTD::move(__rhs.__sb_))
809{
810 basic_ostream<_CharT, _Traits>::set_rdbuf(&__sb_);
811}
812
813template <class _CharT, class _Traits, class _Allocator>
814basic_ostringstream<_CharT, _Traits, _Allocator>&
815basic_ostringstream<_CharT, _Traits, _Allocator>::operator=(basic_ostringstream&& __rhs)
816{
817 basic_ostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
818 __sb_ = _VSTD::move(__rhs.__sb_);
819 return *this;
820}
821
822#endif // _LIBCPP_CXX03_LANG
823
824template <class _CharT, class _Traits, class _Allocator>
825void
826basic_ostringstream<_CharT, _Traits, _Allocator>::swap(basic_ostringstream& __rhs)
827{
828 basic_ostream<char_type, traits_type>::swap(__rhs);
829 __sb_.swap(__rhs.__sb_);
830}
831
832template <class _CharT, class _Traits, class _Allocator>752template <class _CharT, class _Traits, class _Allocator>
833inline _LIBCPP_INLINE_VISIBILITY753inline _LIBCPP_INLINE_VISIBILITY
834void754void
...@@ -838,27 +758,6 @@ swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x,...@@ -838,27 +758,6 @@ swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x,
838 __x.swap(__y);758 __x.swap(__y);
839}759}
840760
841template <class _CharT, class _Traits, class _Allocator>
842basic_stringbuf<_CharT, _Traits, _Allocator>*
843basic_ostringstream<_CharT, _Traits, _Allocator>::rdbuf() const
844{
845 return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
846}
847
848template <class _CharT, class _Traits, class _Allocator>
849basic_string<_CharT, _Traits, _Allocator>
850basic_ostringstream<_CharT, _Traits, _Allocator>::str() const
851{
852 return __sb_.str();
853}
854
855template <class _CharT, class _Traits, class _Allocator>
856void
857basic_ostringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s)
858{
859 __sb_.str(__s);
860}
861
862// basic_stringstream761// basic_stringstream
863762
864template <class _CharT, class _Traits, class _Allocator>763template <class _CharT, class _Traits, class _Allocator>
...@@ -880,74 +779,54 @@ private:...@@ -880,74 +779,54 @@ private:
880779
881public:780public:
882 // 27.8.2.1 Constructors:781 // 27.8.2.1 Constructors:
883 inline _LIBCPP_INLINE_VISIBILITY782 _LIBCPP_INLINE_VISIBILITY
884 explicit basic_stringstream(ios_base::openmode __wch = ios_base::in | ios_base::out);783 explicit basic_stringstream(ios_base::openmode __wch = ios_base::in | ios_base::out)
885 inline _LIBCPP_INLINE_VISIBILITY784 : basic_iostream<_CharT, _Traits>(&__sb_)
785 , __sb_(__wch)
786 { }
787
788 _LIBCPP_INLINE_VISIBILITY
886 explicit basic_stringstream(const string_type& __s,789 explicit basic_stringstream(const string_type& __s,
887 ios_base::openmode __wch = ios_base::in | ios_base::out);790 ios_base::openmode __wch = ios_base::in | ios_base::out)
888#ifndef _LIBCPP_CXX03_LANG791 : basic_iostream<_CharT, _Traits>(&__sb_)
889 inline _LIBCPP_INLINE_VISIBILITY792 , __sb_(__s, __wch)
890 basic_stringstream(basic_stringstream&& __rhs);793 { }
794
795 _LIBCPP_INLINE_VISIBILITY
796 basic_stringstream(basic_stringstream&& __rhs)
797 : basic_iostream<_CharT, _Traits>(_VSTD::move(__rhs))
798 , __sb_(_VSTD::move(__rhs.__sb_))
799 {
800 basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
801 }
891802
892 // 27.8.2.2 Assign and swap:803 // 27.8.2.2 Assign and swap:
893 basic_stringstream& operator=(basic_stringstream&& __rhs);804 basic_stringstream& operator=(basic_stringstream&& __rhs) {
894#endif // _LIBCPP_CXX03_LANG805 basic_iostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
895 inline _LIBCPP_INLINE_VISIBILITY806 __sb_ = _VSTD::move(__rhs.__sb_);
896 void swap(basic_stringstream& __rhs);807 return *this;
808 }
809 _LIBCPP_INLINE_VISIBILITY
810 void swap(basic_stringstream& __rhs) {
811 basic_iostream<char_type, traits_type>::swap(__rhs);
812 __sb_.swap(__rhs.__sb_);
813 }
897814
898 // 27.8.2.3 Members:815 // 27.8.2.3 Members:
899 inline _LIBCPP_INLINE_VISIBILITY816 _LIBCPP_INLINE_VISIBILITY
900 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;817 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const {
901 inline _LIBCPP_INLINE_VISIBILITY818 return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
902 string_type str() const;819 }
903 inline _LIBCPP_INLINE_VISIBILITY820 _LIBCPP_INLINE_VISIBILITY
904 void str(const string_type& __s);821 string_type str() const {
822 return __sb_.str();
823 }
824 _LIBCPP_INLINE_VISIBILITY
825 void str(const string_type& __s) {
826 __sb_.str(__s);
827 }
905};828};
906829
907template <class _CharT, class _Traits, class _Allocator>
908basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(ios_base::openmode __wch)
909 : basic_iostream<_CharT, _Traits>(&__sb_),
910 __sb_(__wch)
911{
912}
913
914template <class _CharT, class _Traits, class _Allocator>
915basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(const string_type& __s,
916 ios_base::openmode __wch)
917 : basic_iostream<_CharT, _Traits>(&__sb_),
918 __sb_(__s, __wch)
919{
920}
921
922#ifndef _LIBCPP_CXX03_LANG
923
924template <class _CharT, class _Traits, class _Allocator>
925basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(basic_stringstream&& __rhs)
926 : basic_iostream<_CharT, _Traits>(_VSTD::move(__rhs)),
927 __sb_(_VSTD::move(__rhs.__sb_))
928{
929 basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
930}
931
932template <class _CharT, class _Traits, class _Allocator>
933basic_stringstream<_CharT, _Traits, _Allocator>&
934basic_stringstream<_CharT, _Traits, _Allocator>::operator=(basic_stringstream&& __rhs)
935{
936 basic_iostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
937 __sb_ = _VSTD::move(__rhs.__sb_);
938 return *this;
939}
940
941#endif // _LIBCPP_CXX03_LANG
942
943template <class _CharT, class _Traits, class _Allocator>
944void
945basic_stringstream<_CharT, _Traits, _Allocator>::swap(basic_stringstream& __rhs)
946{
947 basic_iostream<char_type, traits_type>::swap(__rhs);
948 __sb_.swap(__rhs.__sb_);
949}
950
951template <class _CharT, class _Traits, class _Allocator>830template <class _CharT, class _Traits, class _Allocator>
952inline _LIBCPP_INLINE_VISIBILITY831inline _LIBCPP_INLINE_VISIBILITY
953void832void
...@@ -957,26 +836,12 @@ swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x,...@@ -957,26 +836,12 @@ swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x,
957 __x.swap(__y);836 __x.swap(__y);
958}837}
959838
960template <class _CharT, class _Traits, class _Allocator>839#if defined(_LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1)
961basic_stringbuf<_CharT, _Traits, _Allocator>*840_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringbuf<char>)
962basic_stringstream<_CharT, _Traits, _Allocator>::rdbuf() const841_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringstream<char>)
963{842_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostringstream<char>)
964 return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);843_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istringstream<char>)
965}844#endif
966
967template <class _CharT, class _Traits, class _Allocator>
968basic_string<_CharT, _Traits, _Allocator>
969basic_stringstream<_CharT, _Traits, _Allocator>::str() const
970{
971 return __sb_.str();
972}
973
974template <class _CharT, class _Traits, class _Allocator>
975void
976basic_stringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s)
977{
978 __sb_.str(__s);
979}
980845
981_LIBCPP_END_NAMESPACE_STD846_LIBCPP_END_NAMESPACE_STD
982847
lib/libcxx/include/stdexcept+1-3
...@@ -42,11 +42,9 @@ public:...@@ -42,11 +42,9 @@ public:
42*/42*/
4343
44#include <__config>44#include <__config>
45#include <cstdlib>
45#include <exception>46#include <exception>
46#include <iosfwd> // for string forward decl47#include <iosfwd> // for string forward decl
47#ifdef _LIBCPP_NO_EXCEPTIONS
48#include <cstdlib>
49#endif
5048
51#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)49#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
52#pragma GCC system_header50#pragma GCC system_header
lib/libcxx/include/streambuf+6-8
...@@ -308,12 +308,12 @@ basic_streambuf<_CharT, _Traits>::~basic_streambuf()...@@ -308,12 +308,12 @@ basic_streambuf<_CharT, _Traits>::~basic_streambuf()
308308
309template <class _CharT, class _Traits>309template <class _CharT, class _Traits>
310basic_streambuf<_CharT, _Traits>::basic_streambuf()310basic_streambuf<_CharT, _Traits>::basic_streambuf()
311 : __binp_(0),311 : __binp_(nullptr),
312 __ninp_(0),312 __ninp_(nullptr),
313 __einp_(0),313 __einp_(nullptr),
314 __bout_(0),314 __bout_(nullptr),
315 __nout_(0),315 __nout_(nullptr),
316 __eout_(0)316 __eout_(nullptr)
317{317{
318}318}
319319
...@@ -485,13 +485,11 @@ basic_streambuf<_CharT, _Traits>::overflow(int_type)...@@ -485,13 +485,11 @@ basic_streambuf<_CharT, _Traits>::overflow(int_type)
485 return traits_type::eof();485 return traits_type::eof();
486}486}
487487
488#ifndef _LIBCPP_DO_NOT_ASSUME_STREAMS_EXPLICIT_INSTANTIATION_IN_DYLIB
489_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<char>)488_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<char>)
490_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<wchar_t>)489_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<wchar_t>)
491490
492_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<char>)491_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<char>)
493_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<wchar_t>)492_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<wchar_t>)
494#endif
495493
496_LIBCPP_END_NAMESPACE_STD494_LIBCPP_END_NAMESPACE_STD
497495
lib/libcxx/include/string+174-138
...@@ -153,7 +153,8 @@ public:...@@ -153,7 +153,8 @@ public:
153 void resize(size_type n, value_type c);153 void resize(size_type n, value_type c);
154 void resize(size_type n);154 void resize(size_type n);
155155
156 void reserve(size_type res_arg = 0);156 void reserve(size_type res_arg);
157 void reserve(); // deprecated in C++20
157 void shrink_to_fit();158 void shrink_to_fit();
158 void clear() noexcept;159 void clear() noexcept;
159 bool empty() const noexcept;160 bool empty() const noexcept;
...@@ -448,15 +449,15 @@ typedef basic_string<wchar_t> wstring;...@@ -448,15 +449,15 @@ typedef basic_string<wchar_t> wstring;
448typedef basic_string<char16_t> u16string;449typedef basic_string<char16_t> u16string;
449typedef basic_string<char32_t> u32string;450typedef basic_string<char32_t> u32string;
450451
451int stoi (const string& str, size_t* idx = 0, int base = 10);452int stoi (const string& str, size_t* idx = nullptr, int base = 10);
452long stol (const string& str, size_t* idx = 0, int base = 10);453long stol (const string& str, size_t* idx = nullptr, int base = 10);
453unsigned long stoul (const string& str, size_t* idx = 0, int base = 10);454unsigned long stoul (const string& str, size_t* idx = nullptr, int base = 10);
454long long stoll (const string& str, size_t* idx = 0, int base = 10);455long long stoll (const string& str, size_t* idx = nullptr, int base = 10);
455unsigned long long stoull(const string& str, size_t* idx = 0, int base = 10);456unsigned long long stoull(const string& str, size_t* idx = nullptr, int base = 10);
456457
457float stof (const string& str, size_t* idx = 0);458float stof (const string& str, size_t* idx = nullptr);
458double stod (const string& str, size_t* idx = 0);459double stod (const string& str, size_t* idx = nullptr);
459long double stold(const string& str, size_t* idx = 0);460long double stold(const string& str, size_t* idx = nullptr);
460461
461string to_string(int val);462string to_string(int val);
462string to_string(unsigned val);463string to_string(unsigned val);
...@@ -468,15 +469,15 @@ string to_string(float val);...@@ -468,15 +469,15 @@ string to_string(float val);
468string to_string(double val);469string to_string(double val);
469string to_string(long double val);470string to_string(long double val);
470471
471int stoi (const wstring& str, size_t* idx = 0, int base = 10);472int stoi (const wstring& str, size_t* idx = nullptr, int base = 10);
472long stol (const wstring& str, size_t* idx = 0, int base = 10);473long stol (const wstring& str, size_t* idx = nullptr, int base = 10);
473unsigned long stoul (const wstring& str, size_t* idx = 0, int base = 10);474unsigned long stoul (const wstring& str, size_t* idx = nullptr, int base = 10);
474long long stoll (const wstring& str, size_t* idx = 0, int base = 10);475long long stoll (const wstring& str, size_t* idx = nullptr, int base = 10);
475unsigned long long stoull(const wstring& str, size_t* idx = 0, int base = 10);476unsigned long long stoull(const wstring& str, size_t* idx = nullptr, int base = 10);
476477
477float stof (const wstring& str, size_t* idx = 0);478float stof (const wstring& str, size_t* idx = nullptr);
478double stod (const wstring& str, size_t* idx = 0);479double stod (const wstring& str, size_t* idx = nullptr);
479long double stold(const wstring& str, size_t* idx = 0);480long double stold(const wstring& str, size_t* idx = nullptr);
480481
481wstring to_wstring(int val);482wstring to_wstring(int val);
482wstring to_wstring(unsigned val);483wstring to_wstring(unsigned val);
...@@ -665,8 +666,26 @@ struct __padding<_CharT, 1>...@@ -665,8 +666,26 @@ struct __padding<_CharT, 1>
665666
666#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT667#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
667668
669#ifndef _LIBCPP_NO_HAS_CHAR8_T
670typedef basic_string<char8_t> u8string;
671#endif
672
673#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
674typedef basic_string<char16_t> u16string;
675typedef basic_string<char32_t> u32string;
676#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
677
668template<class _CharT, class _Traits, class _Allocator>678template<class _CharT, class _Traits, class _Allocator>
669class _LIBCPP_TEMPLATE_VIS basic_string679class
680 _LIBCPP_TEMPLATE_VIS
681#ifndef _LIBCPP_NO_HAS_CHAR8_T
682 _LIBCPP_PREFERRED_NAME(u8string)
683#endif
684#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
685 _LIBCPP_PREFERRED_NAME(u16string)
686 _LIBCPP_PREFERRED_NAME(u32string)
687#endif
688 basic_string
670 : private __basic_string_common<true>689 : private __basic_string_common<true>
671{690{
672public:691public:
...@@ -816,7 +835,7 @@ public:...@@ -816,7 +835,7 @@ public:
816 basic_string(const _CharT* __s) : __r_(__default_init_tag(), __default_init_tag()) {835 basic_string(const _CharT* __s) : __r_(__default_init_tag(), __default_init_tag()) {
817 _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected nullptr");836 _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected nullptr");
818 __init(__s, traits_type::length(__s));837 __init(__s, traits_type::length(__s));
819# if _LIBCPP_DEBUG_LEVEL >= 2838# if _LIBCPP_DEBUG_LEVEL == 2
820 __get_db()->__insert_c(this);839 __get_db()->__insert_c(this);
821# endif840# endif
822 }841 }
...@@ -890,7 +909,7 @@ public:...@@ -890,7 +909,7 @@ public:
890 _LIBCPP_INLINE_VISIBILITY basic_string& operator=(const value_type* __s) {return assign(__s);}909 _LIBCPP_INLINE_VISIBILITY basic_string& operator=(const value_type* __s) {return assign(__s);}
891 basic_string& operator=(value_type __c);910 basic_string& operator=(value_type __c);
892911
893#if _LIBCPP_DEBUG_LEVEL >= 2912#if _LIBCPP_DEBUG_LEVEL == 2
894 _LIBCPP_INLINE_VISIBILITY913 _LIBCPP_INLINE_VISIBILITY
895 iterator begin() _NOEXCEPT914 iterator begin() _NOEXCEPT
896 {return iterator(this, __get_pointer());}915 {return iterator(this, __get_pointer());}
...@@ -916,7 +935,7 @@ public:...@@ -916,7 +935,7 @@ public:
916 _LIBCPP_INLINE_VISIBILITY935 _LIBCPP_INLINE_VISIBILITY
917 const_iterator end() const _NOEXCEPT936 const_iterator end() const _NOEXCEPT
918 {return const_iterator(__get_pointer() + size());}937 {return const_iterator(__get_pointer() + size());}
919#endif // _LIBCPP_DEBUG_LEVEL >= 2938#endif // _LIBCPP_DEBUG_LEVEL == 2
920 _LIBCPP_INLINE_VISIBILITY939 _LIBCPP_INLINE_VISIBILITY
921 reverse_iterator rbegin() _NOEXCEPT940 reverse_iterator rbegin() _NOEXCEPT
922 {return reverse_iterator(end());}941 {return reverse_iterator(end());}
...@@ -954,13 +973,13 @@ public:...@@ -954,13 +973,13 @@ public:
954 void resize(size_type __n, value_type __c);973 void resize(size_type __n, value_type __c);
955 _LIBCPP_INLINE_VISIBILITY void resize(size_type __n) {resize(__n, value_type());}974 _LIBCPP_INLINE_VISIBILITY void resize(size_type __n) {resize(__n, value_type());}
956975
957 void reserve(size_type __res_arg);976 void reserve(size_type __requested_capacity);
958 _LIBCPP_INLINE_VISIBILITY void __resize_default_init(size_type __n);977 _LIBCPP_INLINE_VISIBILITY void __resize_default_init(size_type __n);
959978
979 _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_INLINE_VISIBILITY
980 void reserve() _NOEXCEPT {shrink_to_fit();}
960 _LIBCPP_INLINE_VISIBILITY981 _LIBCPP_INLINE_VISIBILITY
961 void reserve() _NOEXCEPT {reserve(0);}982 void shrink_to_fit() _NOEXCEPT;
962 _LIBCPP_INLINE_VISIBILITY
963 void shrink_to_fit() _NOEXCEPT {reserve();}
964 _LIBCPP_INLINE_VISIBILITY983 _LIBCPP_INLINE_VISIBILITY
965 void clear() _NOEXCEPT;984 void clear() _NOEXCEPT;
966 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY985 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
...@@ -1418,18 +1437,20 @@ public:...@@ -1418,18 +1437,20 @@ public:
14181437
1419 _LIBCPP_INLINE_VISIBILITY void __clear_and_shrink() _NOEXCEPT;1438 _LIBCPP_INLINE_VISIBILITY void __clear_and_shrink() _NOEXCEPT;
14201439
1440 _LIBCPP_INLINE_VISIBILITY void __shrink_or_extend(size_type __target_capacity);
1441
1421 _LIBCPP_INLINE_VISIBILITY1442 _LIBCPP_INLINE_VISIBILITY
1422 bool __is_long() const _NOEXCEPT1443 bool __is_long() const _NOEXCEPT
1423 {return bool(__r_.first().__s.__size_ & __short_mask);}1444 {return bool(__r_.first().__s.__size_ & __short_mask);}
14241445
1425#if _LIBCPP_DEBUG_LEVEL >= 21446#if _LIBCPP_DEBUG_LEVEL == 2
14261447
1427 bool __dereferenceable(const const_iterator* __i) const;1448 bool __dereferenceable(const const_iterator* __i) const;
1428 bool __decrementable(const const_iterator* __i) const;1449 bool __decrementable(const const_iterator* __i) const;
1429 bool __addable(const const_iterator* __i, ptrdiff_t __n) const;1450 bool __addable(const const_iterator* __i, ptrdiff_t __n) const;
1430 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;1451 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;
14311452
1432#endif // _LIBCPP_DEBUG_LEVEL >= 21453#endif // _LIBCPP_DEBUG_LEVEL == 2
14331454
1434private:1455private:
1435 _LIBCPP_INLINE_VISIBILITY1456 _LIBCPP_INLINE_VISIBILITY
...@@ -1726,21 +1747,21 @@ inline...@@ -1726,21 +1747,21 @@ inline
1726void1747void
1727basic_string<_CharT, _Traits, _Allocator>::__invalidate_all_iterators()1748basic_string<_CharT, _Traits, _Allocator>::__invalidate_all_iterators()
1728{1749{
1729#if _LIBCPP_DEBUG_LEVEL >= 21750#if _LIBCPP_DEBUG_LEVEL == 2
1730 __get_db()->__invalidate_all(this);1751 __get_db()->__invalidate_all(this);
1731#endif // _LIBCPP_DEBUG_LEVEL >= 21752#endif
1732}1753}
17331754
1734template <class _CharT, class _Traits, class _Allocator>1755template <class _CharT, class _Traits, class _Allocator>
1735inline1756inline
1736void1757void
1737basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type1758basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type
1738#if _LIBCPP_DEBUG_LEVEL >= 21759#if _LIBCPP_DEBUG_LEVEL == 2
1739 __pos1760 __pos
1740#endif1761#endif
1741 )1762 )
1742{1763{
1743#if _LIBCPP_DEBUG_LEVEL >= 21764#if _LIBCPP_DEBUG_LEVEL == 2
1744 __c_node* __c = __get_db()->__find_c_and_lock(this);1765 __c_node* __c = __get_db()->__find_c_and_lock(this);
1745 if (__c)1766 if (__c)
1746 {1767 {
...@@ -1753,12 +1774,12 @@ basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type...@@ -1753,12 +1774,12 @@ basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type
1753 {1774 {
1754 (*__p)->__c_ = nullptr;1775 (*__p)->__c_ = nullptr;
1755 if (--__c->end_ != __p)1776 if (--__c->end_ != __p)
1756 memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));1777 _VSTD::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
1757 }1778 }
1758 }1779 }
1759 __get_db()->unlock();1780 __get_db()->unlock();
1760 }1781 }
1761#endif // _LIBCPP_DEBUG_LEVEL >= 21782#endif // _LIBCPP_DEBUG_LEVEL == 2
1762}1783}
17631784
1764template <class _CharT, class _Traits, class _Allocator>1785template <class _CharT, class _Traits, class _Allocator>
...@@ -1767,7 +1788,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string()...@@ -1767,7 +1788,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string()
1767 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)1788 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
1768 : __r_(__default_init_tag(), __default_init_tag())1789 : __r_(__default_init_tag(), __default_init_tag())
1769{1790{
1770#if _LIBCPP_DEBUG_LEVEL >= 21791#if _LIBCPP_DEBUG_LEVEL == 2
1771 __get_db()->__insert_c(this);1792 __get_db()->__insert_c(this);
1772#endif1793#endif
1773 __zero();1794 __zero();
...@@ -1783,7 +1804,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __...@@ -1783,7 +1804,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __
1783#endif1804#endif
1784: __r_(__default_init_tag(), __a)1805: __r_(__default_init_tag(), __a)
1785{1806{
1786#if _LIBCPP_DEBUG_LEVEL >= 21807#if _LIBCPP_DEBUG_LEVEL == 2
1787 __get_db()->__insert_c(this);1808 __get_db()->__insert_c(this);
1788#endif1809#endif
1789 __zero();1810 __zero();
...@@ -1845,7 +1866,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const...@@ -1845,7 +1866,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const
1845{1866{
1846 _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*, allocator) detected nullptr");1867 _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*, allocator) detected nullptr");
1847 __init(__s, traits_type::length(__s));1868 __init(__s, traits_type::length(__s));
1848#if _LIBCPP_DEBUG_LEVEL >= 21869#if _LIBCPP_DEBUG_LEVEL == 2
1849 __get_db()->__insert_c(this);1870 __get_db()->__insert_c(this);
1850#endif1871#endif
1851}1872}
...@@ -1857,7 +1878,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_...@@ -1857,7 +1878,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_
1857{1878{
1858 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n) detected nullptr");1879 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n) detected nullptr");
1859 __init(__s, __n);1880 __init(__s, __n);
1860#if _LIBCPP_DEBUG_LEVEL >= 21881#if _LIBCPP_DEBUG_LEVEL == 2
1861 __get_db()->__insert_c(this);1882 __get_db()->__insert_c(this);
1862#endif1883#endif
1863}1884}
...@@ -1869,7 +1890,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_...@@ -1869,7 +1890,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_
1869{1890{
1870 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr");1891 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr");
1871 __init(__s, __n);1892 __init(__s, __n);
1872#if _LIBCPP_DEBUG_LEVEL >= 21893#if _LIBCPP_DEBUG_LEVEL == 2
1873 __get_db()->__insert_c(this);1894 __get_db()->__insert_c(this);
1874#endif1895#endif
1875}1896}
...@@ -1884,7 +1905,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st...@@ -1884,7 +1905,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st
1884 __init_copy_ctor_external(_VSTD::__to_address(__str.__get_long_pointer()),1905 __init_copy_ctor_external(_VSTD::__to_address(__str.__get_long_pointer()),
1885 __str.__get_long_size());1906 __str.__get_long_size());
18861907
1887#if _LIBCPP_DEBUG_LEVEL >= 21908#if _LIBCPP_DEBUG_LEVEL == 2
1888 __get_db()->__insert_c(this);1909 __get_db()->__insert_c(this);
1889#endif1910#endif
1890}1911}
...@@ -1899,7 +1920,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(...@@ -1899,7 +1920,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(
1899 else1920 else
1900 __init_copy_ctor_external(_VSTD::__to_address(__str.__get_long_pointer()),1921 __init_copy_ctor_external(_VSTD::__to_address(__str.__get_long_pointer()),
1901 __str.__get_long_size());1922 __str.__get_long_size());
1902#if _LIBCPP_DEBUG_LEVEL >= 21923#if _LIBCPP_DEBUG_LEVEL == 2
1903 __get_db()->__insert_c(this);1924 __get_db()->__insert_c(this);
1904#endif1925#endif
1905}1926}
...@@ -1936,7 +1957,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str)...@@ -1936,7 +1957,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str)
1936 : __r_(_VSTD::move(__str.__r_))1957 : __r_(_VSTD::move(__str.__r_))
1937{1958{
1938 __str.__zero();1959 __str.__zero();
1939#if _LIBCPP_DEBUG_LEVEL >= 21960#if _LIBCPP_DEBUG_LEVEL == 2
1940 __get_db()->__insert_c(this);1961 __get_db()->__insert_c(this);
1941 if (__is_long())1962 if (__is_long())
1942 __get_db()->swap(this, &__str);1963 __get_db()->swap(this, &__str);
...@@ -1955,7 +1976,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, co...@@ -1955,7 +1976,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, co
1955 __r_.first().__r = __str.__r_.first().__r;1976 __r_.first().__r = __str.__r_.first().__r;
1956 __str.__zero();1977 __str.__zero();
1957 }1978 }
1958#if _LIBCPP_DEBUG_LEVEL >= 21979#if _LIBCPP_DEBUG_LEVEL == 2
1959 __get_db()->__insert_c(this);1980 __get_db()->__insert_c(this);
1960 if (__is_long())1981 if (__is_long())
1961 __get_db()->swap(this, &__str);1982 __get_db()->swap(this, &__str);
...@@ -1994,7 +2015,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __...@@ -1994,7 +2015,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __
1994 : __r_(__default_init_tag(), __default_init_tag())2015 : __r_(__default_init_tag(), __default_init_tag())
1995{2016{
1996 __init(__n, __c);2017 __init(__n, __c);
1997#if _LIBCPP_DEBUG_LEVEL >= 22018#if _LIBCPP_DEBUG_LEVEL == 2
1998 __get_db()->__insert_c(this);2019 __get_db()->__insert_c(this);
1999#endif2020#endif
2000}2021}
...@@ -2005,7 +2026,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __...@@ -2005,7 +2026,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __
2005 : __r_(__default_init_tag(), __a)2026 : __r_(__default_init_tag(), __a)
2006{2027{
2007 __init(__n, __c);2028 __init(__n, __c);
2008#if _LIBCPP_DEBUG_LEVEL >= 22029#if _LIBCPP_DEBUG_LEVEL == 2
2009 __get_db()->__insert_c(this);2030 __get_db()->__insert_c(this);
2010#endif2031#endif
2011}2032}
...@@ -2020,7 +2041,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st...@@ -2020,7 +2041,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st
2020 if (__pos > __str_sz)2041 if (__pos > __str_sz)
2021 this->__throw_out_of_range();2042 this->__throw_out_of_range();
2022 __init(__str.data() + __pos, _VSTD::min(__n, __str_sz - __pos));2043 __init(__str.data() + __pos, _VSTD::min(__n, __str_sz - __pos));
2023#if _LIBCPP_DEBUG_LEVEL >= 22044#if _LIBCPP_DEBUG_LEVEL == 2
2024 __get_db()->__insert_c(this);2045 __get_db()->__insert_c(this);
2025#endif2046#endif
2026}2047}
...@@ -2035,7 +2056,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st...@@ -2035,7 +2056,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st
2035 if (__pos > __str_sz)2056 if (__pos > __str_sz)
2036 this->__throw_out_of_range();2057 this->__throw_out_of_range();
2037 __init(__str.data() + __pos, __str_sz - __pos);2058 __init(__str.data() + __pos, __str_sz - __pos);
2038#if _LIBCPP_DEBUG_LEVEL >= 22059#if _LIBCPP_DEBUG_LEVEL == 2
2039 __get_db()->__insert_c(this);2060 __get_db()->__insert_c(this);
2040#endif2061#endif
2041}2062}
...@@ -2049,7 +2070,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(...@@ -2049,7 +2070,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(
2049 __self_view __sv0 = __t;2070 __self_view __sv0 = __t;
2050 __self_view __sv = __sv0.substr(__pos, __n);2071 __self_view __sv = __sv0.substr(__pos, __n);
2051 __init(__sv.data(), __sv.size());2072 __init(__sv.data(), __sv.size());
2052#if _LIBCPP_DEBUG_LEVEL >= 22073#if _LIBCPP_DEBUG_LEVEL == 2
2053 __get_db()->__insert_c(this);2074 __get_db()->__insert_c(this);
2054#endif2075#endif
2055}2076}
...@@ -2061,7 +2082,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t)...@@ -2061,7 +2082,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t)
2061{2082{
2062 __self_view __sv = __t;2083 __self_view __sv = __t;
2063 __init(__sv.data(), __sv.size());2084 __init(__sv.data(), __sv.size());
2064#if _LIBCPP_DEBUG_LEVEL >= 22085#if _LIBCPP_DEBUG_LEVEL == 2
2065 __get_db()->__insert_c(this);2086 __get_db()->__insert_c(this);
2066#endif2087#endif
2067}2088}
...@@ -2073,7 +2094,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t, const _...@@ -2073,7 +2094,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t, const _
2073{2094{
2074 __self_view __sv = __t;2095 __self_view __sv = __t;
2075 __init(__sv.data(), __sv.size());2096 __init(__sv.data(), __sv.size());
2076#if _LIBCPP_DEBUG_LEVEL >= 22097#if _LIBCPP_DEBUG_LEVEL == 2
2077 __get_db()->__insert_c(this);2098 __get_db()->__insert_c(this);
2078#endif2099#endif
2079}2100}
...@@ -2141,7 +2162,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first,...@@ -2141,7 +2162,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first,
2141 : __r_(__default_init_tag(), __default_init_tag())2162 : __r_(__default_init_tag(), __default_init_tag())
2142{2163{
2143 __init(__first, __last);2164 __init(__first, __last);
2144#if _LIBCPP_DEBUG_LEVEL >= 22165#if _LIBCPP_DEBUG_LEVEL == 2
2145 __get_db()->__insert_c(this);2166 __get_db()->__insert_c(this);
2146#endif2167#endif
2147}2168}
...@@ -2154,7 +2175,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first,...@@ -2154,7 +2175,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first,
2154 : __r_(__default_init_tag(), __a)2175 : __r_(__default_init_tag(), __a)
2155{2176{
2156 __init(__first, __last);2177 __init(__first, __last);
2157#if _LIBCPP_DEBUG_LEVEL >= 22178#if _LIBCPP_DEBUG_LEVEL == 2
2158 __get_db()->__insert_c(this);2179 __get_db()->__insert_c(this);
2159#endif2180#endif
2160}2181}
...@@ -2168,7 +2189,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(...@@ -2168,7 +2189,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(
2168 : __r_(__default_init_tag(), __default_init_tag())2189 : __r_(__default_init_tag(), __default_init_tag())
2169{2190{
2170 __init(__il.begin(), __il.end());2191 __init(__il.begin(), __il.end());
2171#if _LIBCPP_DEBUG_LEVEL >= 22192#if _LIBCPP_DEBUG_LEVEL == 2
2172 __get_db()->__insert_c(this);2193 __get_db()->__insert_c(this);
2173#endif2194#endif
2174}2195}
...@@ -2181,7 +2202,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(...@@ -2181,7 +2202,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(
2181 : __r_(__default_init_tag(), __a)2202 : __r_(__default_init_tag(), __a)
2182{2203{
2183 __init(__il.begin(), __il.end());2204 __init(__il.begin(), __il.end());
2184#if _LIBCPP_DEBUG_LEVEL >= 22205#if _LIBCPP_DEBUG_LEVEL == 2
2185 __get_db()->__insert_c(this);2206 __get_db()->__insert_c(this);
2186#endif2207#endif
2187}2208}
...@@ -2191,7 +2212,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(...@@ -2191,7 +2212,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(
2191template <class _CharT, class _Traits, class _Allocator>2212template <class _CharT, class _Traits, class _Allocator>
2192basic_string<_CharT, _Traits, _Allocator>::~basic_string()2213basic_string<_CharT, _Traits, _Allocator>::~basic_string()
2193{2214{
2194#if _LIBCPP_DEBUG_LEVEL >= 22215#if _LIBCPP_DEBUG_LEVEL == 2
2195 __get_db()->__erase_c(this);2216 __get_db()->__erase_c(this);
2196#endif2217#endif
2197 if (__is_long())2218 if (__is_long())
...@@ -2768,7 +2789,7 @@ _EnableIf...@@ -2768,7 +2789,7 @@ _EnableIf
2768>2789>
2769basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIterator __first, _InputIterator __last)2790basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIterator __first, _InputIterator __last)
2770{2791{
2771#if _LIBCPP_DEBUG_LEVEL >= 22792#if _LIBCPP_DEBUG_LEVEL == 2
2772 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this,2793 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this,
2773 "string::insert(iterator, range) called with an iterator not"2794 "string::insert(iterator, range) called with an iterator not"
2774 " referring to this string");2795 " referring to this string");
...@@ -2787,7 +2808,7 @@ _EnableIf...@@ -2787,7 +2808,7 @@ _EnableIf
2787>2808>
2788basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last)2809basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last)
2789{2810{
2790#if _LIBCPP_DEBUG_LEVEL >= 22811#if _LIBCPP_DEBUG_LEVEL == 2
2791 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this,2812 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this,
2792 "string::insert(iterator, range) called with an iterator not"2813 "string::insert(iterator, range) called with an iterator not"
2793 " referring to this string");2814 " referring to this string");
...@@ -2903,7 +2924,7 @@ inline...@@ -2903,7 +2924,7 @@ inline
2903typename basic_string<_CharT, _Traits, _Allocator>::iterator2924typename basic_string<_CharT, _Traits, _Allocator>::iterator
2904basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, size_type __n, value_type __c)2925basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, size_type __n, value_type __c)
2905{2926{
2906#if _LIBCPP_DEBUG_LEVEL >= 22927#if _LIBCPP_DEBUG_LEVEL == 2
2907 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this,2928 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this,
2908 "string::insert(iterator, n, value) called with an iterator not"2929 "string::insert(iterator, n, value) called with an iterator not"
2909 " referring to this string");2930 " referring to this string");
...@@ -3137,7 +3158,7 @@ inline...@@ -3137,7 +3158,7 @@ inline
3137typename basic_string<_CharT, _Traits, _Allocator>::iterator3158typename basic_string<_CharT, _Traits, _Allocator>::iterator
3138basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos)3159basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos)
3139{3160{
3140#if _LIBCPP_DEBUG_LEVEL >= 23161#if _LIBCPP_DEBUG_LEVEL == 2
3141 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this,3162 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this,
3142 "string::erase(iterator) called with an iterator not"3163 "string::erase(iterator) called with an iterator not"
3143 " referring to this string");3164 " referring to this string");
...@@ -3155,7 +3176,7 @@ inline...@@ -3155,7 +3176,7 @@ inline
3155typename basic_string<_CharT, _Traits, _Allocator>::iterator3176typename basic_string<_CharT, _Traits, _Allocator>::iterator
3156basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_iterator __last)3177basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_iterator __last)
3157{3178{
3158#if _LIBCPP_DEBUG_LEVEL >= 23179#if _LIBCPP_DEBUG_LEVEL == 2
3159 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this,3180 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this,
3160 "string::erase(iterator, iterator) called with an iterator not"3181 "string::erase(iterator, iterator) called with an iterator not"
3161 " referring to this string");3182 " referring to this string");
...@@ -3262,65 +3283,88 @@ basic_string<_CharT, _Traits, _Allocator>::max_size() const _NOEXCEPT...@@ -3262,65 +3283,88 @@ basic_string<_CharT, _Traits, _Allocator>::max_size() const _NOEXCEPT
32623283
3263template <class _CharT, class _Traits, class _Allocator>3284template <class _CharT, class _Traits, class _Allocator>
3264void3285void
3265basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __res_arg)3286basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacity)
3266{3287{
3267 if (__res_arg > max_size())3288 if (__requested_capacity > max_size())
3268 this->__throw_length_error();3289 this->__throw_length_error();
3290
3291#if _LIBCPP_STD_VER > 17
3292 // Reserve never shrinks as of C++20.
3293 if (__requested_capacity <= capacity()) return;
3294#endif
3295
3296 size_type __target_capacity = _VSTD::max(__requested_capacity, size());
3297 __target_capacity = __recommend(__target_capacity);
3298 if (__target_capacity == capacity()) return;
3299
3300 __shrink_or_extend(__target_capacity);
3301}
3302
3303template <class _CharT, class _Traits, class _Allocator>
3304void
3305basic_string<_CharT, _Traits, _Allocator>::shrink_to_fit() _NOEXCEPT
3306{
3307 size_type __target_capacity = __recommend(size());
3308 if (__target_capacity == capacity()) return;
3309
3310 __shrink_or_extend(__target_capacity);
3311}
3312
3313template <class _CharT, class _Traits, class _Allocator>
3314void
3315basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target_capacity)
3316{
3269 size_type __cap = capacity();3317 size_type __cap = capacity();
3270 size_type __sz = size();3318 size_type __sz = size();
3271 __res_arg = _VSTD::max(__res_arg, __sz);3319
3272 __res_arg = __recommend(__res_arg);3320 pointer __new_data, __p;
3273 if (__res_arg != __cap)3321 bool __was_long, __now_long;
3322 if (__target_capacity == __min_cap - 1)
3274 {3323 {
3275 pointer __new_data, __p;3324 __was_long = true;
3276 bool __was_long, __now_long;3325 __now_long = false;
3277 if (__res_arg == __min_cap - 1)3326 __new_data = __get_short_pointer();
3278 {3327 __p = __get_long_pointer();
3279 __was_long = true;3328 }
3280 __now_long = false;3329 else
3281 __new_data = __get_short_pointer();3330 {
3282 __p = __get_long_pointer();3331 if (__target_capacity > __cap)
3283 }3332 __new_data = __alloc_traits::allocate(__alloc(), __target_capacity+1);
3284 else3333 else
3285 {3334 {
3286 if (__res_arg > __cap)3335 #ifndef _LIBCPP_NO_EXCEPTIONS
3287 __new_data = __alloc_traits::allocate(__alloc(), __res_arg+1);3336 try
3288 else
3289 {3337 {
3290 #ifndef _LIBCPP_NO_EXCEPTIONS3338 #endif // _LIBCPP_NO_EXCEPTIONS
3291 try3339 __new_data = __alloc_traits::allocate(__alloc(), __target_capacity+1);
3292 {3340 #ifndef _LIBCPP_NO_EXCEPTIONS
3293 #endif // _LIBCPP_NO_EXCEPTIONS
3294 __new_data = __alloc_traits::allocate(__alloc(), __res_arg+1);
3295 #ifndef _LIBCPP_NO_EXCEPTIONS
3296 }
3297 catch (...)
3298 {
3299 return;
3300 }
3301 #else // _LIBCPP_NO_EXCEPTIONS
3302 if (__new_data == nullptr)
3303 return;
3304 #endif // _LIBCPP_NO_EXCEPTIONS
3305 }3341 }
3306 __now_long = true;3342 catch (...)
3307 __was_long = __is_long();3343 {
3308 __p = __get_pointer();3344 return;
3309 }3345 }
3310 traits_type::copy(_VSTD::__to_address(__new_data),3346 #else // _LIBCPP_NO_EXCEPTIONS
3311 _VSTD::__to_address(__p), size()+1);3347 if (__new_data == nullptr)
3312 if (__was_long)3348 return;
3313 __alloc_traits::deallocate(__alloc(), __p, __cap+1);3349 #endif // _LIBCPP_NO_EXCEPTIONS
3314 if (__now_long)
3315 {
3316 __set_long_cap(__res_arg+1);
3317 __set_long_size(__sz);
3318 __set_long_pointer(__new_data);
3319 }3350 }
3320 else3351 __now_long = true;
3321 __set_short_size(__sz);3352 __was_long = __is_long();
3322 __invalidate_all_iterators();3353 __p = __get_pointer();
3323 }3354 }
3355 traits_type::copy(_VSTD::__to_address(__new_data),
3356 _VSTD::__to_address(__p), size()+1);
3357 if (__was_long)
3358 __alloc_traits::deallocate(__alloc(), __p, __cap+1);
3359 if (__now_long)
3360 {
3361 __set_long_cap(__target_capacity+1);
3362 __set_long_size(__sz);
3363 __set_long_pointer(__new_data);
3364 }
3365 else
3366 __set_short_size(__sz);
3367 __invalidate_all_iterators();
3324}3368}
33253369
3326template <class _CharT, class _Traits, class _Allocator>3370template <class _CharT, class _Traits, class _Allocator>
...@@ -3426,7 +3470,7 @@ basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str)...@@ -3426,7 +3470,7 @@ basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str)
3426 __is_nothrow_swappable<allocator_type>::value)3470 __is_nothrow_swappable<allocator_type>::value)
3427#endif3471#endif
3428{3472{
3429#if _LIBCPP_DEBUG_LEVEL >= 23473#if _LIBCPP_DEBUG_LEVEL == 2
3430 if (!__is_long())3474 if (!__is_long())
3431 __get_db()->__invalidate_all(this);3475 __get_db()->__invalidate_all(this);
3432 if (!__str.__is_long())3476 if (!__str.__is_long())
...@@ -3438,7 +3482,7 @@ basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str)...@@ -3438,7 +3482,7 @@ basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str)
3438 __alloc_traits::is_always_equal::value ||3482 __alloc_traits::is_always_equal::value ||
3439 __alloc() == __str.__alloc(), "swapping non-equal allocators");3483 __alloc() == __str.__alloc(), "swapping non-equal allocators");
3440 _VSTD::swap(__r_.first(), __str.__r_.first());3484 _VSTD::swap(__r_.first(), __str.__r_.first());
3441 __swap_allocator(__alloc(), __str.__alloc());3485 _VSTD::__swap_allocator(__alloc(), __str.__alloc());
3442}3486}
34433487
3444// find3488// find
...@@ -3939,9 +3983,9 @@ basic_string<_CharT, _Traits, _Allocator>::__invariants() const...@@ -3939,9 +3983,9 @@ basic_string<_CharT, _Traits, _Allocator>::__invariants() const
3939 return false;3983 return false;
3940 if (capacity() < __min_cap - 1)3984 if (capacity() < __min_cap - 1)
3941 return false;3985 return false;
3942 if (data() == 0)3986 if (data() == nullptr)
3943 return false;3987 return false;
3944 if (data()[size()] != value_type(0))3988 if (data()[size()] != value_type())
3945 return false;3989 return false;
3946 return true;3990 return true;
3947}3991}
...@@ -3959,6 +4003,7 @@ basic_string<_CharT, _Traits, _Allocator>::__clear_and_shrink() _NOEXCEPT...@@ -3959,6 +4003,7 @@ basic_string<_CharT, _Traits, _Allocator>::__clear_and_shrink() _NOEXCEPT
3959 __alloc_traits::deallocate(__alloc(), __get_long_pointer(), capacity() + 1);4003 __alloc_traits::deallocate(__alloc(), __get_long_pointer(), capacity() + 1);
3960 __set_long_cap(0);4004 __set_long_cap(0);
3961 __set_short_size(0);4005 __set_short_size(0);
4006 traits_type::assign(*__get_short_pointer(), value_type());
3962 }4007 }
3963}4008}
39644009
...@@ -4300,24 +4345,15 @@ swap(basic_string<_CharT, _Traits, _Allocator>& __lhs,...@@ -4300,24 +4345,15 @@ swap(basic_string<_CharT, _Traits, _Allocator>& __lhs,
4300 __lhs.swap(__rhs);4345 __lhs.swap(__rhs);
4301}4346}
43024347
4303#ifndef _LIBCPP_NO_HAS_CHAR8_T4348_LIBCPP_FUNC_VIS int stoi (const string& __str, size_t* __idx = nullptr, int __base = 10);
4304typedef basic_string<char8_t> u8string;4349_LIBCPP_FUNC_VIS long stol (const string& __str, size_t* __idx = nullptr, int __base = 10);
4305#endif4350_LIBCPP_FUNC_VIS unsigned long stoul (const string& __str, size_t* __idx = nullptr, int __base = 10);
43064351_LIBCPP_FUNC_VIS long long stoll (const string& __str, size_t* __idx = nullptr, int __base = 10);
4307#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS4352_LIBCPP_FUNC_VIS unsigned long long stoull(const string& __str, size_t* __idx = nullptr, int __base = 10);
4308typedef basic_string<char16_t> u16string;
4309typedef basic_string<char32_t> u32string;
4310#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
4311
4312_LIBCPP_FUNC_VIS int stoi (const string& __str, size_t* __idx = 0, int __base = 10);
4313_LIBCPP_FUNC_VIS long stol (const string& __str, size_t* __idx = 0, int __base = 10);
4314_LIBCPP_FUNC_VIS unsigned long stoul (const string& __str, size_t* __idx = 0, int __base = 10);
4315_LIBCPP_FUNC_VIS long long stoll (const string& __str, size_t* __idx = 0, int __base = 10);
4316_LIBCPP_FUNC_VIS unsigned long long stoull(const string& __str, size_t* __idx = 0, int __base = 10);
43174353
4318_LIBCPP_FUNC_VIS float stof (const string& __str, size_t* __idx = 0);4354_LIBCPP_FUNC_VIS float stof (const string& __str, size_t* __idx = nullptr);
4319_LIBCPP_FUNC_VIS double stod (const string& __str, size_t* __idx = 0);4355_LIBCPP_FUNC_VIS double stod (const string& __str, size_t* __idx = nullptr);
4320_LIBCPP_FUNC_VIS long double stold(const string& __str, size_t* __idx = 0);4356_LIBCPP_FUNC_VIS long double stold(const string& __str, size_t* __idx = nullptr);
43214357
4322_LIBCPP_FUNC_VIS string to_string(int __val);4358_LIBCPP_FUNC_VIS string to_string(int __val);
4323_LIBCPP_FUNC_VIS string to_string(unsigned __val);4359_LIBCPP_FUNC_VIS string to_string(unsigned __val);
...@@ -4329,15 +4365,15 @@ _LIBCPP_FUNC_VIS string to_string(float __val);...@@ -4329,15 +4365,15 @@ _LIBCPP_FUNC_VIS string to_string(float __val);
4329_LIBCPP_FUNC_VIS string to_string(double __val);4365_LIBCPP_FUNC_VIS string to_string(double __val);
4330_LIBCPP_FUNC_VIS string to_string(long double __val);4366_LIBCPP_FUNC_VIS string to_string(long double __val);
43314367
4332_LIBCPP_FUNC_VIS int stoi (const wstring& __str, size_t* __idx = 0, int __base = 10);4368_LIBCPP_FUNC_VIS int stoi (const wstring& __str, size_t* __idx = nullptr, int __base = 10);
4333_LIBCPP_FUNC_VIS long stol (const wstring& __str, size_t* __idx = 0, int __base = 10);4369_LIBCPP_FUNC_VIS long stol (const wstring& __str, size_t* __idx = nullptr, int __base = 10);
4334_LIBCPP_FUNC_VIS unsigned long stoul (const wstring& __str, size_t* __idx = 0, int __base = 10);4370_LIBCPP_FUNC_VIS unsigned long stoul (const wstring& __str, size_t* __idx = nullptr, int __base = 10);
4335_LIBCPP_FUNC_VIS long long stoll (const wstring& __str, size_t* __idx = 0, int __base = 10);4371_LIBCPP_FUNC_VIS long long stoll (const wstring& __str, size_t* __idx = nullptr, int __base = 10);
4336_LIBCPP_FUNC_VIS unsigned long long stoull(const wstring& __str, size_t* __idx = 0, int __base = 10);4372_LIBCPP_FUNC_VIS unsigned long long stoull(const wstring& __str, size_t* __idx = nullptr, int __base = 10);
43374373
4338_LIBCPP_FUNC_VIS float stof (const wstring& __str, size_t* __idx = 0);4374_LIBCPP_FUNC_VIS float stof (const wstring& __str, size_t* __idx = nullptr);
4339_LIBCPP_FUNC_VIS double stod (const wstring& __str, size_t* __idx = 0);4375_LIBCPP_FUNC_VIS double stod (const wstring& __str, size_t* __idx = nullptr);
4340_LIBCPP_FUNC_VIS long double stold(const wstring& __str, size_t* __idx = 0);4376_LIBCPP_FUNC_VIS long double stold(const wstring& __str, size_t* __idx = nullptr);
43414377
4342_LIBCPP_FUNC_VIS wstring to_wstring(int __val);4378_LIBCPP_FUNC_VIS wstring to_wstring(int __val);
4343_LIBCPP_FUNC_VIS wstring to_wstring(unsigned __val);4379_LIBCPP_FUNC_VIS wstring to_wstring(unsigned __val);
...@@ -4425,7 +4461,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -4425,7 +4461,7 @@ inline _LIBCPP_INLINE_VISIBILITY
4425}4461}
4426#endif4462#endif
44274463
4428#if _LIBCPP_DEBUG_LEVEL >= 24464#if _LIBCPP_DEBUG_LEVEL == 2
44294465
4430template<class _CharT, class _Traits, class _Allocator>4466template<class _CharT, class _Traits, class _Allocator>
4431bool4467bool
...@@ -4459,7 +4495,7 @@ basic_string<_CharT, _Traits, _Allocator>::__subscriptable(const const_iterator*...@@ -4459,7 +4495,7 @@ basic_string<_CharT, _Traits, _Allocator>::__subscriptable(const const_iterator*
4459 return this->data() <= __p && __p < this->data() + this->size();4495 return this->data() <= __p && __p < this->data() + this->size();
4460}4496}
44614497
4462#endif // _LIBCPP_DEBUG_LEVEL >= 24498#endif // _LIBCPP_DEBUG_LEVEL == 2
44634499
4464#if _LIBCPP_STD_VER > 114500#if _LIBCPP_STD_VER > 11
4465// Literal suffixes for basic_string [basic.string.literals]4501// Literal suffixes for basic_string [basic.string.literals]
lib/libcxx/include/string_view+24-11
...@@ -192,7 +192,26 @@ _LIBCPP_PUSH_MACROS...@@ -192,7 +192,26 @@ _LIBCPP_PUSH_MACROS
192_LIBCPP_BEGIN_NAMESPACE_STD192_LIBCPP_BEGIN_NAMESPACE_STD
193193
194template<class _CharT, class _Traits = char_traits<_CharT> >194template<class _CharT, class _Traits = char_traits<_CharT> >
195class _LIBCPP_TEMPLATE_VIS basic_string_view {195 class _LIBCPP_TEMPLATE_VIS basic_string_view;
196
197typedef basic_string_view<char> string_view;
198#ifndef _LIBCPP_NO_HAS_CHAR8_T
199typedef basic_string_view<char8_t> u8string_view;
200#endif
201typedef basic_string_view<char16_t> u16string_view;
202typedef basic_string_view<char32_t> u32string_view;
203typedef basic_string_view<wchar_t> wstring_view;
204
205template<class _CharT, class _Traits>
206class
207 _LIBCPP_PREFERRED_NAME(string_view)
208#ifndef _LIBCPP_NO_HAS_CHAR8_T
209 _LIBCPP_PREFERRED_NAME(u8string_view)
210#endif
211 _LIBCPP_PREFERRED_NAME(u16string_view)
212 _LIBCPP_PREFERRED_NAME(u32string_view)
213 _LIBCPP_PREFERRED_NAME(wstring_view)
214 basic_string_view {
196public:215public:
197 // types216 // types
198 typedef _Traits traits_type;217 typedef _Traits traits_type;
...@@ -236,7 +255,7 @@ public:...@@ -236,7 +255,7 @@ public:
236255
237 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY256 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
238 basic_string_view(const _CharT* __s)257 basic_string_view(const _CharT* __s)
239 : __data(__s), __size(std::__char_traits_length_checked<_Traits>(__s)) {}258 : __data(__s), __size(_VSTD::__char_traits_length_checked<_Traits>(__s)) {}
240259
241 // [string.view.iterators], iterators260 // [string.view.iterators], iterators
242 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY261 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
...@@ -278,7 +297,9 @@ public:...@@ -278,7 +297,9 @@ public:
278297
279 // [string.view.access], element access298 // [string.view.access], element access
280 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY299 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
281 const_reference operator[](size_type __pos) const _NOEXCEPT { return __data[__pos]; }300 const_reference operator[](size_type __pos) const _NOEXCEPT {
301 return _LIBCPP_ASSERT(__pos < size(), "string_view[] index out of bounds"), __data[__pos];
302 }
282303
283 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY304 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
284 const_reference at(size_type __pos) const305 const_reference at(size_type __pos) const
...@@ -774,14 +795,6 @@ basic_ostream<_CharT, _Traits>&...@@ -774,14 +795,6 @@ basic_ostream<_CharT, _Traits>&
774operator<<(basic_ostream<_CharT, _Traits>& __os,795operator<<(basic_ostream<_CharT, _Traits>& __os,
775 basic_string_view<_CharT, _Traits> __str);796 basic_string_view<_CharT, _Traits> __str);
776797
777typedef basic_string_view<char> string_view;
778#ifndef _LIBCPP_NO_HAS_CHAR8_T
779typedef basic_string_view<char8_t> u8string_view;
780#endif
781typedef basic_string_view<char16_t> u16string_view;
782typedef basic_string_view<char32_t> u32string_view;
783typedef basic_string_view<wchar_t> wstring_view;
784
785// [string.view.hash]798// [string.view.hash]
786template<class _CharT>799template<class _CharT>
787struct _LIBCPP_TEMPLATE_VIS hash<basic_string_view<_CharT, char_traits<_CharT> > >800struct _LIBCPP_TEMPLATE_VIS hash<basic_string_view<_CharT, char_traits<_CharT> > >
lib/libcxx/include/strstream+8-8
...@@ -19,12 +19,12 @@ class strstreambuf...@@ -19,12 +19,12 @@ class strstreambuf
19public:19public:
20 explicit strstreambuf(streamsize alsize_arg = 0);20 explicit strstreambuf(streamsize alsize_arg = 0);
21 strstreambuf(void* (*palloc_arg)(size_t), void (*pfree_arg)(void*));21 strstreambuf(void* (*palloc_arg)(size_t), void (*pfree_arg)(void*));
22 strstreambuf(char* gnext_arg, streamsize n, char* pbeg_arg = 0);22 strstreambuf(char* gnext_arg, streamsize n, char* pbeg_arg = nullptr);
23 strstreambuf(const char* gnext_arg, streamsize n);23 strstreambuf(const char* gnext_arg, streamsize n);
2424
25 strstreambuf(signed char* gnext_arg, streamsize n, signed char* pbeg_arg = 0);25 strstreambuf(signed char* gnext_arg, streamsize n, signed char* pbeg_arg = nullptr);
26 strstreambuf(const signed char* gnext_arg, streamsize n);26 strstreambuf(const signed char* gnext_arg, streamsize n);
27 strstreambuf(unsigned char* gnext_arg, streamsize n, unsigned char* pbeg_arg = 0);27 strstreambuf(unsigned char* gnext_arg, streamsize n, unsigned char* pbeg_arg = nullptr);
28 strstreambuf(const unsigned char* gnext_arg, streamsize n);28 strstreambuf(const unsigned char* gnext_arg, streamsize n);
2929
30 strstreambuf(strstreambuf&& rhs);30 strstreambuf(strstreambuf&& rhs);
...@@ -142,12 +142,12 @@ class _LIBCPP_TYPE_VIS strstreambuf...@@ -142,12 +142,12 @@ class _LIBCPP_TYPE_VIS strstreambuf
142public:142public:
143 explicit strstreambuf(streamsize __alsize = 0);143 explicit strstreambuf(streamsize __alsize = 0);
144 strstreambuf(void* (*__palloc)(size_t), void (*__pfree)(void*));144 strstreambuf(void* (*__palloc)(size_t), void (*__pfree)(void*));
145 strstreambuf(char* __gnext, streamsize __n, char* __pbeg = 0);145 strstreambuf(char* __gnext, streamsize __n, char* __pbeg = nullptr);
146 strstreambuf(const char* __gnext, streamsize __n);146 strstreambuf(const char* __gnext, streamsize __n);
147147
148 strstreambuf(signed char* __gnext, streamsize __n, signed char* __pbeg = 0);148 strstreambuf(signed char* __gnext, streamsize __n, signed char* __pbeg = nullptr);
149 strstreambuf(const signed char* __gnext, streamsize __n);149 strstreambuf(const signed char* __gnext, streamsize __n);
150 strstreambuf(unsigned char* __gnext, streamsize __n, unsigned char* __pbeg = 0);150 strstreambuf(unsigned char* __gnext, streamsize __n, unsigned char* __pbeg = nullptr);
151 strstreambuf(const unsigned char* __gnext, streamsize __n);151 strstreambuf(const unsigned char* __gnext, streamsize __n);
152152
153#ifndef _LIBCPP_CXX03_LANG153#ifndef _LIBCPP_CXX03_LANG
...@@ -290,7 +290,7 @@ public:...@@ -290,7 +290,7 @@ public:
290 _LIBCPP_INLINE_VISIBILITY290 _LIBCPP_INLINE_VISIBILITY
291 ostrstream(char* __s, int __n, ios_base::openmode __mode = ios_base::out)291 ostrstream(char* __s, int __n, ios_base::openmode __mode = ios_base::out)
292 : ostream(&__sb_),292 : ostream(&__sb_),
293 __sb_(__s, __n, __s + (__mode & ios::app ? strlen(__s) : 0))293 __sb_(__s, __n, __s + (__mode & ios::app ? _VSTD::strlen(__s) : 0))
294 {}294 {}
295295
296#ifndef _LIBCPP_CXX03_LANG296#ifndef _LIBCPP_CXX03_LANG
...@@ -350,7 +350,7 @@ public:...@@ -350,7 +350,7 @@ public:
350 _LIBCPP_INLINE_VISIBILITY350 _LIBCPP_INLINE_VISIBILITY
351 strstream(char* __s, int __n, ios_base::openmode __mode = ios_base::in | ios_base::out)351 strstream(char* __s, int __n, ios_base::openmode __mode = ios_base::in | ios_base::out)
352 : iostream(&__sb_),352 : iostream(&__sb_),
353 __sb_(__s, __n, __s + (__mode & ios::app ? strlen(__s) : 0))353 __sb_(__s, __n, __s + (__mode & ios::app ? _VSTD::strlen(__s) : 0))
354 {}354 {}
355355
356#ifndef _LIBCPP_CXX03_LANG356#ifndef _LIBCPP_CXX03_LANG
lib/libcxx/include/support/ibm/nanosleep.h created+38
...@@ -0,0 +1,38 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP_SUPPORT_IBM_NANOSLEEP_H
11#define _LIBCPP_SUPPORT_IBM_NANOSLEEP_H
12
13#include <unistd.h>
14
15inline int nanosleep(const struct timespec* req, struct timespec* rem)
16{
17 // The nanosleep() function is not available on z/OS. Therefore, we will call
18 // sleep() to sleep for whole seconds and usleep() to sleep for any remaining
19 // fraction of a second. Any remaining nanoseconds will round up to the next
20 // microsecond.
21
22 useconds_t __micro_sec = (rem->tv_nsec + 999) / 1000;
23 if (__micro_sec > 999999)
24 {
25 ++rem->tv_sec;
26 __micro_sec -= 1000000;
27 }
28 while (rem->tv_sec)
29 rem->tv_sec = sleep(rem->tv_sec);
30 if (__micro_sec) {
31 rem->tv_nsec = __micro_sec * 1000;
32 return usleep(__micro_sec);
33 }
34 rem->tv_nsec = 0;
35 return 0;
36}
37
38#endif // _LIBCPP_SUPPORT_IBM_NANOSLEEP_H
lib/libcxx/include/support/ibm/xlocale.h+9-4
...@@ -11,13 +11,13 @@...@@ -11,13 +11,13 @@
11#define _LIBCPP_SUPPORT_IBM_XLOCALE_H11#define _LIBCPP_SUPPORT_IBM_XLOCALE_H
12#include <support/ibm/locale_mgmt_aix.h>12#include <support/ibm/locale_mgmt_aix.h>
1313
14#if defined(_AIX)
15#include "cstdlib"14#include "cstdlib"
1615
17#ifdef __cplusplus16#ifdef __cplusplus
18extern "C" {17extern "C" {
19#endif18#endif
2019
20#if defined(_AIX)
21#if !defined(_AIX71)21#if !defined(_AIX71)
22// AIX 7.1 and higher has these definitions. Definitions and stubs22// AIX 7.1 and higher has these definitions. Definitions and stubs
23// are provied here as a temporary workaround on AIX 6.1.23// are provied here as a temporary workaround on AIX 6.1.
...@@ -207,14 +207,20 @@ size_t wcsxfrm_l(wchar_t *__ws1, const wchar_t *__ws2, size_t __n,...@@ -207,14 +207,20 @@ size_t wcsxfrm_l(wchar_t *__ws1, const wchar_t *__ws2, size_t __n,
207}207}
208#endif // !defined(_AIX71)208#endif // !defined(_AIX71)
209209
210// strftime_l() is defined by POSIX. However, AIX 7.1 does not have it210// strftime_l() is defined by POSIX. However, AIX 7.1 and z/OS do not have it
211// implemented yet.211// implemented yet. z/OS retrieves it from the POSIX fallbacks.
212static inline212static inline
213size_t strftime_l(char *__s, size_t __size, const char *__fmt,213size_t strftime_l(char *__s, size_t __size, const char *__fmt,
214 const struct tm *__tm, locale_t locale) {214 const struct tm *__tm, locale_t locale) {
215 return __xstrftime(locale, __s, __size, __fmt, __tm);215 return __xstrftime(locale, __s, __size, __fmt, __tm);
216}216}
217217
218#elif defined(__MVS__)
219#include <wctype.h>
220// POSIX routines
221#include <support/xlocale/__posix_l_fallback.h>
222#endif // defined(__MVS__)
223
218// The following are not POSIX routines. These are quick-and-dirty hacks224// The following are not POSIX routines. These are quick-and-dirty hacks
219// to make things pretend to work225// to make things pretend to work
220static inline226static inline
...@@ -266,5 +272,4 @@ int vasprintf(char **strp, const char *fmt, va_list ap)...@@ -266,5 +272,4 @@ int vasprintf(char **strp, const char *fmt, va_list ap)
266#ifdef __cplusplus272#ifdef __cplusplus
267}273}
268#endif274#endif
269#endif // defined(_AIX)
270#endif // _LIBCPP_SUPPORT_IBM_XLOCALE_H275#endif // _LIBCPP_SUPPORT_IBM_XLOCALE_H
lib/libcxx/include/support/nuttx/xlocale.h created+18
...@@ -0,0 +1,18 @@
1// -*- C++ -*-
2//===-------------------- support/nuttx/xlocale.h -------------------------===//
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_SUPPORT_NUTTX_XLOCALE_H
11#define _LIBCPP_SUPPORT_NUTTX_XLOCALE_H
12
13#if defined(__NuttX__)
14#include <support/xlocale/__posix_l_fallback.h>
15#include <support/xlocale/__strtonum_fallback.h>
16#endif // __NuttX__
17
18#endif
lib/libcxx/include/support/win32/locale_win32.h+2-2
...@@ -201,8 +201,8 @@ decltype(MB_CUR_MAX) MB_CUR_MAX_L( locale_t __l );...@@ -201,8 +201,8 @@ decltype(MB_CUR_MAX) MB_CUR_MAX_L( locale_t __l );
201#define strtof_l _strtof_l201#define strtof_l _strtof_l
202#define strtold_l _strtold_l202#define strtold_l _strtold_l
203#else203#else
204float strtof_l(const char*, char**, locale_t);204_LIBCPP_FUNC_VIS float strtof_l(const char*, char**, locale_t);
205long double strtold_l(const char*, char**, locale_t);205_LIBCPP_FUNC_VIS long double strtold_l(const char*, char**, locale_t);
206#endif206#endif
207inline _LIBCPP_INLINE_VISIBILITY207inline _LIBCPP_INLINE_VISIBILITY
208int208int
lib/libcxx/include/system_error+2-2
...@@ -253,7 +253,7 @@ public:...@@ -253,7 +253,7 @@ public:
253 template <class _Ep>253 template <class _Ep>
254 _LIBCPP_INLINE_VISIBILITY254 _LIBCPP_INLINE_VISIBILITY
255 error_condition(_Ep __e,255 error_condition(_Ep __e,
256 typename enable_if<is_error_condition_enum<_Ep>::value>::type* = 0256 typename enable_if<is_error_condition_enum<_Ep>::value>::type* = nullptr
257 ) _NOEXCEPT257 ) _NOEXCEPT
258 {*this = make_error_condition(__e);}258 {*this = make_error_condition(__e);}
259259
...@@ -325,7 +325,7 @@ public:...@@ -325,7 +325,7 @@ public:
325 template <class _Ep>325 template <class _Ep>
326 _LIBCPP_INLINE_VISIBILITY326 _LIBCPP_INLINE_VISIBILITY
327 error_code(_Ep __e,327 error_code(_Ep __e,
328 typename enable_if<is_error_code_enum<_Ep>::value>::type* = 0328 typename enable_if<is_error_code_enum<_Ep>::value>::type* = nullptr
329 ) _NOEXCEPT329 ) _NOEXCEPT
330 {*this = make_error_code(__e);}330 {*this = make_error_code(__e);}
331331
lib/libcxx/include/thread+21-24
...@@ -277,18 +277,18 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -277,18 +277,18 @@ inline _LIBCPP_INLINE_VISIBILITY
277void277void
278__thread_execute(tuple<_TSp, _Fp, _Args...>& __t, __tuple_indices<_Indices...>)278__thread_execute(tuple<_TSp, _Fp, _Args...>& __t, __tuple_indices<_Indices...>)
279{279{
280 __invoke(_VSTD::move(_VSTD::get<1>(__t)), _VSTD::move(_VSTD::get<_Indices>(__t))...);280 _VSTD::__invoke(_VSTD::move(_VSTD::get<1>(__t)), _VSTD::move(_VSTD::get<_Indices>(__t))...);
281}281}
282282
283template <class _Fp>283template <class _Fp>
284_LIBCPP_INLINE_VISIBILITY284_LIBCPP_INLINE_VISIBILITY
285void* __thread_proxy(void* __vp)285void* __thread_proxy(void* __vp)
286{286{
287 // _Fp = std::tuple< unique_ptr<__thread_struct>, Functor, Args...>287 // _Fp = tuple< unique_ptr<__thread_struct>, Functor, Args...>
288 std::unique_ptr<_Fp> __p(static_cast<_Fp*>(__vp));288 unique_ptr<_Fp> __p(static_cast<_Fp*>(__vp));
289 __thread_local_data().set_pointer(_VSTD::get<0>(*__p).release());289 __thread_local_data().set_pointer(_VSTD::get<0>(*__p.get()).release());
290 typedef typename __make_tuple_indices<tuple_size<_Fp>::value, 2>::type _Index;290 typedef typename __make_tuple_indices<tuple_size<_Fp>::value, 2>::type _Index;
291 __thread_execute(*__p, _Index());291 _VSTD::__thread_execute(*__p.get(), _Index());
292 return nullptr;292 return nullptr;
293}293}
294294
...@@ -300,11 +300,11 @@ thread::thread(_Fp&& __f, _Args&&... __args)...@@ -300,11 +300,11 @@ thread::thread(_Fp&& __f, _Args&&... __args)
300 typedef unique_ptr<__thread_struct> _TSPtr;300 typedef unique_ptr<__thread_struct> _TSPtr;
301 _TSPtr __tsp(new __thread_struct);301 _TSPtr __tsp(new __thread_struct);
302 typedef tuple<_TSPtr, typename decay<_Fp>::type, typename decay<_Args>::type...> _Gp;302 typedef tuple<_TSPtr, typename decay<_Fp>::type, typename decay<_Args>::type...> _Gp;
303 _VSTD::unique_ptr<_Gp> __p(303 unique_ptr<_Gp> __p(
304 new _Gp(std::move(__tsp),304 new _Gp(_VSTD::move(__tsp),
305 __decay_copy(_VSTD::forward<_Fp>(__f)),305 _VSTD::__decay_copy(_VSTD::forward<_Fp>(__f)),
306 __decay_copy(_VSTD::forward<_Args>(__args))...));306 _VSTD::__decay_copy(_VSTD::forward<_Args>(__args))...));
307 int __ec = __libcpp_thread_create(&__t_, &__thread_proxy<_Gp>, __p.get());307 int __ec = _VSTD::__libcpp_thread_create(&__t_, &__thread_proxy<_Gp>, __p.get());
308 if (__ec == 0)308 if (__ec == 0)
309 __p.release();309 __p.release();
310 else310 else
...@@ -326,7 +326,7 @@ struct __thread_invoke_pair {...@@ -326,7 +326,7 @@ struct __thread_invoke_pair {
326template <class _Fp>326template <class _Fp>
327void* __thread_proxy_cxx03(void* __vp)327void* __thread_proxy_cxx03(void* __vp)
328{328{
329 std::unique_ptr<_Fp> __p(static_cast<_Fp*>(__vp));329 unique_ptr<_Fp> __p(static_cast<_Fp*>(__vp));
330 __thread_local_data().set_pointer(__p->__tsp_.release());330 __thread_local_data().set_pointer(__p->__tsp_.release());
331 (__p->__fn_)();331 (__p->__fn_)();
332 return nullptr;332 return nullptr;
...@@ -337,9 +337,9 @@ thread::thread(_Fp __f)...@@ -337,9 +337,9 @@ thread::thread(_Fp __f)
337{337{
338338
339 typedef __thread_invoke_pair<_Fp> _InvokePair;339 typedef __thread_invoke_pair<_Fp> _InvokePair;
340 typedef std::unique_ptr<_InvokePair> _PairPtr;340 typedef unique_ptr<_InvokePair> _PairPtr;
341 _PairPtr __pp(new _InvokePair(__f));341 _PairPtr __pp(new _InvokePair(__f));
342 int __ec = __libcpp_thread_create(&__t_, &__thread_proxy_cxx03<_InvokePair>, __pp.get());342 int __ec = _VSTD::__libcpp_thread_create(&__t_, &__thread_proxy_cxx03<_InvokePair>, __pp.get());
343 if (__ec == 0)343 if (__ec == 0)
344 __pp.release();344 __pp.release();
345 else345 else
...@@ -360,25 +360,24 @@ template <class _Rep, class _Period>...@@ -360,25 +360,24 @@ template <class _Rep, class _Period>
360void360void
361sleep_for(const chrono::duration<_Rep, _Period>& __d)361sleep_for(const chrono::duration<_Rep, _Period>& __d)
362{362{
363 using namespace chrono;363 if (__d > chrono::duration<_Rep, _Period>::zero())
364 if (__d > duration<_Rep, _Period>::zero())
365 {364 {
366#if defined(_LIBCPP_COMPILER_GCC) && (__powerpc__ || __POWERPC__)365#if defined(_LIBCPP_COMPILER_GCC) && (__powerpc__ || __POWERPC__)
367 // GCC's long double const folding is incomplete for IBM128 long doubles.366 // GCC's long double const folding is incomplete for IBM128 long doubles.
368 _LIBCPP_CONSTEXPR duration<long double> _Max = duration<long double>(ULLONG_MAX/1000000000ULL) ;367 _LIBCPP_CONSTEXPR chrono::duration<long double> _Max = chrono::duration<long double>(ULLONG_MAX/1000000000ULL) ;
369#else368#else
370 _LIBCPP_CONSTEXPR duration<long double> _Max = nanoseconds::max();369 _LIBCPP_CONSTEXPR chrono::duration<long double> _Max = chrono::nanoseconds::max();
371#endif370#endif
372 nanoseconds __ns;371 chrono::nanoseconds __ns;
373 if (__d < _Max)372 if (__d < _Max)
374 {373 {
375 __ns = duration_cast<nanoseconds>(__d);374 __ns = chrono::duration_cast<chrono::nanoseconds>(__d);
376 if (__ns < __d)375 if (__ns < __d)
377 ++__ns;376 ++__ns;
378 }377 }
379 else378 else
380 __ns = nanoseconds::max();379 __ns = chrono::nanoseconds::max();
381 sleep_for(__ns);380 this_thread::sleep_for(__ns);
382 }381 }
383}382}
384383
...@@ -386,7 +385,6 @@ template <class _Clock, class _Duration>...@@ -386,7 +385,6 @@ template <class _Clock, class _Duration>
386void385void
387sleep_until(const chrono::time_point<_Clock, _Duration>& __t)386sleep_until(const chrono::time_point<_Clock, _Duration>& __t)
388{387{
389 using namespace chrono;
390 mutex __mut;388 mutex __mut;
391 condition_variable __cv;389 condition_variable __cv;
392 unique_lock<mutex> __lk(__mut);390 unique_lock<mutex> __lk(__mut);
...@@ -399,8 +397,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -399,8 +397,7 @@ inline _LIBCPP_INLINE_VISIBILITY
399void397void
400sleep_until(const chrono::time_point<chrono::steady_clock, _Duration>& __t)398sleep_until(const chrono::time_point<chrono::steady_clock, _Duration>& __t)
401{399{
402 using namespace chrono;400 this_thread::sleep_for(__t - chrono::steady_clock::now());
403 sleep_for(__t - steady_clock::now());
404}401}
405402
406inline _LIBCPP_INLINE_VISIBILITY403inline _LIBCPP_INLINE_VISIBILITY
lib/libcxx/include/tuple+1-1
...@@ -1393,7 +1393,7 @@ struct _LIBCPP_TEMPLATE_VIS uses_allocator<tuple<_Tp...>, _Alloc>...@@ -1393,7 +1393,7 @@ struct _LIBCPP_TEMPLATE_VIS uses_allocator<tuple<_Tp...>, _Alloc>
13931393
1394template <class _T1, class _T2>1394template <class _T1, class _T2>
1395template <class... _Args1, class... _Args2, size_t ..._I1, size_t ..._I2>1395template <class... _Args1, class... _Args2, size_t ..._I1, size_t ..._I2>
1396inline _LIBCPP_INLINE_VISIBILITY1396inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1397pair<_T1, _T2>::pair(piecewise_construct_t,1397pair<_T1, _T2>::pair(piecewise_construct_t,
1398 tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,1398 tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
1399 __tuple_indices<_I1...>, __tuple_indices<_I2...>)1399 __tuple_indices<_I1...>, __tuple_indices<_I2...>)
lib/libcxx/include/type_traits+93-238
...@@ -514,7 +514,7 @@ template <template <class...> class, class ...>...@@ -514,7 +514,7 @@ template <template <class...> class, class ...>
514false_type __sfinae_test_impl(...);514false_type __sfinae_test_impl(...);
515515
516template <template <class ...> class _Templ, class ..._Args>516template <template <class ...> class _Templ, class ..._Args>
517using _IsValidExpansion _LIBCPP_NODEBUG_TYPE = decltype(std::__sfinae_test_impl<_Templ, _Args...>(0));517using _IsValidExpansion _LIBCPP_NODEBUG_TYPE = decltype(__sfinae_test_impl<_Templ, _Args...>(0));
518518
519template <class>519template <class>
520struct __void_t { typedef void type; };520struct __void_t { typedef void type; };
...@@ -595,75 +595,6 @@ using __is_primary_template = _IsValidExpansion<...@@ -595,75 +595,6 @@ using __is_primary_template = _IsValidExpansion<
595 __test_for_primary_template, _Tp595 __test_for_primary_template, _Tp
596 >;596 >;
597597
598// addressof
599#ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
600
601template <class _Tp>
602inline _LIBCPP_CONSTEXPR_AFTER_CXX14
603_LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
604_Tp*
605addressof(_Tp& __x) _NOEXCEPT
606{
607 return __builtin_addressof(__x);
608}
609
610#else
611
612template <class _Tp>
613inline _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
614_Tp*
615addressof(_Tp& __x) _NOEXCEPT
616{
617 return reinterpret_cast<_Tp *>(
618 const_cast<char *>(&reinterpret_cast<const volatile char &>(__x)));
619}
620
621#endif // _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
622
623#if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF)
624// Objective-C++ Automatic Reference Counting uses qualified pointers
625// that require special addressof() signatures. When
626// _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler
627// itself is providing these definitions. Otherwise, we provide them.
628template <class _Tp>
629inline _LIBCPP_INLINE_VISIBILITY
630__strong _Tp*
631addressof(__strong _Tp& __x) _NOEXCEPT
632{
633 return &__x;
634}
635
636#ifdef _LIBCPP_HAS_OBJC_ARC_WEAK
637template <class _Tp>
638inline _LIBCPP_INLINE_VISIBILITY
639__weak _Tp*
640addressof(__weak _Tp& __x) _NOEXCEPT
641{
642 return &__x;
643}
644#endif
645
646template <class _Tp>
647inline _LIBCPP_INLINE_VISIBILITY
648__autoreleasing _Tp*
649addressof(__autoreleasing _Tp& __x) _NOEXCEPT
650{
651 return &__x;
652}
653
654template <class _Tp>
655inline _LIBCPP_INLINE_VISIBILITY
656__unsafe_unretained _Tp*
657addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT
658{
659 return &__x;
660}
661#endif
662
663#if !defined(_LIBCPP_CXX03_LANG)
664template <class _Tp> _Tp* addressof(const _Tp&&) noexcept = delete;
665#endif
666
667struct __two {char __lx[2];};598struct __two {char __lx[2];};
668599
669// helper class:600// helper class:
...@@ -1821,7 +1752,7 @@ template <typename _Tp>...@@ -1821,7 +1752,7 @@ template <typename _Tp>
1821static void __test_noexcept(_Tp) noexcept;1752static void __test_noexcept(_Tp) noexcept;
18221753
1823template<typename _Fm, typename _To>1754template<typename _Fm, typename _To>
1824static bool_constant<noexcept(__test_noexcept<_To>(declval<_Fm>()))>1755static bool_constant<noexcept(_VSTD::__test_noexcept<_To>(declval<_Fm>()))>
1825__is_nothrow_convertible_test();1756__is_nothrow_convertible_test();
18261757
1827template <typename _Fm, typename _To>1758template <typename _Fm, typename _To>
...@@ -2550,7 +2481,7 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_destructible_v = __is_destructible(...@@ -2550,7 +2481,7 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_destructible_v = __is_destructible(
2550// if it's a function, return false2481// if it's a function, return false
2551// if it's void, return false2482// if it's void, return false
2552// if it's an array of unknown bound, return false2483// if it's an array of unknown bound, return false
2553// Otherwise, return "std::declval<_Up&>().~_Up()" is well-formed2484// Otherwise, return "declval<_Up&>().~_Up()" is well-formed
2554// where _Up is remove_all_extents<_Tp>::type2485// where _Up is remove_all_extents<_Tp>::type
25552486
2556template <class>2487template <class>
...@@ -2876,167 +2807,13 @@ struct __member_pointer_class_type<_Ret _ClassType::*> {...@@ -2876,167 +2807,13 @@ struct __member_pointer_class_type<_Ret _ClassType::*> {
2876 typedef _ClassType type;2807 typedef _ClassType type;
2877};2808};
28782809
2879// result_of
2880
2881template <class _Callable> class result_of;
2882
2883#ifdef _LIBCPP_HAS_NO_VARIADICS
2884
2885template <class _Fn, bool, bool>
2886class __result_of
2887{
2888};
2889
2890template <class _Fn>
2891class __result_of<_Fn(), true, false>
2892{
2893public:
2894 typedef decltype(declval<_Fn>()()) type;
2895};
2896
2897template <class _Fn, class _A0>
2898class __result_of<_Fn(_A0), true, false>
2899{
2900public:
2901 typedef decltype(declval<_Fn>()(declval<_A0>())) type;
2902};
2903
2904template <class _Fn, class _A0, class _A1>
2905class __result_of<_Fn(_A0, _A1), true, false>
2906{
2907public:
2908 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type;
2909};
2910
2911template <class _Fn, class _A0, class _A1, class _A2>
2912class __result_of<_Fn(_A0, _A1, _A2), true, false>
2913{
2914public:
2915 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type;
2916};
2917
2918template <class _MP, class _Tp, bool _IsMemberFunctionPtr>
2919struct __result_of_mp;
2920
2921// member function pointer
2922
2923template <class _MP, class _Tp>
2924struct __result_of_mp<_MP, _Tp, true>
2925 : public __identity<typename __member_pointer_traits<_MP>::_ReturnType>
2926{
2927};
2928
2929// member data pointer
2930
2931template <class _MP, class _Tp, bool>
2932struct __result_of_mdp;
2933
2934template <class _Rp, class _Class, class _Tp>
2935struct __result_of_mdp<_Rp _Class::*, _Tp, false>
2936{
2937 typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type;
2938};
2939
2940template <class _Rp, class _Class, class _Tp>
2941struct __result_of_mdp<_Rp _Class::*, _Tp, true>
2942{
2943 typedef typename __apply_cv<_Tp, _Rp>::type& type;
2944};
2945
2946template <class _Rp, class _Class, class _Tp>
2947struct __result_of_mp<_Rp _Class::*, _Tp, false>
2948 : public __result_of_mdp<_Rp _Class::*, _Tp,
2949 is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
2950{
2951};
2952
2953
2954
2955template <class _Fn, class _Tp>
2956class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer
2957 : public __result_of_mp<typename remove_reference<_Fn>::type,
2958 _Tp,
2959 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2960{
2961};
2962
2963template <class _Fn, class _Tp, class _A0>
2964class __result_of<_Fn(_Tp, _A0), false, true> // _Fn must be member pointer
2965 : public __result_of_mp<typename remove_reference<_Fn>::type,
2966 _Tp,
2967 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2968{
2969};
2970
2971template <class _Fn, class _Tp, class _A0, class _A1>
2972class __result_of<_Fn(_Tp, _A0, _A1), false, true> // _Fn must be member pointer
2973 : public __result_of_mp<typename remove_reference<_Fn>::type,
2974 _Tp,
2975 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2976{
2977};
2978
2979template <class _Fn, class _Tp, class _A0, class _A1, class _A2>
2980class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true> // _Fn must be member pointer
2981 : public __result_of_mp<typename remove_reference<_Fn>::type,
2982 _Tp,
2983 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2984{
2985};
2986
2987// result_of
2988
2989template <class _Fn>
2990class _LIBCPP_TEMPLATE_VIS result_of<_Fn()>
2991 : public __result_of<_Fn(),
2992 is_class<typename remove_reference<_Fn>::type>::value ||
2993 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2994 is_member_pointer<typename remove_reference<_Fn>::type>::value
2995 >
2996{
2997};
2998
2999template <class _Fn, class _A0>
3000class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0)>
3001 : public __result_of<_Fn(_A0),
3002 is_class<typename remove_reference<_Fn>::type>::value ||
3003 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
3004 is_member_pointer<typename remove_reference<_Fn>::type>::value
3005 >
3006{
3007};
3008
3009template <class _Fn, class _A0, class _A1>
3010class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1)>
3011 : public __result_of<_Fn(_A0, _A1),
3012 is_class<typename remove_reference<_Fn>::type>::value ||
3013 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
3014 is_member_pointer<typename remove_reference<_Fn>::type>::value
3015 >
3016{
3017};
3018
3019template <class _Fn, class _A0, class _A1, class _A2>
3020class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1, _A2)>
3021 : public __result_of<_Fn(_A0, _A1, _A2),
3022 is_class<typename remove_reference<_Fn>::type>::value ||
3023 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
3024 is_member_pointer<typename remove_reference<_Fn>::type>::value
3025 >
3026{
3027};
3028
3029#endif // _LIBCPP_HAS_NO_VARIADICS
3030
3031// template <class T, class... Args> struct is_constructible;2810// template <class T, class... Args> struct is_constructible;
30322811
3033namespace __is_construct2812#if defined(_LIBCPP_COMPILER_GCC) && _GNUC_VER_NEW >= 10000
3034{2813# define _LIBCPP_GCC_SUPPORTS_IS_CONSTRUCTIBLE
3035struct __nat {};2814#endif
3036}
30372815
3038#if !defined(_LIBCPP_CXX03_LANG) && (!__has_feature(is_constructible) || \2816#if !defined(_LIBCPP_CXX03_LANG) && !__has_feature(is_constructible) && !defined(_LIBCPP_GCC_SUPPORTS_IS_CONSTRUCTIBLE)
3039 defined(_LIBCPP_TESTING_FALLBACK_IS_CONSTRUCTIBLE))
30402817
3041template <class _Tp, class... _Args>2818template <class _Tp, class... _Args>
3042struct __libcpp_is_constructible;2819struct __libcpp_is_constructible;
...@@ -3151,7 +2928,7 @@ struct __libcpp_is_constructible<_Tp&&, _A0>...@@ -3151,7 +2928,7 @@ struct __libcpp_is_constructible<_Tp&&, _A0>
31512928
3152#endif2929#endif
31532930
3154#if __has_feature(is_constructible)2931#if __has_feature(is_constructible) || defined(_LIBCPP_GCC_SUPPORTS_IS_CONSTRUCTIBLE)
3155template <class _Tp, class ..._Args>2932template <class _Tp, class ..._Args>
3156struct _LIBCPP_TEMPLATE_VIS is_constructible2933struct _LIBCPP_TEMPLATE_VIS is_constructible
3157 : public integral_constant<bool, __is_constructible(_Tp, _Args...)>2934 : public integral_constant<bool, __is_constructible(_Tp, _Args...)>
...@@ -3442,7 +3219,7 @@ void __implicit_conversion_to(_Tp) noexcept { }...@@ -3442,7 +3219,7 @@ void __implicit_conversion_to(_Tp) noexcept { }
34423219
3443template <class _Tp, class _Arg>3220template <class _Tp, class _Arg>
3444struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg>3221struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg>
3445 : public integral_constant<bool, noexcept(__implicit_conversion_to<_Tp>(declval<_Arg>()))>3222 : public integral_constant<bool, noexcept(_VSTD::__implicit_conversion_to<_Tp>(declval<_Arg>()))>
3446{3223{
3447};3224};
34483225
...@@ -3982,14 +3759,97 @@ struct __invoke_of...@@ -3982,14 +3759,97 @@ struct __invoke_of
3982{3759{
3983};3760};
39843761
3762#endif // _LIBCPP_CXX03_LANG
3763
3985// result_of3764// result_of
39863765
3766template <class _Callable> class result_of;
3767
3768#ifndef _LIBCPP_CXX03_LANG
3769
3987template <class _Fp, class ..._Args>3770template <class _Fp, class ..._Args>
3988class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)>3771class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)>
3989 : public __invoke_of<_Fp, _Args...>3772 : public __invoke_of<_Fp, _Args...>
3990{3773{
3991};3774};
39923775
3776#else // C++03
3777
3778template <class _Fn, bool, bool>
3779class __result_of
3780{
3781};
3782
3783template <class _Fn, class ..._Args>
3784class __result_of<_Fn(_Args...), true, false>
3785{
3786public:
3787 typedef decltype(declval<_Fn>()(declval<_Args>()...)) type;
3788};
3789
3790template <class _MP, class _Tp, bool _IsMemberFunctionPtr>
3791struct __result_of_mp;
3792
3793// member function pointer
3794
3795template <class _MP, class _Tp>
3796struct __result_of_mp<_MP, _Tp, true>
3797 : public __identity<typename __member_pointer_traits<_MP>::_ReturnType>
3798{
3799};
3800
3801// member data pointer
3802
3803template <class _MP, class _Tp, bool>
3804struct __result_of_mdp;
3805
3806template <class _Rp, class _Class, class _Tp>
3807struct __result_of_mdp<_Rp _Class::*, _Tp, false>
3808{
3809 typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type;
3810};
3811
3812template <class _Rp, class _Class, class _Tp>
3813struct __result_of_mdp<_Rp _Class::*, _Tp, true>
3814{
3815 typedef typename __apply_cv<_Tp, _Rp>::type& type;
3816};
3817
3818template <class _Rp, class _Class, class _Tp>
3819struct __result_of_mp<_Rp _Class::*, _Tp, false>
3820 : public __result_of_mdp<_Rp _Class::*, _Tp,
3821 is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
3822{
3823};
3824
3825template <class _Fn, class _Tp>
3826class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer
3827 : public __result_of_mp<typename remove_reference<_Fn>::type,
3828 _Tp,
3829 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
3830{
3831};
3832
3833template <class _Fn, class _Tp, class ..._Args>
3834class __result_of<_Fn(_Tp, _Args...), false, true> // _Fn must be member pointer
3835 : public __result_of_mp<typename remove_reference<_Fn>::type,
3836 _Tp,
3837 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
3838{
3839};
3840
3841template <class _Fn, class ..._Args>
3842class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_Args...)>
3843 : public __result_of<_Fn(_Args...),
3844 is_class<typename remove_reference<_Fn>::type>::value ||
3845 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
3846 is_member_pointer<typename remove_reference<_Fn>::type>::value
3847 >
3848{
3849};
3850
3851#endif // C++03
3852
3993#if _LIBCPP_STD_VER > 113853#if _LIBCPP_STD_VER > 11
3994template <class _Tp> using result_of_t = typename result_of<_Tp>::type;3854template <class _Tp> using result_of_t = typename result_of<_Tp>::type;
3995#endif3855#endif
...@@ -4045,8 +3905,6 @@ _LIBCPP_INLINE_VAR constexpr bool is_nothrow_invocable_r_v...@@ -4045,8 +3905,6 @@ _LIBCPP_INLINE_VAR constexpr bool is_nothrow_invocable_r_v
40453905
4046#endif // _LIBCPP_STD_VER > 143906#endif // _LIBCPP_STD_VER > 14
40473907
4048#endif // !defined(_LIBCPP_CXX03_LANG)
4049
4050template <class _Tp> struct __is_swappable;3908template <class _Tp> struct __is_swappable;
4051template <class _Tp> struct __is_nothrow_swappable;3909template <class _Tp> struct __is_nothrow_swappable;
40523910
...@@ -4341,7 +4199,6 @@ _LIBCPP_INLINE_VAR constexpr bool negation_v...@@ -4341,7 +4199,6 @@ _LIBCPP_INLINE_VAR constexpr bool negation_v
4341#endif // _LIBCPP_STD_VER > 144199#endif // _LIBCPP_STD_VER > 14
43424200
4343// These traits are used in __tree and __hash_table4201// These traits are used in __tree and __hash_table
4344#ifndef _LIBCPP_CXX03_LANG
4345struct __extract_key_fail_tag {};4202struct __extract_key_fail_tag {};
4346struct __extract_key_self_tag {};4203struct __extract_key_self_tag {};
4347struct __extract_key_first_tag {};4204struct __extract_key_first_tag {};
...@@ -4353,7 +4210,7 @@ struct __can_extract_key...@@ -4353,7 +4210,7 @@ struct __can_extract_key
4353 __extract_key_fail_tag>::type {};4210 __extract_key_fail_tag>::type {};
43544211
4355template <class _Pair, class _Key, class _First, class _Second>4212template <class _Pair, class _Key, class _First, class _Second>
4356struct __can_extract_key<_Pair, _Key, pair<_First, _Second>>4213struct __can_extract_key<_Pair, _Key, pair<_First, _Second> >
4357 : conditional<_IsSame<typename remove_const<_First>::type, _Key>::value,4214 : conditional<_IsSame<typename remove_const<_First>::type, _Key>::value,
4358 __extract_key_first_tag, __extract_key_fail_tag>::type {};4215 __extract_key_first_tag, __extract_key_fail_tag>::type {};
43594216
...@@ -4371,8 +4228,6 @@ template <class _ValTy, class _Key, class _RawValTy>...@@ -4371,8 +4228,6 @@ template <class _ValTy, class _Key, class _RawValTy>
4371struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy>4228struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy>
4372 : false_type {};4229 : false_type {};
43734230
4374#endif
4375
4376#ifndef _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED4231#ifndef _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED
4377#if _LIBCPP_STD_VER > 174232#if _LIBCPP_STD_VER > 17
4378_LIBCPP_INLINE_VISIBILITY4233_LIBCPP_INLINE_VISIBILITY
lib/libcxx/include/typeinfo+24-5
...@@ -57,6 +57,7 @@ public:...@@ -57,6 +57,7 @@ public:
57*/57*/
5858
59#include <__config>59#include <__config>
60#include <__availability>
60#include <exception>61#include <exception>
61#include <cstddef>62#include <cstddef>
62#include <cstdint>63#include <cstdint>
...@@ -141,7 +142,7 @@ public:...@@ -141,7 +142,7 @@ public:
141// comparison is equal.142// comparison is equal.
142// -------------------------------------------------------------------------- //143// -------------------------------------------------------------------------- //
143// NonUniqueARMRTTIBit144// NonUniqueARMRTTIBit
144// (selected on ARM64 regardless of _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION)145// (_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION = 3)
145// -------------------------------------------------------------------------- //146// -------------------------------------------------------------------------- //
146// This implementation of type_info does not assume always a unique copy of147// This implementation of type_info does not assume always a unique copy of
147// the RTTI for a given type inside a program. It packs the pointer to the148// the RTTI for a given type inside a program. It packs the pointer to the
...@@ -160,6 +161,24 @@ public:...@@ -160,6 +161,24 @@ public:
160// the pointer when it constructs the type_info, depending on whether it can161// the pointer when it constructs the type_info, depending on whether it can
161// guarantee uniqueness for that specific type_info.162// guarantee uniqueness for that specific type_info.
162163
164// This value can be overriden in the __config_site. When it's not overriden,
165// we pick a default implementation based on the platform here.
166#ifndef _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION
167
168 // Windows binaries can't merge typeinfos, so use the NonUnique implementation.
169# ifdef _LIBCPP_OBJECT_FORMAT_COFF
170# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 2
171
172 // On arm64 on Apple platforms, use the special NonUniqueARMRTTIBit implementation.
173# elif defined(__APPLE__) && defined(__LP64__) && !defined(__x86_64__)
174# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 3
175
176 // On all other platforms, assume the Itanium C++ ABI and use the Unique implementation.
177# else
178# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 1
179# endif
180#endif
181
163struct __type_info_implementations {182struct __type_info_implementations {
164 struct __string_impl_base {183 struct __string_impl_base {
165 typedef const char* __type_name_t;184 typedef const char* __type_name_t;
...@@ -243,7 +262,7 @@ struct __type_info_implementations {...@@ -243,7 +262,7 @@ struct __type_info_implementations {
243 private:262 private:
244 // The unique bit is the top bit. It is expected that __type_name_t is 64 bits when263 // The unique bit is the top bit. It is expected that __type_name_t is 64 bits when
245 // this implementation is actually used.264 // this implementation is actually used.
246 typedef std::integral_constant<__type_name_t,265 typedef integral_constant<__type_name_t,
247 (1ULL << ((__CHAR_BIT__ * sizeof(__type_name_t)) - 1))> __non_unique_rtti_bit;266 (1ULL << ((__CHAR_BIT__ * sizeof(__type_name_t)) - 1))> __non_unique_rtti_bit;
248267
249 _LIBCPP_INLINE_VISIBILITY268 _LIBCPP_INLINE_VISIBILITY
...@@ -257,12 +276,12 @@ struct __type_info_implementations {...@@ -257,12 +276,12 @@ struct __type_info_implementations {
257 };276 };
258277
259 typedef278 typedef
260#if defined(__APPLE__) && defined(__LP64__) && !defined(__x86_64__)279#if _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 1
261 __non_unique_arm_rtti_bit_impl
262#elif _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 1
263 __unique_impl280 __unique_impl
264#elif _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 2281#elif _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 2
265 __non_unique_impl282 __non_unique_impl
283#elif _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 3
284 __non_unique_arm_rtti_bit_impl
266#else285#else
267# error invalid configuration for _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION286# error invalid configuration for _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION
268#endif287#endif
lib/libcxx/include/unordered_map+203-67
...@@ -173,10 +173,22 @@ public:...@@ -173,10 +173,22 @@ public:
173173
174 iterator find(const key_type& k);174 iterator find(const key_type& k);
175 const_iterator find(const key_type& k) const;175 const_iterator find(const key_type& k) const;
176 template<typename K>
177 iterator find(const K& x); // C++20
178 template<typename K>
179 const_iterator find(const K& x) const; // C++20
176 size_type count(const key_type& k) const;180 size_type count(const key_type& k) const;
181 template<typename K>
182 size_type count(const K& k) const; // C++20
177 bool contains(const key_type& k) const; // C++20183 bool contains(const key_type& k) const; // C++20
184 template<typename K>
185 bool contains(const K& k) const; // C++20
178 pair<iterator, iterator> equal_range(const key_type& k);186 pair<iterator, iterator> equal_range(const key_type& k);
179 pair<const_iterator, const_iterator> equal_range(const key_type& k) const;187 pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
188 template<typename K>
189 pair<iterator, iterator> equal_range(const K& k); // C++20
190 template<typename K>
191 pair<const_iterator, const_iterator> equal_range(const K& k) const; // C++20
180192
181 mapped_type& operator[](const key_type& k);193 mapped_type& operator[](const key_type& k);
182 mapped_type& operator[](key_type&& k);194 mapped_type& operator[](key_type&& k);
...@@ -355,10 +367,22 @@ public:...@@ -355,10 +367,22 @@ public:
355367
356 iterator find(const key_type& k);368 iterator find(const key_type& k);
357 const_iterator find(const key_type& k) const;369 const_iterator find(const key_type& k) const;
370 template<typename K>
371 iterator find(const K& x); // C++20
372 template<typename K>
373 const_iterator find(const K& x) const; // C++20
358 size_type count(const key_type& k) const;374 size_type count(const key_type& k) const;
375 template<typename K>
376 size_type count(const K& k) const; // C++20
359 bool contains(const key_type& k) const; // C++20377 bool contains(const key_type& k) const; // C++20
378 template<typename K>
379 bool contains(const K& k) const; // C++20
360 pair<iterator, iterator> equal_range(const key_type& k);380 pair<iterator, iterator> equal_range(const key_type& k);
361 pair<const_iterator, const_iterator> equal_range(const key_type& k) const;381 pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
382 template<typename K>
383 pair<iterator, iterator> equal_range(const K& k); // C++20
384 template<typename K>
385 pair<const_iterator, const_iterator> equal_range(const K& k) const; // C++20
362386
363 size_type bucket_count() const noexcept;387 size_type bucket_count() const noexcept;
364 size_type max_bucket_count() const noexcept;388 size_type max_bucket_count() const noexcept;
...@@ -423,7 +447,7 @@ template <class Key, class T, class Hash, class Pred, class Alloc>...@@ -423,7 +447,7 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
423447
424_LIBCPP_BEGIN_NAMESPACE_STD448_LIBCPP_BEGIN_NAMESPACE_STD
425449
426template <class _Key, class _Cp, class _Hash,450template <class _Key, class _Cp, class _Hash, class _Pred,
427 bool = is_empty<_Hash>::value && !__libcpp_is_final<_Hash>::value>451 bool = is_empty<_Hash>::value && !__libcpp_is_final<_Hash>::value>
428class __unordered_map_hasher452class __unordered_map_hasher
429 : private _Hash453 : private _Hash
...@@ -445,6 +469,12 @@ public:...@@ -445,6 +469,12 @@ public:
445 _LIBCPP_INLINE_VISIBILITY469 _LIBCPP_INLINE_VISIBILITY
446 size_t operator()(const _Key& __x) const470 size_t operator()(const _Key& __x) const
447 {return static_cast<const _Hash&>(*this)(__x);}471 {return static_cast<const _Hash&>(*this)(__x);}
472#if _LIBCPP_STD_VER > 17
473 template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
474 _LIBCPP_INLINE_VISIBILITY
475 size_t operator()(const _K2& __x) const
476 {return static_cast<const _Hash&>(*this)(__x);}
477#endif
448 void swap(__unordered_map_hasher&__y)478 void swap(__unordered_map_hasher&__y)
449 _NOEXCEPT_(__is_nothrow_swappable<_Hash>::value)479 _NOEXCEPT_(__is_nothrow_swappable<_Hash>::value)
450 {480 {
...@@ -453,8 +483,8 @@ public:...@@ -453,8 +483,8 @@ public:
453 }483 }
454};484};
455485
456template <class _Key, class _Cp, class _Hash>486template <class _Key, class _Cp, class _Hash, class _Pred>
457class __unordered_map_hasher<_Key, _Cp, _Hash, false>487class __unordered_map_hasher<_Key, _Cp, _Hash, _Pred, false>
458{488{
459 _Hash __hash_;489 _Hash __hash_;
460public:490public:
...@@ -474,6 +504,12 @@ public:...@@ -474,6 +504,12 @@ public:
474 _LIBCPP_INLINE_VISIBILITY504 _LIBCPP_INLINE_VISIBILITY
475 size_t operator()(const _Key& __x) const505 size_t operator()(const _Key& __x) const
476 {return __hash_(__x);}506 {return __hash_(__x);}
507#if _LIBCPP_STD_VER > 17
508 template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
509 _LIBCPP_INLINE_VISIBILITY
510 size_t operator()(const _K2& __x) const
511 {return __hash_(__x);}
512#endif
477 void swap(__unordered_map_hasher&__y)513 void swap(__unordered_map_hasher&__y)
478 _NOEXCEPT_(__is_nothrow_swappable<_Hash>::value)514 _NOEXCEPT_(__is_nothrow_swappable<_Hash>::value)
479 {515 {
...@@ -482,17 +518,17 @@ public:...@@ -482,17 +518,17 @@ public:
482 }518 }
483};519};
484520
485template <class _Key, class _Cp, class _Hash, bool __b>521template <class _Key, class _Cp, class _Hash, class _Pred, bool __b>
486inline _LIBCPP_INLINE_VISIBILITY522inline _LIBCPP_INLINE_VISIBILITY
487void523void
488swap(__unordered_map_hasher<_Key, _Cp, _Hash, __b>& __x,524swap(__unordered_map_hasher<_Key, _Cp, _Hash, _Pred, __b>& __x,
489 __unordered_map_hasher<_Key, _Cp, _Hash, __b>& __y)525 __unordered_map_hasher<_Key, _Cp, _Hash, _Pred, __b>& __y)
490 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))526 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
491{527{
492 __x.swap(__y);528 __x.swap(__y);
493}529}
494530
495template <class _Key, class _Cp, class _Pred,531template <class _Key, class _Cp, class _Pred, class _Hash,
496 bool = is_empty<_Pred>::value && !__libcpp_is_final<_Pred>::value>532 bool = is_empty<_Pred>::value && !__libcpp_is_final<_Pred>::value>
497class __unordered_map_equal533class __unordered_map_equal
498 : private _Pred534 : private _Pred
...@@ -517,6 +553,24 @@ public:...@@ -517,6 +553,24 @@ public:
517 _LIBCPP_INLINE_VISIBILITY553 _LIBCPP_INLINE_VISIBILITY
518 bool operator()(const _Key& __x, const _Cp& __y) const554 bool operator()(const _Key& __x, const _Cp& __y) const
519 {return static_cast<const _Pred&>(*this)(__x, __y.__get_value().first);}555 {return static_cast<const _Pred&>(*this)(__x, __y.__get_value().first);}
556#if _LIBCPP_STD_VER > 17
557 template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
558 _LIBCPP_INLINE_VISIBILITY
559 bool operator()(const _Cp& __x, const _K2& __y) const
560 {return static_cast<const _Pred&>(*this)(__x.__get_value().first, __y);}
561 template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
562 _LIBCPP_INLINE_VISIBILITY
563 bool operator()(const _K2& __x, const _Cp& __y) const
564 {return static_cast<const _Pred&>(*this)(__x, __y.__get_value().first);}
565 template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
566 _LIBCPP_INLINE_VISIBILITY
567 bool operator()(const _Key& __x, const _K2& __y) const
568 {return static_cast<const _Pred&>(*this)(__x, __y);}
569 template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
570 _LIBCPP_INLINE_VISIBILITY
571 bool operator()(const _K2& __x, const _Key& __y) const
572 {return static_cast<const _Pred&>(*this)(__x, __y);}
573#endif
520 void swap(__unordered_map_equal&__y)574 void swap(__unordered_map_equal&__y)
521 _NOEXCEPT_(__is_nothrow_swappable<_Pred>::value)575 _NOEXCEPT_(__is_nothrow_swappable<_Pred>::value)
522 {576 {
...@@ -525,8 +579,8 @@ public:...@@ -525,8 +579,8 @@ public:
525 }579 }
526};580};
527581
528template <class _Key, class _Cp, class _Pred>582template <class _Key, class _Cp, class _Pred, class _Hash>
529class __unordered_map_equal<_Key, _Cp, _Pred, false>583class __unordered_map_equal<_Key, _Cp, _Pred, _Hash, false>
530{584{
531 _Pred __pred_;585 _Pred __pred_;
532public:586public:
...@@ -549,6 +603,24 @@ public:...@@ -549,6 +603,24 @@ public:
549 _LIBCPP_INLINE_VISIBILITY603 _LIBCPP_INLINE_VISIBILITY
550 bool operator()(const _Key& __x, const _Cp& __y) const604 bool operator()(const _Key& __x, const _Cp& __y) const
551 {return __pred_(__x, __y.__get_value().first);}605 {return __pred_(__x, __y.__get_value().first);}
606#if _LIBCPP_STD_VER > 17
607 template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
608 _LIBCPP_INLINE_VISIBILITY
609 bool operator()(const _Cp& __x, const _K2& __y) const
610 {return __pred_(__x.__get_value().first, __y);}
611 template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
612 _LIBCPP_INLINE_VISIBILITY
613 bool operator()(const _K2& __x, const _Cp& __y) const
614 {return __pred_(__x, __y.__get_value().first);}
615 template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
616 _LIBCPP_INLINE_VISIBILITY
617 bool operator()(const _Key& __x, const _K2& __y) const
618 {return __pred_(__x, __y);}
619 template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
620 _LIBCPP_INLINE_VISIBILITY
621 bool operator()(const _K2& __x, const _Key& __y) const
622 {return __pred_(__x, __y);}
623#endif
552 void swap(__unordered_map_equal&__y)624 void swap(__unordered_map_equal&__y)
553 _NOEXCEPT_(__is_nothrow_swappable<_Pred>::value)625 _NOEXCEPT_(__is_nothrow_swappable<_Pred>::value)
554 {626 {
...@@ -557,11 +629,11 @@ public:...@@ -557,11 +629,11 @@ public:
557 }629 }
558};630};
559631
560template <class _Key, class _Cp, class _Pred, bool __b>632template <class _Key, class _Cp, class _Pred, class _Hash, bool __b>
561inline _LIBCPP_INLINE_VISIBILITY633inline _LIBCPP_INLINE_VISIBILITY
562void634void
563swap(__unordered_map_equal<_Key, _Cp, _Pred, __b>& __x,635swap(__unordered_map_equal<_Key, _Cp, _Pred, _Hash, __b>& __x,
564 __unordered_map_equal<_Key, _Cp, _Pred, __b>& __y)636 __unordered_map_equal<_Key, _Cp, _Pred, _Hash, __b>& __y)
565 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))637 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
566{638{
567 __x.swap(__y);639 __x.swap(__y);
...@@ -858,11 +930,11 @@ public:...@@ -858,11 +930,11 @@ public:
858 "Invalid allocator::value_type");930 "Invalid allocator::value_type");
859931
860private:932private:
861 typedef __hash_value_type<key_type, mapped_type> __value_type;933 typedef __hash_value_type<key_type, mapped_type> __value_type;
862 typedef __unordered_map_hasher<key_type, __value_type, hasher> __hasher;934 typedef __unordered_map_hasher<key_type, __value_type, hasher, key_equal> __hasher;
863 typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal;935 typedef __unordered_map_equal<key_type, __value_type, key_equal, hasher> __key_equal;
864 typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,936 typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
865 __value_type>::type __allocator_type;937 __value_type>::type __allocator_type;
866938
867 typedef __hash_table<__value_type, __hasher,939 typedef __hash_table<__value_type, __hasher,
868 __key_equal, __allocator_type> __table;940 __key_equal, __allocator_type> __table;
...@@ -906,7 +978,7 @@ public:...@@ -906,7 +978,7 @@ public:
906 unordered_map()978 unordered_map()
907 _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)979 _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
908 {980 {
909#if _LIBCPP_DEBUG_LEVEL >= 2981#if _LIBCPP_DEBUG_LEVEL == 2
910 __get_db()->__insert_c(this);982 __get_db()->__insert_c(this);
911#endif983#endif
912 }984 }
...@@ -1025,7 +1097,7 @@ public:...@@ -1025,7 +1097,7 @@ public:
1025 {return __table_.__insert_unique(__x);}1097 {return __table_.__insert_unique(__x);}
10261098
1027 iterator insert(const_iterator __p, const value_type& __x) {1099 iterator insert(const_iterator __p, const value_type& __x) {
1028#if _LIBCPP_DEBUG_LEVEL >= 21100#if _LIBCPP_DEBUG_LEVEL == 2
1029 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,1101 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
1030 "unordered_map::insert(const_iterator, const value_type&) called with an iterator not"1102 "unordered_map::insert(const_iterator, const value_type&) called with an iterator not"
1031 " referring to this unordered_map");1103 " referring to this unordered_map");
...@@ -1049,7 +1121,7 @@ public:...@@ -1049,7 +1121,7 @@ public:
1049 {return __table_.__insert_unique(_VSTD::move(__x));}1121 {return __table_.__insert_unique(_VSTD::move(__x));}
10501122
1051 iterator insert(const_iterator __p, value_type&& __x) {1123 iterator insert(const_iterator __p, value_type&& __x) {
1052#if _LIBCPP_DEBUG_LEVEL >= 21124#if _LIBCPP_DEBUG_LEVEL == 2
1053 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,1125 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
1054 "unordered_map::insert(const_iterator, const value_type&) called with an iterator not"1126 "unordered_map::insert(const_iterator, const value_type&) called with an iterator not"
1055 " referring to this unordered_map");1127 " referring to this unordered_map");
...@@ -1070,7 +1142,7 @@ public:...@@ -1070,7 +1142,7 @@ public:
1070 _LIBCPP_INLINE_VISIBILITY1142 _LIBCPP_INLINE_VISIBILITY
1071 iterator insert(const_iterator __p, _Pp&& __x)1143 iterator insert(const_iterator __p, _Pp&& __x)
1072 {1144 {
1073#if _LIBCPP_DEBUG_LEVEL >= 21145#if _LIBCPP_DEBUG_LEVEL == 2
1074 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,1146 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
1075 "unordered_map::insert(const_iterator, value_type&&) called with an iterator not"1147 "unordered_map::insert(const_iterator, value_type&&) called with an iterator not"
1076 " referring to this unordered_map");1148 " referring to this unordered_map");
...@@ -1089,7 +1161,7 @@ public:...@@ -1089,7 +1161,7 @@ public:
1089 template <class... _Args>1161 template <class... _Args>
1090 _LIBCPP_INLINE_VISIBILITY1162 _LIBCPP_INLINE_VISIBILITY
1091 iterator emplace_hint(const_iterator __p, _Args&&... __args) {1163 iterator emplace_hint(const_iterator __p, _Args&&... __args) {
1092#if _LIBCPP_DEBUG_LEVEL >= 21164#if _LIBCPP_DEBUG_LEVEL == 2
1093 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,1165 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
1094 "unordered_map::emplace_hint(const_iterator, args...) called with an iterator not"1166 "unordered_map::emplace_hint(const_iterator, args...) called with an iterator not"
1095 " referring to this unordered_map");1167 " referring to this unordered_map");
...@@ -1106,7 +1178,7 @@ public:...@@ -1106,7 +1178,7 @@ public:
1106 _LIBCPP_INLINE_VISIBILITY1178 _LIBCPP_INLINE_VISIBILITY
1107 pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args)1179 pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args)
1108 {1180 {
1109 return __table_.__emplace_unique_key_args(__k, _VSTD::piecewise_construct,1181 return __table_.__emplace_unique_key_args(__k, piecewise_construct,
1110 _VSTD::forward_as_tuple(__k),1182 _VSTD::forward_as_tuple(__k),
1111 _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));1183 _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
1112 }1184 }
...@@ -1115,7 +1187,7 @@ public:...@@ -1115,7 +1187,7 @@ public:
1115 _LIBCPP_INLINE_VISIBILITY1187 _LIBCPP_INLINE_VISIBILITY
1116 pair<iterator, bool> try_emplace(key_type&& __k, _Args&&... __args)1188 pair<iterator, bool> try_emplace(key_type&& __k, _Args&&... __args)
1117 {1189 {
1118 return __table_.__emplace_unique_key_args(__k, _VSTD::piecewise_construct,1190 return __table_.__emplace_unique_key_args(__k, piecewise_construct,
1119 _VSTD::forward_as_tuple(_VSTD::move(__k)),1191 _VSTD::forward_as_tuple(_VSTD::move(__k)),
1120 _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));1192 _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
1121 }1193 }
...@@ -1124,7 +1196,7 @@ public:...@@ -1124,7 +1196,7 @@ public:
1124 _LIBCPP_INLINE_VISIBILITY1196 _LIBCPP_INLINE_VISIBILITY
1125 iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args)1197 iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args)
1126 {1198 {
1127#if _LIBCPP_DEBUG_LEVEL >= 21199#if _LIBCPP_DEBUG_LEVEL == 2
1128 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__h) == this,1200 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__h) == this,
1129 "unordered_map::try_emplace(const_iterator, key, args...) called with an iterator not"1201 "unordered_map::try_emplace(const_iterator, key, args...) called with an iterator not"
1130 " referring to this unordered_map");1202 " referring to this unordered_map");
...@@ -1138,7 +1210,7 @@ public:...@@ -1138,7 +1210,7 @@ public:
1138 _LIBCPP_INLINE_VISIBILITY1210 _LIBCPP_INLINE_VISIBILITY
1139 iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args)1211 iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args)
1140 {1212 {
1141#if _LIBCPP_DEBUG_LEVEL >= 21213#if _LIBCPP_DEBUG_LEVEL == 2
1142 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__h) == this,1214 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__h) == this,
1143 "unordered_map::try_emplace(const_iterator, key, args...) called with an iterator not"1215 "unordered_map::try_emplace(const_iterator, key, args...) called with an iterator not"
1144 " referring to this unordered_map");1216 " referring to this unordered_map");
...@@ -1280,11 +1352,34 @@ public:...@@ -1280,11 +1352,34 @@ public:
1280 iterator find(const key_type& __k) {return __table_.find(__k);}1352 iterator find(const key_type& __k) {return __table_.find(__k);}
1281 _LIBCPP_INLINE_VISIBILITY1353 _LIBCPP_INLINE_VISIBILITY
1282 const_iterator find(const key_type& __k) const {return __table_.find(__k);}1354 const_iterator find(const key_type& __k) const {return __table_.find(__k);}
1355
1356 #if _LIBCPP_STD_VER > 17
1357 template <typename _K2>
1358 _LIBCPP_INLINE_VISIBILITY
1359 _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, iterator>
1360 find(const _K2& __k) {return __table_.find(__k);}
1361 template <typename _K2>
1362 _LIBCPP_INLINE_VISIBILITY
1363 _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, const_iterator>
1364 find(const _K2& __k) const {return __table_.find(__k);}
1365 #endif // _LIBCPP_STD_VER > 17
1366
1283 _LIBCPP_INLINE_VISIBILITY1367 _LIBCPP_INLINE_VISIBILITY
1284 size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}1368 size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
1369 #if _LIBCPP_STD_VER > 17
1370 template <typename _K2>
1371 _LIBCPP_INLINE_VISIBILITY
1372 _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, size_type>
1373 count(const _K2& __k) const {return __table_.__count_unique(__k);}
1374 #endif // _LIBCPP_STD_VER > 17
1285 #if _LIBCPP_STD_VER > 171375 #if _LIBCPP_STD_VER > 17
1286 _LIBCPP_INLINE_VISIBILITY1376 _LIBCPP_INLINE_VISIBILITY
1287 bool contains(const key_type& __k) const {return find(__k) != end();}1377 bool contains(const key_type& __k) const {return find(__k) != end();}
1378
1379 template <typename _K2>
1380 _LIBCPP_INLINE_VISIBILITY
1381 _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, bool>
1382 contains(const _K2& __k) const {return find(__k) != end();}
1288 #endif // _LIBCPP_STD_VER > 171383 #endif // _LIBCPP_STD_VER > 17
1289 _LIBCPP_INLINE_VISIBILITY1384 _LIBCPP_INLINE_VISIBILITY
1290 pair<iterator, iterator> equal_range(const key_type& __k)1385 pair<iterator, iterator> equal_range(const key_type& __k)
...@@ -1292,6 +1387,16 @@ public:...@@ -1292,6 +1387,16 @@ public:
1292 _LIBCPP_INLINE_VISIBILITY1387 _LIBCPP_INLINE_VISIBILITY
1293 pair<const_iterator, const_iterator> equal_range(const key_type& __k) const1388 pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
1294 {return __table_.__equal_range_unique(__k);}1389 {return __table_.__equal_range_unique(__k);}
1390 #if _LIBCPP_STD_VER > 17
1391 template <typename _K2>
1392 _LIBCPP_INLINE_VISIBILITY
1393 _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<iterator, iterator>>
1394 equal_range(const _K2& __k) {return __table_.__equal_range_unique(__k);}
1395 template <typename _K2>
1396 _LIBCPP_INLINE_VISIBILITY
1397 _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<const_iterator, const_iterator>>
1398 equal_range(const _K2& __k) const {return __table_.__equal_range_unique(__k);}
1399 #endif // _LIBCPP_STD_VER > 17
12951400
1296 mapped_type& operator[](const key_type& __k);1401 mapped_type& operator[](const key_type& __k);
1297#ifndef _LIBCPP_CXX03_LANG1402#ifndef _LIBCPP_CXX03_LANG
...@@ -1336,7 +1441,7 @@ public:...@@ -1336,7 +1441,7 @@ public:
1336 _LIBCPP_INLINE_VISIBILITY1441 _LIBCPP_INLINE_VISIBILITY
1337 void reserve(size_type __n) {__table_.reserve(__n);}1442 void reserve(size_type __n) {__table_.reserve(__n);}
13381443
1339#if _LIBCPP_DEBUG_LEVEL >= 21444#if _LIBCPP_DEBUG_LEVEL == 2
13401445
1341 bool __dereferenceable(const const_iterator* __i) const1446 bool __dereferenceable(const const_iterator* __i) const
1342 {return __table_.__dereferenceable(&__i->__i_);}1447 {return __table_.__dereferenceable(&__i->__i_);}
...@@ -1347,7 +1452,7 @@ public:...@@ -1347,7 +1452,7 @@ public:
1347 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const1452 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
1348 {return __table_.__addable(&__i->__i_, __n);}1453 {return __table_.__addable(&__i->__i_, __n);}
13491454
1350#endif // _LIBCPP_DEBUG_LEVEL >= 21455#endif // _LIBCPP_DEBUG_LEVEL == 2
13511456
1352private:1457private:
13531458
...@@ -1428,7 +1533,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(...@@ -1428,7 +1533,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1428 size_type __n, const hasher& __hf, const key_equal& __eql)1533 size_type __n, const hasher& __hf, const key_equal& __eql)
1429 : __table_(__hf, __eql)1534 : __table_(__hf, __eql)
1430{1535{
1431#if _LIBCPP_DEBUG_LEVEL >= 21536#if _LIBCPP_DEBUG_LEVEL == 2
1432 __get_db()->__insert_c(this);1537 __get_db()->__insert_c(this);
1433#endif1538#endif
1434 __table_.rehash(__n);1539 __table_.rehash(__n);
...@@ -1440,7 +1545,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(...@@ -1440,7 +1545,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1440 const allocator_type& __a)1545 const allocator_type& __a)
1441 : __table_(__hf, __eql, typename __table::allocator_type(__a))1546 : __table_(__hf, __eql, typename __table::allocator_type(__a))
1442{1547{
1443#if _LIBCPP_DEBUG_LEVEL >= 21548#if _LIBCPP_DEBUG_LEVEL == 2
1444 __get_db()->__insert_c(this);1549 __get_db()->__insert_c(this);
1445#endif1550#endif
1446 __table_.rehash(__n);1551 __table_.rehash(__n);
...@@ -1452,7 +1557,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(...@@ -1452,7 +1557,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1452 const allocator_type& __a)1557 const allocator_type& __a)
1453 : __table_(typename __table::allocator_type(__a))1558 : __table_(typename __table::allocator_type(__a))
1454{1559{
1455#if _LIBCPP_DEBUG_LEVEL >= 21560#if _LIBCPP_DEBUG_LEVEL == 2
1456 __get_db()->__insert_c(this);1561 __get_db()->__insert_c(this);
1457#endif1562#endif
1458}1563}
...@@ -1462,7 +1567,7 @@ template <class _InputIterator>...@@ -1462,7 +1567,7 @@ template <class _InputIterator>
1462unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(1567unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1463 _InputIterator __first, _InputIterator __last)1568 _InputIterator __first, _InputIterator __last)
1464{1569{
1465#if _LIBCPP_DEBUG_LEVEL >= 21570#if _LIBCPP_DEBUG_LEVEL == 2
1466 __get_db()->__insert_c(this);1571 __get_db()->__insert_c(this);
1467#endif1572#endif
1468 insert(__first, __last);1573 insert(__first, __last);
...@@ -1475,7 +1580,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(...@@ -1475,7 +1580,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1475 const hasher& __hf, const key_equal& __eql)1580 const hasher& __hf, const key_equal& __eql)
1476 : __table_(__hf, __eql)1581 : __table_(__hf, __eql)
1477{1582{
1478#if _LIBCPP_DEBUG_LEVEL >= 21583#if _LIBCPP_DEBUG_LEVEL == 2
1479 __get_db()->__insert_c(this);1584 __get_db()->__insert_c(this);
1480#endif1585#endif
1481 __table_.rehash(__n);1586 __table_.rehash(__n);
...@@ -1489,7 +1594,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(...@@ -1489,7 +1594,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1489 const hasher& __hf, const key_equal& __eql, const allocator_type& __a)1594 const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
1490 : __table_(__hf, __eql, typename __table::allocator_type(__a))1595 : __table_(__hf, __eql, typename __table::allocator_type(__a))
1491{1596{
1492#if _LIBCPP_DEBUG_LEVEL >= 21597#if _LIBCPP_DEBUG_LEVEL == 2
1493 __get_db()->__insert_c(this);1598 __get_db()->__insert_c(this);
1494#endif1599#endif
1495 __table_.rehash(__n);1600 __table_.rehash(__n);
...@@ -1501,7 +1606,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(...@@ -1501,7 +1606,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1501 const unordered_map& __u)1606 const unordered_map& __u)
1502 : __table_(__u.__table_)1607 : __table_(__u.__table_)
1503{1608{
1504#if _LIBCPP_DEBUG_LEVEL >= 21609#if _LIBCPP_DEBUG_LEVEL == 2
1505 __get_db()->__insert_c(this);1610 __get_db()->__insert_c(this);
1506#endif1611#endif
1507 __table_.rehash(__u.bucket_count());1612 __table_.rehash(__u.bucket_count());
...@@ -1513,7 +1618,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(...@@ -1513,7 +1618,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1513 const unordered_map& __u, const allocator_type& __a)1618 const unordered_map& __u, const allocator_type& __a)
1514 : __table_(__u.__table_, typename __table::allocator_type(__a))1619 : __table_(__u.__table_, typename __table::allocator_type(__a))
1515{1620{
1516#if _LIBCPP_DEBUG_LEVEL >= 21621#if _LIBCPP_DEBUG_LEVEL == 2
1517 __get_db()->__insert_c(this);1622 __get_db()->__insert_c(this);
1518#endif1623#endif
1519 __table_.rehash(__u.bucket_count());1624 __table_.rehash(__u.bucket_count());
...@@ -1529,7 +1634,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(...@@ -1529,7 +1634,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1529 _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)1634 _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
1530 : __table_(_VSTD::move(__u.__table_))1635 : __table_(_VSTD::move(__u.__table_))
1531{1636{
1532#if _LIBCPP_DEBUG_LEVEL >= 21637#if _LIBCPP_DEBUG_LEVEL == 2
1533 __get_db()->__insert_c(this);1638 __get_db()->__insert_c(this);
1534 __get_db()->swap(this, &__u);1639 __get_db()->swap(this, &__u);
1535#endif1640#endif
...@@ -1540,7 +1645,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(...@@ -1540,7 +1645,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1540 unordered_map&& __u, const allocator_type& __a)1645 unordered_map&& __u, const allocator_type& __a)
1541 : __table_(_VSTD::move(__u.__table_), typename __table::allocator_type(__a))1646 : __table_(_VSTD::move(__u.__table_), typename __table::allocator_type(__a))
1542{1647{
1543#if _LIBCPP_DEBUG_LEVEL >= 21648#if _LIBCPP_DEBUG_LEVEL == 2
1544 __get_db()->__insert_c(this);1649 __get_db()->__insert_c(this);
1545#endif1650#endif
1546 if (__a != __u.get_allocator())1651 if (__a != __u.get_allocator())
...@@ -1551,7 +1656,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(...@@ -1551,7 +1656,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1551 __u.__table_.remove((__i++).__i_)->__value_.__move());1656 __u.__table_.remove((__i++).__i_)->__value_.__move());
1552 }1657 }
1553 }1658 }
1554#if _LIBCPP_DEBUG_LEVEL >= 21659#if _LIBCPP_DEBUG_LEVEL == 2
1555 else1660 else
1556 __get_db()->swap(this, &__u);1661 __get_db()->swap(this, &__u);
1557#endif1662#endif
...@@ -1561,7 +1666,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>...@@ -1561,7 +1666,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1561unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(1666unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1562 initializer_list<value_type> __il)1667 initializer_list<value_type> __il)
1563{1668{
1564#if _LIBCPP_DEBUG_LEVEL >= 21669#if _LIBCPP_DEBUG_LEVEL == 2
1565 __get_db()->__insert_c(this);1670 __get_db()->__insert_c(this);
1566#endif1671#endif
1567 insert(__il.begin(), __il.end());1672 insert(__il.begin(), __il.end());
...@@ -1573,7 +1678,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(...@@ -1573,7 +1678,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1573 const key_equal& __eql)1678 const key_equal& __eql)
1574 : __table_(__hf, __eql)1679 : __table_(__hf, __eql)
1575{1680{
1576#if _LIBCPP_DEBUG_LEVEL >= 21681#if _LIBCPP_DEBUG_LEVEL == 2
1577 __get_db()->__insert_c(this);1682 __get_db()->__insert_c(this);
1578#endif1683#endif
1579 __table_.rehash(__n);1684 __table_.rehash(__n);
...@@ -1586,7 +1691,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(...@@ -1586,7 +1691,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1586 const key_equal& __eql, const allocator_type& __a)1691 const key_equal& __eql, const allocator_type& __a)
1587 : __table_(__hf, __eql, typename __table::allocator_type(__a))1692 : __table_(__hf, __eql, typename __table::allocator_type(__a))
1588{1693{
1589#if _LIBCPP_DEBUG_LEVEL >= 21694#if _LIBCPP_DEBUG_LEVEL == 2
1590 __get_db()->__insert_c(this);1695 __get_db()->__insert_c(this);
1591#endif1696#endif
1592 __table_.rehash(__n);1697 __table_.rehash(__n);
...@@ -1633,8 +1738,8 @@ _Tp&...@@ -1633,8 +1738,8 @@ _Tp&
1633unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k)1738unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k)
1634{1739{
1635 return __table_.__emplace_unique_key_args(__k,1740 return __table_.__emplace_unique_key_args(__k,
1636 std::piecewise_construct, std::forward_as_tuple(__k),1741 piecewise_construct, _VSTD::forward_as_tuple(__k),
1637 std::forward_as_tuple()).first->__get_value().second;1742 _VSTD::forward_as_tuple()).first->__get_value().second;
1638}1743}
16391744
1640template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>1745template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
...@@ -1642,8 +1747,8 @@ _Tp&...@@ -1642,8 +1747,8 @@ _Tp&
1642unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](key_type&& __k)1747unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](key_type&& __k)
1643{1748{
1644 return __table_.__emplace_unique_key_args(__k,1749 return __table_.__emplace_unique_key_args(__k,
1645 std::piecewise_construct, std::forward_as_tuple(std::move(__k)),1750 piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__k)),
1646 std::forward_as_tuple()).first->__get_value().second;1751 _VSTD::forward_as_tuple()).first->__get_value().second;
1647}1752}
1648#else // _LIBCPP_CXX03_LANG1753#else // _LIBCPP_CXX03_LANG
16491754
...@@ -1657,7 +1762,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(const...@@ -1657,7 +1762,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(const
1657 __h.get_deleter().__first_constructed = true;1762 __h.get_deleter().__first_constructed = true;
1658 __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__get_value().second));1763 __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__get_value().second));
1659 __h.get_deleter().__second_constructed = true;1764 __h.get_deleter().__second_constructed = true;
1660 return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++031765 return __h;
1661}1766}
16621767
1663template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>1768template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
...@@ -1762,11 +1867,11 @@ public:...@@ -1762,11 +1867,11 @@ public:
1762 "Invalid allocator::value_type");1867 "Invalid allocator::value_type");
17631868
1764private:1869private:
1765 typedef __hash_value_type<key_type, mapped_type> __value_type;1870 typedef __hash_value_type<key_type, mapped_type> __value_type;
1766 typedef __unordered_map_hasher<key_type, __value_type, hasher> __hasher;1871 typedef __unordered_map_hasher<key_type, __value_type, hasher, key_equal> __hasher;
1767 typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal;1872 typedef __unordered_map_equal<key_type, __value_type, key_equal, hasher> __key_equal;
1768 typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,1873 typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
1769 __value_type>::type __allocator_type;1874 __value_type>::type __allocator_type;
17701875
1771 typedef __hash_table<__value_type, __hasher,1876 typedef __hash_table<__value_type, __hasher,
1772 __key_equal, __allocator_type> __table;1877 __key_equal, __allocator_type> __table;
...@@ -1807,7 +1912,7 @@ public:...@@ -1807,7 +1912,7 @@ public:
1807 unordered_multimap()1912 unordered_multimap()
1808 _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)1913 _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
1809 {1914 {
1810#if _LIBCPP_DEBUG_LEVEL >= 21915#if _LIBCPP_DEBUG_LEVEL == 2
1811 __get_db()->__insert_c(this);1916 __get_db()->__insert_c(this);
1812#endif1917#endif
1813 }1918 }
...@@ -2059,11 +2164,32 @@ public:...@@ -2059,11 +2164,32 @@ public:
2059 iterator find(const key_type& __k) {return __table_.find(__k);}2164 iterator find(const key_type& __k) {return __table_.find(__k);}
2060 _LIBCPP_INLINE_VISIBILITY2165 _LIBCPP_INLINE_VISIBILITY
2061 const_iterator find(const key_type& __k) const {return __table_.find(__k);}2166 const_iterator find(const key_type& __k) const {return __table_.find(__k);}
2167 #if _LIBCPP_STD_VER > 17
2168 template <typename _K2>
2169 _LIBCPP_INLINE_VISIBILITY
2170 _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, iterator>
2171 find(const _K2& __k) {return __table_.find(__k);}
2172 template <typename _K2>
2173 _LIBCPP_INLINE_VISIBILITY
2174 _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, const_iterator>
2175 find(const _K2& __k) const {return __table_.find(__k);}
2176 #endif // _LIBCPP_STD_VER > 17
2062 _LIBCPP_INLINE_VISIBILITY2177 _LIBCPP_INLINE_VISIBILITY
2063 size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}2178 size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
2179 #if _LIBCPP_STD_VER > 17
2180 template <typename _K2>
2181 _LIBCPP_INLINE_VISIBILITY
2182 _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, size_type>
2183 count(const _K2& __k) const {return __table_.__count_multi(__k);}
2184 #endif // _LIBCPP_STD_VER > 17
2064 #if _LIBCPP_STD_VER > 172185 #if _LIBCPP_STD_VER > 17
2065 _LIBCPP_INLINE_VISIBILITY2186 _LIBCPP_INLINE_VISIBILITY
2066 bool contains(const key_type& __k) const {return find(__k) != end();}2187 bool contains(const key_type& __k) const {return find(__k) != end();}
2188
2189 template <typename _K2>
2190 _LIBCPP_INLINE_VISIBILITY
2191 _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, bool>
2192 contains(const _K2& __k) const {return find(__k) != end();}
2067 #endif // _LIBCPP_STD_VER > 172193 #endif // _LIBCPP_STD_VER > 17
2068 _LIBCPP_INLINE_VISIBILITY2194 _LIBCPP_INLINE_VISIBILITY
2069 pair<iterator, iterator> equal_range(const key_type& __k)2195 pair<iterator, iterator> equal_range(const key_type& __k)
...@@ -2071,6 +2197,16 @@ public:...@@ -2071,6 +2197,16 @@ public:
2071 _LIBCPP_INLINE_VISIBILITY2197 _LIBCPP_INLINE_VISIBILITY
2072 pair<const_iterator, const_iterator> equal_range(const key_type& __k) const2198 pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
2073 {return __table_.__equal_range_multi(__k);}2199 {return __table_.__equal_range_multi(__k);}
2200 #if _LIBCPP_STD_VER > 17
2201 template <typename _K2>
2202 _LIBCPP_INLINE_VISIBILITY
2203 _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<iterator, iterator>>
2204 equal_range(const _K2& __k) {return __table_.__equal_range_multi(__k);}
2205 template <typename _K2>
2206 _LIBCPP_INLINE_VISIBILITY
2207 _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<const_iterator, const_iterator>>
2208 equal_range(const _K2& __k) const {return __table_.__equal_range_multi(__k);}
2209 #endif // _LIBCPP_STD_VER > 17
20742210
2075 _LIBCPP_INLINE_VISIBILITY2211 _LIBCPP_INLINE_VISIBILITY
2076 size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}2212 size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
...@@ -2108,7 +2244,7 @@ public:...@@ -2108,7 +2244,7 @@ public:
2108 _LIBCPP_INLINE_VISIBILITY2244 _LIBCPP_INLINE_VISIBILITY
2109 void reserve(size_type __n) {__table_.reserve(__n);}2245 void reserve(size_type __n) {__table_.reserve(__n);}
21102246
2111#if _LIBCPP_DEBUG_LEVEL >= 22247#if _LIBCPP_DEBUG_LEVEL == 2
21122248
2113 bool __dereferenceable(const const_iterator* __i) const2249 bool __dereferenceable(const const_iterator* __i) const
2114 {return __table_.__dereferenceable(&__i->__i_);}2250 {return __table_.__dereferenceable(&__i->__i_);}
...@@ -2119,7 +2255,7 @@ public:...@@ -2119,7 +2255,7 @@ public:
2119 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const2255 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
2120 {return __table_.__addable(&__i->__i_, __n);}2256 {return __table_.__addable(&__i->__i_, __n);}
21212257
2122#endif // _LIBCPP_DEBUG_LEVEL >= 22258#endif // _LIBCPP_DEBUG_LEVEL == 2
21232259
21242260
2125};2261};
...@@ -2196,7 +2332,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(...@@ -2196,7 +2332,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2196 size_type __n, const hasher& __hf, const key_equal& __eql)2332 size_type __n, const hasher& __hf, const key_equal& __eql)
2197 : __table_(__hf, __eql)2333 : __table_(__hf, __eql)
2198{2334{
2199#if _LIBCPP_DEBUG_LEVEL >= 22335#if _LIBCPP_DEBUG_LEVEL == 2
2200 __get_db()->__insert_c(this);2336 __get_db()->__insert_c(this);
2201#endif2337#endif
2202 __table_.rehash(__n);2338 __table_.rehash(__n);
...@@ -2208,7 +2344,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(...@@ -2208,7 +2344,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2208 const allocator_type& __a)2344 const allocator_type& __a)
2209 : __table_(__hf, __eql, typename __table::allocator_type(__a))2345 : __table_(__hf, __eql, typename __table::allocator_type(__a))
2210{2346{
2211#if _LIBCPP_DEBUG_LEVEL >= 22347#if _LIBCPP_DEBUG_LEVEL == 2
2212 __get_db()->__insert_c(this);2348 __get_db()->__insert_c(this);
2213#endif2349#endif
2214 __table_.rehash(__n);2350 __table_.rehash(__n);
...@@ -2219,7 +2355,7 @@ template <class _InputIterator>...@@ -2219,7 +2355,7 @@ template <class _InputIterator>
2219unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(2355unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2220 _InputIterator __first, _InputIterator __last)2356 _InputIterator __first, _InputIterator __last)
2221{2357{
2222#if _LIBCPP_DEBUG_LEVEL >= 22358#if _LIBCPP_DEBUG_LEVEL == 2
2223 __get_db()->__insert_c(this);2359 __get_db()->__insert_c(this);
2224#endif2360#endif
2225 insert(__first, __last);2361 insert(__first, __last);
...@@ -2232,7 +2368,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(...@@ -2232,7 +2368,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2232 const hasher& __hf, const key_equal& __eql)2368 const hasher& __hf, const key_equal& __eql)
2233 : __table_(__hf, __eql)2369 : __table_(__hf, __eql)
2234{2370{
2235#if _LIBCPP_DEBUG_LEVEL >= 22371#if _LIBCPP_DEBUG_LEVEL == 2
2236 __get_db()->__insert_c(this);2372 __get_db()->__insert_c(this);
2237#endif2373#endif
2238 __table_.rehash(__n);2374 __table_.rehash(__n);
...@@ -2246,7 +2382,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(...@@ -2246,7 +2382,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2246 const hasher& __hf, const key_equal& __eql, const allocator_type& __a)2382 const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
2247 : __table_(__hf, __eql, typename __table::allocator_type(__a))2383 : __table_(__hf, __eql, typename __table::allocator_type(__a))
2248{2384{
2249#if _LIBCPP_DEBUG_LEVEL >= 22385#if _LIBCPP_DEBUG_LEVEL == 2
2250 __get_db()->__insert_c(this);2386 __get_db()->__insert_c(this);
2251#endif2387#endif
2252 __table_.rehash(__n);2388 __table_.rehash(__n);
...@@ -2259,7 +2395,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(...@@ -2259,7 +2395,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2259 const allocator_type& __a)2395 const allocator_type& __a)
2260 : __table_(typename __table::allocator_type(__a))2396 : __table_(typename __table::allocator_type(__a))
2261{2397{
2262#if _LIBCPP_DEBUG_LEVEL >= 22398#if _LIBCPP_DEBUG_LEVEL == 2
2263 __get_db()->__insert_c(this);2399 __get_db()->__insert_c(this);
2264#endif2400#endif
2265}2401}
...@@ -2269,7 +2405,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(...@@ -2269,7 +2405,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2269 const unordered_multimap& __u)2405 const unordered_multimap& __u)
2270 : __table_(__u.__table_)2406 : __table_(__u.__table_)
2271{2407{
2272#if _LIBCPP_DEBUG_LEVEL >= 22408#if _LIBCPP_DEBUG_LEVEL == 2
2273 __get_db()->__insert_c(this);2409 __get_db()->__insert_c(this);
2274#endif2410#endif
2275 __table_.rehash(__u.bucket_count());2411 __table_.rehash(__u.bucket_count());
...@@ -2281,7 +2417,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(...@@ -2281,7 +2417,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2281 const unordered_multimap& __u, const allocator_type& __a)2417 const unordered_multimap& __u, const allocator_type& __a)
2282 : __table_(__u.__table_, typename __table::allocator_type(__a))2418 : __table_(__u.__table_, typename __table::allocator_type(__a))
2283{2419{
2284#if _LIBCPP_DEBUG_LEVEL >= 22420#if _LIBCPP_DEBUG_LEVEL == 2
2285 __get_db()->__insert_c(this);2421 __get_db()->__insert_c(this);
2286#endif2422#endif
2287 __table_.rehash(__u.bucket_count());2423 __table_.rehash(__u.bucket_count());
...@@ -2297,7 +2433,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(...@@ -2297,7 +2433,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2297 _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)2433 _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
2298 : __table_(_VSTD::move(__u.__table_))2434 : __table_(_VSTD::move(__u.__table_))
2299{2435{
2300#if _LIBCPP_DEBUG_LEVEL >= 22436#if _LIBCPP_DEBUG_LEVEL == 2
2301 __get_db()->__insert_c(this);2437 __get_db()->__insert_c(this);
2302 __get_db()->swap(this, &__u);2438 __get_db()->swap(this, &__u);
2303#endif2439#endif
...@@ -2308,7 +2444,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(...@@ -2308,7 +2444,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2308 unordered_multimap&& __u, const allocator_type& __a)2444 unordered_multimap&& __u, const allocator_type& __a)
2309 : __table_(_VSTD::move(__u.__table_), typename __table::allocator_type(__a))2445 : __table_(_VSTD::move(__u.__table_), typename __table::allocator_type(__a))
2310{2446{
2311#if _LIBCPP_DEBUG_LEVEL >= 22447#if _LIBCPP_DEBUG_LEVEL == 2
2312 __get_db()->__insert_c(this);2448 __get_db()->__insert_c(this);
2313#endif2449#endif
2314 if (__a != __u.get_allocator())2450 if (__a != __u.get_allocator())
...@@ -2320,7 +2456,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(...@@ -2320,7 +2456,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2320 __u.__table_.remove((__i++).__i_)->__value_.__move());2456 __u.__table_.remove((__i++).__i_)->__value_.__move());
2321 }2457 }
2322 }2458 }
2323#if _LIBCPP_DEBUG_LEVEL >= 22459#if _LIBCPP_DEBUG_LEVEL == 2
2324 else2460 else
2325 __get_db()->swap(this, &__u);2461 __get_db()->swap(this, &__u);
2326#endif2462#endif
...@@ -2330,7 +2466,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>...@@ -2330,7 +2466,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2330unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(2466unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2331 initializer_list<value_type> __il)2467 initializer_list<value_type> __il)
2332{2468{
2333#if _LIBCPP_DEBUG_LEVEL >= 22469#if _LIBCPP_DEBUG_LEVEL == 2
2334 __get_db()->__insert_c(this);2470 __get_db()->__insert_c(this);
2335#endif2471#endif
2336 insert(__il.begin(), __il.end());2472 insert(__il.begin(), __il.end());
...@@ -2342,7 +2478,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(...@@ -2342,7 +2478,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2342 const key_equal& __eql)2478 const key_equal& __eql)
2343 : __table_(__hf, __eql)2479 : __table_(__hf, __eql)
2344{2480{
2345#if _LIBCPP_DEBUG_LEVEL >= 22481#if _LIBCPP_DEBUG_LEVEL == 2
2346 __get_db()->__insert_c(this);2482 __get_db()->__insert_c(this);
2347#endif2483#endif
2348 __table_.rehash(__n);2484 __table_.rehash(__n);
...@@ -2355,7 +2491,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(...@@ -2355,7 +2491,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2355 const key_equal& __eql, const allocator_type& __a)2491 const key_equal& __eql, const allocator_type& __a)
2356 : __table_(__hf, __eql, typename __table::allocator_type(__a))2492 : __table_(__hf, __eql, typename __table::allocator_type(__a))
2357{2493{
2358#if _LIBCPP_DEBUG_LEVEL >= 22494#if _LIBCPP_DEBUG_LEVEL == 2
2359 __get_db()->__insert_c(this);2495 __get_db()->__insert_c(this);
2360#endif2496#endif
2361 __table_.rehash(__n);2497 __table_.rehash(__n);
lib/libcxx/include/unordered_set+123-37
...@@ -145,10 +145,22 @@ public:...@@ -145,10 +145,22 @@ public:
145145
146 iterator find(const key_type& k);146 iterator find(const key_type& k);
147 const_iterator find(const key_type& k) const;147 const_iterator find(const key_type& k) const;
148 template<typename K>
149 iterator find(const K& x); // C++20
150 template<typename K>
151 const_iterator find(const K& x) const; // C++20
148 size_type count(const key_type& k) const;152 size_type count(const key_type& k) const;
153 template<typename K>
154 size_type count(const K& k) const; // C++20
149 bool contains(const key_type& k) const; // C++20155 bool contains(const key_type& k) const; // C++20
156 template<typename K>
157 bool contains(const K& k) const; // C++20
150 pair<iterator, iterator> equal_range(const key_type& k);158 pair<iterator, iterator> equal_range(const key_type& k);
151 pair<const_iterator, const_iterator> equal_range(const key_type& k) const;159 pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
160 template<typename K>
161 pair<iterator, iterator> equal_range(const K& k); // C++20
162 template<typename K>
163 pair<const_iterator, const_iterator> equal_range(const K& k) const; // C++20
152164
153 size_type bucket_count() const noexcept;165 size_type bucket_count() const noexcept;
154 size_type max_bucket_count() const noexcept;166 size_type max_bucket_count() const noexcept;
...@@ -310,10 +322,22 @@ public:...@@ -310,10 +322,22 @@ public:
310322
311 iterator find(const key_type& k);323 iterator find(const key_type& k);
312 const_iterator find(const key_type& k) const;324 const_iterator find(const key_type& k) const;
325 template<typename K>
326 iterator find(const K& x); // C++20
327 template<typename K>
328 const_iterator find(const K& x) const; // C++20
313 size_type count(const key_type& k) const;329 size_type count(const key_type& k) const;
330 template<typename K>
331 size_type count(const K& k) const; // C++20
314 bool contains(const key_type& k) const; // C++20332 bool contains(const key_type& k) const; // C++20
333 template<typename K>
334 bool contains(const K& k) const; // C++20
315 pair<iterator, iterator> equal_range(const key_type& k);335 pair<iterator, iterator> equal_range(const key_type& k);
316 pair<const_iterator, const_iterator> equal_range(const key_type& k) const;336 pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
337 template<typename K>
338 pair<iterator, iterator> equal_range(const K& k); // C++20
339 template<typename K>
340 pair<const_iterator, const_iterator> equal_range(const K& k) const; // C++20
317341
318 size_type bucket_count() const noexcept;342 size_type bucket_count() const noexcept;
319 size_type max_bucket_count() const noexcept;343 size_type max_bucket_count() const noexcept;
...@@ -425,7 +449,7 @@ public:...@@ -425,7 +449,7 @@ public:
425 unordered_set()449 unordered_set()
426 _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)450 _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
427 {451 {
428#if _LIBCPP_DEBUG_LEVEL >= 2452#if _LIBCPP_DEBUG_LEVEL == 2
429 __get_db()->__insert_c(this);453 __get_db()->__insert_c(this);
430#endif454#endif
431 }455 }
...@@ -539,7 +563,7 @@ public:...@@ -539,7 +563,7 @@ public:
539 {return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...);}563 {return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...);}
540 template <class... _Args>564 template <class... _Args>
541 _LIBCPP_INLINE_VISIBILITY565 _LIBCPP_INLINE_VISIBILITY
542#if _LIBCPP_DEBUG_LEVEL >= 2566#if _LIBCPP_DEBUG_LEVEL == 2
543 iterator emplace_hint(const_iterator __p, _Args&&... __args)567 iterator emplace_hint(const_iterator __p, _Args&&... __args)
544 {568 {
545 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,569 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
...@@ -556,7 +580,7 @@ public:...@@ -556,7 +580,7 @@ public:
556 pair<iterator, bool> insert(value_type&& __x)580 pair<iterator, bool> insert(value_type&& __x)
557 {return __table_.__insert_unique(_VSTD::move(__x));}581 {return __table_.__insert_unique(_VSTD::move(__x));}
558 _LIBCPP_INLINE_VISIBILITY582 _LIBCPP_INLINE_VISIBILITY
559#if _LIBCPP_DEBUG_LEVEL >= 2583#if _LIBCPP_DEBUG_LEVEL == 2
560 iterator insert(const_iterator __p, value_type&& __x)584 iterator insert(const_iterator __p, value_type&& __x)
561 {585 {
562 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,586 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
...@@ -577,7 +601,7 @@ public:...@@ -577,7 +601,7 @@ public:
577 {return __table_.__insert_unique(__x);}601 {return __table_.__insert_unique(__x);}
578602
579 _LIBCPP_INLINE_VISIBILITY603 _LIBCPP_INLINE_VISIBILITY
580#if _LIBCPP_DEBUG_LEVEL >= 2604#if _LIBCPP_DEBUG_LEVEL == 2
581 iterator insert(const_iterator __p, const value_type& __x)605 iterator insert(const_iterator __p, const value_type& __x)
582 {606 {
583 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,607 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
...@@ -679,11 +703,32 @@ public:...@@ -679,11 +703,32 @@ public:
679 iterator find(const key_type& __k) {return __table_.find(__k);}703 iterator find(const key_type& __k) {return __table_.find(__k);}
680 _LIBCPP_INLINE_VISIBILITY704 _LIBCPP_INLINE_VISIBILITY
681 const_iterator find(const key_type& __k) const {return __table_.find(__k);}705 const_iterator find(const key_type& __k) const {return __table_.find(__k);}
706 #if _LIBCPP_STD_VER > 17
707 template <typename _K2>
708 _LIBCPP_INLINE_VISIBILITY
709 _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, iterator>
710 find(const _K2& __k) {return __table_.find(__k);}
711 template <typename _K2>
712 _LIBCPP_INLINE_VISIBILITY
713 _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, const_iterator>
714 find(const _K2& __k) const {return __table_.find(__k);}
715 #endif // _LIBCPP_STD_VER > 17
682 _LIBCPP_INLINE_VISIBILITY716 _LIBCPP_INLINE_VISIBILITY
683 size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}717 size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
718 #if _LIBCPP_STD_VER > 17
719 template <typename _K2>
720 _LIBCPP_INLINE_VISIBILITY
721 _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, size_type>
722 count(const _K2& __k) const {return __table_.__count_unique(__k);}
723 #endif // _LIBCPP_STD_VER > 17
684 #if _LIBCPP_STD_VER > 17724 #if _LIBCPP_STD_VER > 17
685 _LIBCPP_INLINE_VISIBILITY725 _LIBCPP_INLINE_VISIBILITY
686 bool contains(const key_type& __k) const {return find(__k) != end();}726 bool contains(const key_type& __k) const {return find(__k) != end();}
727
728 template <typename _K2>
729 _LIBCPP_INLINE_VISIBILITY
730 _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, bool>
731 contains(const _K2& __k) const {return find(__k) != end();}
687 #endif // _LIBCPP_STD_VER > 17732 #endif // _LIBCPP_STD_VER > 17
688 _LIBCPP_INLINE_VISIBILITY733 _LIBCPP_INLINE_VISIBILITY
689 pair<iterator, iterator> equal_range(const key_type& __k)734 pair<iterator, iterator> equal_range(const key_type& __k)
...@@ -691,6 +736,16 @@ public:...@@ -691,6 +736,16 @@ public:
691 _LIBCPP_INLINE_VISIBILITY736 _LIBCPP_INLINE_VISIBILITY
692 pair<const_iterator, const_iterator> equal_range(const key_type& __k) const737 pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
693 {return __table_.__equal_range_unique(__k);}738 {return __table_.__equal_range_unique(__k);}
739 #if _LIBCPP_STD_VER > 17
740 template <typename _K2>
741 _LIBCPP_INLINE_VISIBILITY
742 _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<iterator, iterator>>
743 equal_range(const _K2& __k) {return __table_.__equal_range_unique(__k);}
744 template <typename _K2>
745 _LIBCPP_INLINE_VISIBILITY
746 _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<const_iterator, const_iterator>>
747 equal_range(const _K2& __k) const {return __table_.__equal_range_unique(__k);}
748 #endif // _LIBCPP_STD_VER > 17
694749
695 _LIBCPP_INLINE_VISIBILITY750 _LIBCPP_INLINE_VISIBILITY
696 size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}751 size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
...@@ -726,7 +781,7 @@ public:...@@ -726,7 +781,7 @@ public:
726 _LIBCPP_INLINE_VISIBILITY781 _LIBCPP_INLINE_VISIBILITY
727 void reserve(size_type __n) {__table_.reserve(__n);}782 void reserve(size_type __n) {__table_.reserve(__n);}
728783
729#if _LIBCPP_DEBUG_LEVEL >= 2784#if _LIBCPP_DEBUG_LEVEL == 2
730785
731 bool __dereferenceable(const const_iterator* __i) const786 bool __dereferenceable(const const_iterator* __i) const
732 {return __table_.__dereferenceable(__i);}787 {return __table_.__dereferenceable(__i);}
...@@ -737,7 +792,7 @@ public:...@@ -737,7 +792,7 @@ public:
737 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const792 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
738 {return __table_.__addable(__i, __n);}793 {return __table_.__addable(__i, __n);}
739794
740#endif // _LIBCPP_DEBUG_LEVEL >= 2795#endif // _LIBCPP_DEBUG_LEVEL == 2
741796
742};797};
743798
...@@ -802,7 +857,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n,...@@ -802,7 +857,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n,
802 const hasher& __hf, const key_equal& __eql)857 const hasher& __hf, const key_equal& __eql)
803 : __table_(__hf, __eql)858 : __table_(__hf, __eql)
804{859{
805#if _LIBCPP_DEBUG_LEVEL >= 2860#if _LIBCPP_DEBUG_LEVEL == 2
806 __get_db()->__insert_c(this);861 __get_db()->__insert_c(this);
807#endif862#endif
808 __table_.rehash(__n);863 __table_.rehash(__n);
...@@ -813,7 +868,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n,...@@ -813,7 +868,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n,
813 const hasher& __hf, const key_equal& __eql, const allocator_type& __a)868 const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
814 : __table_(__hf, __eql, __a)869 : __table_(__hf, __eql, __a)
815{870{
816#if _LIBCPP_DEBUG_LEVEL >= 2871#if _LIBCPP_DEBUG_LEVEL == 2
817 __get_db()->__insert_c(this);872 __get_db()->__insert_c(this);
818#endif873#endif
819 __table_.rehash(__n);874 __table_.rehash(__n);
...@@ -824,7 +879,7 @@ template <class _InputIterator>...@@ -824,7 +879,7 @@ template <class _InputIterator>
824unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(879unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
825 _InputIterator __first, _InputIterator __last)880 _InputIterator __first, _InputIterator __last)
826{881{
827#if _LIBCPP_DEBUG_LEVEL >= 2882#if _LIBCPP_DEBUG_LEVEL == 2
828 __get_db()->__insert_c(this);883 __get_db()->__insert_c(this);
829#endif884#endif
830 insert(__first, __last);885 insert(__first, __last);
...@@ -837,7 +892,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(...@@ -837,7 +892,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
837 const hasher& __hf, const key_equal& __eql)892 const hasher& __hf, const key_equal& __eql)
838 : __table_(__hf, __eql)893 : __table_(__hf, __eql)
839{894{
840#if _LIBCPP_DEBUG_LEVEL >= 2895#if _LIBCPP_DEBUG_LEVEL == 2
841 __get_db()->__insert_c(this);896 __get_db()->__insert_c(this);
842#endif897#endif
843 __table_.rehash(__n);898 __table_.rehash(__n);
...@@ -851,7 +906,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(...@@ -851,7 +906,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
851 const hasher& __hf, const key_equal& __eql, const allocator_type& __a)906 const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
852 : __table_(__hf, __eql, __a)907 : __table_(__hf, __eql, __a)
853{908{
854#if _LIBCPP_DEBUG_LEVEL >= 2909#if _LIBCPP_DEBUG_LEVEL == 2
855 __get_db()->__insert_c(this);910 __get_db()->__insert_c(this);
856#endif911#endif
857 __table_.rehash(__n);912 __table_.rehash(__n);
...@@ -864,7 +919,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(...@@ -864,7 +919,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
864 const allocator_type& __a)919 const allocator_type& __a)
865 : __table_(__a)920 : __table_(__a)
866{921{
867#if _LIBCPP_DEBUG_LEVEL >= 2922#if _LIBCPP_DEBUG_LEVEL == 2
868 __get_db()->__insert_c(this);923 __get_db()->__insert_c(this);
869#endif924#endif
870}925}
...@@ -874,7 +929,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(...@@ -874,7 +929,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
874 const unordered_set& __u)929 const unordered_set& __u)
875 : __table_(__u.__table_)930 : __table_(__u.__table_)
876{931{
877#if _LIBCPP_DEBUG_LEVEL >= 2932#if _LIBCPP_DEBUG_LEVEL == 2
878 __get_db()->__insert_c(this);933 __get_db()->__insert_c(this);
879#endif934#endif
880 __table_.rehash(__u.bucket_count());935 __table_.rehash(__u.bucket_count());
...@@ -886,7 +941,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(...@@ -886,7 +941,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
886 const unordered_set& __u, const allocator_type& __a)941 const unordered_set& __u, const allocator_type& __a)
887 : __table_(__u.__table_, __a)942 : __table_(__u.__table_, __a)
888{943{
889#if _LIBCPP_DEBUG_LEVEL >= 2944#if _LIBCPP_DEBUG_LEVEL == 2
890 __get_db()->__insert_c(this);945 __get_db()->__insert_c(this);
891#endif946#endif
892 __table_.rehash(__u.bucket_count());947 __table_.rehash(__u.bucket_count());
...@@ -902,7 +957,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(...@@ -902,7 +957,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
902 _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)957 _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
903 : __table_(_VSTD::move(__u.__table_))958 : __table_(_VSTD::move(__u.__table_))
904{959{
905#if _LIBCPP_DEBUG_LEVEL >= 2960#if _LIBCPP_DEBUG_LEVEL == 2
906 __get_db()->__insert_c(this);961 __get_db()->__insert_c(this);
907 __get_db()->swap(this, &__u);962 __get_db()->swap(this, &__u);
908#endif963#endif
...@@ -913,7 +968,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(...@@ -913,7 +968,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
913 unordered_set&& __u, const allocator_type& __a)968 unordered_set&& __u, const allocator_type& __a)
914 : __table_(_VSTD::move(__u.__table_), __a)969 : __table_(_VSTD::move(__u.__table_), __a)
915{970{
916#if _LIBCPP_DEBUG_LEVEL >= 2971#if _LIBCPP_DEBUG_LEVEL == 2
917 __get_db()->__insert_c(this);972 __get_db()->__insert_c(this);
918#endif973#endif
919 if (__a != __u.get_allocator())974 if (__a != __u.get_allocator())
...@@ -922,7 +977,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(...@@ -922,7 +977,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
922 while (__u.size() != 0)977 while (__u.size() != 0)
923 __table_.__insert_unique(_VSTD::move(__u.__table_.remove(__i++)->__value_));978 __table_.__insert_unique(_VSTD::move(__u.__table_.remove(__i++)->__value_));
924 }979 }
925#if _LIBCPP_DEBUG_LEVEL >= 2980#if _LIBCPP_DEBUG_LEVEL == 2
926 else981 else
927 __get_db()->swap(this, &__u);982 __get_db()->swap(this, &__u);
928#endif983#endif
...@@ -932,7 +987,7 @@ template <class _Value, class _Hash, class _Pred, class _Alloc>...@@ -932,7 +987,7 @@ template <class _Value, class _Hash, class _Pred, class _Alloc>
932unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(987unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
933 initializer_list<value_type> __il)988 initializer_list<value_type> __il)
934{989{
935#if _LIBCPP_DEBUG_LEVEL >= 2990#if _LIBCPP_DEBUG_LEVEL == 2
936 __get_db()->__insert_c(this);991 __get_db()->__insert_c(this);
937#endif992#endif
938 insert(__il.begin(), __il.end());993 insert(__il.begin(), __il.end());
...@@ -944,7 +999,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(...@@ -944,7 +999,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
944 const key_equal& __eql)999 const key_equal& __eql)
945 : __table_(__hf, __eql)1000 : __table_(__hf, __eql)
946{1001{
947#if _LIBCPP_DEBUG_LEVEL >= 21002#if _LIBCPP_DEBUG_LEVEL == 2
948 __get_db()->__insert_c(this);1003 __get_db()->__insert_c(this);
949#endif1004#endif
950 __table_.rehash(__n);1005 __table_.rehash(__n);
...@@ -957,7 +1012,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(...@@ -957,7 +1012,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
957 const key_equal& __eql, const allocator_type& __a)1012 const key_equal& __eql, const allocator_type& __a)
958 : __table_(__hf, __eql, __a)1013 : __table_(__hf, __eql, __a)
959{1014{
960#if _LIBCPP_DEBUG_LEVEL >= 21015#if _LIBCPP_DEBUG_LEVEL == 2
961 __get_db()->__insert_c(this);1016 __get_db()->__insert_c(this);
962#endif1017#endif
963 __table_.rehash(__n);1018 __table_.rehash(__n);
...@@ -1091,7 +1146,7 @@ public:...@@ -1091,7 +1146,7 @@ public:
1091 unordered_multiset()1146 unordered_multiset()
1092 _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)1147 _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
1093 {1148 {
1094#if _LIBCPP_DEBUG_LEVEL >= 21149#if _LIBCPP_DEBUG_LEVEL == 2
1095 __get_db()->__insert_c(this);1150 __get_db()->__insert_c(this);
1096#endif1151#endif
1097 }1152 }
...@@ -1314,11 +1369,32 @@ public:...@@ -1314,11 +1369,32 @@ public:
1314 iterator find(const key_type& __k) {return __table_.find(__k);}1369 iterator find(const key_type& __k) {return __table_.find(__k);}
1315 _LIBCPP_INLINE_VISIBILITY1370 _LIBCPP_INLINE_VISIBILITY
1316 const_iterator find(const key_type& __k) const {return __table_.find(__k);}1371 const_iterator find(const key_type& __k) const {return __table_.find(__k);}
1372 #if _LIBCPP_STD_VER > 17
1373 template <typename _K2>
1374 _LIBCPP_INLINE_VISIBILITY
1375 _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, iterator>
1376 find(const _K2& __k) {return __table_.find(__k);}
1377 template <typename _K2>
1378 _LIBCPP_INLINE_VISIBILITY
1379 _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, const_iterator>
1380 find(const _K2& __k) const {return __table_.find(__k);}
1381 #endif // _LIBCPP_STD_VER > 17
1317 _LIBCPP_INLINE_VISIBILITY1382 _LIBCPP_INLINE_VISIBILITY
1318 size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}1383 size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
1384 #if _LIBCPP_STD_VER > 17
1385 template <typename _K2>
1386 _LIBCPP_INLINE_VISIBILITY
1387 _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, size_type>
1388 count(const _K2& __k) const {return __table_.__count_multi(__k);}
1389 #endif // _LIBCPP_STD_VER > 17
1319 #if _LIBCPP_STD_VER > 171390 #if _LIBCPP_STD_VER > 17
1320 _LIBCPP_INLINE_VISIBILITY1391 _LIBCPP_INLINE_VISIBILITY
1321 bool contains(const key_type& __k) const {return find(__k) != end();}1392 bool contains(const key_type& __k) const {return find(__k) != end();}
1393
1394 template <typename _K2>
1395 _LIBCPP_INLINE_VISIBILITY
1396 _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, bool>
1397 contains(const _K2& __k) const {return find(__k) != end();}
1322 #endif // _LIBCPP_STD_VER > 171398 #endif // _LIBCPP_STD_VER > 17
1323 _LIBCPP_INLINE_VISIBILITY1399 _LIBCPP_INLINE_VISIBILITY
1324 pair<iterator, iterator> equal_range(const key_type& __k)1400 pair<iterator, iterator> equal_range(const key_type& __k)
...@@ -1326,6 +1402,16 @@ public:...@@ -1326,6 +1402,16 @@ public:
1326 _LIBCPP_INLINE_VISIBILITY1402 _LIBCPP_INLINE_VISIBILITY
1327 pair<const_iterator, const_iterator> equal_range(const key_type& __k) const1403 pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
1328 {return __table_.__equal_range_multi(__k);}1404 {return __table_.__equal_range_multi(__k);}
1405 #if _LIBCPP_STD_VER > 17
1406 template <typename _K2>
1407 _LIBCPP_INLINE_VISIBILITY
1408 _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<iterator, iterator>>
1409 equal_range(const _K2& __k) {return __table_.__equal_range_multi(__k);}
1410 template <typename _K2>
1411 _LIBCPP_INLINE_VISIBILITY
1412 _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<const_iterator, const_iterator>>
1413 equal_range(const _K2& __k) const {return __table_.__equal_range_multi(__k);}
1414 #endif // _LIBCPP_STD_VER > 17
13291415
1330 _LIBCPP_INLINE_VISIBILITY1416 _LIBCPP_INLINE_VISIBILITY
1331 size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}1417 size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
...@@ -1361,7 +1447,7 @@ public:...@@ -1361,7 +1447,7 @@ public:
1361 _LIBCPP_INLINE_VISIBILITY1447 _LIBCPP_INLINE_VISIBILITY
1362 void reserve(size_type __n) {__table_.reserve(__n);}1448 void reserve(size_type __n) {__table_.reserve(__n);}
13631449
1364#if _LIBCPP_DEBUG_LEVEL >= 21450#if _LIBCPP_DEBUG_LEVEL == 2
13651451
1366 bool __dereferenceable(const const_iterator* __i) const1452 bool __dereferenceable(const const_iterator* __i) const
1367 {return __table_.__dereferenceable(__i);}1453 {return __table_.__dereferenceable(__i);}
...@@ -1372,7 +1458,7 @@ public:...@@ -1372,7 +1458,7 @@ public:
1372 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const1458 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
1373 {return __table_.__addable(__i, __n);}1459 {return __table_.__addable(__i, __n);}
13741460
1375#endif // _LIBCPP_DEBUG_LEVEL >= 21461#endif // _LIBCPP_DEBUG_LEVEL == 2
13761462
1377};1463};
13781464
...@@ -1435,7 +1521,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(...@@ -1435,7 +1521,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1435 size_type __n, const hasher& __hf, const key_equal& __eql)1521 size_type __n, const hasher& __hf, const key_equal& __eql)
1436 : __table_(__hf, __eql)1522 : __table_(__hf, __eql)
1437{1523{
1438#if _LIBCPP_DEBUG_LEVEL >= 21524#if _LIBCPP_DEBUG_LEVEL == 2
1439 __get_db()->__insert_c(this);1525 __get_db()->__insert_c(this);
1440#endif1526#endif
1441 __table_.rehash(__n);1527 __table_.rehash(__n);
...@@ -1447,7 +1533,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(...@@ -1447,7 +1533,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1447 const allocator_type& __a)1533 const allocator_type& __a)
1448 : __table_(__hf, __eql, __a)1534 : __table_(__hf, __eql, __a)
1449{1535{
1450#if _LIBCPP_DEBUG_LEVEL >= 21536#if _LIBCPP_DEBUG_LEVEL == 2
1451 __get_db()->__insert_c(this);1537 __get_db()->__insert_c(this);
1452#endif1538#endif
1453 __table_.rehash(__n);1539 __table_.rehash(__n);
...@@ -1458,7 +1544,7 @@ template <class _InputIterator>...@@ -1458,7 +1544,7 @@ template <class _InputIterator>
1458unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(1544unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1459 _InputIterator __first, _InputIterator __last)1545 _InputIterator __first, _InputIterator __last)
1460{1546{
1461#if _LIBCPP_DEBUG_LEVEL >= 21547#if _LIBCPP_DEBUG_LEVEL == 2
1462 __get_db()->__insert_c(this);1548 __get_db()->__insert_c(this);
1463#endif1549#endif
1464 insert(__first, __last);1550 insert(__first, __last);
...@@ -1471,7 +1557,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(...@@ -1471,7 +1557,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1471 const hasher& __hf, const key_equal& __eql)1557 const hasher& __hf, const key_equal& __eql)
1472 : __table_(__hf, __eql)1558 : __table_(__hf, __eql)
1473{1559{
1474#if _LIBCPP_DEBUG_LEVEL >= 21560#if _LIBCPP_DEBUG_LEVEL == 2
1475 __get_db()->__insert_c(this);1561 __get_db()->__insert_c(this);
1476#endif1562#endif
1477 __table_.rehash(__n);1563 __table_.rehash(__n);
...@@ -1485,7 +1571,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(...@@ -1485,7 +1571,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1485 const hasher& __hf, const key_equal& __eql, const allocator_type& __a)1571 const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
1486 : __table_(__hf, __eql, __a)1572 : __table_(__hf, __eql, __a)
1487{1573{
1488#if _LIBCPP_DEBUG_LEVEL >= 21574#if _LIBCPP_DEBUG_LEVEL == 2
1489 __get_db()->__insert_c(this);1575 __get_db()->__insert_c(this);
1490#endif1576#endif
1491 __table_.rehash(__n);1577 __table_.rehash(__n);
...@@ -1498,7 +1584,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(...@@ -1498,7 +1584,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1498 const allocator_type& __a)1584 const allocator_type& __a)
1499 : __table_(__a)1585 : __table_(__a)
1500{1586{
1501#if _LIBCPP_DEBUG_LEVEL >= 21587#if _LIBCPP_DEBUG_LEVEL == 2
1502 __get_db()->__insert_c(this);1588 __get_db()->__insert_c(this);
1503#endif1589#endif
1504}1590}
...@@ -1508,7 +1594,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(...@@ -1508,7 +1594,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1508 const unordered_multiset& __u)1594 const unordered_multiset& __u)
1509 : __table_(__u.__table_)1595 : __table_(__u.__table_)
1510{1596{
1511#if _LIBCPP_DEBUG_LEVEL >= 21597#if _LIBCPP_DEBUG_LEVEL == 2
1512 __get_db()->__insert_c(this);1598 __get_db()->__insert_c(this);
1513#endif1599#endif
1514 __table_.rehash(__u.bucket_count());1600 __table_.rehash(__u.bucket_count());
...@@ -1520,7 +1606,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(...@@ -1520,7 +1606,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1520 const unordered_multiset& __u, const allocator_type& __a)1606 const unordered_multiset& __u, const allocator_type& __a)
1521 : __table_(__u.__table_, __a)1607 : __table_(__u.__table_, __a)
1522{1608{
1523#if _LIBCPP_DEBUG_LEVEL >= 21609#if _LIBCPP_DEBUG_LEVEL == 2
1524 __get_db()->__insert_c(this);1610 __get_db()->__insert_c(this);
1525#endif1611#endif
1526 __table_.rehash(__u.bucket_count());1612 __table_.rehash(__u.bucket_count());
...@@ -1536,7 +1622,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(...@@ -1536,7 +1622,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1536 _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)1622 _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
1537 : __table_(_VSTD::move(__u.__table_))1623 : __table_(_VSTD::move(__u.__table_))
1538{1624{
1539#if _LIBCPP_DEBUG_LEVEL >= 21625#if _LIBCPP_DEBUG_LEVEL == 2
1540 __get_db()->__insert_c(this);1626 __get_db()->__insert_c(this);
1541 __get_db()->swap(this, &__u);1627 __get_db()->swap(this, &__u);
1542#endif1628#endif
...@@ -1547,7 +1633,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(...@@ -1547,7 +1633,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1547 unordered_multiset&& __u, const allocator_type& __a)1633 unordered_multiset&& __u, const allocator_type& __a)
1548 : __table_(_VSTD::move(__u.__table_), __a)1634 : __table_(_VSTD::move(__u.__table_), __a)
1549{1635{
1550#if _LIBCPP_DEBUG_LEVEL >= 21636#if _LIBCPP_DEBUG_LEVEL == 2
1551 __get_db()->__insert_c(this);1637 __get_db()->__insert_c(this);
1552#endif1638#endif
1553 if (__a != __u.get_allocator())1639 if (__a != __u.get_allocator())
...@@ -1556,7 +1642,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(...@@ -1556,7 +1642,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1556 while (__u.size() != 0)1642 while (__u.size() != 0)
1557 __table_.__insert_multi(_VSTD::move(__u.__table_.remove(__i++)->__value_));1643 __table_.__insert_multi(_VSTD::move(__u.__table_.remove(__i++)->__value_));
1558 }1644 }
1559#if _LIBCPP_DEBUG_LEVEL >= 21645#if _LIBCPP_DEBUG_LEVEL == 2
1560 else1646 else
1561 __get_db()->swap(this, &__u);1647 __get_db()->swap(this, &__u);
1562#endif1648#endif
...@@ -1566,7 +1652,7 @@ template <class _Value, class _Hash, class _Pred, class _Alloc>...@@ -1566,7 +1652,7 @@ template <class _Value, class _Hash, class _Pred, class _Alloc>
1566unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(1652unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1567 initializer_list<value_type> __il)1653 initializer_list<value_type> __il)
1568{1654{
1569#if _LIBCPP_DEBUG_LEVEL >= 21655#if _LIBCPP_DEBUG_LEVEL == 2
1570 __get_db()->__insert_c(this);1656 __get_db()->__insert_c(this);
1571#endif1657#endif
1572 insert(__il.begin(), __il.end());1658 insert(__il.begin(), __il.end());
...@@ -1578,7 +1664,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(...@@ -1578,7 +1664,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1578 const key_equal& __eql)1664 const key_equal& __eql)
1579 : __table_(__hf, __eql)1665 : __table_(__hf, __eql)
1580{1666{
1581#if _LIBCPP_DEBUG_LEVEL >= 21667#if _LIBCPP_DEBUG_LEVEL == 2
1582 __get_db()->__insert_c(this);1668 __get_db()->__insert_c(this);
1583#endif1669#endif
1584 __table_.rehash(__n);1670 __table_.rehash(__n);
...@@ -1591,7 +1677,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(...@@ -1591,7 +1677,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1591 const key_equal& __eql, const allocator_type& __a)1677 const key_equal& __eql, const allocator_type& __a)
1592 : __table_(__hf, __eql, __a)1678 : __table_(__hf, __eql, __a)
1593{1679{
1594#if _LIBCPP_DEBUG_LEVEL >= 21680#if _LIBCPP_DEBUG_LEVEL == 2
1595 __get_db()->__insert_c(this);1681 __get_db()->__insert_c(this);
1596#endif1682#endif
1597 __table_.rehash(__n);1683 __table_.rehash(__n);
lib/libcxx/include/utility+24-14
...@@ -499,7 +499,7 @@ struct _LIBCPP_TEMPLATE_VIS pair...@@ -499,7 +499,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
499 second(_VSTD::get<1>(_VSTD::forward<_Tuple>(__p))) {}499 second(_VSTD::get<1>(_VSTD::forward<_Tuple>(__p))) {}
500500
501 template <class... _Args1, class... _Args2>501 template <class... _Args1, class... _Args2>
502 _LIBCPP_INLINE_VISIBILITY502 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
503 pair(piecewise_construct_t __pc,503 pair(piecewise_construct_t __pc,
504 tuple<_Args1...> __first_args, tuple<_Args2...> __second_args)504 tuple<_Args1...> __first_args, tuple<_Args2...> __second_args)
505 _NOEXCEPT_((is_nothrow_constructible<first_type, _Args1...>::value &&505 _NOEXCEPT_((is_nothrow_constructible<first_type, _Args1...>::value &&
...@@ -508,7 +508,7 @@ struct _LIBCPP_TEMPLATE_VIS pair...@@ -508,7 +508,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
508 typename __make_tuple_indices<sizeof...(_Args1)>::type(),508 typename __make_tuple_indices<sizeof...(_Args1)>::type(),
509 typename __make_tuple_indices<sizeof...(_Args2) >::type()) {}509 typename __make_tuple_indices<sizeof...(_Args2) >::type()) {}
510510
511 _LIBCPP_INLINE_VISIBILITY511 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
512 pair& operator=(typename conditional<512 pair& operator=(typename conditional<
513 is_copy_assignable<first_type>::value &&513 is_copy_assignable<first_type>::value &&
514 is_copy_assignable<second_type>::value,514 is_copy_assignable<second_type>::value,
...@@ -521,7 +521,7 @@ struct _LIBCPP_TEMPLATE_VIS pair...@@ -521,7 +521,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
521 return *this;521 return *this;
522 }522 }
523523
524 _LIBCPP_INLINE_VISIBILITY524 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
525 pair& operator=(typename conditional<525 pair& operator=(typename conditional<
526 is_move_assignable<first_type>::value &&526 is_move_assignable<first_type>::value &&
527 is_move_assignable<second_type>::value,527 is_move_assignable<second_type>::value,
...@@ -537,7 +537,7 @@ struct _LIBCPP_TEMPLATE_VIS pair...@@ -537,7 +537,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
537 template <class _Tuple, _EnableB<537 template <class _Tuple, _EnableB<
538 _CheckTLC<_Tuple>::template __enable_assign<_Tuple>()538 _CheckTLC<_Tuple>::template __enable_assign<_Tuple>()
539 > = false>539 > = false>
540 _LIBCPP_INLINE_VISIBILITY540 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
541 pair& operator=(_Tuple&& __p) {541 pair& operator=(_Tuple&& __p) {
542 first = _VSTD::get<0>(_VSTD::forward<_Tuple>(__p));542 first = _VSTD::get<0>(_VSTD::forward<_Tuple>(__p));
543 second = _VSTD::get<1>(_VSTD::forward<_Tuple>(__p));543 second = _VSTD::get<1>(_VSTD::forward<_Tuple>(__p));
...@@ -545,7 +545,7 @@ struct _LIBCPP_TEMPLATE_VIS pair...@@ -545,7 +545,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
545 }545 }
546#endif546#endif
547547
548 _LIBCPP_INLINE_VISIBILITY548 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
549 void549 void
550 swap(pair& __p) _NOEXCEPT_(__is_nothrow_swappable<first_type>::value &&550 swap(pair& __p) _NOEXCEPT_(__is_nothrow_swappable<first_type>::value &&
551 __is_nothrow_swappable<second_type>::value)551 __is_nothrow_swappable<second_type>::value)
...@@ -558,10 +558,10 @@ private:...@@ -558,10 +558,10 @@ private:
558558
559#ifndef _LIBCPP_CXX03_LANG559#ifndef _LIBCPP_CXX03_LANG
560 template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>560 template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
561 _LIBCPP_INLINE_VISIBILITY561 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
562 pair(piecewise_construct_t,562 pair(piecewise_construct_t,
563 tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,563 tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
564 __tuple_indices<_I1...>, __tuple_indices<_I2...>);564 __tuple_indices<_I1...>, __tuple_indices<_I2...>);
565#endif565#endif
566};566};
567567
...@@ -619,7 +619,7 @@ operator<=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)...@@ -619,7 +619,7 @@ operator<=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
619}619}
620620
621template <class _T1, class _T2>621template <class _T1, class _T2>
622inline _LIBCPP_INLINE_VISIBILITY622inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
623typename enable_if623typename enable_if
624<624<
625 __is_swappable<_T1>::value &&625 __is_swappable<_T1>::value &&
...@@ -970,7 +970,7 @@ _Size...@@ -970,7 +970,7 @@ _Size
970__loadword(const void* __p)970__loadword(const void* __p)
971{971{
972 _Size __r;972 _Size __r;
973 std::memcpy(&__r, __p, sizeof(__r));973 _VSTD::memcpy(&__r, __p, sizeof(__r));
974 return __r;974 return __r;
975}975}
976976
...@@ -1189,7 +1189,7 @@ __murmur2_or_cityhash<_Size, 64>::operator()(const void* __key, _Size __len)...@@ -1189,7 +1189,7 @@ __murmur2_or_cityhash<_Size, 64>::operator()(const void* __key, _Size __len)
1189 __v = __weak_hash_len_32_with_seeds(__s, __v.second * __k1, __x + __w.first);1189 __v = __weak_hash_len_32_with_seeds(__s, __v.second * __k1, __x + __w.first);
1190 __w = __weak_hash_len_32_with_seeds(__s + 32, __z + __w.second,1190 __w = __weak_hash_len_32_with_seeds(__s + 32, __z + __w.second,
1191 __y + __loadword<_Size>(__s + 16));1191 __y + __loadword<_Size>(__s + 16));
1192 std::swap(__z, __x);1192 _VSTD::swap(__z, __x);
1193 __s += 64;1193 __s += 64;
1194 __len -= 64;1194 __len -= 64;
1195 } while (__len != 0);1195 } while (__len != 0);
...@@ -1364,6 +1364,16 @@ struct _LIBCPP_TEMPLATE_VIS hash<unsigned char>...@@ -1364,6 +1364,16 @@ struct _LIBCPP_TEMPLATE_VIS hash<unsigned char>
1364 size_t operator()(unsigned char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}1364 size_t operator()(unsigned char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
1365};1365};
13661366
1367#ifndef _LIBCPP_NO_HAS_CHAR8_T
1368template <>
1369struct _LIBCPP_TEMPLATE_VIS hash<char8_t>
1370 : public unary_function<char8_t, size_t>
1371{
1372 _LIBCPP_INLINE_VISIBILITY
1373 size_t operator()(char8_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
1374};
1375#endif // !_LIBCPP_NO_HAS_CHAR8_T
1376
1367#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS1377#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
13681378
1369template <>1379template <>
...@@ -1506,7 +1516,7 @@ struct _LIBCPP_TEMPLATE_VIS hash<long double>...@@ -1506,7 +1516,7 @@ struct _LIBCPP_TEMPLATE_VIS hash<long double>
1506 // -0.0 and 0.0 should return same hash1516 // -0.0 and 0.0 should return same hash
1507 if (__v == 0.0L)1517 if (__v == 0.0L)
1508 return 0;1518 return 0;
1509#if defined(__i386__)1519#if defined(__i386__) || (defined(__x86_64__) && defined(__ILP32__))
1510 // Zero out padding bits1520 // Zero out padding bits
1511 union1521 union
1512 {1522 {
...@@ -1593,7 +1603,7 @@ using __check_hash_requirements _LIBCPP_NODEBUG_TYPE = integral_constant<bool,...@@ -1593,7 +1603,7 @@ using __check_hash_requirements _LIBCPP_NODEBUG_TYPE = integral_constant<bool,
1593 __invokable_r<size_t, _Hash, _Key const&>::value1603 __invokable_r<size_t, _Hash, _Key const&>::value
1594>;1604>;
15951605
1596template <class _Key, class _Hash = std::hash<_Key> >1606template <class _Key, class _Hash = hash<_Key> >
1597using __has_enabled_hash _LIBCPP_NODEBUG_TYPE = integral_constant<bool,1607using __has_enabled_hash _LIBCPP_NODEBUG_TYPE = integral_constant<bool,
1598 __check_hash_requirements<_Key, _Hash>::value &&1608 __check_hash_requirements<_Key, _Hash>::value &&
1599 is_default_constructible<_Hash>::value1609 is_default_constructible<_Hash>::value
lib/libcxx/include/valarray+73-95
...@@ -136,6 +136,7 @@ public:...@@ -136,6 +136,7 @@ public:
136 void operator>>=(const valarray<value_type>& v) const;136 void operator>>=(const valarray<value_type>& v) const;
137137
138 void operator=(const value_type& x) const;138 void operator=(const value_type& x) const;
139 void operator=(const valarray<T>& val_arr) const;
139140
140 slice_array() = delete;141 slice_array() = delete;
141};142};
...@@ -802,7 +803,7 @@ private:...@@ -802,7 +803,7 @@ private:
802public:803public:
803 // construct/destroy:804 // construct/destroy:
804 _LIBCPP_INLINE_VISIBILITY805 _LIBCPP_INLINE_VISIBILITY
805 valarray() : __begin_(0), __end_(0) {}806 valarray() : __begin_(nullptr), __end_(nullptr) {}
806 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1807 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
807 explicit valarray(size_t __n);808 explicit valarray(size_t __n);
808 _LIBCPP_INLINE_VISIBILITY809 _LIBCPP_INLINE_VISIBILITY
...@@ -1264,6 +1265,9 @@ public:...@@ -1264,6 +1265,9 @@ public:
1264 _LIBCPP_INLINE_VISIBILITY1265 _LIBCPP_INLINE_VISIBILITY
1265 void operator=(const value_type& __x) const;1266 void operator=(const value_type& __x) const;
12661267
1268 _LIBCPP_INLINE_VISIBILITY
1269 void operator=(const valarray<value_type>& __va) const;
1270
1267private:1271private:
1268 _LIBCPP_INLINE_VISIBILITY1272 _LIBCPP_INLINE_VISIBILITY
1269 slice_array(const slice& __sl, const valarray<value_type>& __v)1273 slice_array(const slice& __sl, const valarray<value_type>& __v)
...@@ -1303,6 +1307,15 @@ slice_array<_Tp>::operator=(const _Expr& __v) const...@@ -1303,6 +1307,15 @@ slice_array<_Tp>::operator=(const _Expr& __v) const
1303 *__t = __v[__i];1307 *__t = __v[__i];
1304}1308}
13051309
1310template <class _Tp>
1311inline void
1312slice_array<_Tp>::operator=(const valarray<value_type>& __va) const
1313{
1314 value_type* __t = __vp_;
1315 for (size_t __i = 0; __i < __va.size(); ++__i, __t += __stride_)
1316 *__t = __va[__i];
1317}
1318
1306template <class _Tp>1319template <class _Tp>
1307template <class _Expr>1320template <class _Expr>
1308inline1321inline
...@@ -2738,11 +2751,9 @@ __val_expr<_ValExpr>::operator valarray<__val_expr::result_type>() const...@@ -2738,11 +2751,9 @@ __val_expr<_ValExpr>::operator valarray<__val_expr::result_type>() const
2738 if (__n)2751 if (__n)
2739 {2752 {
2740 __r.__begin_ =2753 __r.__begin_ =
2741 __r.__end_ =2754 __r.__end_ = allocator<result_type>().allocate(__n);
2742 static_cast<result_type*>(
2743 _VSTD::__libcpp_allocate(__n * sizeof(result_type), _LIBCPP_ALIGNOF(result_type)));
2744 for (size_t __i = 0; __i != __n; ++__r.__end_, ++__i)2755 for (size_t __i = 0; __i != __n; ++__r.__end_, ++__i)
2745 ::new (__r.__end_) result_type(__expr_[__i]);2756 ::new ((void*)__r.__end_) result_type(__expr_[__i]);
2746 }2757 }
2747 return __r;2758 return __r;
2748}2759}
...@@ -2752,19 +2763,18 @@ __val_expr<_ValExpr>::operator valarray<__val_expr::result_type>() const...@@ -2752,19 +2763,18 @@ __val_expr<_ValExpr>::operator valarray<__val_expr::result_type>() const
2752template <class _Tp>2763template <class _Tp>
2753inline2764inline
2754valarray<_Tp>::valarray(size_t __n)2765valarray<_Tp>::valarray(size_t __n)
2755 : __begin_(0),2766 : __begin_(nullptr),
2756 __end_(0)2767 __end_(nullptr)
2757{2768{
2758 if (__n)2769 if (__n)
2759 {2770 {
2760 __begin_ = __end_ = static_cast<value_type*>(2771 __begin_ = __end_ = allocator<value_type>().allocate(__n);
2761 _VSTD::__libcpp_allocate(__n * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)));
2762#ifndef _LIBCPP_NO_EXCEPTIONS2772#ifndef _LIBCPP_NO_EXCEPTIONS
2763 try2773 try
2764 {2774 {
2765#endif // _LIBCPP_NO_EXCEPTIONS2775#endif // _LIBCPP_NO_EXCEPTIONS
2766 for (size_t __n_left = __n; __n_left; --__n_left, ++__end_)2776 for (size_t __n_left = __n; __n_left; --__n_left, ++__end_)
2767 ::new (__end_) value_type();2777 ::new ((void*)__end_) value_type();
2768#ifndef _LIBCPP_NO_EXCEPTIONS2778#ifndef _LIBCPP_NO_EXCEPTIONS
2769 }2779 }
2770 catch (...)2780 catch (...)
...@@ -2779,27 +2789,26 @@ valarray<_Tp>::valarray(size_t __n)...@@ -2779,27 +2789,26 @@ valarray<_Tp>::valarray(size_t __n)
2779template <class _Tp>2789template <class _Tp>
2780inline2790inline
2781valarray<_Tp>::valarray(const value_type& __x, size_t __n)2791valarray<_Tp>::valarray(const value_type& __x, size_t __n)
2782 : __begin_(0),2792 : __begin_(nullptr),
2783 __end_(0)2793 __end_(nullptr)
2784{2794{
2785 resize(__n, __x);2795 resize(__n, __x);
2786}2796}
27872797
2788template <class _Tp>2798template <class _Tp>
2789valarray<_Tp>::valarray(const value_type* __p, size_t __n)2799valarray<_Tp>::valarray(const value_type* __p, size_t __n)
2790 : __begin_(0),2800 : __begin_(nullptr),
2791 __end_(0)2801 __end_(nullptr)
2792{2802{
2793 if (__n)2803 if (__n)
2794 {2804 {
2795 __begin_ = __end_ = static_cast<value_type*>(2805 __begin_ = __end_ = allocator<value_type>().allocate(__n);
2796 _VSTD::__libcpp_allocate(__n * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)));
2797#ifndef _LIBCPP_NO_EXCEPTIONS2806#ifndef _LIBCPP_NO_EXCEPTIONS
2798 try2807 try
2799 {2808 {
2800#endif // _LIBCPP_NO_EXCEPTIONS2809#endif // _LIBCPP_NO_EXCEPTIONS
2801 for (size_t __n_left = __n; __n_left; ++__end_, ++__p, --__n_left)2810 for (size_t __n_left = __n; __n_left; ++__end_, ++__p, --__n_left)
2802 ::new (__end_) value_type(*__p);2811 ::new ((void*)__end_) value_type(*__p);
2803#ifndef _LIBCPP_NO_EXCEPTIONS2812#ifndef _LIBCPP_NO_EXCEPTIONS
2804 }2813 }
2805 catch (...)2814 catch (...)
...@@ -2813,19 +2822,18 @@ valarray<_Tp>::valarray(const value_type* __p, size_t __n)...@@ -2813,19 +2822,18 @@ valarray<_Tp>::valarray(const value_type* __p, size_t __n)
28132822
2814template <class _Tp>2823template <class _Tp>
2815valarray<_Tp>::valarray(const valarray& __v)2824valarray<_Tp>::valarray(const valarray& __v)
2816 : __begin_(0),2825 : __begin_(nullptr),
2817 __end_(0)2826 __end_(nullptr)
2818{2827{
2819 if (__v.size())2828 if (__v.size())
2820 {2829 {
2821 __begin_ = __end_ = static_cast<value_type*>(2830 __begin_ = __end_ = allocator<value_type>().allocate(__v.size());
2822 _VSTD::__libcpp_allocate(__v.size() * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)));
2823#ifndef _LIBCPP_NO_EXCEPTIONS2831#ifndef _LIBCPP_NO_EXCEPTIONS
2824 try2832 try
2825 {2833 {
2826#endif // _LIBCPP_NO_EXCEPTIONS2834#endif // _LIBCPP_NO_EXCEPTIONS
2827 for (value_type* __p = __v.__begin_; __p != __v.__end_; ++__end_, ++__p)2835 for (value_type* __p = __v.__begin_; __p != __v.__end_; ++__end_, ++__p)
2828 ::new (__end_) value_type(*__p);2836 ::new ((void*)__end_) value_type(*__p);
2829#ifndef _LIBCPP_NO_EXCEPTIONS2837#ifndef _LIBCPP_NO_EXCEPTIONS
2830 }2838 }
2831 catch (...)2839 catch (...)
...@@ -2850,21 +2858,20 @@ valarray<_Tp>::valarray(valarray&& __v) _NOEXCEPT...@@ -2850,21 +2858,20 @@ valarray<_Tp>::valarray(valarray&& __v) _NOEXCEPT
28502858
2851template <class _Tp>2859template <class _Tp>
2852valarray<_Tp>::valarray(initializer_list<value_type> __il)2860valarray<_Tp>::valarray(initializer_list<value_type> __il)
2853 : __begin_(0),2861 : __begin_(nullptr),
2854 __end_(0)2862 __end_(nullptr)
2855{2863{
2856 const size_t __n = __il.size();2864 const size_t __n = __il.size();
2857 if (__n)2865 if (__n)
2858 {2866 {
2859 __begin_ = __end_ = static_cast<value_type*>(2867 __begin_ = __end_ = allocator<value_type>().allocate(__n);
2860_VSTD::__libcpp_allocate(__n * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)));
2861#ifndef _LIBCPP_NO_EXCEPTIONS2868#ifndef _LIBCPP_NO_EXCEPTIONS
2862 try2869 try
2863 {2870 {
2864#endif // _LIBCPP_NO_EXCEPTIONS2871#endif // _LIBCPP_NO_EXCEPTIONS
2865 size_t __n_left = __n;2872 size_t __n_left = __n;
2866 for (const value_type* __p = __il.begin(); __n_left; ++__end_, ++__p, --__n_left)2873 for (const value_type* __p = __il.begin(); __n_left; ++__end_, ++__p, --__n_left)
2867 ::new (__end_) value_type(*__p);2874 ::new ((void*)__end_) value_type(*__p);
2868#ifndef _LIBCPP_NO_EXCEPTIONS2875#ifndef _LIBCPP_NO_EXCEPTIONS
2869 }2876 }
2870 catch (...)2877 catch (...)
...@@ -2880,21 +2887,20 @@ _VSTD::__libcpp_allocate(__n * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)))...@@ -2880,21 +2887,20 @@ _VSTD::__libcpp_allocate(__n * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)))
28802887
2881template <class _Tp>2888template <class _Tp>
2882valarray<_Tp>::valarray(const slice_array<value_type>& __sa)2889valarray<_Tp>::valarray(const slice_array<value_type>& __sa)
2883 : __begin_(0),2890 : __begin_(nullptr),
2884 __end_(0)2891 __end_(nullptr)
2885{2892{
2886 const size_t __n = __sa.__size_;2893 const size_t __n = __sa.__size_;
2887 if (__n)2894 if (__n)
2888 {2895 {
2889 __begin_ = __end_ = static_cast<value_type*>(2896 __begin_ = __end_ = allocator<value_type>().allocate(__n);
2890 _VSTD::__libcpp_allocate(__n * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)));
2891#ifndef _LIBCPP_NO_EXCEPTIONS2897#ifndef _LIBCPP_NO_EXCEPTIONS
2892 try2898 try
2893 {2899 {
2894#endif // _LIBCPP_NO_EXCEPTIONS2900#endif // _LIBCPP_NO_EXCEPTIONS
2895 size_t __n_left = __n;2901 size_t __n_left = __n;
2896 for (const value_type* __p = __sa.__vp_; __n_left; ++__end_, __p += __sa.__stride_, --__n_left)2902 for (const value_type* __p = __sa.__vp_; __n_left; ++__end_, __p += __sa.__stride_, --__n_left)
2897 ::new (__end_) value_type(*__p);2903 ::new ((void*)__end_) value_type(*__p);
2898#ifndef _LIBCPP_NO_EXCEPTIONS2904#ifndef _LIBCPP_NO_EXCEPTIONS
2899 }2905 }
2900 catch (...)2906 catch (...)
...@@ -2908,14 +2914,13 @@ valarray<_Tp>::valarray(const slice_array<value_type>& __sa)...@@ -2908,14 +2914,13 @@ valarray<_Tp>::valarray(const slice_array<value_type>& __sa)
29082914
2909template <class _Tp>2915template <class _Tp>
2910valarray<_Tp>::valarray(const gslice_array<value_type>& __ga)2916valarray<_Tp>::valarray(const gslice_array<value_type>& __ga)
2911 : __begin_(0),2917 : __begin_(nullptr),
2912 __end_(0)2918 __end_(nullptr)
2913{2919{
2914 const size_t __n = __ga.__1d_.size();2920 const size_t __n = __ga.__1d_.size();
2915 if (__n)2921 if (__n)
2916 {2922 {
2917 __begin_ = __end_ = static_cast<value_type*>(2923 __begin_ = __end_ = allocator<value_type>().allocate(__n);
2918 _VSTD::__libcpp_allocate(__n * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)));
2919#ifndef _LIBCPP_NO_EXCEPTIONS2924#ifndef _LIBCPP_NO_EXCEPTIONS
2920 try2925 try
2921 {2926 {
...@@ -2924,7 +2929,7 @@ valarray<_Tp>::valarray(const gslice_array<value_type>& __ga)...@@ -2924,7 +2929,7 @@ valarray<_Tp>::valarray(const gslice_array<value_type>& __ga)
2924 const value_type* __s = __ga.__vp_;2929 const value_type* __s = __ga.__vp_;
2925 for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_;2930 for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_;
2926 __i != __e; ++__i, ++__end_)2931 __i != __e; ++__i, ++__end_)
2927 ::new (__end_) value_type(__s[*__i]);2932 ::new ((void*)__end_) value_type(__s[*__i]);
2928#ifndef _LIBCPP_NO_EXCEPTIONS2933#ifndef _LIBCPP_NO_EXCEPTIONS
2929 }2934 }
2930 catch (...)2935 catch (...)
...@@ -2938,14 +2943,13 @@ valarray<_Tp>::valarray(const gslice_array<value_type>& __ga)...@@ -2938,14 +2943,13 @@ valarray<_Tp>::valarray(const gslice_array<value_type>& __ga)
29382943
2939template <class _Tp>2944template <class _Tp>
2940valarray<_Tp>::valarray(const mask_array<value_type>& __ma)2945valarray<_Tp>::valarray(const mask_array<value_type>& __ma)
2941 : __begin_(0),2946 : __begin_(nullptr),
2942 __end_(0)2947 __end_(nullptr)
2943{2948{
2944 const size_t __n = __ma.__1d_.size();2949 const size_t __n = __ma.__1d_.size();
2945 if (__n)2950 if (__n)
2946 {2951 {
2947 __begin_ = __end_ = static_cast<value_type*>(2952 __begin_ = __end_ = allocator<value_type>().allocate(__n);
2948 _VSTD::__libcpp_allocate(__n * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)));
2949#ifndef _LIBCPP_NO_EXCEPTIONS2953#ifndef _LIBCPP_NO_EXCEPTIONS
2950 try2954 try
2951 {2955 {
...@@ -2954,7 +2958,7 @@ valarray<_Tp>::valarray(const mask_array<value_type>& __ma)...@@ -2954,7 +2958,7 @@ valarray<_Tp>::valarray(const mask_array<value_type>& __ma)
2954 const value_type* __s = __ma.__vp_;2958 const value_type* __s = __ma.__vp_;
2955 for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_;2959 for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_;
2956 __i != __e; ++__i, ++__end_)2960 __i != __e; ++__i, ++__end_)
2957 ::new (__end_) value_type(__s[*__i]);2961 ::new ((void*)__end_) value_type(__s[*__i]);
2958#ifndef _LIBCPP_NO_EXCEPTIONS2962#ifndef _LIBCPP_NO_EXCEPTIONS
2959 }2963 }
2960 catch (...)2964 catch (...)
...@@ -2968,14 +2972,13 @@ valarray<_Tp>::valarray(const mask_array<value_type>& __ma)...@@ -2968,14 +2972,13 @@ valarray<_Tp>::valarray(const mask_array<value_type>& __ma)
29682972
2969template <class _Tp>2973template <class _Tp>
2970valarray<_Tp>::valarray(const indirect_array<value_type>& __ia)2974valarray<_Tp>::valarray(const indirect_array<value_type>& __ia)
2971 : __begin_(0),2975 : __begin_(nullptr),
2972 __end_(0)2976 __end_(nullptr)
2973{2977{
2974 const size_t __n = __ia.__1d_.size();2978 const size_t __n = __ia.__1d_.size();
2975 if (__n)2979 if (__n)
2976 {2980 {
2977 __begin_ = __end_ = static_cast<value_type*>(2981 __begin_ = __end_ = allocator<value_type>().allocate(__n);
2978 _VSTD::__libcpp_allocate(__n * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)));
2979#ifndef _LIBCPP_NO_EXCEPTIONS2982#ifndef _LIBCPP_NO_EXCEPTIONS
2980 try2983 try
2981 {2984 {
...@@ -2984,7 +2987,7 @@ valarray<_Tp>::valarray(const indirect_array<value_type>& __ia)...@@ -2984,7 +2987,7 @@ valarray<_Tp>::valarray(const indirect_array<value_type>& __ia)
2984 const value_type* __s = __ia.__vp_;2987 const value_type* __s = __ia.__vp_;
2985 for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_;2988 for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_;
2986 __i != __e; ++__i, ++__end_)2989 __i != __e; ++__i, ++__end_)
2987 ::new (__end_) value_type(__s[*__i]);2990 ::new ((void*)__end_) value_type(__s[*__i]);
2988#ifndef _LIBCPP_NO_EXCEPTIONS2991#ifndef _LIBCPP_NO_EXCEPTIONS
2989 }2992 }
2990 catch (...)2993 catch (...)
...@@ -3011,8 +3014,7 @@ valarray<_Tp>::__assign_range(const value_type* __f, const value_type* __l)...@@ -3011,8 +3014,7 @@ valarray<_Tp>::__assign_range(const value_type* __f, const value_type* __l)
3011 if (size() != __n)3014 if (size() != __n)
3012 {3015 {
3013 __clear(size());3016 __clear(size());
3014 __begin_ = static_cast<value_type*>(3017 __begin_ = allocator<value_type>().allocate(__n);
3015 _VSTD::__libcpp_allocate(__n * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)));
3016 __end_ = __begin_ + __n;3018 __end_ = __begin_ + __n;
3017 _VSTD::uninitialized_copy(__f, __l, __begin_);3019 _VSTD::uninitialized_copy(__f, __l, __begin_);
3018 } else {3020 } else {
...@@ -3265,12 +3267,9 @@ valarray<_Tp>::operator+() const...@@ -3265,12 +3267,9 @@ valarray<_Tp>::operator+() const
3265 size_t __n = size();3267 size_t __n = size();
3266 if (__n)3268 if (__n)
3267 {3269 {
3268 __r.__begin_ =3270 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
3269 __r.__end_ =
3270 static_cast<value_type*>(
3271 _VSTD::__libcpp_allocate(__n * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)));
3272 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)3271 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3273 ::new (__r.__end_) value_type(+*__p);3272 ::new ((void*)__r.__end_) value_type(+*__p);
3274 }3273 }
3275 return __r;3274 return __r;
3276}3275}
...@@ -3283,12 +3282,9 @@ valarray<_Tp>::operator-() const...@@ -3283,12 +3282,9 @@ valarray<_Tp>::operator-() const
3283 size_t __n = size();3282 size_t __n = size();
3284 if (__n)3283 if (__n)
3285 {3284 {
3286 __r.__begin_ =3285 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
3287 __r.__end_ =
3288 static_cast<value_type*>(
3289 _VSTD::__libcpp_allocate(__n * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)));
3290 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)3286 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3291 ::new (__r.__end_) value_type(-*__p);3287 ::new ((void*)__r.__end_) value_type(-*__p);
3292 }3288 }
3293 return __r;3289 return __r;
3294}3290}
...@@ -3301,12 +3297,9 @@ valarray<_Tp>::operator~() const...@@ -3301,12 +3297,9 @@ valarray<_Tp>::operator~() const
3301 size_t __n = size();3297 size_t __n = size();
3302 if (__n)3298 if (__n)
3303 {3299 {
3304 __r.__begin_ =3300 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
3305 __r.__end_ =
3306 static_cast<value_type*>(
3307 _VSTD::__libcpp_allocate(__n * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)));
3308 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)3301 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3309 ::new (__r.__end_) value_type(~*__p);3302 ::new ((void*)__r.__end_) value_type(~*__p);
3310 }3303 }
3311 return __r;3304 return __r;
3312}3305}
...@@ -3319,11 +3312,9 @@ valarray<_Tp>::operator!() const...@@ -3319,11 +3312,9 @@ valarray<_Tp>::operator!() const
3319 size_t __n = size();3312 size_t __n = size();
3320 if (__n)3313 if (__n)
3321 {3314 {
3322 __r.__begin_ =3315 __r.__begin_ = __r.__end_ = allocator<bool>().allocate(__n);
3323 __r.__end_ =
3324 static_cast<bool*>(_VSTD::__libcpp_allocate(__n * sizeof(bool), _LIBCPP_ALIGNOF(bool)));
3325 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)3316 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3326 ::new (__r.__end_) bool(!*__p);3317 ::new ((void*)__r.__end_) bool(!*__p);
3327 }3318 }
3328 return __r;3319 return __r;
3329}3320}
...@@ -3639,10 +3630,7 @@ valarray<_Tp>::shift(int __i) const...@@ -3639,10 +3630,7 @@ valarray<_Tp>::shift(int __i) const
3639 size_t __n = size();3630 size_t __n = size();
3640 if (__n)3631 if (__n)
3641 {3632 {
3642 __r.__begin_ =3633 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
3643 __r.__end_ =
3644 static_cast<value_type*>(
3645 _VSTD::__libcpp_allocate(__n * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)));
3646 const value_type* __sb;3634 const value_type* __sb;
3647 value_type* __tb;3635 value_type* __tb;
3648 value_type* __te;3636 value_type* __te;
...@@ -3661,11 +3649,11 @@ valarray<_Tp>::shift(int __i) const...@@ -3661,11 +3649,11 @@ valarray<_Tp>::shift(int __i) const
3661 __te = __r.__begin_ + __n;3649 __te = __r.__begin_ + __n;
3662 }3650 }
3663 for (; __r.__end_ != __tb; ++__r.__end_)3651 for (; __r.__end_ != __tb; ++__r.__end_)
3664 ::new (__r.__end_) value_type();3652 ::new ((void*)__r.__end_) value_type();
3665 for (; __r.__end_ != __te; ++__r.__end_, ++__sb)3653 for (; __r.__end_ != __te; ++__r.__end_, ++__sb)
3666 ::new (__r.__end_) value_type(*__sb);3654 ::new ((void*)__r.__end_) value_type(*__sb);
3667 for (__te = __r.__begin_ + __n; __r.__end_ != __te; ++__r.__end_)3655 for (__te = __r.__begin_ + __n; __r.__end_ != __te; ++__r.__end_)
3668 ::new (__r.__end_) value_type();3656 ::new ((void*)__r.__end_) value_type();
3669 }3657 }
3670 return __r;3658 return __r;
3671}3659}
...@@ -3678,16 +3666,13 @@ valarray<_Tp>::cshift(int __i) const...@@ -3678,16 +3666,13 @@ valarray<_Tp>::cshift(int __i) const
3678 size_t __n = size();3666 size_t __n = size();
3679 if (__n)3667 if (__n)
3680 {3668 {
3681 __r.__begin_ =3669 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
3682 __r.__end_ =
3683 static_cast<value_type*>(
3684 _VSTD::__libcpp_allocate(__n * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)));
3685 __i %= static_cast<int>(__n);3670 __i %= static_cast<int>(__n);
3686 const value_type* __m = __i >= 0 ? __begin_ + __i : __end_ + __i;3671 const value_type* __m = __i >= 0 ? __begin_ + __i : __end_ + __i;
3687 for (const value_type* __s = __m; __s != __end_; ++__r.__end_, ++__s)3672 for (const value_type* __s = __m; __s != __end_; ++__r.__end_, ++__s)
3688 ::new (__r.__end_) value_type(*__s);3673 ::new ((void*)__r.__end_) value_type(*__s);
3689 for (const value_type* __s = __begin_; __s != __m; ++__r.__end_, ++__s)3674 for (const value_type* __s = __begin_; __s != __m; ++__r.__end_, ++__s)
3690 ::new (__r.__end_) value_type(*__s);3675 ::new ((void*)__r.__end_) value_type(*__s);
3691 }3676 }
3692 return __r;3677 return __r;
3693}3678}
...@@ -3700,12 +3685,9 @@ valarray<_Tp>::apply(value_type __f(value_type)) const...@@ -3700,12 +3685,9 @@ valarray<_Tp>::apply(value_type __f(value_type)) const
3700 size_t __n = size();3685 size_t __n = size();
3701 if (__n)3686 if (__n)
3702 {3687 {
3703 __r.__begin_ =3688 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
3704 __r.__end_ =
3705 static_cast<value_type*>(
3706 _VSTD::__libcpp_allocate(__n * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)));
3707 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)3689 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3708 ::new (__r.__end_) value_type(__f(*__p));3690 ::new ((void*)__r.__end_) value_type(__f(*__p));
3709 }3691 }
3710 return __r;3692 return __r;
3711}3693}
...@@ -3718,12 +3700,9 @@ valarray<_Tp>::apply(value_type __f(const value_type&)) const...@@ -3718,12 +3700,9 @@ valarray<_Tp>::apply(value_type __f(const value_type&)) const
3718 size_t __n = size();3700 size_t __n = size();
3719 if (__n)3701 if (__n)
3720 {3702 {
3721 __r.__begin_ =3703 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
3722 __r.__end_ =
3723 static_cast<value_type*>(
3724 _VSTD::__libcpp_allocate(__n * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)));
3725 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)3704 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3726 ::new (__r.__end_) value_type(__f(*__p));3705 ::new ((void*)__r.__end_) value_type(__f(*__p));
3727 }3706 }
3728 return __r;3707 return __r;
3729}3708}
...@@ -3736,7 +3715,7 @@ void valarray<_Tp>::__clear(size_t __capacity)...@@ -3736,7 +3715,7 @@ void valarray<_Tp>::__clear(size_t __capacity)
3736 {3715 {
3737 while (__end_ != __begin_)3716 while (__end_ != __begin_)
3738 (--__end_)->~value_type();3717 (--__end_)->~value_type();
3739 _VSTD::__libcpp_deallocate(__begin_, __capacity * sizeof(value_type), _LIBCPP_ALIGNOF(value_type));3718 allocator<value_type>().deallocate(__begin_, __capacity);
3740 __begin_ = __end_ = nullptr;3719 __begin_ = __end_ = nullptr;
3741 }3720 }
3742}3721}
...@@ -3748,14 +3727,13 @@ valarray<_Tp>::resize(size_t __n, value_type __x)...@@ -3748,14 +3727,13 @@ valarray<_Tp>::resize(size_t __n, value_type __x)
3748 __clear(size());3727 __clear(size());
3749 if (__n)3728 if (__n)
3750 {3729 {
3751 __begin_ = __end_ = static_cast<value_type*>(3730 __begin_ = __end_ = allocator<value_type>().allocate(__n);
3752 _VSTD::__libcpp_allocate(__n * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)));
3753#ifndef _LIBCPP_NO_EXCEPTIONS3731#ifndef _LIBCPP_NO_EXCEPTIONS
3754 try3732 try
3755 {3733 {
3756#endif // _LIBCPP_NO_EXCEPTIONS3734#endif // _LIBCPP_NO_EXCEPTIONS
3757 for (size_t __n_left = __n; __n_left; --__n_left, ++__end_)3735 for (size_t __n_left = __n; __n_left; --__n_left, ++__end_)
3758 ::new (__end_) value_type(__x);3736 ::new ((void*)__end_) value_type(__x);
3759#ifndef _LIBCPP_NO_EXCEPTIONS3737#ifndef _LIBCPP_NO_EXCEPTIONS
3760 }3738 }
3761 catch (...)3739 catch (...)
lib/libcxx/include/variant+29-25
...@@ -197,6 +197,7 @@ namespace std {...@@ -197,6 +197,7 @@ namespace std {
197*/197*/
198198
199#include <__config>199#include <__config>
200#include <__availability>
200#include <__tuple>201#include <__tuple>
201#include <array>202#include <array>
202#include <exception>203#include <exception>
...@@ -227,7 +228,10 @@ public:...@@ -227,7 +228,10 @@ public:
227228
228_LIBCPP_BEGIN_NAMESPACE_STD229_LIBCPP_BEGIN_NAMESPACE_STD
229230
230#if _LIBCPP_STD_VER > 14231// TODO: GCC 5 lies about its support for C++17 (it says it supports it but it
232// really doesn't). That breaks variant, which uses some C++17 features.
233// Remove this once we drop support for GCC 5.
234#if _LIBCPP_STD_VER > 14 && !(defined(_LIBCPP_COMPILER_GCC) && _GNUC_VER_NEW < 6000)
231235
232_LIBCPP_NORETURN236_LIBCPP_NORETURN
233inline _LIBCPP_INLINE_VISIBILITY237inline _LIBCPP_INLINE_VISIBILITY
...@@ -290,9 +294,9 @@ struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, variant<_Types...>> {...@@ -290,9 +294,9 @@ struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, variant<_Types...>> {
290_LIBCPP_INLINE_VAR constexpr size_t variant_npos = static_cast<size_t>(-1);294_LIBCPP_INLINE_VAR constexpr size_t variant_npos = static_cast<size_t>(-1);
291295
292constexpr int __choose_index_type(unsigned int __num_elem) {296constexpr int __choose_index_type(unsigned int __num_elem) {
293 if (__num_elem < std::numeric_limits<unsigned char>::max())297 if (__num_elem < numeric_limits<unsigned char>::max())
294 return 0;298 return 0;
295 if (__num_elem < std::numeric_limits<unsigned short>::max())299 if (__num_elem < numeric_limits<unsigned short>::max())
296 return 1;300 return 1;
297 return 2;301 return 2;
298}302}
...@@ -482,12 +486,12 @@ private:...@@ -482,12 +486,12 @@ private:
482 return __result{{_VSTD::forward<_Fs>(__fs)...}};486 return __result{{_VSTD::forward<_Fs>(__fs)...}};
483 }487 }
484488
485 template <std::size_t... _Is>489 template <size_t... _Is>
486 struct __dispatcher {490 struct __dispatcher {
487 template <class _Fp, class... _Vs>491 template <class _Fp, class... _Vs>
488 inline _LIBCPP_INLINE_VISIBILITY492 inline _LIBCPP_INLINE_VISIBILITY
489 static constexpr decltype(auto) __dispatch(_Fp __f, _Vs... __vs) {493 static constexpr decltype(auto) __dispatch(_Fp __f, _Vs... __vs) {
490 return __invoke_constexpr(494 return _VSTD::__invoke_constexpr(
491 static_cast<_Fp>(__f),495 static_cast<_Fp>(__f),
492 __access::__base::__get_alt<_Is>(static_cast<_Vs>(__vs))...);496 __access::__base::__get_alt<_Is>(static_cast<_Vs>(__vs))...);
493 }497 }
...@@ -595,7 +599,7 @@ private:...@@ -595,7 +599,7 @@ private:
595 __std_visit_exhaustive_visitor_check<599 __std_visit_exhaustive_visitor_check<
596 _Visitor,600 _Visitor,
597 decltype((_VSTD::forward<_Alts>(__alts).__value))...>();601 decltype((_VSTD::forward<_Alts>(__alts).__value))...>();
598 return __invoke_constexpr(_VSTD::forward<_Visitor>(__visitor),602 return _VSTD::__invoke_constexpr(_VSTD::forward<_Visitor>(__visitor),
599 _VSTD::forward<_Alts>(__alts).__value...);603 _VSTD::forward<_Alts>(__alts).__value...);
600 }604 }
601 _Visitor&& __visitor;605 _Visitor&& __visitor;
...@@ -720,12 +724,12 @@ protected:...@@ -720,12 +724,12 @@ protected:
720};724};
721725
722template <class _Traits, _Trait = _Traits::__destructible_trait>726template <class _Traits, _Trait = _Traits::__destructible_trait>
723class _LIBCPP_TEMPLATE_VIS __destructor;727class _LIBCPP_TEMPLATE_VIS __dtor;
724728
725#define _LIBCPP_VARIANT_DESTRUCTOR(destructible_trait, destructor, destroy) \729#define _LIBCPP_VARIANT_DESTRUCTOR(destructible_trait, destructor, destroy) \
726 template <class... _Types> \730 template <class... _Types> \
727 class _LIBCPP_TEMPLATE_VIS __destructor<__traits<_Types...>, \731 class _LIBCPP_TEMPLATE_VIS __dtor<__traits<_Types...>, \
728 destructible_trait> \732 destructible_trait> \
729 : public __base<destructible_trait, _Types...> { \733 : public __base<destructible_trait, _Types...> { \
730 using __base_type = __base<destructible_trait, _Types...>; \734 using __base_type = __base<destructible_trait, _Types...>; \
731 using __index_t = typename __base_type::__index_t; \735 using __index_t = typename __base_type::__index_t; \
...@@ -734,11 +738,11 @@ class _LIBCPP_TEMPLATE_VIS __destructor;...@@ -734,11 +738,11 @@ class _LIBCPP_TEMPLATE_VIS __destructor;
734 using __base_type::__base_type; \738 using __base_type::__base_type; \
735 using __base_type::operator=; \739 using __base_type::operator=; \
736 \740 \
737 __destructor(const __destructor&) = default; \741 __dtor(const __dtor&) = default; \
738 __destructor(__destructor&&) = default; \742 __dtor(__dtor&&) = default; \
739 destructor \743 destructor \
740 __destructor& operator=(const __destructor&) = default; \744 __dtor& operator=(const __dtor&) = default; \
741 __destructor& operator=(__destructor&&) = default; \745 __dtor& operator=(__dtor&&) = default; \
742 \746 \
743 protected: \747 protected: \
744 inline _LIBCPP_INLINE_VISIBILITY \748 inline _LIBCPP_INLINE_VISIBILITY \
...@@ -747,12 +751,12 @@ class _LIBCPP_TEMPLATE_VIS __destructor;...@@ -747,12 +751,12 @@ class _LIBCPP_TEMPLATE_VIS __destructor;
747751
748_LIBCPP_VARIANT_DESTRUCTOR(752_LIBCPP_VARIANT_DESTRUCTOR(
749 _Trait::_TriviallyAvailable,753 _Trait::_TriviallyAvailable,
750 ~__destructor() = default;,754 ~__dtor() = default;,
751 void __destroy() noexcept { this->__index = __variant_npos<__index_t>; });755 void __destroy() noexcept { this->__index = __variant_npos<__index_t>; });
752756
753_LIBCPP_VARIANT_DESTRUCTOR(757_LIBCPP_VARIANT_DESTRUCTOR(
754 _Trait::_Available,758 _Trait::_Available,
755 ~__destructor() { __destroy(); },759 ~__dtor() { __destroy(); },
756 void __destroy() noexcept {760 void __destroy() noexcept {
757 if (!this->valueless_by_exception()) {761 if (!this->valueless_by_exception()) {
758 __visitation::__base::__visit_alt(762 __visitation::__base::__visit_alt(
...@@ -767,14 +771,14 @@ _LIBCPP_VARIANT_DESTRUCTOR(...@@ -767,14 +771,14 @@ _LIBCPP_VARIANT_DESTRUCTOR(
767771
768_LIBCPP_VARIANT_DESTRUCTOR(772_LIBCPP_VARIANT_DESTRUCTOR(
769 _Trait::_Unavailable,773 _Trait::_Unavailable,
770 ~__destructor() = delete;,774 ~__dtor() = delete;,
771 void __destroy() noexcept = delete;);775 void __destroy() noexcept = delete;);
772776
773#undef _LIBCPP_VARIANT_DESTRUCTOR777#undef _LIBCPP_VARIANT_DESTRUCTOR
774778
775template <class _Traits>779template <class _Traits>
776class _LIBCPP_TEMPLATE_VIS __constructor : public __destructor<_Traits> {780class _LIBCPP_TEMPLATE_VIS __ctor : public __dtor<_Traits> {
777 using __base_type = __destructor<_Traits>;781 using __base_type = __dtor<_Traits>;
778782
779public:783public:
780 using __base_type::__base_type;784 using __base_type::__base_type;
...@@ -791,7 +795,7 @@ protected:...@@ -791,7 +795,7 @@ protected:
791795
792 template <class _Rhs>796 template <class _Rhs>
793 inline _LIBCPP_INLINE_VISIBILITY797 inline _LIBCPP_INLINE_VISIBILITY
794 static void __generic_construct(__constructor& __lhs, _Rhs&& __rhs) {798 static void __generic_construct(__ctor& __lhs, _Rhs&& __rhs) {
795 __lhs.__destroy();799 __lhs.__destroy();
796 if (!__rhs.valueless_by_exception()) {800 if (!__rhs.valueless_by_exception()) {
797 __visitation::__base::__visit_alt_at(801 __visitation::__base::__visit_alt_at(
...@@ -813,10 +817,10 @@ class _LIBCPP_TEMPLATE_VIS __move_constructor;...@@ -813,10 +817,10 @@ class _LIBCPP_TEMPLATE_VIS __move_constructor;
813#define _LIBCPP_VARIANT_MOVE_CONSTRUCTOR(move_constructible_trait, \817#define _LIBCPP_VARIANT_MOVE_CONSTRUCTOR(move_constructible_trait, \
814 move_constructor) \818 move_constructor) \
815 template <class... _Types> \819 template <class... _Types> \
816 class _LIBCPP_TEMPLATE_VIS __move_constructor<__traits<_Types...>, \820 class _LIBCPP_TEMPLATE_VIS __move_constructor<__traits<_Types...>, \
817 move_constructible_trait> \821 move_constructible_trait> \
818 : public __constructor<__traits<_Types...>> { \822 : public __ctor<__traits<_Types...>> { \
819 using __base_type = __constructor<__traits<_Types...>>; \823 using __base_type = __ctor<__traits<_Types...>>; \
820 \824 \
821 public: \825 public: \
822 using __base_type::__base_type; \826 using __base_type::__base_type; \
...@@ -1104,7 +1108,7 @@ struct __narrowing_check {...@@ -1104,7 +1108,7 @@ struct __narrowing_check {
1104 template <class _Dest>1108 template <class _Dest>
1105 static auto __test_impl(_Dest (&&)[1]) -> __identity<_Dest>;1109 static auto __test_impl(_Dest (&&)[1]) -> __identity<_Dest>;
1106 template <class _Dest, class _Source>1110 template <class _Dest, class _Source>
1107 using _Apply _LIBCPP_NODEBUG_TYPE = decltype(__test_impl<_Dest>({std::declval<_Source>()}));1111 using _Apply _LIBCPP_NODEBUG_TYPE = decltype(__test_impl<_Dest>({_VSTD::declval<_Source>()}));
1108};1112};
11091113
1110template <class _Dest, class _Source>1114template <class _Dest, class _Source>
...@@ -1510,7 +1514,7 @@ template <class _Operator>...@@ -1510,7 +1514,7 @@ template <class _Operator>
1510struct __convert_to_bool {1514struct __convert_to_bool {
1511 template <class _T1, class _T2>1515 template <class _T1, class _T2>
1512 _LIBCPP_INLINE_VISIBILITY constexpr bool operator()(_T1 && __t1, _T2&& __t2) const {1516 _LIBCPP_INLINE_VISIBILITY constexpr bool operator()(_T1 && __t1, _T2&& __t2) const {
1513 static_assert(std::is_convertible<decltype(_Operator{}(_VSTD::forward<_T1>(__t1), _VSTD::forward<_T2>(__t2))), bool>::value,1517 static_assert(is_convertible<decltype(_Operator{}(_VSTD::forward<_T1>(__t1), _VSTD::forward<_T2>(__t2))), bool>::value,
1514 "the relational operator does not return a type which is implicitly convertible to bool");1518 "the relational operator does not return a type which is implicitly convertible to bool");
1515 return _Operator{}(_VSTD::forward<_T1>(__t1), _VSTD::forward<_T2>(__t2));1519 return _Operator{}(_VSTD::forward<_T1>(__t1), _VSTD::forward<_T2>(__t2));
1516 }1520 }
lib/libcxx/include/vector+48-51
...@@ -454,7 +454,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -454,7 +454,7 @@ inline _LIBCPP_INLINE_VISIBILITY
454__vector_base<_Tp, _Allocator>::__vector_base(allocator_type&& __a) _NOEXCEPT454__vector_base<_Tp, _Allocator>::__vector_base(allocator_type&& __a) _NOEXCEPT
455 : __begin_(nullptr),455 : __begin_(nullptr),
456 __end_(nullptr),456 __end_(nullptr),
457 __end_cap_(nullptr, std::move(__a)) {}457 __end_cap_(nullptr, _VSTD::move(__a)) {}
458#endif458#endif
459459
460template <class _Tp, class _Allocator>460template <class _Tp, class _Allocator>
...@@ -496,7 +496,7 @@ public:...@@ -496,7 +496,7 @@ public:
496 _LIBCPP_INLINE_VISIBILITY496 _LIBCPP_INLINE_VISIBILITY
497 vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)497 vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
498 {498 {
499#if _LIBCPP_DEBUG_LEVEL >= 2499#if _LIBCPP_DEBUG_LEVEL == 2
500 __get_db()->__insert_c(this);500 __get_db()->__insert_c(this);
501#endif501#endif
502 }502 }
...@@ -508,7 +508,7 @@ public:...@@ -508,7 +508,7 @@ public:
508#endif508#endif
509 : __base(__a)509 : __base(__a)
510 {510 {
511#if _LIBCPP_DEBUG_LEVEL >= 2511#if _LIBCPP_DEBUG_LEVEL == 2
512 __get_db()->__insert_c(this);512 __get_db()->__insert_c(this);
513#endif513#endif
514 }514 }
...@@ -551,7 +551,7 @@ public:...@@ -551,7 +551,7 @@ public:
551 ~vector()551 ~vector()
552 {552 {
553 __annotate_delete();553 __annotate_delete();
554#if _LIBCPP_DEBUG_LEVEL >= 2554#if _LIBCPP_DEBUG_LEVEL == 2
555 __get_db()->__erase_c(this);555 __get_db()->__erase_c(this);
556#endif556#endif
557 }557 }
...@@ -789,14 +789,14 @@ public:...@@ -789,14 +789,14 @@ public:
789789
790 bool __invariants() const;790 bool __invariants() const;
791791
792#if _LIBCPP_DEBUG_LEVEL >= 2792#if _LIBCPP_DEBUG_LEVEL == 2
793793
794 bool __dereferenceable(const const_iterator* __i) const;794 bool __dereferenceable(const const_iterator* __i) const;
795 bool __decrementable(const const_iterator* __i) const;795 bool __decrementable(const const_iterator* __i) const;
796 bool __addable(const const_iterator* __i, ptrdiff_t __n) const;796 bool __addable(const const_iterator* __i, ptrdiff_t __n) const;
797 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;797 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;
798798
799#endif // _LIBCPP_DEBUG_LEVEL >= 2799#endif // _LIBCPP_DEBUG_LEVEL == 2
800800
801private:801private:
802 _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators();802 _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators();
...@@ -931,7 +931,7 @@ private:...@@ -931,7 +931,7 @@ private:
931931
932#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES932#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
933template<class _InputIterator,933template<class _InputIterator,
934 class _Alloc = typename std::allocator<typename iterator_traits<_InputIterator>::value_type>,934 class _Alloc = allocator<typename iterator_traits<_InputIterator>::value_type>,
935 class = typename enable_if<__is_allocator<_Alloc>::value, void>::type935 class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
936 >936 >
937vector(_InputIterator, _InputIterator)937vector(_InputIterator, _InputIterator)
...@@ -951,8 +951,7 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a...@@ -951,8 +951,7 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a
951{951{
952952
953 __annotate_delete();953 __annotate_delete();
954 __alloc_traits::__construct_backward_with_exception_guarantees(954 _VSTD::__construct_backward_with_exception_guarantees(this->__alloc(), this->__begin_, this->__end_, __v.__begin_);
955 this->__alloc(), this->__begin_, this->__end_, __v.__begin_);
956 _VSTD::swap(this->__begin_, __v.__begin_);955 _VSTD::swap(this->__begin_, __v.__begin_);
957 _VSTD::swap(this->__end_, __v.__end_);956 _VSTD::swap(this->__end_, __v.__end_);
958 _VSTD::swap(this->__end_cap(), __v.__end_cap());957 _VSTD::swap(this->__end_cap(), __v.__end_cap());
...@@ -967,10 +966,8 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a...@@ -967,10 +966,8 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a
967{966{
968 __annotate_delete();967 __annotate_delete();
969 pointer __r = __v.__begin_;968 pointer __r = __v.__begin_;
970 __alloc_traits::__construct_backward_with_exception_guarantees(969 _VSTD::__construct_backward_with_exception_guarantees(this->__alloc(), this->__begin_, __p, __v.__begin_);
971 this->__alloc(), this->__begin_, __p, __v.__begin_);970 _VSTD::__construct_forward_with_exception_guarantees(this->__alloc(), __p, this->__end_, __v.__end_);
972 __alloc_traits::__construct_forward_with_exception_guarantees(
973 this->__alloc(), __p, this->__end_, __v.__end_);
974 _VSTD::swap(this->__begin_, __v.__begin_);971 _VSTD::swap(this->__begin_, __v.__begin_);
975 _VSTD::swap(this->__end_, __v.__end_);972 _VSTD::swap(this->__end_, __v.__end_);
976 _VSTD::swap(this->__end_cap(), __v.__end_cap());973 _VSTD::swap(this->__end_cap(), __v.__end_cap());
...@@ -1077,7 +1074,7 @@ typename enable_if...@@ -1077,7 +1074,7 @@ typename enable_if
1077vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n)1074vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n)
1078{1075{
1079 _ConstructTransaction __tx(*this, __n);1076 _ConstructTransaction __tx(*this, __n);
1080 __alloc_traits::__construct_range_forward(this->__alloc(), __first, __last, __tx.__pos_);1077 _VSTD::__construct_range_forward(this->__alloc(), __first, __last, __tx.__pos_);
1081}1078}
10821079
1083// Default constructs __n objects starting at __end_1080// Default constructs __n objects starting at __end_
...@@ -1121,7 +1118,7 @@ vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x)...@@ -1121,7 +1118,7 @@ vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x)
1121template <class _Tp, class _Allocator>1118template <class _Tp, class _Allocator>
1122vector<_Tp, _Allocator>::vector(size_type __n)1119vector<_Tp, _Allocator>::vector(size_type __n)
1123{1120{
1124#if _LIBCPP_DEBUG_LEVEL >= 21121#if _LIBCPP_DEBUG_LEVEL == 2
1125 __get_db()->__insert_c(this);1122 __get_db()->__insert_c(this);
1126#endif1123#endif
1127 if (__n > 0)1124 if (__n > 0)
...@@ -1136,7 +1133,7 @@ template <class _Tp, class _Allocator>...@@ -1136,7 +1133,7 @@ template <class _Tp, class _Allocator>
1136vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a)1133vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a)
1137 : __base(__a)1134 : __base(__a)
1138{1135{
1139#if _LIBCPP_DEBUG_LEVEL >= 21136#if _LIBCPP_DEBUG_LEVEL == 2
1140 __get_db()->__insert_c(this);1137 __get_db()->__insert_c(this);
1141#endif1138#endif
1142 if (__n > 0)1139 if (__n > 0)
...@@ -1150,7 +1147,7 @@ vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a)...@@ -1150,7 +1147,7 @@ vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a)
1150template <class _Tp, class _Allocator>1147template <class _Tp, class _Allocator>
1151vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x)1148vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x)
1152{1149{
1153#if _LIBCPP_DEBUG_LEVEL >= 21150#if _LIBCPP_DEBUG_LEVEL == 2
1154 __get_db()->__insert_c(this);1151 __get_db()->__insert_c(this);
1155#endif1152#endif
1156 if (__n > 0)1153 if (__n > 0)
...@@ -1164,7 +1161,7 @@ template <class _Tp, class _Allocator>...@@ -1164,7 +1161,7 @@ template <class _Tp, class _Allocator>
1164vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x, const allocator_type& __a)1161vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x, const allocator_type& __a)
1165 : __base(__a)1162 : __base(__a)
1166{1163{
1167#if _LIBCPP_DEBUG_LEVEL >= 21164#if _LIBCPP_DEBUG_LEVEL == 2
1168 __get_db()->__insert_c(this);1165 __get_db()->__insert_c(this);
1169#endif1166#endif
1170 if (__n > 0)1167 if (__n > 0)
...@@ -1184,7 +1181,7 @@ vector<_Tp, _Allocator>::vector(_InputIterator __first,...@@ -1184,7 +1181,7 @@ vector<_Tp, _Allocator>::vector(_InputIterator __first,
1184 typename iterator_traits<_InputIterator>::reference>::value,1181 typename iterator_traits<_InputIterator>::reference>::value,
1185 _InputIterator>::type __last)1182 _InputIterator>::type __last)
1186{1183{
1187#if _LIBCPP_DEBUG_LEVEL >= 21184#if _LIBCPP_DEBUG_LEVEL == 2
1188 __get_db()->__insert_c(this);1185 __get_db()->__insert_c(this);
1189#endif1186#endif
1190 for (; __first != __last; ++__first)1187 for (; __first != __last; ++__first)
...@@ -1201,7 +1198,7 @@ vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, c...@@ -1201,7 +1198,7 @@ vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, c
1201 typename iterator_traits<_InputIterator>::reference>::value>::type*)1198 typename iterator_traits<_InputIterator>::reference>::value>::type*)
1202 : __base(__a)1199 : __base(__a)
1203{1200{
1204#if _LIBCPP_DEBUG_LEVEL >= 21201#if _LIBCPP_DEBUG_LEVEL == 2
1205 __get_db()->__insert_c(this);1202 __get_db()->__insert_c(this);
1206#endif1203#endif
1207 for (; __first != __last; ++__first)1204 for (; __first != __last; ++__first)
...@@ -1217,7 +1214,7 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first,...@@ -1217,7 +1214,7 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first,
1217 typename iterator_traits<_ForwardIterator>::reference>::value,1214 typename iterator_traits<_ForwardIterator>::reference>::value,
1218 _ForwardIterator>::type __last)1215 _ForwardIterator>::type __last)
1219{1216{
1220#if _LIBCPP_DEBUG_LEVEL >= 21217#if _LIBCPP_DEBUG_LEVEL == 2
1221 __get_db()->__insert_c(this);1218 __get_db()->__insert_c(this);
1222#endif1219#endif
1223 size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));1220 size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
...@@ -1237,7 +1234,7 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __las...@@ -1237,7 +1234,7 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __las
1237 typename iterator_traits<_ForwardIterator>::reference>::value>::type*)1234 typename iterator_traits<_ForwardIterator>::reference>::value>::type*)
1238 : __base(__a)1235 : __base(__a)
1239{1236{
1240#if _LIBCPP_DEBUG_LEVEL >= 21237#if _LIBCPP_DEBUG_LEVEL == 2
1241 __get_db()->__insert_c(this);1238 __get_db()->__insert_c(this);
1242#endif1239#endif
1243 size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));1240 size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
...@@ -1252,7 +1249,7 @@ template <class _Tp, class _Allocator>...@@ -1252,7 +1249,7 @@ template <class _Tp, class _Allocator>
1252vector<_Tp, _Allocator>::vector(const vector& __x)1249vector<_Tp, _Allocator>::vector(const vector& __x)
1253 : __base(__alloc_traits::select_on_container_copy_construction(__x.__alloc()))1250 : __base(__alloc_traits::select_on_container_copy_construction(__x.__alloc()))
1254{1251{
1255#if _LIBCPP_DEBUG_LEVEL >= 21252#if _LIBCPP_DEBUG_LEVEL == 2
1256 __get_db()->__insert_c(this);1253 __get_db()->__insert_c(this);
1257#endif1254#endif
1258 size_type __n = __x.size();1255 size_type __n = __x.size();
...@@ -1267,7 +1264,7 @@ template <class _Tp, class _Allocator>...@@ -1267,7 +1264,7 @@ template <class _Tp, class _Allocator>
1267vector<_Tp, _Allocator>::vector(const vector& __x, const allocator_type& __a)1264vector<_Tp, _Allocator>::vector(const vector& __x, const allocator_type& __a)
1268 : __base(__a)1265 : __base(__a)
1269{1266{
1270#if _LIBCPP_DEBUG_LEVEL >= 21267#if _LIBCPP_DEBUG_LEVEL == 2
1271 __get_db()->__insert_c(this);1268 __get_db()->__insert_c(this);
1272#endif1269#endif
1273 size_type __n = __x.size();1270 size_type __n = __x.size();
...@@ -1290,7 +1287,7 @@ vector<_Tp, _Allocator>::vector(vector&& __x)...@@ -1290,7 +1287,7 @@ vector<_Tp, _Allocator>::vector(vector&& __x)
1290#endif1287#endif
1291 : __base(_VSTD::move(__x.__alloc()))1288 : __base(_VSTD::move(__x.__alloc()))
1292{1289{
1293#if _LIBCPP_DEBUG_LEVEL >= 21290#if _LIBCPP_DEBUG_LEVEL == 2
1294 __get_db()->__insert_c(this);1291 __get_db()->__insert_c(this);
1295 __get_db()->swap(this, &__x);1292 __get_db()->swap(this, &__x);
1296#endif1293#endif
...@@ -1305,7 +1302,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -1305,7 +1302,7 @@ inline _LIBCPP_INLINE_VISIBILITY
1305vector<_Tp, _Allocator>::vector(vector&& __x, const allocator_type& __a)1302vector<_Tp, _Allocator>::vector(vector&& __x, const allocator_type& __a)
1306 : __base(__a)1303 : __base(__a)
1307{1304{
1308#if _LIBCPP_DEBUG_LEVEL >= 21305#if _LIBCPP_DEBUG_LEVEL == 2
1309 __get_db()->__insert_c(this);1306 __get_db()->__insert_c(this);
1310#endif1307#endif
1311 if (__a == __x.__alloc())1308 if (__a == __x.__alloc())
...@@ -1314,7 +1311,7 @@ vector<_Tp, _Allocator>::vector(vector&& __x, const allocator_type& __a)...@@ -1314,7 +1311,7 @@ vector<_Tp, _Allocator>::vector(vector&& __x, const allocator_type& __a)
1314 this->__end_ = __x.__end_;1311 this->__end_ = __x.__end_;
1315 this->__end_cap() = __x.__end_cap();1312 this->__end_cap() = __x.__end_cap();
1316 __x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr;1313 __x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr;
1317#if _LIBCPP_DEBUG_LEVEL >= 21314#if _LIBCPP_DEBUG_LEVEL == 2
1318 __get_db()->swap(this, &__x);1315 __get_db()->swap(this, &__x);
1319#endif1316#endif
1320 }1317 }
...@@ -1329,7 +1326,7 @@ template <class _Tp, class _Allocator>...@@ -1329,7 +1326,7 @@ template <class _Tp, class _Allocator>
1329inline _LIBCPP_INLINE_VISIBILITY1326inline _LIBCPP_INLINE_VISIBILITY
1330vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il)1327vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il)
1331{1328{
1332#if _LIBCPP_DEBUG_LEVEL >= 21329#if _LIBCPP_DEBUG_LEVEL == 2
1333 __get_db()->__insert_c(this);1330 __get_db()->__insert_c(this);
1334#endif1331#endif
1335 if (__il.size() > 0)1332 if (__il.size() > 0)
...@@ -1344,7 +1341,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -1344,7 +1341,7 @@ inline _LIBCPP_INLINE_VISIBILITY
1344vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)1341vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)
1345 : __base(__a)1342 : __base(__a)
1346{1343{
1347#if _LIBCPP_DEBUG_LEVEL >= 21344#if _LIBCPP_DEBUG_LEVEL == 2
1348 __get_db()->__insert_c(this);1345 __get_db()->__insert_c(this);
1349#endif1346#endif
1350 if (__il.size() > 0)1347 if (__il.size() > 0)
...@@ -1390,7 +1387,7 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)...@@ -1390,7 +1387,7 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)
1390 this->__end_ = __c.__end_;1387 this->__end_ = __c.__end_;
1391 this->__end_cap() = __c.__end_cap();1388 this->__end_cap() = __c.__end_cap();
1392 __c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr;1389 __c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr;
1393#if _LIBCPP_DEBUG_LEVEL >= 21390#if _LIBCPP_DEBUG_LEVEL == 2
1394 __get_db()->swap(this, &__c);1391 __get_db()->swap(this, &__c);
1395#endif1392#endif
1396}1393}
...@@ -1493,7 +1490,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -1493,7 +1490,7 @@ inline _LIBCPP_INLINE_VISIBILITY
1493typename vector<_Tp, _Allocator>::iterator1490typename vector<_Tp, _Allocator>::iterator
1494vector<_Tp, _Allocator>::__make_iter(pointer __p) _NOEXCEPT1491vector<_Tp, _Allocator>::__make_iter(pointer __p) _NOEXCEPT
1495{1492{
1496#if _LIBCPP_DEBUG_LEVEL >= 21493#if _LIBCPP_DEBUG_LEVEL == 2
1497 return iterator(this, __p);1494 return iterator(this, __p);
1498#else1495#else
1499 return iterator(__p);1496 return iterator(__p);
...@@ -1505,7 +1502,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -1505,7 +1502,7 @@ inline _LIBCPP_INLINE_VISIBILITY
1505typename vector<_Tp, _Allocator>::const_iterator1502typename vector<_Tp, _Allocator>::const_iterator
1506vector<_Tp, _Allocator>::__make_iter(const_pointer __p) const _NOEXCEPT1503vector<_Tp, _Allocator>::__make_iter(const_pointer __p) const _NOEXCEPT
1507{1504{
1508#if _LIBCPP_DEBUG_LEVEL >= 21505#if _LIBCPP_DEBUG_LEVEL == 2
1509 return const_iterator(this, __p);1506 return const_iterator(this, __p);
1510#else1507#else
1511 return const_iterator(__p);1508 return const_iterator(__p);
...@@ -1709,7 +1706,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -1709,7 +1706,7 @@ inline _LIBCPP_INLINE_VISIBILITY
1709typename vector<_Tp, _Allocator>::iterator1706typename vector<_Tp, _Allocator>::iterator
1710vector<_Tp, _Allocator>::erase(const_iterator __position)1707vector<_Tp, _Allocator>::erase(const_iterator __position)
1711{1708{
1712#if _LIBCPP_DEBUG_LEVEL >= 21709#if _LIBCPP_DEBUG_LEVEL == 2
1713 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,1710 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,
1714 "vector::erase(iterator) called with an iterator not"1711 "vector::erase(iterator) called with an iterator not"
1715 " referring to this vector");1712 " referring to this vector");
...@@ -1728,7 +1725,7 @@ template <class _Tp, class _Allocator>...@@ -1728,7 +1725,7 @@ template <class _Tp, class _Allocator>
1728typename vector<_Tp, _Allocator>::iterator1725typename vector<_Tp, _Allocator>::iterator
1729vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last)1726vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last)
1730{1727{
1731#if _LIBCPP_DEBUG_LEVEL >= 21728#if _LIBCPP_DEBUG_LEVEL == 2
1732 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this,1729 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this,
1733 "vector::erase(iterator, iterator) called with an iterator not"1730 "vector::erase(iterator, iterator) called with an iterator not"
1734 " referring to this vector");1731 " referring to this vector");
...@@ -1769,7 +1766,7 @@ template <class _Tp, class _Allocator>...@@ -1769,7 +1766,7 @@ template <class _Tp, class _Allocator>
1769typename vector<_Tp, _Allocator>::iterator1766typename vector<_Tp, _Allocator>::iterator
1770vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x)1767vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x)
1771{1768{
1772#if _LIBCPP_DEBUG_LEVEL >= 21769#if _LIBCPP_DEBUG_LEVEL == 2
1773 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,1770 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,
1774 "vector::insert(iterator, x) called with an iterator not"1771 "vector::insert(iterator, x) called with an iterator not"
1775 " referring to this vector");1772 " referring to this vector");
...@@ -1806,7 +1803,7 @@ template <class _Tp, class _Allocator>...@@ -1806,7 +1803,7 @@ template <class _Tp, class _Allocator>
1806typename vector<_Tp, _Allocator>::iterator1803typename vector<_Tp, _Allocator>::iterator
1807vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x)1804vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x)
1808{1805{
1809#if _LIBCPP_DEBUG_LEVEL >= 21806#if _LIBCPP_DEBUG_LEVEL == 2
1810 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,1807 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,
1811 "vector::insert(iterator, x) called with an iterator not"1808 "vector::insert(iterator, x) called with an iterator not"
1812 " referring to this vector");1809 " referring to this vector");
...@@ -1839,7 +1836,7 @@ template <class... _Args>...@@ -1839,7 +1836,7 @@ template <class... _Args>
1839typename vector<_Tp, _Allocator>::iterator1836typename vector<_Tp, _Allocator>::iterator
1840vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args)1837vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args)
1841{1838{
1842#if _LIBCPP_DEBUG_LEVEL >= 21839#if _LIBCPP_DEBUG_LEVEL == 2
1843 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,1840 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,
1844 "vector::emplace(iterator, x) called with an iterator not"1841 "vector::emplace(iterator, x) called with an iterator not"
1845 " referring to this vector");1842 " referring to this vector");
...@@ -1874,7 +1871,7 @@ template <class _Tp, class _Allocator>...@@ -1874,7 +1871,7 @@ template <class _Tp, class _Allocator>
1874typename vector<_Tp, _Allocator>::iterator1871typename vector<_Tp, _Allocator>::iterator
1875vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x)1872vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x)
1876{1873{
1877#if _LIBCPP_DEBUG_LEVEL >= 21874#if _LIBCPP_DEBUG_LEVEL == 2
1878 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,1875 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,
1879 "vector::insert(iterator, n, x) called with an iterator not"1876 "vector::insert(iterator, n, x) called with an iterator not"
1880 " referring to this vector");1877 " referring to this vector");
...@@ -1925,7 +1922,7 @@ typename enable_if...@@ -1925,7 +1922,7 @@ typename enable_if
1925>::type1922>::type
1926vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last)1923vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last)
1927{1924{
1928#if _LIBCPP_DEBUG_LEVEL >= 21925#if _LIBCPP_DEBUG_LEVEL == 2
1929 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,1926 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,
1930 "vector::insert(iterator, range) called with an iterator not"1927 "vector::insert(iterator, range) called with an iterator not"
1931 " referring to this vector");1928 " referring to this vector");
...@@ -1978,7 +1975,7 @@ typename enable_if...@@ -1978,7 +1975,7 @@ typename enable_if
1978>::type1975>::type
1979vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last)1976vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last)
1980{1977{
1981#if _LIBCPP_DEBUG_LEVEL >= 21978#if _LIBCPP_DEBUG_LEVEL == 2
1982 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,1979 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,
1983 "vector::insert(iterator, range) called with an iterator not"1980 "vector::insert(iterator, range) called with an iterator not"
1984 " referring to this vector");1981 " referring to this vector");
...@@ -2057,11 +2054,11 @@ vector<_Tp, _Allocator>::swap(vector& __x)...@@ -2057,11 +2054,11 @@ vector<_Tp, _Allocator>::swap(vector& __x)
2057 _VSTD::swap(this->__begin_, __x.__begin_);2054 _VSTD::swap(this->__begin_, __x.__begin_);
2058 _VSTD::swap(this->__end_, __x.__end_);2055 _VSTD::swap(this->__end_, __x.__end_);
2059 _VSTD::swap(this->__end_cap(), __x.__end_cap());2056 _VSTD::swap(this->__end_cap(), __x.__end_cap());
2060 __swap_allocator(this->__alloc(), __x.__alloc(),2057 _VSTD::__swap_allocator(this->__alloc(), __x.__alloc(),
2061 integral_constant<bool,__alloc_traits::propagate_on_container_swap::value>());2058 integral_constant<bool,__alloc_traits::propagate_on_container_swap::value>());
2062#if _LIBCPP_DEBUG_LEVEL >= 22059#if _LIBCPP_DEBUG_LEVEL == 2
2063 __get_db()->swap(this, &__x);2060 __get_db()->swap(this, &__x);
2064#endif // _LIBCPP_DEBUG_LEVEL >= 22061#endif
2065}2062}
20662063
2067template <class _Tp, class _Allocator>2064template <class _Tp, class _Allocator>
...@@ -2085,7 +2082,7 @@ vector<_Tp, _Allocator>::__invariants() const...@@ -2085,7 +2082,7 @@ vector<_Tp, _Allocator>::__invariants() const
2085 return true;2082 return true;
2086}2083}
20872084
2088#if _LIBCPP_DEBUG_LEVEL >= 22085#if _LIBCPP_DEBUG_LEVEL == 2
20892086
2090template <class _Tp, class _Allocator>2087template <class _Tp, class _Allocator>
2091bool2088bool
...@@ -2117,16 +2114,16 @@ vector<_Tp, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __...@@ -2117,16 +2114,16 @@ vector<_Tp, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __
2117 return this->__begin_ <= __p && __p < this->__end_;2114 return this->__begin_ <= __p && __p < this->__end_;
2118}2115}
21192116
2120#endif // _LIBCPP_DEBUG_LEVEL >= 22117#endif // _LIBCPP_DEBUG_LEVEL == 2
21212118
2122template <class _Tp, class _Allocator>2119template <class _Tp, class _Allocator>
2123inline _LIBCPP_INLINE_VISIBILITY2120inline _LIBCPP_INLINE_VISIBILITY
2124void2121void
2125vector<_Tp, _Allocator>::__invalidate_all_iterators()2122vector<_Tp, _Allocator>::__invalidate_all_iterators()
2126{2123{
2127#if _LIBCPP_DEBUG_LEVEL >= 22124#if _LIBCPP_DEBUG_LEVEL == 2
2128 __get_db()->__invalidate_all(this);2125 __get_db()->__invalidate_all(this);
2129#endif // _LIBCPP_DEBUG_LEVEL >= 22126#endif
2130}2127}
21312128
21322129
...@@ -2134,7 +2131,7 @@ template <class _Tp, class _Allocator>...@@ -2134,7 +2131,7 @@ template <class _Tp, class _Allocator>
2134inline _LIBCPP_INLINE_VISIBILITY2131inline _LIBCPP_INLINE_VISIBILITY
2135void2132void
2136vector<_Tp, _Allocator>::__invalidate_iterators_past(pointer __new_last) {2133vector<_Tp, _Allocator>::__invalidate_iterators_past(pointer __new_last) {
2137#if _LIBCPP_DEBUG_LEVEL >= 22134#if _LIBCPP_DEBUG_LEVEL == 2
2138 __c_node* __c = __get_db()->__find_c_and_lock(this);2135 __c_node* __c = __get_db()->__find_c_and_lock(this);
2139 for (__i_node** __p = __c->end_; __p != __c->beg_; ) {2136 for (__i_node** __p = __c->end_; __p != __c->beg_; ) {
2140 --__p;2137 --__p;
...@@ -2142,7 +2139,7 @@ vector<_Tp, _Allocator>::__invalidate_iterators_past(pointer __new_last) {...@@ -2142,7 +2139,7 @@ vector<_Tp, _Allocator>::__invalidate_iterators_past(pointer __new_last) {
2142 if (__i->base() > __new_last) {2139 if (__i->base() > __new_last) {
2143 (*__p)->__c_ = nullptr;2140 (*__p)->__c_ = nullptr;
2144 if (--__c->end_ != __p)2141 if (--__c->end_ != __p)
2145 memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));2142 _VSTD::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
2146 }2143 }
2147 }2144 }
2148 __get_db()->unlock();2145 __get_db()->unlock();
...@@ -2883,7 +2880,7 @@ inline _LIBCPP_INLINE_VISIBILITY vector<bool, _Allocator>::vector(vector&& __v)...@@ -2883,7 +2880,7 @@ inline _LIBCPP_INLINE_VISIBILITY vector<bool, _Allocator>::vector(vector&& __v)
2883#endif2880#endif
2884 : __begin_(__v.__begin_),2881 : __begin_(__v.__begin_),
2885 __size_(__v.__size_),2882 __size_(__v.__size_),
2886 __cap_alloc_(std::move(__v.__cap_alloc_)) {2883 __cap_alloc_(_VSTD::move(__v.__cap_alloc_)) {
2887 __v.__begin_ = nullptr;2884 __v.__begin_ = nullptr;
2888 __v.__size_ = 0;2885 __v.__size_ = 0;
2889 __v.__cap() = 0;2886 __v.__cap() = 0;
...@@ -3235,7 +3232,7 @@ vector<bool, _Allocator>::swap(vector& __x)...@@ -3235,7 +3232,7 @@ vector<bool, _Allocator>::swap(vector& __x)
3235 _VSTD::swap(this->__begin_, __x.__begin_);3232 _VSTD::swap(this->__begin_, __x.__begin_);
3236 _VSTD::swap(this->__size_, __x.__size_);3233 _VSTD::swap(this->__size_, __x.__size_);
3237 _VSTD::swap(this->__cap(), __x.__cap());3234 _VSTD::swap(this->__cap(), __x.__cap());
3238 __swap_allocator(this->__alloc(), __x.__alloc(),3235 _VSTD::__swap_allocator(this->__alloc(), __x.__alloc(),
3239 integral_constant<bool, __alloc_traits::propagate_on_container_swap::value>());3236 integral_constant<bool, __alloc_traits::propagate_on_container_swap::value>());
3240}3237}
32413238
lib/libcxx/include/version+34-2
...@@ -24,8 +24,14 @@ __cpp_lib_apply 201603L <tuple>...@@ -24,8 +24,14 @@ __cpp_lib_apply 201603L <tuple>
24__cpp_lib_array_constexpr 201811L <iterator> <array>24__cpp_lib_array_constexpr 201811L <iterator> <array>
25 201603L // C++1725 201603L // C++17
26__cpp_lib_as_const 201510L <utility>26__cpp_lib_as_const 201510L <utility>
27__cpp_lib_atomic_flag_test 201907L <atomic>
28__cpp_lib_atomic_float 201711L <atomic>
27__cpp_lib_atomic_is_always_lock_free 201603L <atomic>29__cpp_lib_atomic_is_always_lock_free 201603L <atomic>
30__cpp_lib_atomic_lock_free_type_aliases 201907L <atomic>
28__cpp_lib_atomic_ref 201806L <atomic>31__cpp_lib_atomic_ref 201806L <atomic>
32__cpp_lib_atomic_shared_ptr 201711L <atomic>
33__cpp_lib_atomic_value_initialization 201911L <atomic> <memory>
34__cpp_lib_atomic_wait 201907L <atomic>
29__cpp_lib_bind_front 201811L <functional>35__cpp_lib_bind_front 201811L <functional>
30__cpp_lib_bit_cast 201806L <bit>36__cpp_lib_bit_cast 201806L <bit>
31__cpp_lib_bool_constant 201505L <type_traits>37__cpp_lib_bool_constant 201505L <type_traits>
...@@ -39,9 +45,12 @@ __cpp_lib_chrono_udls 201304L <chrono>...@@ -39,9 +45,12 @@ __cpp_lib_chrono_udls 201304L <chrono>
39__cpp_lib_clamp 201603L <algorithm>45__cpp_lib_clamp 201603L <algorithm>
40__cpp_lib_complex_udls 201309L <complex>46__cpp_lib_complex_udls 201309L <complex>
41__cpp_lib_concepts 201806L <concepts>47__cpp_lib_concepts 201806L <concepts>
48__cpp_lib_constexpr_dynamic_alloc 201907L <memory>
42__cpp_lib_constexpr_misc 201811L <array> <functional> <iterator>49__cpp_lib_constexpr_misc 201811L <array> <functional> <iterator>
43 <string_view> <tuple> <utility>50 <string_view> <tuple> <utility>
51__cpp_lib_constexpr_numeric 201911L <numeric>
44__cpp_lib_constexpr_swap_algorithms 201806L <algorithm>52__cpp_lib_constexpr_swap_algorithms 201806L <algorithm>
53__cpp_lib_constexpr_utility 201811L <utility>
45__cpp_lib_destroying_delete 201806L <new>54__cpp_lib_destroying_delete 201806L <new>
46__cpp_lib_enable_shared_from_this 201603L <memory>55__cpp_lib_enable_shared_from_this 201603L <memory>
47__cpp_lib_endian 201907L <bit>56__cpp_lib_endian 201907L <bit>
...@@ -58,6 +67,7 @@ __cpp_lib_hardware_interference_size 201703L <new>...@@ -58,6 +67,7 @@ __cpp_lib_hardware_interference_size 201703L <new>
58__cpp_lib_has_unique_object_representations 201606L <type_traits>67__cpp_lib_has_unique_object_representations 201606L <type_traits>
59__cpp_lib_hypot 201603L <cmath>68__cpp_lib_hypot 201603L <cmath>
60__cpp_lib_incomplete_container_elements 201505L <forward_list> <list> <vector>69__cpp_lib_incomplete_container_elements 201505L <forward_list> <list> <vector>
70__cpp_lib_int_pow2 202002L <bit>
61__cpp_lib_integer_sequence 201304L <utility>71__cpp_lib_integer_sequence 201304L <utility>
62__cpp_lib_integral_constant_callable 201304L <type_traits>72__cpp_lib_integral_constant_callable 201304L <type_traits>
63__cpp_lib_interpolate 201902L <numeric>73__cpp_lib_interpolate 201902L <numeric>
...@@ -200,7 +210,7 @@ __cpp_lib_void_t 201411L <type_traits>...@@ -200,7 +210,7 @@ __cpp_lib_void_t 201411L <type_traits>
200# if !defined(_LIBCPP_HAS_NO_THREADS)210# if !defined(_LIBCPP_HAS_NO_THREADS)
201# define __cpp_lib_shared_mutex 201505L211# define __cpp_lib_shared_mutex 201505L
202# endif212# endif
203// # define __cpp_lib_shared_ptr_arrays 201611L213# define __cpp_lib_shared_ptr_arrays 201611L
204# define __cpp_lib_shared_ptr_weak_type 201606L214# define __cpp_lib_shared_ptr_weak_type 201606L
205# define __cpp_lib_string_view 201606L215# define __cpp_lib_string_view 201606L
206// # define __cpp_lib_to_chars 201611L216// # define __cpp_lib_to_chars 201611L
...@@ -217,22 +227,44 @@ __cpp_lib_void_t 201411L <type_traits>...@@ -217,22 +227,44 @@ __cpp_lib_void_t 201411L <type_traits>
217# undef __cpp_lib_array_constexpr227# undef __cpp_lib_array_constexpr
218# define __cpp_lib_array_constexpr 201811L228# define __cpp_lib_array_constexpr 201811L
219# if !defined(_LIBCPP_HAS_NO_THREADS)229# if !defined(_LIBCPP_HAS_NO_THREADS)
230# define __cpp_lib_atomic_flag_test 201907L
231# endif
232# if !defined(_LIBCPP_HAS_NO_THREADS)
233// # define __cpp_lib_atomic_float 201711L
234# endif
235# if !defined(_LIBCPP_HAS_NO_THREADS)
236# define __cpp_lib_atomic_lock_free_type_aliases 201907L
237# endif
238# if !defined(_LIBCPP_HAS_NO_THREADS)
220// # define __cpp_lib_atomic_ref 201806L239// # define __cpp_lib_atomic_ref 201806L
221# endif240# endif
241# if !defined(_LIBCPP_HAS_NO_THREADS)
242// # define __cpp_lib_atomic_shared_ptr 201711L
243# endif
244# if !defined(_LIBCPP_HAS_NO_THREADS)
245// # define __cpp_lib_atomic_value_initialization 201911L
246# endif
247# if !defined(_LIBCPP_HAS_NO_THREADS)
248# define __cpp_lib_atomic_wait 201907L
249# endif
222// # define __cpp_lib_bind_front 201811L250// # define __cpp_lib_bind_front 201811L
223// # define __cpp_lib_bit_cast 201806L251// # define __cpp_lib_bit_cast 201806L
224# if !defined(_LIBCPP_NO_HAS_CHAR8_T)252# if !defined(_LIBCPP_NO_HAS_CHAR8_T)
225# define __cpp_lib_char8_t 201811L253# define __cpp_lib_char8_t 201811L
226# endif254# endif
227// # define __cpp_lib_concepts 201806L255// # define __cpp_lib_concepts 201806L
256# define __cpp_lib_constexpr_dynamic_alloc 201907L
228// # define __cpp_lib_constexpr_misc 201811L257// # define __cpp_lib_constexpr_misc 201811L
258# define __cpp_lib_constexpr_numeric 201911L
229// # define __cpp_lib_constexpr_swap_algorithms 201806L259// # define __cpp_lib_constexpr_swap_algorithms 201806L
260# define __cpp_lib_constexpr_utility 201811L
230# if _LIBCPP_STD_VER > 17 && defined(__cpp_impl_destroying_delete) && __cpp_impl_destroying_delete >= 201806L261# if _LIBCPP_STD_VER > 17 && defined(__cpp_impl_destroying_delete) && __cpp_impl_destroying_delete >= 201806L
231# define __cpp_lib_destroying_delete 201806L262# define __cpp_lib_destroying_delete 201806L
232# endif263# endif
233# define __cpp_lib_endian 201907L264# define __cpp_lib_endian 201907L
234# define __cpp_lib_erase_if 202002L265# define __cpp_lib_erase_if 202002L
235// # define __cpp_lib_generic_unordered_lookup 201811L266# define __cpp_lib_generic_unordered_lookup 201811L
267# define __cpp_lib_int_pow2 202002L
236# define __cpp_lib_interpolate 201902L268# define __cpp_lib_interpolate 201902L
237# if !defined(_LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED)269# if !defined(_LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED)
238# define __cpp_lib_is_constant_evaluated 201811L270# define __cpp_lib_is_constant_evaluated 201811L
lib/libcxx/include/wctype.h+3-1
...@@ -50,7 +50,9 @@ wctrans_t wctrans(const char* property);...@@ -50,7 +50,9 @@ wctrans_t wctrans(const char* property);
50#pragma GCC system_header50#pragma GCC system_header
51#endif51#endif
5252
53#include_next <wctype.h>53#if __has_include_next(<wctype.h>)
54# include_next <wctype.h>
55#endif
5456
55#ifdef __cplusplus57#ifdef __cplusplus
5658
lib/libcxx/src/atomic.cpp-2
...@@ -13,8 +13,6 @@...@@ -13,8 +13,6 @@
13#include <atomic>13#include <atomic>
14#include <functional>14#include <functional>
1515
16#include <iostream>
17
18#ifdef __linux__16#ifdef __linux__
1917
20#include <unistd.h>18#include <unistd.h>
lib/libcxx/src/barrier.cpp+3-9
...@@ -26,21 +26,15 @@ public:...@@ -26,21 +26,15 @@ public:
26 } __tickets[64];26 } __tickets[64];
27 };27 };
2828
29 ptrdiff_t& __expected;29 ptrdiff_t& __expected;
30 unique_ptr<char[]> __state_allocation;30 unique_ptr<__state_t[]> __state;
31 __state_t* __state;
3231
33 _LIBCPP_HIDDEN32 _LIBCPP_HIDDEN
34 __barrier_algorithm_base(ptrdiff_t& __expected)33 __barrier_algorithm_base(ptrdiff_t& __expected)
35 : __expected(__expected)34 : __expected(__expected)
36 {35 {
37 size_t const __count = (__expected + 1) >> 1;36 size_t const __count = (__expected + 1) >> 1;
38 size_t const __size = sizeof(__state_t) * __count;37 __state = unique_ptr<__state_t[]>(new __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 }38 }
45 _LIBCPP_HIDDEN39 _LIBCPP_HIDDEN
46 bool __arrive(__barrier_phase_t __old_phase)40 bool __arrive(__barrier_phase_t __old_phase)
lib/libcxx/src/chrono.cpp+53-44
...@@ -13,11 +13,15 @@...@@ -13,11 +13,15 @@
13#include "include/apple_availability.h"13#include "include/apple_availability.h"
1414
15#if __has_include(<unistd.h>)15#if __has_include(<unistd.h>)
16#include <unistd.h>16# include <unistd.h>
17#endif
18
19#if __has_include(<sys/time.h>)
20# include <sys/time.h> // for gettimeofday and timeval
17#endif21#endif
1822
19#if !defined(__APPLE__) && _POSIX_TIMERS > 023#if !defined(__APPLE__) && _POSIX_TIMERS > 0
20#define _LIBCPP_USE_CLOCK_GETTIME24# define _LIBCPP_USE_CLOCK_GETTIME
21#endif25#endif
2226
23#if defined(_LIBCPP_WIN32API)27#if defined(_LIBCPP_WIN32API)
...@@ -27,10 +31,6 @@...@@ -27,10 +31,6 @@
27# if _WIN32_WINNT >= _WIN32_WINNT_WIN831# if _WIN32_WINNT >= _WIN32_WINNT_WIN8
28# include <winapifamily.h>32# include <winapifamily.h>
29# endif33# endif
30#else
31# if !defined(CLOCK_REALTIME)
32# include <sys/time.h> // for gettimeofday and timeval
33# endif // !defined(CLOCK_REALTIME)
34#endif // defined(_LIBCPP_WIN32API)34#endif // defined(_LIBCPP_WIN32API)
3535
36#if defined(__ELF__) && defined(_LIBCPP_LINK_RT_LIB)36#if defined(__ELF__) && defined(_LIBCPP_LINK_RT_LIB)
...@@ -42,14 +42,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -42,14 +42,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD
42namespace chrono42namespace chrono
43{43{
4444
45//
45// system_clock46// system_clock
47//
4648
47const bool system_clock::is_steady;
48
49system_clock::time_point
50system_clock::now() _NOEXCEPT
51{
52#if defined(_LIBCPP_WIN32API)49#if defined(_LIBCPP_WIN32API)
50
51static system_clock::time_point __libcpp_system_clock_now() {
53 // FILETIME is in 100ns units52 // FILETIME is in 100ns units
54 using filetime_duration =53 using filetime_duration =
55 _VSTD::chrono::duration<__int64,54 _VSTD::chrono::duration<__int64,
...@@ -60,31 +59,42 @@ system_clock::now() _NOEXCEPT...@@ -60,31 +59,42 @@ system_clock::now() _NOEXCEPT
60 static _LIBCPP_CONSTEXPR const seconds nt_to_unix_epoch{11644473600};59 static _LIBCPP_CONSTEXPR const seconds nt_to_unix_epoch{11644473600};
6160
62 FILETIME ft;61 FILETIME ft;
63#if _WIN32_WINNT >= _WIN32_WINNT_WIN862#if _WIN32_WINNT >= _WIN32_WINNT_WIN8 && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
64#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
65 GetSystemTimePreciseAsFileTime(&ft);63 GetSystemTimePreciseAsFileTime(&ft);
66#else
67 GetSystemTimeAsFileTime(&ft);
68#endif
69#else64#else
70 GetSystemTimeAsFileTime(&ft);65 GetSystemTimeAsFileTime(&ft);
71#endif66#endif
7267
73 filetime_duration d{(static_cast<__int64>(ft.dwHighDateTime) << 32) |68 filetime_duration d{(static_cast<__int64>(ft.dwHighDateTime) << 32) |
74 static_cast<__int64>(ft.dwLowDateTime)};69 static_cast<__int64>(ft.dwLowDateTime)};
75 return time_point(duration_cast<duration>(d - nt_to_unix_epoch));70 return system_clock::time_point(duration_cast<system_clock::duration>(d - nt_to_unix_epoch));
76#else71}
77#if defined(CLOCK_REALTIME)72
73#elif defined(CLOCK_REALTIME) && defined(_LIBCPP_USE_CLOCK_GETTIME)
74
75static system_clock::time_point __libcpp_system_clock_now() {
78 struct timespec tp;76 struct timespec tp;
79 if (0 != clock_gettime(CLOCK_REALTIME, &tp))77 if (0 != clock_gettime(CLOCK_REALTIME, &tp))
80 __throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed");78 __throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed");
81 return time_point(seconds(tp.tv_sec) + microseconds(tp.tv_nsec / 1000));79 return system_clock::time_point(seconds(tp.tv_sec) + microseconds(tp.tv_nsec / 1000));
80}
81
82#else82#else
83
84static system_clock::time_point __libcpp_system_clock_now() {
83 timeval tv;85 timeval tv;
84 gettimeofday(&tv, 0);86 gettimeofday(&tv, 0);
85 return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));87 return system_clock::time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));
86#endif // CLOCK_REALTIME88}
89
87#endif90#endif
91
92const bool system_clock::is_steady;
93
94system_clock::time_point
95system_clock::now() _NOEXCEPT
96{
97 return __libcpp_system_clock_now();
88}98}
8999
90time_t100time_t
...@@ -99,33 +109,28 @@ system_clock::from_time_t(time_t t) _NOEXCEPT...@@ -99,33 +109,28 @@ system_clock::from_time_t(time_t t) _NOEXCEPT
99 return system_clock::time_point(seconds(t));109 return system_clock::time_point(seconds(t));
100}110}
101111
102#ifndef _LIBCPP_HAS_NO_MONOTONIC_CLOCK112//
103// steady_clock113// steady_clock
104//114//
105// Warning: If this is not truly steady, then it is non-conforming. It is115// Warning: If this is not truly steady, then it is non-conforming. It is
106// better for it to not exist and have the rest of libc++ use system_clock116// better for it to not exist and have the rest of libc++ use system_clock
107// instead.117// instead.
118//
108119
109const bool steady_clock::is_steady;120#ifndef _LIBCPP_HAS_NO_MONOTONIC_CLOCK
110121
111#if defined(__APPLE__)122#if defined(__APPLE__)
112123
113#if !defined(CLOCK_MONOTONIC_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 or124// On Apple platforms, only CLOCK_UPTIME_RAW, CLOCK_MONOTONIC_RAW or
118// mach_absolute_time are able to time functions in the nanosecond range.125// mach_absolute_time are able to time functions in the nanosecond range.
119// Furthermore, only CLOCK_MONOTONIC_RAW is truly monotonic, because it126// Furthermore, only CLOCK_MONOTONIC_RAW is truly monotonic, because it
120// also counts cycles when the system is asleep. Thus, it is the only127// also counts cycles when the system is asleep. Thus, it is the only
121// acceptable implementation of steady_clock.128// acceptable implementation of steady_clock.
122steady_clock::time_point129static steady_clock::time_point __libcpp_steady_clock_now() {
123steady_clock::now() _NOEXCEPT
124{
125 struct timespec tp;130 struct timespec tp;
126 if (0 != clock_gettime(CLOCK_MONOTONIC_RAW, &tp))131 if (0 != clock_gettime(CLOCK_MONOTONIC_RAW, &tp))
127 __throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC_RAW) failed");132 __throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC_RAW) failed");
128 return time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec));133 return steady_clock::time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec));
129}134}
130135
131#elif defined(_LIBCPP_WIN32API)136#elif defined(_LIBCPP_WIN32API)
...@@ -138,36 +143,40 @@ steady_clock::now() _NOEXCEPT...@@ -138,36 +143,40 @@ steady_clock::now() _NOEXCEPT
138static LARGE_INTEGER143static LARGE_INTEGER
139__QueryPerformanceFrequency()144__QueryPerformanceFrequency()
140{145{
141 LARGE_INTEGER val;146 LARGE_INTEGER val;
142 (void) QueryPerformanceFrequency(&val);147 (void) QueryPerformanceFrequency(&val);
143 return val;148 return val;
144}149}
145150
146steady_clock::time_point151static steady_clock::time_point __libcpp_steady_clock_now() {
147steady_clock::now() _NOEXCEPT
148{
149 static const LARGE_INTEGER freq = __QueryPerformanceFrequency();152 static const LARGE_INTEGER freq = __QueryPerformanceFrequency();
150153
151 LARGE_INTEGER counter;154 LARGE_INTEGER counter;
152 (void) QueryPerformanceCounter(&counter);155 (void) QueryPerformanceCounter(&counter);
153 return time_point(duration(counter.QuadPart * nano::den / freq.QuadPart));156 return steady_clock::time_point(steady_clock::duration(counter.QuadPart * nano::den / freq.QuadPart));
154}157}
155158
156#elif defined(CLOCK_MONOTONIC)159#elif defined(CLOCK_MONOTONIC)
157160
158steady_clock::time_point161static steady_clock::time_point __libcpp_steady_clock_now() {
159steady_clock::now() _NOEXCEPT
160{
161 struct timespec tp;162 struct timespec tp;
162 if (0 != clock_gettime(CLOCK_MONOTONIC, &tp))163 if (0 != clock_gettime(CLOCK_MONOTONIC, &tp))
163 __throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC) failed");164 __throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC) failed");
164 return time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec));165 return steady_clock::time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec));
165}166}
166167
167#else168#else
168# error "Monotonic clock not implemented"169# error "Monotonic clock not implemented on this platform"
169#endif170#endif
170171
172const bool steady_clock::is_steady;
173
174steady_clock::time_point
175steady_clock::now() _NOEXCEPT
176{
177 return __libcpp_steady_clock_now();
178}
179
171#endif // !_LIBCPP_HAS_NO_MONOTONIC_CLOCK180#endif // !_LIBCPP_HAS_NO_MONOTONIC_CLOCK
172181
173}182}
lib/libcxx/src/experimental/memory_resource.cpp-10
...@@ -76,16 +76,6 @@ union ResourceInitHelper {...@@ -76,16 +76,6 @@ union ResourceInitHelper {
76 ~ResourceInitHelper() {}76 ~ResourceInitHelper() {}
77};77};
7878
79// Detect if the init_priority attribute is supported.
80#if (defined(_LIBCPP_COMPILER_GCC) && defined(__APPLE__)) \
81 || defined(_LIBCPP_COMPILER_MSVC)
82// GCC on Apple doesn't support the init priority attribute,
83// and MSVC doesn't support any GCC attributes.
84# define _LIBCPP_INIT_PRIORITY_MAX
85#else
86# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101)))
87#endif
88
89// When compiled in C++14 this initialization should be a constant expression.79// When compiled in C++14 this initialization should be a constant expression.
90// Only in C++11 is "init_priority" needed to ensure initialization order.80// Only in C++11 is "init_priority" needed to ensure initialization order.
91#if _LIBCPP_STD_VER > 1181#if _LIBCPP_STD_VER > 11
lib/libcxx/src/filesystem/filesystem_common.h+53-39
...@@ -13,8 +13,9 @@...@@ -13,8 +13,9 @@
13#include "filesystem"13#include "filesystem"
14#include "array"14#include "array"
15#include "chrono"15#include "chrono"
16#include "cstdlib"
17#include "climits"16#include "climits"
17#include "cstdlib"
18#include "ctime"
1819
19#include <unistd.h>20#include <unistd.h>
20#include <sys/stat.h>21#include <sys/stat.h>
...@@ -47,7 +48,7 @@ static string format_string_imp(const char* msg, ...) {...@@ -47,7 +48,7 @@ static string format_string_imp(const char* msg, ...) {
47 struct GuardVAList {48 struct GuardVAList {
48 va_list& target;49 va_list& target;
49 bool active = true;50 bool active = true;
50 GuardVAList(va_list& target) : target(target), active(true) {}51 GuardVAList(va_list& tgt) : target(tgt), active(true) {}
51 void clear() {52 void clear() {
52 if (active)53 if (active)
53 va_end(target);54 va_end(target);
...@@ -134,50 +135,50 @@ path error_value<path>() {...@@ -134,50 +135,50 @@ path error_value<path>() {
134135
135template <class T>136template <class T>
136struct ErrorHandler {137struct ErrorHandler {
137 const char* func_name;138 const char* func_name_;
138 error_code* ec = nullptr;139 error_code* ec_ = nullptr;
139 const path* p1 = nullptr;140 const path* p1_ = nullptr;
140 const path* p2 = nullptr;141 const path* p2_ = nullptr;
141142
142 ErrorHandler(const char* fname, error_code* ec, const path* p1 = nullptr,143 ErrorHandler(const char* fname, error_code* ec, const path* p1 = nullptr,
143 const path* p2 = nullptr)144 const path* p2 = nullptr)
144 : func_name(fname), ec(ec), p1(p1), p2(p2) {145 : func_name_(fname), ec_(ec), p1_(p1), p2_(p2) {
145 if (ec)146 if (ec_)
146 ec->clear();147 ec_->clear();
147 }148 }
148149
149 T report(const error_code& m_ec) const {150 T report(const error_code& ec) const {
150 if (ec) {151 if (ec_) {
151 *ec = m_ec;152 *ec_ = ec;
152 return error_value<T>();153 return error_value<T>();
153 }154 }
154 string what = string("in ") + func_name;155 string what = string("in ") + func_name_;
155 switch (bool(p1) + bool(p2)) {156 switch (bool(p1_) + bool(p2_)) {
156 case 0:157 case 0:
157 __throw_filesystem_error(what, m_ec);158 __throw_filesystem_error(what, ec);
158 case 1:159 case 1:
159 __throw_filesystem_error(what, *p1, m_ec);160 __throw_filesystem_error(what, *p1_, ec);
160 case 2:161 case 2:
161 __throw_filesystem_error(what, *p1, *p2, m_ec);162 __throw_filesystem_error(what, *p1_, *p2_, ec);
162 }163 }
163 _LIBCPP_UNREACHABLE();164 _LIBCPP_UNREACHABLE();
164 }165 }
165166
166 template <class... Args>167 template <class... Args>
167 T report(const error_code& m_ec, const char* msg, Args const&... args) const {168 T report(const error_code& ec, const char* msg, Args const&... args) const {
168 if (ec) {169 if (ec_) {
169 *ec = m_ec;170 *ec_ = ec;
170 return error_value<T>();171 return error_value<T>();
171 }172 }
172 string what =173 string what =
173 string("in ") + func_name + ": " + format_string(msg, args...);174 string("in ") + func_name_ + ": " + format_string(msg, args...);
174 switch (bool(p1) + bool(p2)) {175 switch (bool(p1_) + bool(p2_)) {
175 case 0:176 case 0:
176 __throw_filesystem_error(what, m_ec);177 __throw_filesystem_error(what, ec);
177 case 1:178 case 1:
178 __throw_filesystem_error(what, *p1, m_ec);179 __throw_filesystem_error(what, *p1_, ec);
179 case 2:180 case 2:
180 __throw_filesystem_error(what, *p1, *p2, m_ec);181 __throw_filesystem_error(what, *p1_, *p2_, ec);
181 }182 }
182 _LIBCPP_UNREACHABLE();183 _LIBCPP_UNREACHABLE();
183 }184 }
...@@ -197,8 +198,9 @@ private:...@@ -197,8 +198,9 @@ private:
197using chrono::duration;198using chrono::duration;
198using chrono::duration_cast;199using chrono::duration_cast;
199200
200using TimeSpec = struct ::timespec;201using TimeSpec = struct timespec;
201using StatT = struct ::stat;202using TimeVal = struct timeval;
203using StatT = struct stat;
202204
203template <class FileTimeT, class TimeT,205template <class FileTimeT, class TimeT,
204 bool IsFloat = is_floating_point<typename FileTimeT::rep>::value>206 bool IsFloat = is_floating_point<typename FileTimeT::rep>::value>
...@@ -380,26 +382,38 @@ public:...@@ -380,26 +382,38 @@ public:
380using fs_time = time_util<file_time_type, time_t, TimeSpec>;382using fs_time = time_util<file_time_type, time_t, TimeSpec>;
381383
382#if defined(__APPLE__)384#if defined(__APPLE__)
383TimeSpec extract_mtime(StatT const& st) { return st.st_mtimespec; }385inline TimeSpec extract_mtime(StatT const& st) { return st.st_mtimespec; }
384TimeSpec extract_atime(StatT const& st) { return st.st_atimespec; }386inline TimeSpec extract_atime(StatT const& st) { return st.st_atimespec; }
387#elif defined(__MVS__)
388inline TimeSpec extract_mtime(StatT const& st) {
389 TimeSpec TS = {st.st_mtime, 0};
390 return TS;
391}
392inline TimeSpec extract_atime(StatT const& st) {
393 TimeSpec TS = {st.st_atime, 0};
394 return TS;
395}
385#else396#else
386TimeSpec extract_mtime(StatT const& st) { return st.st_mtim; }397inline TimeSpec extract_mtime(StatT const& st) { return st.st_mtim; }
387TimeSpec extract_atime(StatT const& st) { return st.st_atim; }398inline TimeSpec extract_atime(StatT const& st) { return st.st_atim; }
388#endif399#endif
389400
390// allow the utimes implementation to compile even it we're not going401inline TimeVal make_timeval(TimeSpec const& ts) {
391// to use it.
392
393bool posix_utimes(const path& p, std::array<TimeSpec, 2> const& TS,
394 error_code& ec) {
395 using namespace chrono;402 using namespace chrono;
396 auto Convert = [](long nsec) {403 auto Convert = [](long nsec) {
397 using int_type = decltype(std::declval< ::timeval>().tv_usec);404 using int_type = decltype(std::declval<TimeVal>().tv_usec);
398 auto dur = duration_cast<microseconds>(nanoseconds(nsec)).count();405 auto dur = duration_cast<microseconds>(nanoseconds(nsec)).count();
399 return static_cast<int_type>(dur);406 return static_cast<int_type>(dur);
400 };407 };
401 struct ::timeval ConvertedTS[2] = {{TS[0].tv_sec, Convert(TS[0].tv_nsec)},408 TimeVal TV = {};
402 {TS[1].tv_sec, Convert(TS[1].tv_nsec)}};409 TV.tv_sec = ts.tv_sec;
410 TV.tv_usec = Convert(ts.tv_nsec);
411 return TV;
412}
413
414inline bool posix_utimes(const path& p, std::array<TimeSpec, 2> const& TS,
415 error_code& ec) {
416 TimeVal ConvertedTS[2] = {make_timeval(TS[0]), make_timeval(TS[1])};
403 if (::utimes(p.c_str(), ConvertedTS) == -1) {417 if (::utimes(p.c_str(), ConvertedTS) == -1) {
404 ec = capture_errno();418 ec = capture_errno();
405 return true;419 return true;
lib/libcxx/src/filesystem/operations.cpp+99-102
...@@ -9,8 +9,6 @@...@@ -9,8 +9,6 @@
9#include "filesystem"9#include "filesystem"
10#include "array"10#include "array"
11#include "iterator"11#include "iterator"
12#include "fstream"
13#include "random" /* for unique_path */
14#include "string_view"12#include "string_view"
15#include "type_traits"13#include "type_traits"
16#include "vector"14#include "vector"
...@@ -25,29 +23,23 @@...@@ -25,29 +23,23 @@
25#include <time.h>23#include <time.h>
26#include <fcntl.h> /* values for fchmodat */24#include <fcntl.h> /* values for fchmodat */
2725
28#if defined(__linux__)26#if __has_include(<sys/sendfile.h>)
29#include <linux/version.h>27# include <sys/sendfile.h>
30#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 33)28# define _LIBCPP_FILESYSTEM_USE_SENDFILE
31#include <sys/sendfile.h>
32#define _LIBCPP_USE_SENDFILE
33#endif
34#elif defined(__APPLE__) || __has_include(<copyfile.h>)29#elif defined(__APPLE__) || __has_include(<copyfile.h>)
35#include <copyfile.h>30# include <copyfile.h>
36#define _LIBCPP_USE_COPYFILE31# define _LIBCPP_FILESYSTEM_USE_COPYFILE
32#else
33# include "fstream"
34# define _LIBCPP_FILESYSTEM_USE_FSTREAM
37#endif35#endif
3836
39#if !defined(CLOCK_REALTIME)37#if !defined(CLOCK_REALTIME)
40#include <sys/time.h> // for gettimeofday and timeval38# include <sys/time.h> // for gettimeofday and timeval
41#endif // !defined(CLOCK_REALTIME)
42
43#if defined(__ELF__) && defined(_LIBCPP_LINK_RT_LIB)
44#pragma comment(lib, "rt")
45#endif39#endif
4640
47#if defined(_LIBCPP_COMPILER_GCC)41#if defined(__ELF__) && defined(_LIBCPP_LINK_RT_LIB)
48#if _GNUC_VER < 50042# pragma comment(lib, "rt")
49#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
50#endif
51#endif43#endif
5244
53_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM45_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
...@@ -542,7 +534,7 @@ path __canonical(path const& orig_p, error_code* ec) {...@@ -542,7 +534,7 @@ path __canonical(path const& orig_p, error_code* ec) {
542 ErrorHandler<path> err("canonical", ec, &orig_p, &cwd);534 ErrorHandler<path> err("canonical", ec, &orig_p, &cwd);
543535
544 path p = __do_absolute(orig_p, &cwd, ec);536 path p = __do_absolute(orig_p, &cwd, ec);
545#if _POSIX_VERSION >= 200112537#if defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112
546 std::unique_ptr<char, decltype(&::free)>538 std::unique_ptr<char, decltype(&::free)>
547 hold(::realpath(p.c_str(), nullptr), &::free);539 hold(::realpath(p.c_str(), nullptr), &::free);
548 if (hold.get() == nullptr)540 if (hold.get() == nullptr)
...@@ -646,96 +638,83 @@ void __copy(const path& from, const path& to, copy_options options,...@@ -646,96 +638,83 @@ void __copy(const path& from, const path& to, copy_options options,
646namespace detail {638namespace detail {
647namespace {639namespace {
648640
649#ifdef _LIBCPP_USE_SENDFILE641#if defined(_LIBCPP_FILESYSTEM_USE_SENDFILE)
650bool copy_file_impl_sendfile(FileDescriptor& read_fd, FileDescriptor& write_fd,642 bool copy_file_impl(FileDescriptor& read_fd, FileDescriptor& write_fd, error_code& ec) {
651 error_code& ec) {643 size_t count = read_fd.get_stat().st_size;
652644 do {
653 size_t count = read_fd.get_stat().st_size;645 ssize_t res;
654 do {646 if ((res = ::sendfile(write_fd.fd, read_fd.fd, nullptr, count)) == -1) {
655 ssize_t res;647 ec = capture_errno();
656 if ((res = ::sendfile(write_fd.fd, read_fd.fd, nullptr, count)) == -1) {648 return false;
657 ec = capture_errno();649 }
658 return false;650 count -= res;
659 }651 } while (count > 0);
660 count -= res;
661 } while (count > 0);
662
663 ec.clear();
664652
665 return true;653 ec.clear();
666}
667#elif defined(_LIBCPP_USE_COPYFILE)
668bool copy_file_impl_copyfile(FileDescriptor& read_fd, FileDescriptor& write_fd,
669 error_code& ec) {
670 struct CopyFileState {
671 copyfile_state_t state;
672 CopyFileState() { state = copyfile_state_alloc(); }
673 ~CopyFileState() { copyfile_state_free(state); }
674
675 private:
676 CopyFileState(CopyFileState const&) = delete;
677 CopyFileState& operator=(CopyFileState const&) = delete;
678 };
679654
680 CopyFileState cfs;655 return true;
681 if (fcopyfile(read_fd.fd, write_fd.fd, cfs.state, COPYFILE_DATA) < 0) {
682 ec = capture_errno();
683 return false;
684 }656 }
657#elif defined(_LIBCPP_FILESYSTEM_USE_COPYFILE)
658 bool copy_file_impl(FileDescriptor& read_fd, FileDescriptor& write_fd, error_code& ec) {
659 struct CopyFileState {
660 copyfile_state_t state;
661 CopyFileState() { state = copyfile_state_alloc(); }
662 ~CopyFileState() { copyfile_state_free(state); }
685663
686 ec.clear();664 private:
687 return true;665 CopyFileState(CopyFileState const&) = delete;
688}666 CopyFileState& operator=(CopyFileState const&) = delete;
689#endif667 };
690668
691// Note: This function isn't guarded by ifdef's even though it may be unused669 CopyFileState cfs;
692// in order to assure it still compiles.670 if (fcopyfile(read_fd.fd, write_fd.fd, cfs.state, COPYFILE_DATA) < 0) {
693__attribute__((unused)) bool copy_file_impl_default(FileDescriptor& read_fd,671 ec = capture_errno();
694 FileDescriptor& write_fd,672 return false;
695 error_code& ec) {673 }
696 ifstream in;
697 in.__open(read_fd.fd, ios::binary);
698 if (!in.is_open()) {
699 // This assumes that __open didn't reset the error code.
700 ec = capture_errno();
701 return false;
702 }
703 ofstream out;
704 out.__open(write_fd.fd, ios::binary);
705 if (!out.is_open()) {
706 ec = capture_errno();
707 return false;
708 }
709674
710 if (in.good() && out.good()) {675 ec.clear();
711 using InIt = istreambuf_iterator<char>;676 return true;
712 using OutIt = ostreambuf_iterator<char>;
713 InIt bin(in);
714 InIt ein;
715 OutIt bout(out);
716 copy(bin, ein, bout);
717 }
718 if (out.fail() || in.fail()) {
719 ec = make_error_code(errc::io_error);
720 return false;
721 }677 }
678#elif defined(_LIBCPP_FILESYSTEM_USE_FSTREAM)
679 bool copy_file_impl(FileDescriptor& read_fd, FileDescriptor& write_fd, error_code& ec) {
680 ifstream in;
681 in.__open(read_fd.fd, ios::binary);
682 if (!in.is_open()) {
683 // This assumes that __open didn't reset the error code.
684 ec = capture_errno();
685 return false;
686 }
687 read_fd.fd = -1;
688 ofstream out;
689 out.__open(write_fd.fd, ios::binary);
690 if (!out.is_open()) {
691 ec = capture_errno();
692 return false;
693 }
694 write_fd.fd = -1;
695
696 if (in.good() && out.good()) {
697 using InIt = istreambuf_iterator<char>;
698 using OutIt = ostreambuf_iterator<char>;
699 InIt bin(in);
700 InIt ein;
701 OutIt bout(out);
702 copy(bin, ein, bout);
703 }
704 if (out.fail() || in.fail()) {
705 ec = make_error_code(errc::io_error);
706 return false;
707 }
722708
723 ec.clear();709 ec.clear();
724 return true;710 return true;
725}711 }
726
727bool copy_file_impl(FileDescriptor& from, FileDescriptor& to, error_code& ec) {
728#if defined(_LIBCPP_USE_SENDFILE)
729 return copy_file_impl_sendfile(from, to, ec);
730#elif defined(_LIBCPP_USE_COPYFILE)
731 return copy_file_impl_copyfile(from, to, ec);
732#else712#else
733 return copy_file_impl_default(from, to, ec);713# error "Unknown implementation for copy_file_impl"
734#endif714#endif // copy_file_impl implementation
735}
736715
737} // namespace716} // end anonymous namespace
738} // namespace detail717} // end namespace detail
739718
740bool __copy_file(const path& from, const path& to, copy_options options,719bool __copy_file(const path& from, const path& to, copy_options options,
741 error_code* ec) {720 error_code* ec) {
...@@ -870,8 +849,17 @@ bool __create_directory(const path& p, error_code* ec) {...@@ -870,8 +849,17 @@ bool __create_directory(const path& p, error_code* ec) {
870849
871 if (::mkdir(p.c_str(), static_cast<int>(perms::all)) == 0)850 if (::mkdir(p.c_str(), static_cast<int>(perms::all)) == 0)
872 return true;851 return true;
873 if (errno != EEXIST)852
853 if (errno == EEXIST) {
854 error_code mec = capture_errno();
855 error_code ignored_ec;
856 const file_status st = status(p, ignored_ec);
857 if (!is_directory(st)) {
858 err.report(mec);
859 }
860 } else {
874 err.report(capture_errno());861 err.report(capture_errno());
862 }
875 return false;863 return false;
876}864}
877865
...@@ -889,8 +877,17 @@ bool __create_directory(path const& p, path const& attributes, error_code* ec) {...@@ -889,8 +877,17 @@ bool __create_directory(path const& p, path const& attributes, error_code* ec) {
889877
890 if (::mkdir(p.c_str(), attr_stat.st_mode) == 0)878 if (::mkdir(p.c_str(), attr_stat.st_mode) == 0)
891 return true;879 return true;
892 if (errno != EEXIST)880
881 if (errno == EEXIST) {
882 error_code mec = capture_errno();
883 error_code ignored_ec;
884 const file_status st = status(p, ignored_ec);
885 if (!is_directory(st)) {
886 err.report(mec);
887 }
888 } else {
893 err.report(capture_errno());889 err.report(capture_errno());
890 }
894 return false;891 return false;
895}892}
896893
lib/libcxx/src/include/config_elast.h+4
...@@ -17,10 +17,14 @@...@@ -17,10 +17,14 @@
17#include <errno.h>17#include <errno.h>
18#endif18#endif
1919
20// Note: _LIBCPP_ELAST needs to be defined only on platforms
21// where strerror/strerror_r can't handle out-of-range errno values.
20#if defined(ELAST)22#if defined(ELAST)
21#define _LIBCPP_ELAST ELAST23#define _LIBCPP_ELAST ELAST
22#elif defined(_NEWLIB_VERSION)24#elif defined(_NEWLIB_VERSION)
23#define _LIBCPP_ELAST __ELASTERROR25#define _LIBCPP_ELAST __ELASTERROR
26#elif defined(__NuttX__)
27// No _LIBCPP_ELAST needed on NuttX
24#elif defined(__Fuchsia__)28#elif defined(__Fuchsia__)
25// No _LIBCPP_ELAST needed on Fuchsia29// No _LIBCPP_ELAST needed on Fuchsia
26#elif defined(__wasi__)30#elif defined(__wasi__)
lib/libcxx/src/include/refstring.h+19-6
...@@ -13,12 +13,25 @@...@@ -13,12 +13,25 @@
13#include <stdexcept>13#include <stdexcept>
14#include <cstddef>14#include <cstddef>
15#include <cstring>15#include <cstring>
16#ifdef __APPLE__
17#include <dlfcn.h>
18#include <mach-o/dyld.h>
19#endif
20#include "atomic_support.h"16#include "atomic_support.h"
2117
18// MacOS and iOS used to ship with libstdc++, and still support old applications
19// linking against libstdc++. The libc++ and libstdc++ exceptions are supposed
20// to be ABI compatible, such that they can be thrown from one library and caught
21// in the other.
22//
23// For that reason, we must look for libstdc++ in the same process and if found,
24// check the string stored in the exception object to see if it is the GCC empty
25// string singleton before manipulating the reference count. This is done so that
26// if an exception is created with a zero-length string in libstdc++, libc++abi
27// won't try to delete the memory.
28#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || \
29 defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__)
30# define _LIBCPP_CHECK_FOR_GCC_EMPTY_STRING_STORAGE
31# include <dlfcn.h>
32# include <mach-o/dyld.h>
33#endif
34
22_LIBCPP_BEGIN_NAMESPACE_STD35_LIBCPP_BEGIN_NAMESPACE_STD
2336
24namespace __refstring_imp { namespace {37namespace __refstring_imp { namespace {
...@@ -40,7 +53,7 @@ inline char * data_from_rep(_Rep_base *rep) noexcept {...@@ -40,7 +53,7 @@ inline char * data_from_rep(_Rep_base *rep) noexcept {
40 return data + sizeof(*rep);53 return data + sizeof(*rep);
41}54}
4255
43#if defined(__APPLE__)56#if defined(_LIBCPP_CHECK_FOR_GCC_EMPTY_STRING_STORAGE)
44inline57inline
45const char* compute_gcc_empty_string_storage() _NOEXCEPT58const char* compute_gcc_empty_string_storage() _NOEXCEPT
46{59{
...@@ -115,7 +128,7 @@ __libcpp_refstring::~__libcpp_refstring() {...@@ -115,7 +128,7 @@ __libcpp_refstring::~__libcpp_refstring() {
115128
116inline129inline
117bool __libcpp_refstring::__uses_refcount() const {130bool __libcpp_refstring::__uses_refcount() const {
118#ifdef __APPLE__131#if defined(_LIBCPP_CHECK_FOR_GCC_EMPTY_STRING_STORAGE)
119 return __imp_ != get_gcc_empty_string_storage();132 return __imp_ != get_gcc_empty_string_storage();
120#else133#else
121 return true;134 return true;
lib/libcxx/src/ios.cpp-16
...@@ -15,30 +15,14 @@...@@ -15,30 +15,14 @@
15#include "__locale"15#include "__locale"
16#include "algorithm"16#include "algorithm"
17#include "include/config_elast.h"17#include "include/config_elast.h"
18#include "istream"
19#include "limits"18#include "limits"
20#include "memory"19#include "memory"
21#include "new"20#include "new"
22#include "streambuf"
23#include "string"21#include "string"
24#include "__undef_macros"22#include "__undef_macros"
2523
26_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
2725
28template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ios<char>;
29template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ios<wchar_t>;
30
31template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_streambuf<char>;
32template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_streambuf<wchar_t>;
33
34template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_istream<char>;
35template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_istream<wchar_t>;
36
37template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ostream<char>;
38template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ostream<wchar_t>;
39
40template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_iostream<char>;
41
42class _LIBCPP_HIDDEN __iostream_category26class _LIBCPP_HIDDEN __iostream_category
43 : public __do_message27 : public __do_message
44{28{
lib/libcxx/src/ios.instantiations.cpp created+43
...@@ -0,0 +1,43 @@
1//===----------------------------------------------------------------------===//
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#include "fstream"
11#include "ios"
12#include "istream"
13#include "ostream"
14#include "sstream"
15#include "streambuf"
16
17
18_LIBCPP_BEGIN_NAMESPACE_STD
19
20// Original explicit instantiations provided in the library
21template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ios<char>;
22template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ios<wchar_t>;
23template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_streambuf<char>;
24template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_streambuf<wchar_t>;
25template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_istream<char>;
26template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_istream<wchar_t>;
27template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ostream<char>;
28template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ostream<wchar_t>;
29template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_iostream<char>;
30
31// Additional instantiations added later. Whether programs rely on these being
32// available is protected by _LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1.
33template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_stringbuf<char>;
34template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_stringstream<char>;
35template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ostringstream<char>;
36template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_istringstream<char>;
37template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ifstream<char>;
38template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ofstream<char>;
39template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_filebuf<char>;
40
41// Add more here if needed...
42
43_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/iostream.cpp+1-1
...@@ -77,7 +77,7 @@ __asm__("?wclog@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_t...@@ -77,7 +77,7 @@ __asm__("?wclog@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_t
77#endif77#endif
78;78;
7979
80_LIBCPP_HIDDEN ios_base::Init __start_std_streams;80_LIBCPP_HIDDEN ios_base::Init __start_std_streams _LIBCPP_INIT_PRIORITY_MAX;
8181
82// On Windows the TLS storage for locales needs to be initialized before we create82// On Windows the TLS storage for locales needs to be initialized before we create
83// the standard streams, otherwise it may not be alive during program termination83// the standard streams, otherwise it may not be alive during program termination
lib/libcxx/src/locale.cpp+199-9
...@@ -30,7 +30,7 @@...@@ -30,7 +30,7 @@
30#include "__sso_allocator"30#include "__sso_allocator"
31#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)31#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
32#include "support/win32/locale_win32.h"32#include "support/win32/locale_win32.h"
33#elif !defined(__BIONIC__)33#elif !defined(__BIONIC__) && !defined(__NuttX__)
34#include <langinfo.h>34#include <langinfo.h>
35#endif35#endif
36#include <stdlib.h>36#include <stdlib.h>
...@@ -158,7 +158,7 @@ const locale::category locale::all;...@@ -158,7 +158,7 @@ const locale::category locale::all;
158class _LIBCPP_HIDDEN locale::__imp158class _LIBCPP_HIDDEN locale::__imp
159 : public facet159 : public facet
160{160{
161 enum {N = 28};161 enum {N = 30};
162#if defined(_LIBCPP_COMPILER_MSVC)162#if defined(_LIBCPP_COMPILER_MSVC)
163// FIXME: MSVC doesn't support aligned parameters by value.163// FIXME: MSVC doesn't support aligned parameters by value.
164// I can't get the __sso_allocator to work here164// I can't get the __sso_allocator to work here
...@@ -202,8 +202,14 @@ locale::__imp::__imp(size_t refs)...@@ -202,8 +202,14 @@ locale::__imp::__imp(size_t refs)
202 install(&make<_VSTD::ctype<wchar_t> >(1u));202 install(&make<_VSTD::ctype<wchar_t> >(1u));
203 install(&make<codecvt<char, char, mbstate_t> >(1u));203 install(&make<codecvt<char, char, mbstate_t> >(1u));
204 install(&make<codecvt<wchar_t, char, mbstate_t> >(1u));204 install(&make<codecvt<wchar_t, char, mbstate_t> >(1u));
205_LIBCPP_SUPPRESS_DEPRECATED_PUSH
205 install(&make<codecvt<char16_t, char, mbstate_t> >(1u));206 install(&make<codecvt<char16_t, char, mbstate_t> >(1u));
206 install(&make<codecvt<char32_t, char, mbstate_t> >(1u));207 install(&make<codecvt<char32_t, char, mbstate_t> >(1u));
208_LIBCPP_SUPPRESS_DEPRECATED_POP
209#ifndef _LIBCPP_NO_HAS_CHAR8_T
210 install(&make<codecvt<char16_t, char8_t, mbstate_t> >(1u));
211 install(&make<codecvt<char32_t, char8_t, mbstate_t> >(1u));
212#endif
207 install(&make<numpunct<char> >(1u));213 install(&make<numpunct<char> >(1u));
208 install(&make<numpunct<wchar_t> >(1u));214 install(&make<numpunct<wchar_t> >(1u));
209 install(&make<num_get<char> >(1u));215 install(&make<num_get<char> >(1u));
...@@ -245,8 +251,14 @@ locale::__imp::__imp(const string& name, size_t refs)...@@ -245,8 +251,14 @@ locale::__imp::__imp(const string& name, size_t refs)
245 install(new ctype_byname<wchar_t>(name_));251 install(new ctype_byname<wchar_t>(name_));
246 install(new codecvt_byname<char, char, mbstate_t>(name_));252 install(new codecvt_byname<char, char, mbstate_t>(name_));
247 install(new codecvt_byname<wchar_t, char, mbstate_t>(name_));253 install(new codecvt_byname<wchar_t, char, mbstate_t>(name_));
254_LIBCPP_SUPPRESS_DEPRECATED_PUSH
248 install(new codecvt_byname<char16_t, char, mbstate_t>(name_));255 install(new codecvt_byname<char16_t, char, mbstate_t>(name_));
249 install(new codecvt_byname<char32_t, char, mbstate_t>(name_));256 install(new codecvt_byname<char32_t, char, mbstate_t>(name_));
257_LIBCPP_SUPPRESS_DEPRECATED_POP
258#ifndef _LIBCPP_NO_HAS_CHAR8_T
259 install(new codecvt_byname<char16_t, char8_t, mbstate_t>(name_));
260 install(new codecvt_byname<char32_t, char8_t, mbstate_t>(name_));
261#endif
250 install(new numpunct_byname<char>(name_));262 install(new numpunct_byname<char>(name_));
251 install(new numpunct_byname<wchar_t>(name_));263 install(new numpunct_byname<wchar_t>(name_));
252 install(new moneypunct_byname<char, false>(name_));264 install(new moneypunct_byname<char, false>(name_));
...@@ -315,8 +327,14 @@ locale::__imp::__imp(const __imp& other, const string& name, locale::category c)...@@ -315,8 +327,14 @@ locale::__imp::__imp(const __imp& other, const string& name, locale::category c)
315 install(new ctype_byname<wchar_t>(name));327 install(new ctype_byname<wchar_t>(name));
316 install(new codecvt_byname<char, char, mbstate_t>(name));328 install(new codecvt_byname<char, char, mbstate_t>(name));
317 install(new codecvt_byname<wchar_t, char, mbstate_t>(name));329 install(new codecvt_byname<wchar_t, char, mbstate_t>(name));
330_LIBCPP_SUPPRESS_DEPRECATED_PUSH
318 install(new codecvt_byname<char16_t, char, mbstate_t>(name));331 install(new codecvt_byname<char16_t, char, mbstate_t>(name));
319 install(new codecvt_byname<char32_t, char, mbstate_t>(name));332 install(new codecvt_byname<char32_t, char, mbstate_t>(name));
333_LIBCPP_SUPPRESS_DEPRECATED_POP
334#ifndef _LIBCPP_NO_HAS_CHAR8_T
335 install(new codecvt_byname<char16_t, char8_t, mbstate_t>(name));
336 install(new codecvt_byname<char32_t, char8_t, mbstate_t>(name));
337#endif
320 }338 }
321 if (c & locale::monetary)339 if (c & locale::monetary)
322 {340 {
...@@ -385,8 +403,14 @@ locale::__imp::__imp(const __imp& other, const __imp& one, locale::category c)...@@ -385,8 +403,14 @@ locale::__imp::__imp(const __imp& other, const __imp& one, locale::category c)
385 install_from<_VSTD::ctype<char> >(one);403 install_from<_VSTD::ctype<char> >(one);
386 install_from<_VSTD::ctype<wchar_t> >(one);404 install_from<_VSTD::ctype<wchar_t> >(one);
387 install_from<_VSTD::codecvt<char, char, mbstate_t> >(one);405 install_from<_VSTD::codecvt<char, char, mbstate_t> >(one);
406_LIBCPP_SUPPRESS_DEPRECATED_PUSH
388 install_from<_VSTD::codecvt<char16_t, char, mbstate_t> >(one);407 install_from<_VSTD::codecvt<char16_t, char, mbstate_t> >(one);
389 install_from<_VSTD::codecvt<char32_t, char, mbstate_t> >(one);408 install_from<_VSTD::codecvt<char32_t, char, mbstate_t> >(one);
409_LIBCPP_SUPPRESS_DEPRECATED_POP
410#ifndef _LIBCPP_NO_HAS_CHAR8_T
411 install_from<_VSTD::codecvt<char16_t, char8_t, mbstate_t> >(one);
412 install_from<_VSTD::codecvt<char32_t, char8_t, mbstate_t> >(one);
413#endif
390 install_from<_VSTD::codecvt<wchar_t, char, mbstate_t> >(one);414 install_from<_VSTD::codecvt<wchar_t, char, mbstate_t> >(one);
391 }415 }
392 if (c & locale::monetary)416 if (c & locale::monetary)
...@@ -1149,7 +1173,7 @@ ctype<char>::__classic_upper_table() _NOEXCEPT...@@ -1149,7 +1173,7 @@ ctype<char>::__classic_upper_table() _NOEXCEPT
1149{1173{
1150 return _LIBCPP_GET_C_LOCALE->__ctype_toupper;1174 return _LIBCPP_GET_C_LOCALE->__ctype_toupper;
1151}1175}
1152#elif __NetBSD__1176#elif defined(__NetBSD__)
1153const short*1177const short*
1154ctype<char>::__classic_lower_table() _NOEXCEPT1178ctype<char>::__classic_lower_table() _NOEXCEPT
1155{1179{
...@@ -3171,6 +3195,87 @@ codecvt<char16_t, char, mbstate_t>::do_max_length() const _NOEXCEPT...@@ -3171,6 +3195,87 @@ codecvt<char16_t, char, mbstate_t>::do_max_length() const _NOEXCEPT
3171 return 4;3195 return 4;
3172}3196}
31733197
3198#ifndef _LIBCPP_NO_HAS_CHAR8_T
3199
3200// template <> class codecvt<char16_t, char8_t, mbstate_t>
3201
3202locale::id codecvt<char16_t, char8_t, mbstate_t>::id;
3203
3204codecvt<char16_t, char8_t, mbstate_t>::~codecvt()
3205{
3206}
3207
3208codecvt<char16_t, char8_t, mbstate_t>::result
3209codecvt<char16_t, char8_t, mbstate_t>::do_out(state_type&,
3210 const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
3211 extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
3212{
3213 const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
3214 const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
3215 const uint16_t* _frm_nxt = _frm;
3216 uint8_t* _to = reinterpret_cast<uint8_t*>(to);
3217 uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
3218 uint8_t* _to_nxt = _to;
3219 result r = utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
3220 frm_nxt = frm + (_frm_nxt - _frm);
3221 to_nxt = to + (_to_nxt - _to);
3222 return r;
3223}
3224
3225codecvt<char16_t, char8_t, mbstate_t>::result
3226codecvt<char16_t, char8_t, mbstate_t>::do_in(state_type&,
3227 const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
3228 intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
3229{
3230 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
3231 const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
3232 const uint8_t* _frm_nxt = _frm;
3233 uint16_t* _to = reinterpret_cast<uint16_t*>(to);
3234 uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
3235 uint16_t* _to_nxt = _to;
3236 result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
3237 frm_nxt = frm + (_frm_nxt - _frm);
3238 to_nxt = to + (_to_nxt - _to);
3239 return r;
3240}
3241
3242codecvt<char16_t, char8_t, mbstate_t>::result
3243codecvt<char16_t, char8_t, mbstate_t>::do_unshift(state_type&,
3244 extern_type* to, extern_type*, extern_type*& to_nxt) const
3245{
3246 to_nxt = to;
3247 return noconv;
3248}
3249
3250int
3251codecvt<char16_t, char8_t, mbstate_t>::do_encoding() const _NOEXCEPT
3252{
3253 return 0;
3254}
3255
3256bool
3257codecvt<char16_t, char8_t, mbstate_t>::do_always_noconv() const _NOEXCEPT
3258{
3259 return false;
3260}
3261
3262int
3263codecvt<char16_t, char8_t, mbstate_t>::do_length(state_type&,
3264 const extern_type* frm, const extern_type* frm_end, size_t mx) const
3265{
3266 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
3267 const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
3268 return utf8_to_utf16_length(_frm, _frm_end, mx);
3269}
3270
3271int
3272codecvt<char16_t, char8_t, mbstate_t>::do_max_length() const _NOEXCEPT
3273{
3274 return 4;
3275}
3276
3277#endif
3278
3174// template <> class codecvt<char32_t, char, mbstate_t>3279// template <> class codecvt<char32_t, char, mbstate_t>
31753280
3176locale::id codecvt<char32_t, char, mbstate_t>::id;3281locale::id codecvt<char32_t, char, mbstate_t>::id;
...@@ -3248,6 +3353,87 @@ codecvt<char32_t, char, mbstate_t>::do_max_length() const _NOEXCEPT...@@ -3248,6 +3353,87 @@ codecvt<char32_t, char, mbstate_t>::do_max_length() const _NOEXCEPT
3248 return 4;3353 return 4;
3249}3354}
32503355
3356#ifndef _LIBCPP_NO_HAS_CHAR8_T
3357
3358// template <> class codecvt<char32_t, char8_t, mbstate_t>
3359
3360locale::id codecvt<char32_t, char8_t, mbstate_t>::id;
3361
3362codecvt<char32_t, char8_t, mbstate_t>::~codecvt()
3363{
3364}
3365
3366codecvt<char32_t, char8_t, mbstate_t>::result
3367codecvt<char32_t, char8_t, mbstate_t>::do_out(state_type&,
3368 const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
3369 extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
3370{
3371 const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
3372 const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
3373 const uint32_t* _frm_nxt = _frm;
3374 uint8_t* _to = reinterpret_cast<uint8_t*>(to);
3375 uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
3376 uint8_t* _to_nxt = _to;
3377 result r = ucs4_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
3378 frm_nxt = frm + (_frm_nxt - _frm);
3379 to_nxt = to + (_to_nxt - _to);
3380 return r;
3381}
3382
3383codecvt<char32_t, char8_t, mbstate_t>::result
3384codecvt<char32_t, char8_t, mbstate_t>::do_in(state_type&,
3385 const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
3386 intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
3387{
3388 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
3389 const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
3390 const uint8_t* _frm_nxt = _frm;
3391 uint32_t* _to = reinterpret_cast<uint32_t*>(to);
3392 uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
3393 uint32_t* _to_nxt = _to;
3394 result r = utf8_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
3395 frm_nxt = frm + (_frm_nxt - _frm);
3396 to_nxt = to + (_to_nxt - _to);
3397 return r;
3398}
3399
3400codecvt<char32_t, char8_t, mbstate_t>::result
3401codecvt<char32_t, char8_t, mbstate_t>::do_unshift(state_type&,
3402 extern_type* to, extern_type*, extern_type*& to_nxt) const
3403{
3404 to_nxt = to;
3405 return noconv;
3406}
3407
3408int
3409codecvt<char32_t, char8_t, mbstate_t>::do_encoding() const _NOEXCEPT
3410{
3411 return 0;
3412}
3413
3414bool
3415codecvt<char32_t, char8_t, mbstate_t>::do_always_noconv() const _NOEXCEPT
3416{
3417 return false;
3418}
3419
3420int
3421codecvt<char32_t, char8_t, mbstate_t>::do_length(state_type&,
3422 const extern_type* frm, const extern_type* frm_end, size_t mx) const
3423{
3424 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
3425 const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
3426 return utf8_to_ucs4_length(_frm, _frm_end, mx);
3427}
3428
3429int
3430codecvt<char32_t, char8_t, mbstate_t>::do_max_length() const _NOEXCEPT
3431{
3432 return 4;
3433}
3434
3435#endif
3436
3251// __codecvt_utf8<wchar_t>3437// __codecvt_utf8<wchar_t>
32523438
3253__codecvt_utf8<wchar_t>::result3439__codecvt_utf8<wchar_t>::result
...@@ -5128,7 +5314,7 @@ __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct)...@@ -5128,7 +5314,7 @@ __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct)
5128 mb = mbstate_t();5314 mb = mbstate_t();
5129 const char* bb = buf;5315 const char* bb = buf;
5130 size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);5316 size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
5131 if (j == size_t(-1))5317 if (j == size_t(-1) || j == 0)
5132 __throw_runtime_error("locale not supported");5318 __throw_runtime_error("locale not supported");
5133 wbe = wbuf + j;5319 wbe = wbuf + j;
5134 __weeks_[i].assign(wbuf, wbe);5320 __weeks_[i].assign(wbuf, wbe);
...@@ -5136,7 +5322,7 @@ __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct)...@@ -5136,7 +5322,7 @@ __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct)
5136 mb = mbstate_t();5322 mb = mbstate_t();
5137 bb = buf;5323 bb = buf;
5138 j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);5324 j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
5139 if (j == size_t(-1))5325 if (j == size_t(-1) || j == 0)
5140 __throw_runtime_error("locale not supported");5326 __throw_runtime_error("locale not supported");
5141 wbe = wbuf + j;5327 wbe = wbuf + j;
5142 __weeks_[i+7].assign(wbuf, wbe);5328 __weeks_[i+7].assign(wbuf, wbe);
...@@ -5149,7 +5335,7 @@ __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct)...@@ -5149,7 +5335,7 @@ __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct)
5149 mb = mbstate_t();5335 mb = mbstate_t();
5150 const char* bb = buf;5336 const char* bb = buf;
5151 size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);5337 size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
5152 if (j == size_t(-1))5338 if (j == size_t(-1) || j == 0)
5153 __throw_runtime_error("locale not supported");5339 __throw_runtime_error("locale not supported");
5154 wbe = wbuf + j;5340 wbe = wbuf + j;
5155 __months_[i].assign(wbuf, wbe);5341 __months_[i].assign(wbuf, wbe);
...@@ -5157,7 +5343,7 @@ __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct)...@@ -5157,7 +5343,7 @@ __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct)
5157 mb = mbstate_t();5343 mb = mbstate_t();
5158 bb = buf;5344 bb = buf;
5159 j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);5345 j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
5160 if (j == size_t(-1))5346 if (j == size_t(-1) || j == 0)
5161 __throw_runtime_error("locale not supported");5347 __throw_runtime_error("locale not supported");
5162 wbe = wbuf + j;5348 wbe = wbuf + j;
5163 __months_[i+12].assign(wbuf, wbe);5349 __months_[i+12].assign(wbuf, wbe);
...@@ -6148,7 +6334,11 @@ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS messages_byname<wchar_t>...@@ -6148,7 +6334,11 @@ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS messages_byname<wchar_t>
61486334
6149template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char, char, mbstate_t>;6335template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char, char, mbstate_t>;
6150template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<wchar_t, char, mbstate_t>;6336template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<wchar_t, char, mbstate_t>;
6151template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char16_t, char, mbstate_t>;6337template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DEPRECATED_IN_CXX20 codecvt_byname<char16_t, char, mbstate_t>;
6152template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char32_t, char, mbstate_t>;6338template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DEPRECATED_IN_CXX20 codecvt_byname<char32_t, char, mbstate_t>;
6339#ifndef _LIBCPP_NO_HAS_CHAR8_T
6340template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char16_t, char8_t, mbstate_t>;
6341template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char32_t, char8_t, mbstate_t>;
6342#endif
61536343
6154_LIBCPP_END_NAMESPACE_STD6344_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/memory.cpp-4
...@@ -124,16 +124,12 @@ __shared_weak_count::lock() _NOEXCEPT...@@ -124,16 +124,12 @@ __shared_weak_count::lock() _NOEXCEPT
124 return nullptr;124 return nullptr;
125}125}
126126
127#if !defined(_LIBCPP_NO_RTTI) || !defined(_LIBCPP_BUILD_STATIC)
128
129const void*127const void*
130__shared_weak_count::__get_deleter(const type_info&) const _NOEXCEPT128__shared_weak_count::__get_deleter(const type_info&) const _NOEXCEPT
131{129{
132 return nullptr;130 return nullptr;
133}131}
134132
135#endif // _LIBCPP_NO_RTTI
136
137#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)133#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
138134
139_LIBCPP_SAFE_STATIC static const std::size_t __sp_mut_count = 16;135_LIBCPP_SAFE_STATIC static const std::size_t __sp_mut_count = 16;
lib/libcxx/src/new.cpp+18-19
...@@ -64,7 +64,7 @@ operator new(std::size_t size) _THROW_BAD_ALLOC...@@ -64,7 +64,7 @@ operator new(std::size_t size) _THROW_BAD_ALLOC
64 if (size == 0)64 if (size == 0)
65 size = 1;65 size = 1;
66 void* p;66 void* p;
67 while ((p = ::malloc(size)) == 0)67 while ((p = ::malloc(size)) == nullptr)
68 {68 {
69 // If malloc fails and there is a new_handler,69 // If malloc fails and there is a new_handler,
70 // call it to try free up memory.70 // call it to try free up memory.
...@@ -85,7 +85,7 @@ _LIBCPP_WEAK...@@ -85,7 +85,7 @@ _LIBCPP_WEAK
85void*85void*
86operator new(size_t size, const std::nothrow_t&) _NOEXCEPT86operator new(size_t size, const std::nothrow_t&) _NOEXCEPT
87{87{
88 void* p = 0;88 void* p = nullptr;
89#ifndef _LIBCPP_NO_EXCEPTIONS89#ifndef _LIBCPP_NO_EXCEPTIONS
90 try90 try
91 {91 {
...@@ -111,7 +111,7 @@ _LIBCPP_WEAK...@@ -111,7 +111,7 @@ _LIBCPP_WEAK
111void*111void*
112operator new[](size_t size, const std::nothrow_t&) _NOEXCEPT112operator new[](size_t size, const std::nothrow_t&) _NOEXCEPT
113{113{
114 void* p = 0;114 void* p = nullptr;
115#ifndef _LIBCPP_NO_EXCEPTIONS115#ifndef _LIBCPP_NO_EXCEPTIONS
116 try116 try
117 {117 {
...@@ -130,7 +130,8 @@ _LIBCPP_WEAK...@@ -130,7 +130,8 @@ _LIBCPP_WEAK
130void130void
131operator delete(void* ptr) _NOEXCEPT131operator delete(void* ptr) _NOEXCEPT
132{132{
133 ::free(ptr);133 if (ptr)
134 ::free(ptr);
134}135}
135136
136_LIBCPP_WEAK137_LIBCPP_WEAK
...@@ -178,15 +179,16 @@ operator new(std::size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC...@@ -178,15 +179,16 @@ operator new(std::size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC
178 size = 1;179 size = 1;
179 if (static_cast<size_t>(alignment) < sizeof(void*))180 if (static_cast<size_t>(alignment) < sizeof(void*))
180 alignment = std::align_val_t(sizeof(void*));181 alignment = std::align_val_t(sizeof(void*));
182
183 // Try allocating memory. If allocation fails and there is a new_handler,
184 // call it to try free up memory, and try again until it succeeds, or until
185 // the new_handler decides to terminate.
186 //
187 // If allocation fails and there is no new_handler, we throw bad_alloc
188 // (or return nullptr if exceptions are disabled).
181 void* p;189 void* p;
182#if defined(_LIBCPP_MSVCRT_LIKE)190 while ((p = std::__libcpp_aligned_alloc(static_cast<std::size_t>(alignment), size)) == nullptr)
183 while ((p = _aligned_malloc(size, static_cast<size_t>(alignment))) == nullptr)
184#else
185 while (::posix_memalign(&p, static_cast<size_t>(alignment), size) != 0)
186#endif
187 {191 {
188 // If posix_memalign fails and there is a new_handler,
189 // call it to try free up memory.
190 std::new_handler nh = std::get_new_handler();192 std::new_handler nh = std::get_new_handler();
191 if (nh)193 if (nh)
192 nh();194 nh();
...@@ -194,7 +196,6 @@ operator new(std::size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC...@@ -194,7 +196,6 @@ operator new(std::size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC
194#ifndef _LIBCPP_NO_EXCEPTIONS196#ifndef _LIBCPP_NO_EXCEPTIONS
195 throw std::bad_alloc();197 throw std::bad_alloc();
196#else198#else
197 p = nullptr; // posix_memalign doesn't initialize 'p' on failure
198 break;199 break;
199#endif200#endif
200 }201 }
...@@ -206,7 +207,7 @@ _LIBCPP_WEAK...@@ -206,7 +207,7 @@ _LIBCPP_WEAK
206void*207void*
207operator new(size_t size, std::align_val_t alignment, const std::nothrow_t&) _NOEXCEPT208operator new(size_t size, std::align_val_t alignment, const std::nothrow_t&) _NOEXCEPT
208{209{
209 void* p = 0;210 void* p = nullptr;
210#ifndef _LIBCPP_NO_EXCEPTIONS211#ifndef _LIBCPP_NO_EXCEPTIONS
211 try212 try
212 {213 {
...@@ -232,7 +233,7 @@ _LIBCPP_WEAK...@@ -232,7 +233,7 @@ _LIBCPP_WEAK
232void*233void*
233operator new[](size_t size, std::align_val_t alignment, const std::nothrow_t&) _NOEXCEPT234operator new[](size_t size, std::align_val_t alignment, const std::nothrow_t&) _NOEXCEPT
234{235{
235 void* p = 0;236 void* p = nullptr;
236#ifndef _LIBCPP_NO_EXCEPTIONS237#ifndef _LIBCPP_NO_EXCEPTIONS
237 try238 try
238 {239 {
...@@ -251,11 +252,9 @@ _LIBCPP_WEAK...@@ -251,11 +252,9 @@ _LIBCPP_WEAK
251void252void
252operator delete(void* ptr, std::align_val_t) _NOEXCEPT253operator delete(void* ptr, std::align_val_t) _NOEXCEPT
253{254{
254#if defined(_LIBCPP_MSVCRT_LIKE)255 if (ptr) {
255 ::_aligned_free(ptr);256 std::__libcpp_aligned_free(ptr);
256#else257 }
257 ::free(ptr);
258#endif
259}258}
260259
261_LIBCPP_WEAK260_LIBCPP_WEAK
lib/libcxx/src/optional.cpp+1
...@@ -7,6 +7,7 @@...@@ -7,6 +7,7 @@
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "optional"9#include "optional"
10#include "__availability"
1011
11namespace std12namespace std
12{13{
lib/libcxx/src/support/runtime/exception_fallback.ipp-4
...@@ -49,7 +49,6 @@ get_terminate() _NOEXCEPT...@@ -49,7 +49,6 @@ get_terminate() _NOEXCEPT
49 return __libcpp_atomic_load(&__terminate_handler);49 return __libcpp_atomic_load(&__terminate_handler);
50}50}
5151
52#ifndef __EMSCRIPTEN__ // We provide this in JS
53_LIBCPP_NORETURN52_LIBCPP_NORETURN
54void53void
55terminate() _NOEXCEPT54terminate() _NOEXCEPT
...@@ -72,9 +71,7 @@ terminate() _NOEXCEPT...@@ -72,9 +71,7 @@ terminate() _NOEXCEPT
72 }71 }
73#endif // _LIBCPP_NO_EXCEPTIONS72#endif // _LIBCPP_NO_EXCEPTIONS
74}73}
75#endif // !__EMSCRIPTEN__
7674
77#if !defined(__EMSCRIPTEN__)
78bool uncaught_exception() _NOEXCEPT { return uncaught_exceptions() > 0; }75bool uncaught_exception() _NOEXCEPT { return uncaught_exceptions() > 0; }
7976
80int uncaught_exceptions() _NOEXCEPT77int uncaught_exceptions() _NOEXCEPT
...@@ -83,7 +80,6 @@ int uncaught_exceptions() _NOEXCEPT...@@ -83,7 +80,6 @@ int uncaught_exceptions() _NOEXCEPT
83 fprintf(stderr, "uncaught_exceptions not yet implemented\n");80 fprintf(stderr, "uncaught_exceptions not yet implemented\n");
84 ::abort();81 ::abort();
85}82}
86#endif // !__EMSCRIPTEN__
8783
8884
89exception::~exception() _NOEXCEPT85exception::~exception() _NOEXCEPT
lib/libcxx/src/thread.cpp+2-16
...@@ -14,17 +14,9 @@...@@ -14,17 +14,9 @@
14#include "vector"14#include "vector"
15#include "future"15#include "future"
16#include "limits"16#include "limits"
17#include <sys/types.h>
18
19#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
20# include <sys/param.h>
21# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__APPLE__)
22# include <sys/sysctl.h>
23# endif
24#endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
2517
26#if __has_include(<unistd.h>)18#if __has_include(<unistd.h>)
27#include <unistd.h>19# include <unistd.h> // for sysconf
28#endif20#endif
2921
30#if defined(__NetBSD__)22#if defined(__NetBSD__)
...@@ -80,13 +72,7 @@ thread::detach()...@@ -80,13 +72,7 @@ thread::detach()
80unsigned72unsigned
81thread::hardware_concurrency() _NOEXCEPT73thread::hardware_concurrency() _NOEXCEPT
82{74{
83#if defined(CTL_HW) && defined(HW_NCPU)75#if defined(_SC_NPROCESSORS_ONLN)
84 unsigned n;
85 int mib[2] = {CTL_HW, HW_NCPU};
86 std::size_t s = sizeof(n);
87 sysctl(mib, 2, &n, &s, 0, 0);
88 return n;
89#elif defined(_SC_NPROCESSORS_ONLN)
90 long result = sysconf(_SC_NPROCESSORS_ONLN);76 long result = sysconf(_SC_NPROCESSORS_ONLN);
91 // sysconf returns -1 if the name is invalid, the option does not exist or77 // sysconf returns -1 if the name is invalid, the option does not exist or
92 // does not have a definite limit.78 // does not have a definite limit.
src/libcxx.zig+1
...@@ -49,6 +49,7 @@ const libcxx_files = [_][]const u8{...@@ -49,6 +49,7 @@ const libcxx_files = [_][]const u8{
49 "src/future.cpp",49 "src/future.cpp",
50 "src/hash.cpp",50 "src/hash.cpp",
51 "src/ios.cpp",51 "src/ios.cpp",
52 "src/ios.instantiations.cpp",
52 "src/iostream.cpp",53 "src/iostream.cpp",
53 "src/locale.cpp",54 "src/locale.cpp",
54 "src/memory.cpp",55 "src/memory.cpp",