aboutsummaryrefslogtreecommitdiff
path: root/libcxx/include
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/include')
-rw-r--r--libcxx/include/__availability206
-rw-r--r--libcxx/include/__bit_reference30
-rw-r--r--libcxx/include/__bits146
-rw-r--r--libcxx/include/__config304
-rw-r--r--libcxx/include/__debug39
-rw-r--r--libcxx/include/__functional_0348
-rw-r--r--libcxx/include/__functional_base79
-rw-r--r--libcxx/include/__functional_base_0324
-rw-r--r--libcxx/include/__hash_table238
-rw-r--r--libcxx/include/__libcpp_version2
-rw-r--r--libcxx/include/__locale270
-rw-r--r--libcxx/include/__memory/allocator_traits.h401
-rw-r--r--libcxx/include/__memory/base.h127
-rw-r--r--libcxx/include/__memory/pointer_traits.h169
-rw-r--r--libcxx/include/__memory/utilities.h88
-rw-r--r--libcxx/include/__mutex_base15
-rw-r--r--libcxx/include/__split_buffer24
-rw-r--r--libcxx/include/__sso_allocator9
-rw-r--r--libcxx/include/__string96
-rw-r--r--libcxx/include/__threading_support62
-rw-r--r--libcxx/include/__tree220
-rw-r--r--libcxx/include/algorithm685
-rw-r--r--libcxx/include/any30
-rw-r--r--libcxx/include/array20
-rw-r--r--libcxx/include/atomic170
-rw-r--r--libcxx/include/barrier12
-rw-r--r--libcxx/include/bit146
-rw-r--r--libcxx/include/bitset12
-rw-r--r--libcxx/include/charconv27
-rw-r--r--libcxx/include/chrono7
-rw-r--r--libcxx/include/cmath4
-rw-r--r--libcxx/include/codecvt24
-rw-r--r--libcxx/include/compare13
-rw-r--r--libcxx/include/complex17
-rw-r--r--libcxx/include/concepts5
-rw-r--r--libcxx/include/ctime16
-rw-r--r--libcxx/include/deque16
-rw-r--r--libcxx/include/exception2
-rw-r--r--libcxx/include/experimental/memory_resource5
-rw-r--r--libcxx/include/experimental/simd5
-rw-r--r--libcxx/include/ext/hash_map2
-rw-r--r--libcxx/include/filesystem405
-rw-r--r--libcxx/include/forward_list6
-rw-r--r--libcxx/include/fstream155
-rw-r--r--libcxx/include/functional160
-rw-r--r--libcxx/include/future248
-rw-r--r--libcxx/include/iomanip4
-rw-r--r--libcxx/include/ios31
-rw-r--r--libcxx/include/iosfwd59
-rw-r--r--libcxx/include/istream34
-rw-r--r--libcxx/include/iterator121
-rw-r--r--libcxx/include/latch8
-rw-r--r--libcxx/include/list186
-rw-r--r--libcxx/include/locale184
-rw-r--r--libcxx/include/locale.h6
-rw-r--r--libcxx/include/map50
-rw-r--r--libcxx/include/memory1799
-rw-r--r--libcxx/include/module.modulemap1
-rw-r--r--libcxx/include/mutex2
-rw-r--r--libcxx/include/new173
-rw-r--r--libcxx/include/numbers2
-rw-r--r--libcxx/include/numeric191
-rw-r--r--libcxx/include/optional5
-rw-r--r--libcxx/include/ostream28
-rw-r--r--libcxx/include/queue19
-rw-r--r--libcxx/include/random498
-rw-r--r--libcxx/include/regex183
-rw-r--r--libcxx/include/semaphore9
-rw-r--r--libcxx/include/shared_mutex1
-rw-r--r--libcxx/include/span7
-rw-r--r--libcxx/include/sstream492
-rw-r--r--libcxx/include/stdexcept4
-rw-r--r--libcxx/include/streambuf14
-rw-r--r--libcxx/include/string342
-rw-r--r--libcxx/include/string_view65
-rw-r--r--libcxx/include/strstream26
-rw-r--r--libcxx/include/system_error4
-rw-r--r--libcxx/include/thread45
-rw-r--r--libcxx/include/tuple2
-rw-r--r--libcxx/include/type_traits382
-rw-r--r--libcxx/include/typeinfo29
-rw-r--r--libcxx/include/unordered_map270
-rw-r--r--libcxx/include/unordered_set160
-rw-r--r--libcxx/include/utility38
-rw-r--r--libcxx/include/valarray168
-rw-r--r--libcxx/include/variant127
-rw-r--r--libcxx/include/vector99
-rw-r--r--libcxx/include/version170
-rw-r--r--libcxx/include/wctype.h4
89 files changed, 5972 insertions, 4859 deletions
diff --git a/libcxx/include/__availability b/libcxx/include/__availability
new file mode 100644
index 000000000000..db2267c8eb16
--- /dev/null
+++ b/libcxx/include/__availability
@@ -0,0 +1,206 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___AVAILABILITY
+#define _LIBCPP___AVAILABILITY
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+// Libc++ is shipped by various vendors. In particular, it is used as a system
+// library on macOS, iOS and other Apple platforms. In order for users to be
+// able to compile a binary that is intended to be deployed to an older version
+// of a platform, Clang provides availability attributes [1]. These attributes
+// can be placed on declarations and are used to describe the life cycle of a
+// symbol in the library.
+//
+// The main goal is to ensure a compile-time error if a symbol that hasn't been
+// introduced in a previously released library is used in a program that targets
+// that previously released library. Normally, this would be a load-time error
+// when one tries to launch the program against the older library.
+//
+// For example, the filesystem library was introduced in the dylib in macOS 10.15.
+// If a user compiles on a macOS 10.15 host but targets macOS 10.13 with their
+// program, the compiler would normally not complain (because the required
+// declarations are in the headers), but the dynamic loader would fail to find
+// the symbols when actually trying to launch the program on macOS 10.13. To
+// turn this into a compile-time issue instead, declarations are annotated with
+// when they were introduced, and the compiler can produce a diagnostic if the
+// program references something that isn't available on the deployment target.
+//
+// This mechanism is general in nature, and any vendor can add their markup to
+// the library (see below). Whenever a new feature is added that requires support
+// in the shared library, a macro should be added below to mark this feature
+// as unavailable. When vendors decide to ship the feature as part of their
+// shared library, they can update the markup appropriately.
+//
+// Note that this mechanism is disabled by default in the "upstream" libc++.
+// Availability annotations are only meaningful when shipping libc++ inside
+// a platform (i.e. as a system library), and so vendors that want them should
+// turn those annotations on at CMake configuration time.
+//
+// [1]: https://clang.llvm.org/docs/AttributeReference.html#availability
+
+
+// For backwards compatibility, allow users to define _LIBCPP_DISABLE_AVAILABILITY
+// for a while.
+#if defined(_LIBCPP_DISABLE_AVAILABILITY)
+# if !defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)
+# define _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS
+# endif
+#endif
+
+// Availability markup is disabled when building the library, or when the compiler
+// doesn't support the proper attributes.
+#if defined(_LIBCPP_BUILDING_LIBRARY) || \
+ defined(_LIBCXXABI_BUILDING_LIBRARY) || \
+ !__has_feature(attribute_availability_with_strict) || \
+ !__has_feature(attribute_availability_in_templates) || \
+ !__has_extension(pragma_clang_attribute_external_declaration)
+# if !defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)
+# define _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS
+# endif
+#endif
+
+#if defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)
+
+ // This controls the availability of std::shared_mutex and std::shared_timed_mutex,
+ // which were added to the dylib later.
+# define _LIBCPP_AVAILABILITY_SHARED_MUTEX
+
+ // These macros control the availability of std::bad_optional_access and
+ // other exception types. These were put in the shared library to prevent
+ // code bloat from every user program defining the vtable for these exception
+ // types.
+# define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
+# define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
+# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST
+
+ // This controls the availability of std::uncaught_exceptions().
+# define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS
+
+ // This controls the availability of the sized version of ::operator delete,
+ // which was added to the dylib later.
+# define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE
+
+ // This controls the availability of the std::future_error exception.
+# define _LIBCPP_AVAILABILITY_FUTURE_ERROR
+
+ // This controls the availability of std::type_info's vtable.
+ // I can't imagine how using std::type_info can work at all if
+ // this isn't supported.
+# define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE
+
+ // This controls the availability of std::locale::category members
+ // (e.g. std::locale::collate), which are defined in the dylib.
+# define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY
+
+ // This controls the availability of atomic operations on std::shared_ptr
+ // (e.g. `std::atomic_store(std::shared_ptr)`), which require a shared
+ // lock table located in the dylib.
+# define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
+
+ // These macros control the availability of all parts of <filesystem> that
+ // depend on something in the dylib.
+# define _LIBCPP_AVAILABILITY_FILESYSTEM
+# define _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH
+# define _LIBCPP_AVAILABILITY_FILESYSTEM_POP
+
+ // This controls the availability of std::to_chars.
+# define _LIBCPP_AVAILABILITY_TO_CHARS
+
+ // This controls the availability of the C++20 synchronization library,
+ // which requires shared library support for various operations
+ // (see libcxx/src/atomic.cpp).
+# define _LIBCPP_AVAILABILITY_SYNC
+
+#elif defined(__APPLE__)
+
+# define _LIBCPP_AVAILABILITY_SHARED_MUTEX \
+ __attribute__((availability(macosx,strict,introduced=10.12))) \
+ __attribute__((availability(ios,strict,introduced=10.0))) \
+ __attribute__((availability(tvos,strict,introduced=10.0))) \
+ __attribute__((availability(watchos,strict,introduced=3.0)))
+# define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS \
+ __attribute__((availability(macosx,strict,introduced=10.13))) \
+ __attribute__((availability(ios,strict,introduced=11.0))) \
+ __attribute__((availability(tvos,strict,introduced=11.0))) \
+ __attribute__((availability(watchos,strict,introduced=4.0)))
+# define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS \
+ _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
+# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST \
+ _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
+# define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS \
+ __attribute__((availability(macosx,strict,introduced=10.12))) \
+ __attribute__((availability(ios,strict,introduced=10.0))) \
+ __attribute__((availability(tvos,strict,introduced=10.0))) \
+ __attribute__((availability(watchos,strict,introduced=3.0)))
+# define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE \
+ __attribute__((availability(macosx,strict,introduced=10.12))) \
+ __attribute__((availability(ios,strict,introduced=10.0))) \
+ __attribute__((availability(tvos,strict,introduced=10.0))) \
+ __attribute__((availability(watchos,strict,introduced=3.0)))
+# define _LIBCPP_AVAILABILITY_FUTURE_ERROR \
+ __attribute__((availability(ios,strict,introduced=6.0)))
+# define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE \
+ __attribute__((availability(macosx,strict,introduced=10.9))) \
+ __attribute__((availability(ios,strict,introduced=7.0)))
+# define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY \
+ __attribute__((availability(macosx,strict,introduced=10.9))) \
+ __attribute__((availability(ios,strict,introduced=7.0)))
+# define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR \
+ __attribute__((availability(macosx,strict,introduced=10.9))) \
+ __attribute__((availability(ios,strict,introduced=7.0)))
+# define _LIBCPP_AVAILABILITY_FILESYSTEM \
+ __attribute__((availability(macosx,strict,introduced=10.15))) \
+ __attribute__((availability(ios,strict,introduced=13.0))) \
+ __attribute__((availability(tvos,strict,introduced=13.0))) \
+ __attribute__((availability(watchos,strict,introduced=6.0)))
+# define _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH \
+ _Pragma("clang attribute push(__attribute__((availability(macosx,strict,introduced=10.15))), apply_to=any(function,record))") \
+ _Pragma("clang attribute push(__attribute__((availability(ios,strict,introduced=13.0))), apply_to=any(function,record))") \
+ _Pragma("clang attribute push(__attribute__((availability(tvos,strict,introduced=13.0))), apply_to=any(function,record))") \
+ _Pragma("clang attribute push(__attribute__((availability(watchos,strict,introduced=6.0))), apply_to=any(function,record))")
+# define _LIBCPP_AVAILABILITY_FILESYSTEM_POP \
+ _Pragma("clang attribute pop") \
+ _Pragma("clang attribute pop") \
+ _Pragma("clang attribute pop") \
+ _Pragma("clang attribute pop")
+# define _LIBCPP_AVAILABILITY_TO_CHARS \
+ _LIBCPP_AVAILABILITY_FILESYSTEM
+# define _LIBCPP_AVAILABILITY_SYNC \
+ __attribute__((unavailable))
+
+#else
+
+// ...New vendors can add availability markup here...
+
+# error "It looks like you're trying to enable vendor availability markup, but you haven't defined the corresponding macros yet!"
+
+#endif
+
+// Define availability attributes that depend on _LIBCPP_NO_EXCEPTIONS.
+// Those are defined in terms of the availability attributes above, and
+// should not be vendor-specific.
+#if defined(_LIBCPP_NO_EXCEPTIONS)
+# define _LIBCPP_AVAILABILITY_FUTURE
+# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
+# define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
+# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
+#else
+# define _LIBCPP_AVAILABILITY_FUTURE _LIBCPP_AVAILABILITY_FUTURE_ERROR
+# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _LIBCPP_AVAILABILITY_BAD_ANY_CAST
+# define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
+# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
+#endif
+
+#endif // _LIBCPP___AVAILABILITY
diff --git a/libcxx/include/__bit_reference b/libcxx/include/__bit_reference
index 4a2b82064b3c..9cfb4b84e653 100644
--- a/libcxx/include/__bit_reference
+++ b/libcxx/include/__bit_reference
@@ -11,7 +11,7 @@
#define _LIBCPP___BIT_REFERENCE
#include <__config>
-#include <bit>
+#include <__bits>
#include <algorithm>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -239,8 +239,8 @@ __bit_iterator<_Cp, _IsConst>
find(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value_)
{
if (static_cast<bool>(__value_))
- return __find_bool_true(__first, static_cast<typename _Cp::size_type>(__last - __first));
- return __find_bool_false(__first, static_cast<typename _Cp::size_type>(__last - __first));
+ return _VSTD::__find_bool_true(__first, static_cast<typename _Cp::size_type>(__last - __first));
+ return _VSTD::__find_bool_false(__first, static_cast<typename _Cp::size_type>(__last - __first));
}
// count
@@ -313,8 +313,8 @@ typename __bit_iterator<_Cp, _IsConst>::difference_type
count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value_)
{
if (static_cast<bool>(__value_))
- return __count_bool_true(__first, static_cast<typename _Cp::size_type>(__last - __first));
- return __count_bool_false(__first, static_cast<typename _Cp::size_type>(__last - __first));
+ return _VSTD::__count_bool_true(__first, static_cast<typename _Cp::size_type>(__last - __first));
+ return _VSTD::__count_bool_false(__first, static_cast<typename _Cp::size_type>(__last - __first));
}
// fill_n
@@ -387,9 +387,9 @@ fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __v
if (__n > 0)
{
if (__value_)
- __fill_n_true(__first, __n);
+ _VSTD::__fill_n_true(__first, __n);
else
- __fill_n_false(__first, __n);
+ _VSTD::__fill_n_false(__first, __n);
}
}
@@ -538,8 +538,8 @@ __bit_iterator<_Cp, false>
copy(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result)
{
if (__first.__ctz_ == __result.__ctz_)
- return __copy_aligned(__first, __last, __result);
- return __copy_unaligned(__first, __last, __result);
+ return _VSTD::__copy_aligned(__first, __last, __result);
+ return _VSTD::__copy_unaligned(__first, __last, __result);
}
// copy_backward
@@ -685,8 +685,8 @@ __bit_iterator<_Cp, false>
copy_backward(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result)
{
if (__last.__ctz_ == __result.__ctz_)
- return __copy_backward_aligned(__first, __last, __result);
- return __copy_backward_unaligned(__first, __last, __result);
+ return _VSTD::__copy_backward_aligned(__first, __last, __result);
+ return _VSTD::__copy_backward_unaligned(__first, __last, __result);
}
// move
@@ -868,8 +868,8 @@ swap_ranges(__bit_iterator<__C1, false> __first1, __bit_iterator<__C1, false> __
__bit_iterator<__C2, false> __first2)
{
if (__first1.__ctz_ == __first2.__ctz_)
- return __swap_ranges_aligned(__first1, __last1, __first2);
- return __swap_ranges_unaligned(__first1, __last1, __first2);
+ return _VSTD::__swap_ranges_aligned(__first1, __last1, __first2);
+ return _VSTD::__swap_ranges_unaligned(__first1, __last1, __first2);
}
// rotate
@@ -1083,8 +1083,8 @@ bool
equal(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, __bit_iterator<_Cp, _IC2> __first2)
{
if (__first1.__ctz_ == __first2.__ctz_)
- return __equal_aligned(__first1, __last1, __first2);
- return __equal_unaligned(__first1, __last1, __first2);
+ return _VSTD::__equal_aligned(__first1, __last1, __first2);
+ return _VSTD::__equal_unaligned(__first1, __last1, __first2);
}
template <class _Cp, bool _IsConst,
diff --git a/libcxx/include/__bits b/libcxx/include/__bits
new file mode 100644
index 000000000000..0d321da92285
--- /dev/null
+++ b/libcxx/include/__bits
@@ -0,0 +1,146 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___BITS
+#define _LIBCPP___BITS
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifndef _LIBCPP_COMPILER_MSVC
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+int __libcpp_ctz(unsigned __x) _NOEXCEPT { return __builtin_ctz(__x); }
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+int __libcpp_ctz(unsigned long __x) _NOEXCEPT { return __builtin_ctzl(__x); }
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+int __libcpp_ctz(unsigned long long __x) _NOEXCEPT { return __builtin_ctzll(__x); }
+
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+int __libcpp_clz(unsigned __x) _NOEXCEPT { return __builtin_clz(__x); }
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+int __libcpp_clz(unsigned long __x) _NOEXCEPT { return __builtin_clzl(__x); }
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+int __libcpp_clz(unsigned long long __x) _NOEXCEPT { return __builtin_clzll(__x); }
+
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+int __libcpp_popcount(unsigned __x) _NOEXCEPT { return __builtin_popcount(__x); }
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+int __libcpp_popcount(unsigned long __x) _NOEXCEPT { return __builtin_popcountl(__x); }
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+int __libcpp_popcount(unsigned long long __x) _NOEXCEPT { return __builtin_popcountll(__x); }
+
+#else // _LIBCPP_COMPILER_MSVC
+
+// Precondition: __x != 0
+inline _LIBCPP_INLINE_VISIBILITY
+int __libcpp_ctz(unsigned __x) {
+ static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
+ static_assert(sizeof(unsigned long) == 4, "");
+ unsigned long __where;
+ if (_BitScanForward(&__where, __x))
+ return static_cast<int>(__where);
+ return 32;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+int __libcpp_ctz(unsigned long __x) {
+ static_assert(sizeof(unsigned long) == sizeof(unsigned), "");
+ return __ctz(static_cast<unsigned>(__x));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+int __libcpp_ctz(unsigned long long __x) {
+ unsigned long __where;
+#if defined(_LIBCPP_HAS_BITSCAN64)
+ (defined(_M_AMD64) || defined(__x86_64__))
+ if (_BitScanForward64(&__where, __x))
+ return static_cast<int>(__where);
+#else
+ // Win32 doesn't have _BitScanForward64 so emulate it with two 32 bit calls.
+ if (_BitScanForward(&__where, static_cast<unsigned long>(__x)))
+ return static_cast<int>(__where);
+ if (_BitScanForward(&__where, static_cast<unsigned long>(__x >> 32)))
+ return static_cast<int>(__where + 32);
+#endif
+ return 64;
+}
+
+// Precondition: __x != 0
+inline _LIBCPP_INLINE_VISIBILITY
+int __libcpp_clz(unsigned __x) {
+ static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
+ static_assert(sizeof(unsigned long) == 4, "");
+ unsigned long __where;
+ if (_BitScanReverse(&__where, __x))
+ return static_cast<int>(31 - __where);
+ return 32; // Undefined Behavior.
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+int __libcpp_clz(unsigned long __x) {
+ static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
+ return __libcpp_clz(static_cast<unsigned>(__x));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+int __libcpp_clz(unsigned long long __x) {
+ unsigned long __where;
+#if defined(_LIBCPP_HAS_BITSCAN64)
+ if (_BitScanReverse64(&__where, __x))
+ return static_cast<int>(63 - __where);
+#else
+ // Win32 doesn't have _BitScanReverse64 so emulate it with two 32 bit calls.
+ if (_BitScanReverse(&__where, static_cast<unsigned long>(__x >> 32)))
+ return static_cast<int>(63 - (__where + 32));
+ if (_BitScanReverse(&__where, static_cast<unsigned long>(__x)))
+ return static_cast<int>(63 - __where);
+#endif
+ return 64; // Undefined Behavior.
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int __libcpp_popcount(unsigned __x) {
+ static_assert(sizeof(unsigned) == 4, "");
+ return __popcnt(__x);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int __libcpp_popcount(unsigned long __x) {
+ static_assert(sizeof(unsigned long) == 4, "");
+ return __popcnt(__x);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int __libcpp_popcount(unsigned long long __x) {
+ static_assert(sizeof(unsigned long long) == 8, "");
+ return __popcnt64(__x);
+}
+
+#endif // _LIBCPP_COMPILER_MSVC
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP__BITS
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 575147cead42..a3838c89e8e1 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -32,13 +32,13 @@
# define _GNUC_VER_NEW 0
#endif
-#define _LIBCPP_VERSION 11000
+#define _LIBCPP_VERSION 12000
#ifndef _LIBCPP_ABI_VERSION
# define _LIBCPP_ABI_VERSION 1
#endif
-#ifndef __STDC_HOSTED__
+#if __STDC_HOSTED__ == 0
# define _LIBCPP_FREESTANDING
#endif
@@ -49,8 +49,10 @@
# define _LIBCPP_STD_VER 14
# elif __cplusplus <= 201703L
# define _LIBCPP_STD_VER 17
+# elif __cplusplus <= 202002L
+# define _LIBCPP_STD_VER 20
# else
-# define _LIBCPP_STD_VER 18 // current year, or date of c++2a ratification
+# define _LIBCPP_STD_VER 21 // current year, or date of c++2b ratification
# endif
#endif // _LIBCPP_STD_VER
@@ -63,7 +65,7 @@
#elif defined(__wasm__)
# define _LIBCPP_OBJECT_FORMAT_WASM 1
#else
-# error Unknown object file format
+ // ... add new file formats here ...
#endif
#if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2
@@ -105,6 +107,10 @@
// Re-worked external template instantiations for std::string with a focus on
// performance and fast-path inlining.
# define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION
+// Enable clang::trivial_abi on std::unique_ptr.
+# define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI
+// Enable clang::trivial_abi on std::shared_ptr and std::weak_ptr
+# define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI
#elif _LIBCPP_ABI_VERSION == 1
# if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
// Enable compiling copies of now inline methods into the dylib to support
@@ -121,9 +127,11 @@
# endif
#endif
-#ifdef _LIBCPP_TRIVIAL_PAIR_COPY_CTOR
-#error "_LIBCPP_TRIVIAL_PAIR_COPY_CTOR" is no longer supported. \
- use _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR instead
+#if defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2
+// Enable additional explicit instantiations of iostreams components. This
+// reduces the number of weak definitions generated in programs that use
+// iostreams by providing a single strong definition in the shared library.
+# define _LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1
#endif
#define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y
@@ -256,14 +264,14 @@
# endif // __LONG_LONG_SUPPORTED
#endif // __FreeBSD__
-#ifdef __NetBSD__
+#if defined(__NetBSD__) || defined(__OpenBSD__)
# include <sys/endian.h>
# if _BYTE_ORDER == _LITTLE_ENDIAN
# define _LIBCPP_LITTLE_ENDIAN
# else // _BYTE_ORDER == _LITTLE_ENDIAN
# define _LIBCPP_BIG_ENDIAN
# endif // _BYTE_ORDER == _LITTLE_ENDIAN
-#endif // __NetBSD__
+#endif // defined(__NetBSD__) || defined(__OpenBSD__)
#if defined(_WIN32)
# define _LIBCPP_WIN32API
@@ -304,7 +312,7 @@
# endif
#endif // __sun__
-#if defined(__CloudABI__)
+#if defined(__OpenBSD__) || defined(__CloudABI__)
// Certain architectures provide arc4random(). Prefer using
// arc4random() over /dev/{u,}random to make it possible to obtain
// random data even when using sandboxing mechanisms such as chroots,
@@ -344,13 +352,11 @@
# if defined(__FreeBSD__)
# define _LIBCPP_HAS_ALIGNED_ALLOC
# define _LIBCPP_HAS_QUICK_EXIT
-# define _LIBCPP_HAS_C11_FEATURES
# if __FreeBSD_version >= 1300064 || \
(__FreeBSD_version >= 1201504 && __FreeBSD_version < 1300000)
# define _LIBCPP_HAS_TIMESPEC_GET
# endif
# elif defined(__BIONIC__)
-# define _LIBCPP_HAS_C11_FEATURES
# if __ANDROID_API__ >= 21
# define _LIBCPP_HAS_QUICK_EXIT
# endif
@@ -364,7 +370,9 @@
# define _LIBCPP_HAS_ALIGNED_ALLOC
# define _LIBCPP_HAS_QUICK_EXIT
# define _LIBCPP_HAS_TIMESPEC_GET
-# define _LIBCPP_HAS_C11_FEATURES
+# elif defined(__OpenBSD__)
+# define _LIBCPP_HAS_ALIGNED_ALLOC
+# define _LIBCPP_HAS_TIMESPEC_GET
# elif defined(__linux__)
# if !defined(_LIBCPP_HAS_MUSL_LIBC)
# if _LIBCPP_GLIBC_PREREQ(2, 15) || defined(__BIONIC__)
@@ -372,16 +380,24 @@
# endif
# if _LIBCPP_GLIBC_PREREQ(2, 17)
# define _LIBCPP_HAS_ALIGNED_ALLOC
-# define _LIBCPP_HAS_C11_FEATURES
# define _LIBCPP_HAS_TIMESPEC_GET
# endif
# else // defined(_LIBCPP_HAS_MUSL_LIBC)
# define _LIBCPP_HAS_ALIGNED_ALLOC
# define _LIBCPP_HAS_QUICK_EXIT
# define _LIBCPP_HAS_TIMESPEC_GET
-# define _LIBCPP_HAS_C11_FEATURES
# endif
-# endif // __linux__
+# elif defined(__APPLE__)
+ // timespec_get and aligned_alloc were introduced in macOS 10.15 and
+ // aligned releases
+# if (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101500 || \
+ __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 130000 || \
+ __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 130000 || \
+ __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 60000)
+# define _LIBCPP_HAS_ALIGNED_ALLOC
+# define _LIBCPP_HAS_TIMESPEC_GET
+# endif
+# endif // __APPLE__
#endif
#ifndef _LIBCPP_CXX03_LANG
@@ -389,9 +405,7 @@
#elif defined(_LIBCPP_COMPILER_CLANG)
# define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp)
#else
-// This definition is potentially buggy, but it's only taken with GCC in C++03,
-// which we barely support anyway. See llvm.org/PR39713
-# define _LIBCPP_ALIGNOF(_Tp) __alignof(_Tp)
+# error "We don't know a correct way to implement alignof(T) in C++03 outside of Clang"
#endif
#define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp)
@@ -433,10 +447,6 @@ typedef __char32_t char32_t;
# define _LIBCPP_NORETURN __attribute__ ((noreturn))
#endif
-#if !(__has_feature(cxx_lambdas))
-#define _LIBCPP_HAS_NO_LAMBDAS
-#endif
-
#if !(__has_feature(cxx_nullptr))
# if (__has_extension(cxx_nullptr) || __has_keyword(__nullptr)) && defined(_LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR)
# define nullptr __nullptr
@@ -445,18 +455,6 @@ typedef __char32_t char32_t;
# endif
#endif
-#if !(__has_feature(cxx_rvalue_references))
-#define _LIBCPP_HAS_NO_RVALUE_REFERENCES
-#endif
-
-#if !(__has_feature(cxx_auto_type))
-#define _LIBCPP_HAS_NO_AUTO_TYPE
-#endif
-
-#if !(__has_feature(cxx_variadic_templates))
-#define _LIBCPP_HAS_NO_VARIADICS
-#endif
-
// Objective-C++ features (opt-in)
#if __has_feature(objc_arc)
#define _LIBCPP_HAS_OBJC_ARC
@@ -720,7 +718,7 @@ typedef __char32_t char32_t;
#endif
#ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
-# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
+# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__visibility__("default")))
# else
# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
@@ -754,16 +752,6 @@ typedef __char32_t char32_t;
# endif
#endif
-#ifndef _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION
-# ifdef _LIBCPP_OBJECT_FORMAT_COFF // Windows binaries can't merge typeinfos.
-# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 2
-# else
- // TODO: This isn't strictly correct on ELF platforms due to llvm.org/PR37398
- // And we should consider defaulting to OFF.
-# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 1
-# endif
-#endif
-
#ifndef _LIBCPP_HIDE_FROM_ABI
# if _LIBCPP_HIDE_FROM_ABI_PER_TU
# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE
@@ -838,6 +826,12 @@ typedef unsigned int char32_t;
# define _LIBCPP_CONSTEXPR constexpr
#endif
+#ifndef __cpp_consteval
+# define _LIBCPP_CONSTEVAL _LIBCPP_CONSTEXPR
+#else
+# define _LIBCPP_CONSTEVAL consteval
+#endif
+
#ifdef _LIBCPP_CXX03_LANG
# define _LIBCPP_DEFAULT {}
#else
@@ -863,10 +857,6 @@ typedef unsigned int char32_t;
# define _LIBCPP_EXPLICIT
#endif
-#if !__has_builtin(__builtin_operator_new) || !__has_builtin(__builtin_operator_delete)
-#define _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE
-#endif
-
#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
# define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx
# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
@@ -880,34 +870,43 @@ typedef unsigned int char32_t;
# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
#endif // _LIBCPP_HAS_NO_STRONG_ENUMS
-#ifdef _LIBCPP_DEBUG
-# if _LIBCPP_DEBUG == 0
-# define _LIBCPP_DEBUG_LEVEL 1
-# elif _LIBCPP_DEBUG == 1
-# define _LIBCPP_DEBUG_LEVEL 2
-# else
-# error Supported values for _LIBCPP_DEBUG are 0 and 1
-# endif
-# if !defined(_LIBCPP_BUILDING_LIBRARY)
-# define _LIBCPP_EXTERN_TEMPLATE(...)
-# endif
+// _LIBCPP_DEBUG potential values:
+// - undefined: No assertions. This is the default.
+// - 0: Basic assertions
+// - 1: Basic assertions + iterator validity checks.
+#if !defined(_LIBCPP_DEBUG)
+# define _LIBCPP_DEBUG_LEVEL 0
+#elif _LIBCPP_DEBUG == 0
+# define _LIBCPP_DEBUG_LEVEL 1
+#elif _LIBCPP_DEBUG == 1
+# define _LIBCPP_DEBUG_LEVEL 2
+#else
+# error Supported values for _LIBCPP_DEBUG are 0 and 1
#endif
-#ifndef _LIBCPP_DEBUG_LEVEL
-# define _LIBCPP_DEBUG_LEVEL 0
+// _LIBCPP_DEBUG_LEVEL is always defined to one of [0, 1, 2] at this point
+#if _LIBCPP_DEBUG_LEVEL >= 1 && !defined(_LIBCPP_DISABLE_EXTERN_TEMPLATE)
+# define _LIBCPP_EXTERN_TEMPLATE(...)
#endif
#ifdef _LIBCPP_DISABLE_EXTERN_TEMPLATE
-#define _LIBCPP_EXTERN_TEMPLATE(...)
-#define _LIBCPP_EXTERN_TEMPLATE2(...)
+# define _LIBCPP_EXTERN_TEMPLATE(...)
+# define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...)
#endif
#ifndef _LIBCPP_EXTERN_TEMPLATE
#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
#endif
-#ifndef _LIBCPP_EXTERN_TEMPLATE2
-#define _LIBCPP_EXTERN_TEMPLATE2(...) extern template __VA_ARGS__;
+// When the Debug mode is enabled, we disable extern declarations because we
+// don't want to use the functions compiled in the library, which might not
+// have had the debug mode enabled when built. However, some extern declarations
+// need to be used, because code correctness depends on it (several instances
+// in the <locale>). Those special declarations are declared with
+// _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE, which is enabled even
+// when the debug mode is enabled.
+#ifndef _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE
+# define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) extern template __VA_ARGS__;
#endif
#ifndef _LIBCPP_EXTERN_TEMPLATE_DEFINE
@@ -938,6 +937,8 @@ typedef unsigned int char32_t;
// We're deferring to Microsoft's STL to provide aligned new et al. We don't
// have it unless the language feature test macro is defined.
# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
+#elif defined(__MVS__)
+# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
#endif
#if defined(__APPLE__)
@@ -999,6 +1000,18 @@ typedef unsigned int char32_t;
# define _LIBCPP_DEPRECATED_IN_CXX17
#endif
+#if _LIBCPP_STD_VER > 17
+# define _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_DEPRECATED
+#else
+# define _LIBCPP_DEPRECATED_IN_CXX20
+#endif
+
+#if !defined(_LIBCPP_NO_HAS_CHAR8_T)
+# define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED
+#else
+# define _LIBCPP_DEPRECATED_WITH_CHAR8_T
+#endif
+
// Macros to enter and leave a state where deprecation warnings are suppressed.
#if !defined(_LIBCPP_SUPPRESS_DEPRECATED_PUSH) && \
(defined(_LIBCPP_COMPILER_CLANG) || defined(_LIBCPP_COMPILER_GCC))
@@ -1037,14 +1050,6 @@ typedef unsigned int char32_t;
# define _LIBCPP_CONSTEXPR_AFTER_CXX17
#endif
-#if _LIBCPP_STD_VER > 17 && \
- !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) && \
- !defined(_LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED)
-# define _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED constexpr
-#else
-# define _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
-#endif
-
// The _LIBCPP_NODISCARD_ATTRIBUTE should only be used to define other
// NODISCARD macros to the correct attribute.
#if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC)
@@ -1079,12 +1084,6 @@ typedef unsigned int char32_t;
# define _LIBCPP_INLINE_VAR
#endif
-#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-# define _LIBCPP_EXPLICIT_MOVE(x) _VSTD::move(x)
-#else
-# define _LIBCPP_EXPLICIT_MOVE(x) (x)
-#endif
-
#ifndef _LIBCPP_CONSTEXPR_IF_NODEBUG
#if defined(_LIBCPP_DEBUG) || defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
#define _LIBCPP_CONSTEXPR_IF_NODEBUG
@@ -1100,7 +1099,7 @@ typedef unsigned int char32_t;
#endif
#ifndef _LIBCPP_HAS_NO_ASAN
-_LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
+extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
const void *, const void *, const void *, const void *);
#endif
@@ -1125,11 +1124,14 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
# if defined(__FreeBSD__) || \
defined(__wasi__) || \
defined(__NetBSD__) || \
+ defined(__OpenBSD__) || \
+ defined(__NuttX__) || \
defined(__linux__) || \
defined(__GNU__) || \
defined(__APPLE__) || \
defined(__CloudABI__) || \
defined(__sun__) || \
+ defined(__MVS__) || \
(defined(__MINGW32__) && __has_include(<pthread.h>))
# define _LIBCPP_HAS_THREAD_API_PTHREAD
# elif defined(__Fuchsia__)
@@ -1167,10 +1169,6 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
_LIBCPP_HAS_NO_THREADS is defined.
#endif
-#if defined(__STDCPP_THREADS__) && defined(_LIBCPP_HAS_NO_THREADS)
-#error _LIBCPP_HAS_NO_THREADS cannot be set when __STDCPP_THREADS__ is set.
-#endif
-
#if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__)
#define __STDCPP_THREADS__ 1
#endif
@@ -1222,13 +1220,15 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
// Some systems do not provide gets() in their C library, for security reasons.
#ifndef _LIBCPP_C_HAS_NO_GETS
# if defined(_LIBCPP_MSVCRT) || \
- (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043)
+ (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) || \
+ defined(__OpenBSD__)
# define _LIBCPP_C_HAS_NO_GETS
# endif
#endif
-#if defined(__BIONIC__) || defined(__CloudABI__) || \
- defined(__Fuchsia__) || defined(__wasi__) || defined(_LIBCPP_HAS_MUSL_LIBC)
+#if defined(__BIONIC__) || defined(__CloudABI__) || defined(__NuttX__) || \
+ defined(__Fuchsia__) || defined(__wasi__) || defined(_LIBCPP_HAS_MUSL_LIBC) || \
+ defined(__MVS__) || defined(__OpenBSD__)
#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
#endif
@@ -1337,6 +1337,12 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
#endif
#endif // !defined(_LIBCPP_NODEBUG_TYPE)
+#if __has_attribute(__preferred_name__)
+#define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x)))
+#else
+#define _LIBCPP_PREFERRED_NAME(x)
+#endif
+
#if defined(_LIBCPP_ABI_MICROSOFT) && \
(defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases))
# define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
@@ -1367,120 +1373,6 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
#define _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
#endif
-// Decide whether to use availability macros.
-#if !defined(_LIBCPP_BUILDING_LIBRARY) && \
- !defined(_LIBCXXABI_BUILDING_LIBRARY) && \
- !defined(_LIBCPP_DISABLE_AVAILABILITY) && \
- __has_feature(attribute_availability_with_strict) && \
- __has_feature(attribute_availability_in_templates) && \
- __has_extension(pragma_clang_attribute_external_declaration)
-# ifdef __APPLE__
-# define _LIBCPP_USE_AVAILABILITY_APPLE
-# endif
-#endif
-
-// Define availability macros.
-#if defined(_LIBCPP_USE_AVAILABILITY_APPLE)
-# define _LIBCPP_AVAILABILITY_SHARED_MUTEX \
- __attribute__((availability(macosx,strict,introduced=10.12))) \
- __attribute__((availability(ios,strict,introduced=10.0))) \
- __attribute__((availability(tvos,strict,introduced=10.0))) \
- __attribute__((availability(watchos,strict,introduced=3.0)))
-# define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS \
- __attribute__((availability(macosx,strict,introduced=10.13))) \
- __attribute__((availability(ios,strict,introduced=11.0))) \
- __attribute__((availability(tvos,strict,introduced=11.0))) \
- __attribute__((availability(watchos,strict,introduced=4.0)))
-# define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS \
- _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
-# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST \
- _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
-# define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS \
- __attribute__((availability(macosx,strict,introduced=10.12))) \
- __attribute__((availability(ios,strict,introduced=10.0))) \
- __attribute__((availability(tvos,strict,introduced=10.0))) \
- __attribute__((availability(watchos,strict,introduced=3.0)))
-# define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE \
- __attribute__((availability(macosx,strict,introduced=10.12))) \
- __attribute__((availability(ios,strict,introduced=10.0))) \
- __attribute__((availability(tvos,strict,introduced=10.0))) \
- __attribute__((availability(watchos,strict,introduced=3.0)))
-# define _LIBCPP_AVAILABILITY_FUTURE_ERROR \
- __attribute__((availability(ios,strict,introduced=6.0)))
-# define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE \
- __attribute__((availability(macosx,strict,introduced=10.9))) \
- __attribute__((availability(ios,strict,introduced=7.0)))
-# define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY \
- __attribute__((availability(macosx,strict,introduced=10.9))) \
- __attribute__((availability(ios,strict,introduced=7.0)))
-# define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR \
- __attribute__((availability(macosx,strict,introduced=10.9))) \
- __attribute__((availability(ios,strict,introduced=7.0)))
-# define _LIBCPP_AVAILABILITY_FILESYSTEM \
- __attribute__((availability(macosx,strict,introduced=10.15))) \
- __attribute__((availability(ios,strict,introduced=13.0))) \
- __attribute__((availability(tvos,strict,introduced=13.0))) \
- __attribute__((availability(watchos,strict,introduced=6.0)))
-# define _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH \
- _Pragma("clang attribute push(__attribute__((availability(macosx,strict,introduced=10.15))), apply_to=any(function,record))") \
- _Pragma("clang attribute push(__attribute__((availability(ios,strict,introduced=13.0))), apply_to=any(function,record))") \
- _Pragma("clang attribute push(__attribute__((availability(tvos,strict,introduced=13.0))), apply_to=any(function,record))") \
- _Pragma("clang attribute push(__attribute__((availability(watchos,strict,introduced=6.0))), apply_to=any(function,record))")
-# define _LIBCPP_AVAILABILITY_FILESYSTEM_POP \
- _Pragma("clang attribute pop") \
- _Pragma("clang attribute pop") \
- _Pragma("clang attribute pop") \
- _Pragma("clang attribute pop")
-# define _LIBCPP_AVAILABILITY_TO_CHARS \
- _LIBCPP_AVAILABILITY_FILESYSTEM
-# define _LIBCPP_AVAILABILITY_SYNC \
- __attribute__((unavailable))
-#else
-# define _LIBCPP_AVAILABILITY_SHARED_MUTEX
-# define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
-# define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
-# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST
-# define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS
-# define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE
-# define _LIBCPP_AVAILABILITY_FUTURE_ERROR
-# define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE
-# define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY
-# define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
-# define _LIBCPP_AVAILABILITY_FILESYSTEM
-# define _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH
-# define _LIBCPP_AVAILABILITY_FILESYSTEM_POP
-# define _LIBCPP_AVAILABILITY_TO_CHARS
-# define _LIBCPP_AVAILABILITY_SYNC
-#endif
-
-// Define availability that depends on _LIBCPP_NO_EXCEPTIONS.
-#ifdef _LIBCPP_NO_EXCEPTIONS
-# define _LIBCPP_AVAILABILITY_FUTURE
-# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
-# define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
-# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
-#else
-# define _LIBCPP_AVAILABILITY_FUTURE _LIBCPP_AVAILABILITY_FUTURE_ERROR
-# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _LIBCPP_AVAILABILITY_BAD_ANY_CAST
-# define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
-# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
-#endif
-
-// The stream API was dropped and re-added in the dylib shipped on macOS
-// and iOS. We can only assume the dylib to provide these definitions for
-// macosx >= 10.9 and ios >= 7.0. Otherwise, the definitions are available
-// from the headers, but not from the dylib. Explicit instantiation
-// declarations for streams exist conditionally to this; if we provide
-// an explicit instantiation declaration and we try to deploy to a dylib
-// that does not provide those symbols, we'll get a load-time error.
-#if !defined(_LIBCPP_BUILDING_LIBRARY) && \
- ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
- __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1090) || \
- (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \
- __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 70000))
-# define _LIBCPP_DO_NOT_ASSUME_STREAMS_EXPLICIT_INSTANTIATION_IN_DYLIB
-#endif
-
#if defined(_LIBCPP_COMPILER_IBM)
#define _LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO
#endif
@@ -1547,6 +1439,12 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
#define _LIBCPP_HAS_NO_FGETPOS_FSETPOS
#endif
+#if __has_attribute(init_priority)
+# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101)))
+#else
+# define _LIBCPP_INIT_PRIORITY_MAX
+#endif
+
#endif // __cplusplus
#endif // _LIBCPP_CONFIG
diff --git a/libcxx/include/__debug b/libcxx/include/__debug
index 11367413fccc..7b5bfb3f8378 100644
--- a/libcxx/include/__debug
+++ b/libcxx/include/__debug
@@ -27,26 +27,21 @@
# include <cstddef>
#endif
-#if _LIBCPP_DEBUG_LEVEL >= 1 && !defined(_LIBCPP_ASSERT)
-# define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : \
- _VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info(__FILE__, __LINE__, #x, m)))
-#endif
-
-#if _LIBCPP_DEBUG_LEVEL >= 2
-#ifndef _LIBCPP_DEBUG_ASSERT
-#define _LIBCPP_DEBUG_ASSERT(x, m) _LIBCPP_ASSERT(x, m)
-#endif
-#define _LIBCPP_DEBUG_MODE(...) __VA_ARGS__
-#endif
-
-#ifndef _LIBCPP_ASSERT
-# define _LIBCPP_ASSERT(x, m) ((void)0)
-#endif
-#ifndef _LIBCPP_DEBUG_ASSERT
+#if _LIBCPP_DEBUG_LEVEL == 0
+# define _LIBCPP_DEBUG_ASSERT(x, m) ((void)0)
+# define _LIBCPP_ASSERT_IMPL(x, m) ((void)0)
+#elif _LIBCPP_DEBUG_LEVEL == 1
# define _LIBCPP_DEBUG_ASSERT(x, m) ((void)0)
+# define _LIBCPP_ASSERT_IMPL(x, m) ((x) ? (void)0 : _VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info(__FILE__, __LINE__, #x, m)))
+#elif _LIBCPP_DEBUG_LEVEL == 2
+# define _LIBCPP_DEBUG_ASSERT(x, m) _LIBCPP_ASSERT(x, m)
+# define _LIBCPP_ASSERT_IMPL(x, m) ((x) ? (void)0 : _VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info(__FILE__, __LINE__, #x, m)))
+#else
+# error _LIBCPP_DEBUG_LEVEL must be one of 0, 1, 2
#endif
-#ifndef _LIBCPP_DEBUG_MODE
-#define _LIBCPP_DEBUG_MODE(...) ((void)0)
+
+#if !defined(_LIBCPP_ASSERT)
+# define _LIBCPP_ASSERT(x, m) _LIBCPP_ASSERT_IMPL(x, m)
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -59,7 +54,7 @@ struct _LIBCPP_TEMPLATE_VIS __libcpp_debug_info {
__libcpp_debug_info(const char* __f, int __l, const char* __p, const char* __m)
: __file_(__f), __line_(__l), __pred_(__p), __msg_(__m) {}
- _LIBCPP_FUNC_VIS std::string what() const;
+ _LIBCPP_FUNC_VIS string what() const;
const char* __file_;
int __line_;
@@ -83,7 +78,7 @@ void __libcpp_abort_debug_function(__libcpp_debug_info const&);
_LIBCPP_FUNC_VIS
bool __libcpp_set_debug_function(__libcpp_debug_function_type __func);
-#if _LIBCPP_DEBUG_LEVEL >= 2 || defined(_LIBCPP_BUILDING_LIBRARY)
+#if _LIBCPP_DEBUG_LEVEL == 2 || defined(_LIBCPP_BUILDING_LIBRARY)
struct _LIBCPP_TYPE_VIS __c_node;
@@ -226,7 +221,7 @@ public:
template <class _Cont>
_LIBCPP_INLINE_VISIBILITY static __c_node* __create_C_node(void *__mem, void *__c, __c_node *__next) {
- return ::new(__mem) _C_node<_Cont>(__c, __next);
+ return ::new (__mem) _C_node<_Cont>(__c, __next);
}
template <class _Cont>
@@ -271,7 +266,7 @@ _LIBCPP_FUNC_VIS __libcpp_db* __get_db();
_LIBCPP_FUNC_VIS const __libcpp_db* __get_const_db();
-#endif // _LIBCPP_DEBUG_LEVEL >= 2 || defined(_LIBCPP_BUILDING_LIBRARY)
+#endif // _LIBCPP_DEBUG_LEVEL == 2 || defined(_LIBCPP_BUILDING_LIBRARY)
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__functional_03 b/libcxx/include/__functional_03
index bf86428dea05..9616480611dc 100644
--- a/libcxx/include/__functional_03
+++ b/libcxx/include/__functional_03
@@ -126,7 +126,7 @@ __func<_Fp, _Alloc, _Rp()>::__clone() const
_Ap __a(__f_.second());
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
- ::new (__hold.get()) __func(__f_.first(), _Alloc(__a));
+ ::new ((void*)__hold.get()) __func(__f_.first(), _Alloc(__a));
return __hold.release();
}
@@ -134,7 +134,7 @@ template<class _Fp, class _Alloc, class _Rp>
void
__func<_Fp, _Alloc, _Rp()>::__clone(__base<_Rp()>* __p) const
{
- ::new (__p) __func(__f_.first(), __f_.second());
+ ::new ((void*)__p) __func(__f_.first(), __f_.second());
}
template<class _Fp, class _Alloc, class _Rp>
@@ -212,7 +212,7 @@ __func<_Fp, _Alloc, _Rp(_A0)>::__clone() const
_Ap __a(__f_.second());
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
- ::new (__hold.get()) __func(__f_.first(), _Alloc(__a));
+ ::new ((void*)__hold.get()) __func(__f_.first(), _Alloc(__a));
return __hold.release();
}
@@ -220,7 +220,7 @@ template<class _Fp, class _Alloc, class _Rp, class _A0>
void
__func<_Fp, _Alloc, _Rp(_A0)>::__clone(__base<_Rp(_A0)>* __p) const
{
- ::new (__p) __func(__f_.first(), __f_.second());
+ ::new ((void*)__p) __func(__f_.first(), __f_.second());
}
template<class _Fp, class _Alloc, class _Rp, class _A0>
@@ -298,7 +298,7 @@ __func<_Fp, _Alloc, _Rp(_A0, _A1)>::__clone() const
_Ap __a(__f_.second());
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
- ::new (__hold.get()) __func(__f_.first(), _Alloc(__a));
+ ::new ((void*)__hold.get()) __func(__f_.first(), _Alloc(__a));
return __hold.release();
}
@@ -306,7 +306,7 @@ template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
void
__func<_Fp, _Alloc, _Rp(_A0, _A1)>::__clone(__base<_Rp(_A0, _A1)>* __p) const
{
- ::new (__p) __func(__f_.first(), __f_.second());
+ ::new ((void*)__p) __func(__f_.first(), __f_.second());
}
template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
@@ -384,7 +384,7 @@ __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::__clone() const
_Ap __a(__f_.second());
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
- ::new (__hold.get()) __func(__f_.first(), _Alloc(__a));
+ ::new ((void*)__hold.get()) __func(__f_.first(), _Alloc(__a));
return __hold.release();
}
@@ -392,7 +392,7 @@ template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
void
__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::__clone(__base<_Rp(_A0, _A1, _A2)>* __p) const
{
- ::new (__p) __func(__f_.first(), __f_.second());
+ ::new ((void*)__p) __func(__f_.first(), __f_.second());
}
template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
@@ -554,7 +554,7 @@ function<_Rp()>::function(_Fp __f,
if (sizeof(_FF) <= sizeof(__buf_))
{
__f_ = (__base*)&__buf_;
- ::new (__f_) _FF(__f);
+ ::new ((void*)__f_) _FF(__f);
}
else
{
@@ -562,7 +562,7 @@ function<_Rp()>::function(_Fp __f,
_Ap __a;
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
- ::new (__hold.get()) _FF(__f, allocator<_Fp>(__a));
+ ::new ((void*)__hold.get()) _FF(__f, allocator<_Fp>(__a));
__f_ = __hold.release();
}
}
@@ -581,7 +581,7 @@ function<_Rp()>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
if (sizeof(_FF) <= sizeof(__buf_))
{
__f_ = (__base*)&__buf_;
- ::new (__f_) _FF(__f, __a0);
+ ::new ((void*)__f_) _FF(__f, __a0);
}
else
{
@@ -589,7 +589,7 @@ function<_Rp()>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
_Ap __a(__a0);
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
- ::new (__hold.get()) _FF(__f, _Alloc(__a));
+ ::new ((void*)__hold.get()) _FF(__f, _Alloc(__a));
__f_ = __hold.release();
}
}
@@ -834,7 +834,7 @@ function<_Rp(_A0)>::function(_Fp __f,
if (sizeof(_FF) <= sizeof(__buf_))
{
__f_ = (__base*)&__buf_;
- ::new (__f_) _FF(__f);
+ ::new ((void*)__f_) _FF(__f);
}
else
{
@@ -842,7 +842,7 @@ function<_Rp(_A0)>::function(_Fp __f,
_Ap __a;
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
- ::new (__hold.get()) _FF(__f, allocator<_Fp>(__a));
+ ::new ((void*)__hold.get()) _FF(__f, allocator<_Fp>(__a));
__f_ = __hold.release();
}
}
@@ -861,7 +861,7 @@ function<_Rp(_A0)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
if (sizeof(_FF) <= sizeof(__buf_))
{
__f_ = (__base*)&__buf_;
- ::new (__f_) _FF(__f, __a0);
+ ::new ((void*)__f_) _FF(__f, __a0);
}
else
{
@@ -869,7 +869,7 @@ function<_Rp(_A0)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
_Ap __a(__a0);
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
- ::new (__hold.get()) _FF(__f, _Alloc(__a));
+ ::new ((void*)__hold.get()) _FF(__f, _Alloc(__a));
__f_ = __hold.release();
}
}
@@ -1114,7 +1114,7 @@ function<_Rp(_A0, _A1)>::function(_Fp __f,
if (sizeof(_FF) <= sizeof(__buf_))
{
__f_ = (__base*)&__buf_;
- ::new (__f_) _FF(__f);
+ ::new ((void*)__f_) _FF(__f);
}
else
{
@@ -1122,7 +1122,7 @@ function<_Rp(_A0, _A1)>::function(_Fp __f,
_Ap __a;
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
- ::new (__hold.get()) _FF(__f, allocator<_Fp>(__a));
+ ::new ((void*)__hold.get()) _FF(__f, allocator<_Fp>(__a));
__f_ = __hold.release();
}
}
@@ -1141,7 +1141,7 @@ function<_Rp(_A0, _A1)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
if (sizeof(_FF) <= sizeof(__buf_))
{
__f_ = (__base*)&__buf_;
- ::new (__f_) _FF(__f, __a0);
+ ::new ((void*)__f_) _FF(__f, __a0);
}
else
{
@@ -1149,7 +1149,7 @@ function<_Rp(_A0, _A1)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
_Ap __a(__a0);
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
- ::new (__hold.get()) _FF(__f, _Alloc(__a));
+ ::new ((void*)__hold.get()) _FF(__f, _Alloc(__a));
__f_ = __hold.release();
}
}
@@ -1394,7 +1394,7 @@ function<_Rp(_A0, _A1, _A2)>::function(_Fp __f,
if (sizeof(_FF) <= sizeof(__buf_))
{
__f_ = (__base*)&__buf_;
- ::new (__f_) _FF(__f);
+ ::new ((void*)__f_) _FF(__f);
}
else
{
@@ -1402,7 +1402,7 @@ function<_Rp(_A0, _A1, _A2)>::function(_Fp __f,
_Ap __a;
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
- ::new (__hold.get()) _FF(__f, allocator<_Fp>(__a));
+ ::new ((void*)__hold.get()) _FF(__f, allocator<_Fp>(__a));
__f_ = __hold.release();
}
}
@@ -1421,7 +1421,7 @@ function<_Rp(_A0, _A1, _A2)>::function(allocator_arg_t, const _Alloc& __a0, _Fp
if (sizeof(_FF) <= sizeof(__buf_))
{
__f_ = (__base*)&__buf_;
- ::new (__f_) _FF(__f, __a0);
+ ::new ((void*)__f_) _FF(__f, __a0);
}
else
{
@@ -1429,7 +1429,7 @@ function<_Rp(_A0, _A1, _A2)>::function(allocator_arg_t, const _Alloc& __a0, _Fp
_Ap __a(__a0);
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
- ::new (__hold.get()) _FF(__f, _Alloc(__a));
+ ::new ((void*)__hold.get()) _FF(__f, _Alloc(__a));
__f_ = __hold.release();
}
}
diff --git a/libcxx/include/__functional_base b/libcxx/include/__functional_base
index f591bf5a9dce..1c02e960d5f0 100644
--- a/libcxx/include/__functional_base
+++ b/libcxx/include/__functional_base
@@ -298,7 +298,7 @@ struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile>
template <class _Tp, class ..._Args>
struct __invoke_return
{
- typedef decltype(__invoke(_VSTD::declval<_Tp>(), _VSTD::declval<_Args>()...)) type;
+ typedef decltype(_VSTD::__invoke(declval<_Tp>(), declval<_Args>()...)) type;
};
#else // defined(_LIBCPP_CXX03_LANG)
@@ -308,64 +308,64 @@ struct __invoke_return
#endif // !defined(_LIBCPP_CXX03_LANG)
-template <class _Ret>
+template <class _Ret, bool = is_void<_Ret>::value>
struct __invoke_void_return_wrapper
{
#ifndef _LIBCPP_CXX03_LANG
template <class ..._Args>
static _Ret __call(_Args&&... __args) {
- return __invoke(_VSTD::forward<_Args>(__args)...);
+ return _VSTD::__invoke(_VSTD::forward<_Args>(__args)...);
}
#else
template <class _Fn>
static _Ret __call(_Fn __f) {
- return __invoke(__f);
+ return _VSTD::__invoke(__f);
}
template <class _Fn, class _A0>
static _Ret __call(_Fn __f, _A0& __a0) {
- return __invoke(__f, __a0);
+ return _VSTD::__invoke(__f, __a0);
}
template <class _Fn, class _A0, class _A1>
static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1) {
- return __invoke(__f, __a0, __a1);
+ return _VSTD::__invoke(__f, __a0, __a1);
}
template <class _Fn, class _A0, class _A1, class _A2>
static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2){
- return __invoke(__f, __a0, __a1, __a2);
+ return _VSTD::__invoke(__f, __a0, __a1, __a2);
}
#endif
};
-template <>
-struct __invoke_void_return_wrapper<void>
+template <class _Ret>
+struct __invoke_void_return_wrapper<_Ret, true>
{
#ifndef _LIBCPP_CXX03_LANG
template <class ..._Args>
static void __call(_Args&&... __args) {
- __invoke(_VSTD::forward<_Args>(__args)...);
+ _VSTD::__invoke(_VSTD::forward<_Args>(__args)...);
}
#else
template <class _Fn>
static void __call(_Fn __f) {
- __invoke(__f);
+ _VSTD::__invoke(__f);
}
template <class _Fn, class _A0>
static void __call(_Fn __f, _A0& __a0) {
- __invoke(__f, __a0);
+ _VSTD::__invoke(__f, __a0);
}
template <class _Fn, class _A0, class _A1>
static void __call(_Fn __f, _A0& __a0, _A1& __a1) {
- __invoke(__f, __a0, __a1);
+ _VSTD::__invoke(__f, __a0, __a1);
}
template <class _Fn, class _A0, class _A1, class _A2>
static void __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2) {
- __invoke(__f, __a0, __a1, __a2);
+ _VSTD::__invoke(__f, __a0, __a1, __a2);
}
#endif
};
@@ -382,135 +382,138 @@ private:
public:
// construct/copy/destroy
- _LIBCPP_INLINE_VISIBILITY reference_wrapper(type& __f) _NOEXCEPT
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ reference_wrapper(type& __f) _NOEXCEPT
: __f_(_VSTD::addressof(__f)) {}
#ifndef _LIBCPP_CXX03_LANG
private: reference_wrapper(type&&); public: // = delete; // do not bind to temps
#endif
// access
- _LIBCPP_INLINE_VISIBILITY operator type& () const _NOEXCEPT {return *__f_;}
- _LIBCPP_INLINE_VISIBILITY type& get() const _NOEXCEPT {return *__f_;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ operator type&() const _NOEXCEPT {return *__f_;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ type& get() const _NOEXCEPT {return *__f_;}
#ifndef _LIBCPP_CXX03_LANG
// invoke
template <class... _ArgTypes>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
typename __invoke_of<type&, _ArgTypes...>::type
operator() (_ArgTypes&&... __args) const {
- return __invoke(get(), _VSTD::forward<_ArgTypes>(__args)...);
+ return _VSTD::__invoke(get(), _VSTD::forward<_ArgTypes>(__args)...);
}
#else
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return<type>::type
operator() () const {
- return __invoke(get());
+ return _VSTD::__invoke(get());
}
template <class _A0>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return0<type, _A0>::type
operator() (_A0& __a0) const {
- return __invoke(get(), __a0);
+ return _VSTD::__invoke(get(), __a0);
}
template <class _A0>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return0<type, _A0 const>::type
operator() (_A0 const& __a0) const {
- return __invoke(get(), __a0);
+ return _VSTD::__invoke(get(), __a0);
}
template <class _A0, class _A1>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return1<type, _A0, _A1>::type
operator() (_A0& __a0, _A1& __a1) const {
- return __invoke(get(), __a0, __a1);
+ return _VSTD::__invoke(get(), __a0, __a1);
}
template <class _A0, class _A1>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return1<type, _A0 const, _A1>::type
operator() (_A0 const& __a0, _A1& __a1) const {
- return __invoke(get(), __a0, __a1);
+ return _VSTD::__invoke(get(), __a0, __a1);
}
template <class _A0, class _A1>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return1<type, _A0, _A1 const>::type
operator() (_A0& __a0, _A1 const& __a1) const {
- return __invoke(get(), __a0, __a1);
+ return _VSTD::__invoke(get(), __a0, __a1);
}
template <class _A0, class _A1>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return1<type, _A0 const, _A1 const>::type
operator() (_A0 const& __a0, _A1 const& __a1) const {
- return __invoke(get(), __a0, __a1);
+ return _VSTD::__invoke(get(), __a0, __a1);
}
template <class _A0, class _A1, class _A2>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return2<type, _A0, _A1, _A2>::type
operator() (_A0& __a0, _A1& __a1, _A2& __a2) const {
- return __invoke(get(), __a0, __a1, __a2);
+ return _VSTD::__invoke(get(), __a0, __a1, __a2);
}
template <class _A0, class _A1, class _A2>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return2<type, _A0 const, _A1, _A2>::type
operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const {
- return __invoke(get(), __a0, __a1, __a2);
+ return _VSTD::__invoke(get(), __a0, __a1, __a2);
}
template <class _A0, class _A1, class _A2>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return2<type, _A0, _A1 const, _A2>::type
operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const {
- return __invoke(get(), __a0, __a1, __a2);
+ return _VSTD::__invoke(get(), __a0, __a1, __a2);
}
template <class _A0, class _A1, class _A2>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return2<type, _A0, _A1, _A2 const>::type
operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const {
- return __invoke(get(), __a0, __a1, __a2);
+ return _VSTD::__invoke(get(), __a0, __a1, __a2);
}
template <class _A0, class _A1, class _A2>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return2<type, _A0 const, _A1 const, _A2>::type
operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const {
- return __invoke(get(), __a0, __a1, __a2);
+ return _VSTD::__invoke(get(), __a0, __a1, __a2);
}
template <class _A0, class _A1, class _A2>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return2<type, _A0 const, _A1, _A2 const>::type
operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const {
- return __invoke(get(), __a0, __a1, __a2);
+ return _VSTD::__invoke(get(), __a0, __a1, __a2);
}
template <class _A0, class _A1, class _A2>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return2<type, _A0, _A1 const, _A2 const>::type
operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const {
- return __invoke(get(), __a0, __a1, __a2);
+ return _VSTD::__invoke(get(), __a0, __a1, __a2);
}
template <class _A0, class _A1, class _A2>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return2<type, _A0 const, _A1 const, _A2 const>::type
operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const {
- return __invoke(get(), __a0, __a1, __a2);
+ return _VSTD::__invoke(get(), __a0, __a1, __a2);
}
#endif // _LIBCPP_CXX03_LANG
};
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
reference_wrapper<_Tp>
ref(_Tp& __t) _NOEXCEPT
{
@@ -518,7 +521,7 @@ ref(_Tp& __t) _NOEXCEPT
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
reference_wrapper<_Tp>
ref(reference_wrapper<_Tp> __t) _NOEXCEPT
{
@@ -526,7 +529,7 @@ ref(reference_wrapper<_Tp> __t) _NOEXCEPT
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
reference_wrapper<const _Tp>
cref(const _Tp& __t) _NOEXCEPT
{
@@ -534,7 +537,7 @@ cref(const _Tp& __t) _NOEXCEPT
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
reference_wrapper<const _Tp>
cref(reference_wrapper<_Tp> __t) _NOEXCEPT
{
diff --git a/libcxx/include/__functional_base_03 b/libcxx/include/__functional_base_03
index e6dac90c84f7..9b08bd26a8fd 100644
--- a/libcxx/include/__functional_base_03
+++ b/libcxx/include/__functional_base_03
@@ -40,7 +40,7 @@ struct __enable_invoke_imp<_Ret, _T1, false, true> {
template <class _Ret, class _T1>
struct __enable_invoke_imp<_Ret, _T1, false, false> {
typedef typename add_lvalue_reference<
- typename __apply_cv<decltype(*_VSTD::declval<_T1>()), _Ret>::type
+ typename __apply_cv<decltype(*declval<_T1>()), _Ret>::type
>::type _Bullet4;
typedef _Bullet4 type;
};
@@ -142,7 +142,7 @@ __invoke(_Fn __f, _T1& __t1) {
template <class _Fp>
inline _LIBCPP_INLINE_VISIBILITY
-decltype(_VSTD::declval<_Fp&>()())
+decltype(declval<_Fp&>()())
__invoke(_Fp& __f)
{
return __f();
@@ -150,7 +150,7 @@ __invoke(_Fp& __f)
template <class _Fp, class _A0>
inline _LIBCPP_INLINE_VISIBILITY
-decltype(_VSTD::declval<_Fp&>()(_VSTD::declval<_A0&>()))
+decltype(declval<_Fp&>()(declval<_A0&>()))
__invoke(_Fp& __f, _A0& __a0)
{
return __f(__a0);
@@ -158,7 +158,7 @@ __invoke(_Fp& __f, _A0& __a0)
template <class _Fp, class _A0, class _A1>
inline _LIBCPP_INLINE_VISIBILITY
-decltype(_VSTD::declval<_Fp&>()(_VSTD::declval<_A0&>(), _VSTD::declval<_A1&>()))
+decltype(declval<_Fp&>()(declval<_A0&>(), declval<_A1&>()))
__invoke(_Fp& __f, _A0& __a0, _A1& __a1)
{
return __f(__a0, __a1);
@@ -166,7 +166,7 @@ __invoke(_Fp& __f, _A0& __a0, _A1& __a1)
template <class _Fp, class _A0, class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
-decltype(_VSTD::declval<_Fp&>()(_VSTD::declval<_A0&>(), _VSTD::declval<_A1&>(), _VSTD::declval<_A2&>()))
+decltype(declval<_Fp&>()(declval<_A0&>(), declval<_A1&>(), declval<_A2&>()))
__invoke(_Fp& __f, _A0& __a0, _A1& __a1, _A2& __a2)
{
return __f(__a0, __a1, __a2);
@@ -181,13 +181,13 @@ struct __invoke_return
template <class _Fp>
struct __invoke_return<_Fp, false>
{
- typedef decltype(__invoke(_VSTD::declval<_Fp&>())) type;
+ typedef decltype(_VSTD::__invoke(declval<_Fp&>())) type;
};
template <class _Tp, class _A0>
struct __invoke_return0
{
- typedef decltype(__invoke(_VSTD::declval<_Tp&>(), _VSTD::declval<_A0&>())) type;
+ typedef decltype(_VSTD::__invoke(declval<_Tp&>(), declval<_A0&>())) type;
};
template <class _Rp, class _Tp, class _A0>
@@ -199,8 +199,8 @@ struct __invoke_return0<_Rp _Tp::*, _A0>
template <class _Tp, class _A0, class _A1>
struct __invoke_return1
{
- typedef decltype(__invoke(_VSTD::declval<_Tp&>(), _VSTD::declval<_A0&>(),
- _VSTD::declval<_A1&>())) type;
+ typedef decltype(_VSTD::__invoke(declval<_Tp&>(), declval<_A0&>(),
+ declval<_A1&>())) type;
};
template <class _Rp, class _Class, class _A0, class _A1>
@@ -211,9 +211,9 @@ struct __invoke_return1<_Rp _Class::*, _A0, _A1> {
template <class _Tp, class _A0, class _A1, class _A2>
struct __invoke_return2
{
- typedef decltype(__invoke(_VSTD::declval<_Tp&>(), _VSTD::declval<_A0&>(),
- _VSTD::declval<_A1&>(),
- _VSTD::declval<_A2&>())) type;
+ typedef decltype(_VSTD::__invoke(declval<_Tp&>(), declval<_A0&>(),
+ declval<_A1&>(),
+ declval<_A2&>())) type;
};
template <class _Ret, class _Class, class _A0, class _A1, class _A2>
diff --git a/libcxx/include/__hash_table b/libcxx/include/__hash_table
index 13ff096897b4..521ebbf2c45f 100644
--- a/libcxx/include/__hash_table
+++ b/libcxx/include/__hash_table
@@ -34,19 +34,17 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Key, class _Tp>
struct __hash_value_type;
-#ifndef _LIBCPP_CXX03_LANG
template <class _Tp>
struct __is_hash_value_type_imp : false_type {};
template <class _Key, class _Value>
-struct __is_hash_value_type_imp<__hash_value_type<_Key, _Value>> : true_type {};
+struct __is_hash_value_type_imp<__hash_value_type<_Key, _Value> > : true_type {};
template <class ..._Args>
struct __is_hash_value_type : false_type {};
template <class _One>
struct __is_hash_value_type<_One> : __is_hash_value_type_imp<typename __uncvref<_One>::type> {};
-#endif
_LIBCPP_FUNC_VIS
size_t __next_prime(size_t __n);
@@ -122,7 +120,7 @@ inline _LIBCPP_INLINE_VISIBILITY
size_t
__next_hash_pow2(size_t __n)
{
- return __n < 2 ? __n : (size_t(1) << (std::numeric_limits<size_t>::digits - __libcpp_clz(__n-1)));
+ return __n < 2 ? __n : (size_t(1) << (numeric_limits<size_t>::digits - __libcpp_clz(__n-1)));
}
@@ -155,12 +153,10 @@ struct __hash_key_value_types {
static __container_value_type* __get_ptr(__node_value_type& __n) {
return _VSTD::addressof(__n);
}
-#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
static __container_value_type&& __move(__node_value_type& __v) {
return _VSTD::move(__v);
}
-#endif
};
template <class _Key, class _Tp>
@@ -197,13 +193,10 @@ struct __hash_key_value_types<__hash_value_type<_Key, _Tp> > {
static __container_value_type* __get_ptr(__node_value_type& __n) {
return _VSTD::addressof(__n.__get_value());
}
-#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
static pair<key_type&&, mapped_type&&> __move(__node_value_type& __v) {
return __v.__move();
}
-#endif
-
};
template <class _Tp, class _AllocPtr, class _KVTypes = __hash_key_value_types<_Tp>,
@@ -295,10 +288,12 @@ public:
typedef typename _NodeTypes::__node_value_type_pointer pointer;
_LIBCPP_INLINE_VISIBILITY __hash_iterator() _NOEXCEPT : __node_(nullptr) {
- _LIBCPP_DEBUG_MODE(__get_db()->__insert_i(this));
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __get_db()->__insert_i(this);
+#endif
}
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY
__hash_iterator(const __hash_iterator& __i)
: __node_(__i.__node_)
@@ -322,7 +317,7 @@ public:
}
return *this;
}
-#endif // _LIBCPP_DEBUG_LEVEL >= 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY
reference operator*() const {
@@ -364,7 +359,7 @@ public:
{return !(__x == __y);}
private:
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY
__hash_iterator(__next_pointer __node, const void* __c) _NOEXCEPT
: __node_(__node)
@@ -405,17 +400,21 @@ public:
_LIBCPP_INLINE_VISIBILITY __hash_const_iterator() _NOEXCEPT : __node_(nullptr) {
- _LIBCPP_DEBUG_MODE(__get_db()->__insert_i(this));
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __get_db()->__insert_i(this);
+#endif
}
_LIBCPP_INLINE_VISIBILITY
__hash_const_iterator(const __non_const_iterator& __x) _NOEXCEPT
: __node_(__x.__node_)
{
- _LIBCPP_DEBUG_MODE(__get_db()->__iterator_copy(this, &__x));
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __get_db()->__iterator_copy(this, &__x);
+#endif
}
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY
__hash_const_iterator(const __hash_const_iterator& __i)
: __node_(__i.__node_)
@@ -439,7 +438,7 @@ public:
}
return *this;
}
-#endif // _LIBCPP_DEBUG_LEVEL >= 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY
reference operator*() const {
@@ -480,7 +479,7 @@ public:
{return !(__x == __y);}
private:
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY
__hash_const_iterator(__next_pointer __node, const void* __c) _NOEXCEPT
: __node_(__node)
@@ -518,10 +517,12 @@ public:
typedef typename _NodeTypes::__node_value_type_pointer pointer;
_LIBCPP_INLINE_VISIBILITY __hash_local_iterator() _NOEXCEPT : __node_(nullptr) {
- _LIBCPP_DEBUG_MODE(__get_db()->__insert_i(this));
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __get_db()->__insert_i(this);
+#endif
}
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY
__hash_local_iterator(const __hash_local_iterator& __i)
: __node_(__i.__node_),
@@ -549,7 +550,7 @@ public:
}
return *this;
}
-#endif // _LIBCPP_DEBUG_LEVEL >= 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY
reference operator*() const {
@@ -593,7 +594,7 @@ public:
{return !(__x == __y);}
private:
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY
__hash_local_iterator(__next_pointer __node, size_t __bucket,
size_t __bucket_count, const void* __c) _NOEXCEPT
@@ -650,7 +651,9 @@ public:
_LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator() _NOEXCEPT : __node_(nullptr) {
- _LIBCPP_DEBUG_MODE(__get_db()->__insert_i(this));
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __get_db()->__insert_i(this);
+#endif
}
_LIBCPP_INLINE_VISIBILITY
@@ -659,10 +662,12 @@ public:
__bucket_(__x.__bucket_),
__bucket_count_(__x.__bucket_count_)
{
- _LIBCPP_DEBUG_MODE(__get_db()->__iterator_copy(this, &__x));
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __get_db()->__iterator_copy(this, &__x);
+#endif
}
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY
__hash_const_local_iterator(const __hash_const_local_iterator& __i)
: __node_(__i.__node_),
@@ -690,7 +695,7 @@ public:
}
return *this;
}
-#endif // _LIBCPP_DEBUG_LEVEL >= 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY
reference operator*() const {
@@ -734,7 +739,7 @@ public:
{return !(__x == __y);}
private:
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY
__hash_const_local_iterator(__next_pointer __node, size_t __bucket,
size_t __bucket_count, const void* __c) _NOEXCEPT
@@ -783,7 +788,6 @@ public:
_NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
: __data_(__size, __a) {}
-#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
__bucket_list_deallocator(__bucket_list_deallocator&& __x)
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
@@ -791,7 +795,6 @@ public:
{
__x.size() = 0;
}
-#endif
_LIBCPP_INLINE_VISIBILITY
size_type& size() _NOEXCEPT {return __data_.first();}
@@ -1007,7 +1010,6 @@ public:
explicit __hash_table(const allocator_type& __a);
__hash_table(const __hash_table& __u);
__hash_table(const __hash_table& __u, const allocator_type& __a);
-#ifndef _LIBCPP_CXX03_LANG
__hash_table(__hash_table&& __u)
_NOEXCEPT_(
is_nothrow_move_constructible<__bucket_list>::value &&
@@ -1016,11 +1018,9 @@ public:
is_nothrow_move_constructible<hasher>::value &&
is_nothrow_move_constructible<key_equal>::value);
__hash_table(__hash_table&& __u, const allocator_type& __a);
-#endif // _LIBCPP_CXX03_LANG
~__hash_table();
__hash_table& operator=(const __hash_table& __u);
-#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
__hash_table& operator=(__hash_table&& __u)
_NOEXCEPT_(
@@ -1028,7 +1028,6 @@ public:
is_nothrow_move_assignable<__node_allocator>::value &&
is_nothrow_move_assignable<hasher>::value &&
is_nothrow_move_assignable<key_equal>::value);
-#endif
template <class _InputIterator>
void __assign_unique(_InputIterator __first, _InputIterator __last);
template <class _InputIterator>
@@ -1037,7 +1036,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
size_type max_size() const _NOEXCEPT
{
- return std::min<size_type>(
+ return _VSTD::min<size_type>(
__node_traits::max_size(__node_alloc()),
numeric_limits<difference_type >::max()
);
@@ -1066,7 +1065,6 @@ public:
iterator __node_insert_multi(const_iterator __p,
__node_pointer __nd);
-#ifndef _LIBCPP_CXX03_LANG
template <class _Key, class ..._Args>
_LIBCPP_INLINE_VISIBILITY
pair<iterator, bool> __emplace_unique_key_args(_Key const& __k, _Args&&... __args);
@@ -1151,15 +1149,6 @@ public:
return __emplace_hint_multi(__p, _VSTD::forward<_Pp>(__x));
}
-#else // !defined(_LIBCPP_CXX03_LANG)
- template <class _Key, class _Args>
- _LIBCPP_INLINE_VISIBILITY
- pair<iterator, bool> __emplace_unique_key_args(_Key const&, _Args& __args);
-
- iterator __insert_multi(const __container_value_type& __x);
- iterator __insert_multi(const_iterator __p, const __container_value_type& __x);
-#endif
-
_LIBCPP_INLINE_VISIBILITY
pair<iterator, bool> __insert_unique(const __container_value_type& __x) {
return __emplace_unique_key_args(_NodeTypes::__get_key(__x), __x);
@@ -1295,7 +1284,7 @@ public:
{
_LIBCPP_ASSERT(__n < bucket_count(),
"unordered container::begin(n) called with n >= bucket_count()");
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
return local_iterator(__bucket_list_[__n], __n, bucket_count(), this);
#else
return local_iterator(__bucket_list_[__n], __n, bucket_count());
@@ -1308,7 +1297,7 @@ public:
{
_LIBCPP_ASSERT(__n < bucket_count(),
"unordered container::end(n) called with n >= bucket_count()");
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
return local_iterator(nullptr, __n, bucket_count(), this);
#else
return local_iterator(nullptr, __n, bucket_count());
@@ -1321,7 +1310,7 @@ public:
{
_LIBCPP_ASSERT(__n < bucket_count(),
"unordered container::cbegin(n) called with n >= bucket_count()");
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
return const_local_iterator(__bucket_list_[__n], __n, bucket_count(), this);
#else
return const_local_iterator(__bucket_list_[__n], __n, bucket_count());
@@ -1334,35 +1323,30 @@ public:
{
_LIBCPP_ASSERT(__n < bucket_count(),
"unordered container::cend(n) called with n >= bucket_count()");
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
return const_local_iterator(nullptr, __n, bucket_count(), this);
#else
return const_local_iterator(nullptr, __n, bucket_count());
#endif
}
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
bool __dereferenceable(const const_iterator* __i) const;
bool __decrementable(const const_iterator* __i) const;
bool __addable(const const_iterator* __i, ptrdiff_t __n) const;
bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;
-#endif // _LIBCPP_DEBUG_LEVEL >= 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
private:
void __rehash(size_type __n);
-#ifndef _LIBCPP_CXX03_LANG
template <class ..._Args>
__node_holder __construct_node(_Args&& ...__args);
template <class _First, class ..._Rest>
__node_holder __construct_node_hash(size_t __hash, _First&& __f, _Rest&&... __rest);
-#else // _LIBCPP_CXX03_LANG
- __node_holder __construct_node(const __container_value_type& __v);
- __node_holder __construct_node_hash(size_t __hash, const __container_value_type& __v);
-#endif
_LIBCPP_INLINE_VISIBILITY
@@ -1373,7 +1357,6 @@ private:
_LIBCPP_INLINE_VISIBILITY
void __copy_assign_alloc(const __hash_table&, false_type) {}
-#ifndef _LIBCPP_CXX03_LANG
void __move_assign(__hash_table& __u, false_type);
void __move_assign(__hash_table& __u, true_type)
_NOEXCEPT_(
@@ -1400,7 +1383,6 @@ private:
}
_LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(__hash_table&, false_type) _NOEXCEPT {}
-#endif // _LIBCPP_CXX03_LANG
void __deallocate_node(__next_pointer __np) _NOEXCEPT;
__next_pointer __detach() _NOEXCEPT;
@@ -1477,8 +1459,6 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u,
{
}
-#ifndef _LIBCPP_CXX03_LANG
-
template <class _Tp, class _Hash, class _Equal, class _Alloc>
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u)
_NOEXCEPT_(
@@ -1526,8 +1506,6 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u,
}
}
-#endif // _LIBCPP_CXX03_LANG
-
template <class _Tp, class _Hash, class _Equal, class _Alloc>
__hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table()
{
@@ -1539,7 +1517,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table()
#endif
__deallocate_node(__p1_.first().__next_);
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__erase_c(this);
#endif
}
@@ -1583,7 +1561,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__deallocate_node(__next_pointer __np)
while (__np != nullptr)
{
__next_pointer __next = __np->__next_;
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__c_node* __c = __get_db()->__find_c_and_lock(this);
for (__i_node** __p = __c->end_; __p != __c->beg_; )
{
@@ -1593,7 +1571,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__deallocate_node(__next_pointer __np)
{
(*__p)->__c_ = nullptr;
if (--__c->end_ != __p)
- memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
+ _VSTD::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
}
}
__get_db()->unlock();
@@ -1618,8 +1596,6 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__detach() _NOEXCEPT
return __cache;
}
-#ifndef _LIBCPP_CXX03_LANG
-
template <class _Tp, class _Hash, class _Equal, class _Alloc>
void
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(
@@ -1646,7 +1622,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(
__u.__p1_.first().__next_ = nullptr;
__u.size() = 0;
}
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->swap(this, &__u);
#endif
}
@@ -1714,8 +1690,6 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::operator=(__hash_table&& __u)
return *this;
}
-#endif // _LIBCPP_CXX03_LANG
-
template <class _Tp, class _Hash, class _Equal, class _Alloc>
template <class _InputIterator>
void
@@ -1800,7 +1774,7 @@ inline
typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
__hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() _NOEXCEPT
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
return iterator(__p1_.first().__next_, this);
#else
return iterator(__p1_.first().__next_);
@@ -1812,7 +1786,7 @@ inline
typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
__hash_table<_Tp, _Hash, _Equal, _Alloc>::end() _NOEXCEPT
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
return iterator(nullptr, this);
#else
return iterator(nullptr);
@@ -1824,7 +1798,7 @@ inline
typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator
__hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() const _NOEXCEPT
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
return const_iterator(__p1_.first().__next_, this);
#else
return const_iterator(__p1_.first().__next_);
@@ -1836,7 +1810,7 @@ inline
typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator
__hash_table<_Tp, _Hash, _Equal, _Alloc>::end() const _NOEXCEPT
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
return const_iterator(nullptr, this);
#else
return const_iterator(nullptr);
@@ -1945,7 +1919,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique(__node_pointer __
__existing_node = __nd->__ptr();
__inserted = true;
}
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
return pair<iterator, bool>(iterator(__existing_node, this), __inserted);
#else
return pair<iterator, bool>(iterator(__existing_node), __inserted);
@@ -1955,7 +1929,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique(__node_pointer __
// Prepare the container for an insertion of the value __cp_val with the hash
// __cp_hash. This does a lookup into the container to see if __cp_value is
// already present, and performs a rehash if necessary. Returns a pointer to the
-// last occurance of __cp_val in the map.
+// last occurrence of __cp_val in the map.
//
// Note that this function does forward exceptions if key_eq() throws, and never
// mutates __value or actually inserts into the map.
@@ -2043,7 +2017,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(__node_pointer __c
__next_pointer __pn = __node_insert_multi_prepare(__cp->__hash(), __cp->__value_);
__node_insert_multi_perform(__cp, __pn);
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
return iterator(__cp->__ptr(), this);
#else
return iterator(__cp->__ptr());
@@ -2055,7 +2029,7 @@ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(
const_iterator __p, __node_pointer __cp)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
"unordered container::emplace_hint(const_iterator, args...) called with an iterator not"
" referring to this unordered container");
@@ -2078,7 +2052,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(
__cp->__next_ = __np;
__pp->__next_ = static_cast<__next_pointer>(__cp);
++size();
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
return iterator(static_cast<__next_pointer>(__cp), this);
#else
return iterator(static_cast<__next_pointer>(__cp));
@@ -2089,17 +2063,10 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(
-#ifndef _LIBCPP_CXX03_LANG
template <class _Tp, class _Hash, class _Equal, class _Alloc>
template <class _Key, class ..._Args>
pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator, bool>
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const& __k, _Args&&... __args)
-#else
-template <class _Tp, class _Hash, class _Equal, class _Alloc>
-template <class _Key, class _Args>
-pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator, bool>
-__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const& __k, _Args& __args)
-#endif
{
size_t __hash = hash_function()(__k);
@@ -2123,11 +2090,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const&
}
}
{
-#ifndef _LIBCPP_CXX03_LANG
__node_holder __h = __construct_node_hash(__hash, _VSTD::forward<_Args>(__args)...);
-#else
- __node_holder __h = __construct_node_hash(__hash, __args);
-#endif
if (size()+1 > __bc * max_load_factor() || __bc == 0)
{
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&
__inserted = true;
}
__done:
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
return pair<iterator, bool>(iterator(__nd, this), __inserted);
#else
return pair<iterator, bool>(iterator(__nd), __inserted);
#endif
}
-#ifndef _LIBCPP_CXX03_LANG
-
template <class _Tp, class _Hash, class _Equal, class _Alloc>
template <class... _Args>
pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator, bool>
@@ -2197,7 +2158,7 @@ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_hint_multi(
const_iterator __p, _Args&&... __args)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
"unordered container::emplace_hint(const_iterator, args...) called with an iterator not"
" referring to this unordered container");
@@ -2208,36 +2169,6 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_hint_multi(
return __r;
}
-#else // _LIBCPP_CXX03_LANG
-
-template <class _Tp, class _Hash, class _Equal, class _Alloc>
-typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
-__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_multi(const __container_value_type& __x)
-{
- __node_holder __h = __construct_node(__x);
- iterator __r = __node_insert_multi(__h.get());
- __h.release();
- return __r;
-}
-
-template <class _Tp, class _Hash, class _Equal, class _Alloc>
-typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
-__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_multi(const_iterator __p,
- const __container_value_type& __x)
-{
-#if _LIBCPP_DEBUG_LEVEL >= 2
- _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
- "unordered container::insert(const_iterator, lvalue) called with an iterator not"
- " referring to this unordered container");
-#endif
- __node_holder __h = __construct_node(__x);
- iterator __r = __node_insert_multi(__p, __h.get());
- __h.release();
- return __r;
-}
-
-#endif // _LIBCPP_CXX03_LANG
-
#if _LIBCPP_STD_VER > 14
template <class _Tp, class _Hash, class _Equal, class _Alloc>
template <class _NodeHandle, class _InsertReturnType>
@@ -2399,9 +2330,9 @@ template <class _Tp, class _Hash, class _Equal, class _Alloc>
void
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __nbc)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__invalidate_all(this);
-#endif // _LIBCPP_DEBUG_LEVEL >= 2
+#endif
__pointer_allocator& __npa = __bucket_list_.get_deleter().__alloc();
__bucket_list_.reset(__nbc > 0 ?
__pointer_alloc_traits::allocate(__npa, __nbc) : nullptr);
@@ -2470,7 +2401,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k)
{
if ((__nd->__hash() == __hash)
&& key_eq()(__nd->__upcast()->__value_, __k))
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
return iterator(__nd, this);
#else
return iterator(__nd);
@@ -2501,7 +2432,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) const
{
if ((__nd->__hash() == __hash)
&& key_eq()(__nd->__upcast()->__value_, __k))
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
return const_iterator(__nd, this);
#else
return const_iterator(__nd);
@@ -2513,8 +2444,6 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) const
return end();
}
-#ifndef _LIBCPP_CXX03_LANG
-
template <class _Tp, class _Hash, class _Equal, class _Alloc>
template <class ..._Args>
typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder
@@ -2550,43 +2479,12 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node_hash(
return __h;
}
-#else // _LIBCPP_CXX03_LANG
-
-template <class _Tp, class _Hash, class _Equal, class _Alloc>
-typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder
-__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(const __container_value_type& __v)
-{
- __node_allocator& __na = __node_alloc();
- __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
- __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), __v);
- __h.get_deleter().__value_constructed = true;
- __h->__hash_ = hash_function()(__h->__value_);
- __h->__next_ = nullptr;
- return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03
-}
-
-template <class _Tp, class _Hash, class _Equal, class _Alloc>
-typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder
-__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node_hash(size_t __hash,
- const __container_value_type& __v)
-{
- __node_allocator& __na = __node_alloc();
- __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
- __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), __v);
- __h.get_deleter().__value_constructed = true;
- __h->__hash_ = __hash;
- __h->__next_ = nullptr;
- return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03
-}
-
-#endif // _LIBCPP_CXX03_LANG
-
template <class _Tp, class _Hash, class _Equal, class _Alloc>
typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
__hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __p)
{
__next_pointer __np = __p.__node_;
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
"unordered container erase(iterator) called with an iterator not"
" referring to this container");
@@ -2606,7 +2504,7 @@ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
__hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __first,
const_iterator __last)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this,
"unodered container::erase(iterator, iterator) called with an iterator not"
" referring to this unodered container");
@@ -2620,7 +2518,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __first,
erase(__p);
}
__next_pointer __np = __last.__node_;
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
return iterator (__np, this);
#else
return iterator (__np);
@@ -2691,7 +2589,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT
__pn->__next_ = __cn->__next_;
__cn->__next_ = nullptr;
--size();
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__c_node* __c = __get_db()->__find_c_and_lock(this);
for (__i_node** __dp = __c->end_; __dp != __c->beg_; )
{
@@ -2701,7 +2599,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT
{
(*__dp)->__c_ = nullptr;
if (--__c->end_ != __dp)
- memmove(__dp, __dp+1, (__c->end_ - __dp)*sizeof(__i_node*));
+ _VSTD::memmove(__dp, __dp+1, (__c->end_ - __dp)*sizeof(__i_node*));
}
}
__get_db()->unlock();
@@ -2830,9 +2728,9 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u)
__u.__bucket_list_.reset(__npp);
}
_VSTD::swap(__bucket_list_.get_deleter().size(), __u.__bucket_list_.get_deleter().size());
- __swap_allocator(__bucket_list_.get_deleter().__alloc(),
+ _VSTD::__swap_allocator(__bucket_list_.get_deleter().__alloc(),
__u.__bucket_list_.get_deleter().__alloc());
- __swap_allocator(__node_alloc(), __u.__node_alloc());
+ _VSTD::__swap_allocator(__node_alloc(), __u.__node_alloc());
_VSTD::swap(__p1_.first().__next_, __u.__p1_.first().__next_);
__p2_.swap(__u.__p2_);
__p3_.swap(__u.__p3_);
@@ -2842,7 +2740,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u)
if (__u.size() > 0)
__u.__bucket_list_[__constrain_hash(__u.__p1_.first().__next_->__hash(), __u.bucket_count())] =
__u.__p1_.first().__ptr();
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->swap(this, &__u);
#endif
}
@@ -2876,7 +2774,7 @@ swap(__hash_table<_Tp, _Hash, _Equal, _Alloc>& __x,
__x.swap(__y);
}
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
template <class _Tp, class _Hash, class _Equal, class _Alloc>
bool
@@ -2906,7 +2804,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__subscriptable(const const_iterator*,
return false;
}
-#endif // _LIBCPP_DEBUG_LEVEL >= 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__libcpp_version b/libcxx/include/__libcpp_version
index 82b3803a20e9..e334181b4006 100644
--- a/libcxx/include/__libcpp_version
+++ b/libcxx/include/__libcpp_version
@@ -1 +1 @@
-11000
+12000
diff --git a/libcxx/include/__locale b/libcxx/include/__locale
index 6d10fa4d3d64..a2da7d78049f 100644
--- a/libcxx/include/__locale
+++ b/libcxx/include/__locale
@@ -11,6 +11,7 @@
#define _LIBCPP___LOCALE
#include <__config>
+#include <__availability>
#include <string>
#include <memory>
#include <utility>
@@ -21,7 +22,9 @@
#if defined(_LIBCPP_MSVCRT_LIKE)
# include <cstring>
# include <support/win32/locale_win32.h>
-#elif defined(_AIX)
+#elif defined(__NuttX__)
+# include <support/nuttx/xlocale.h>
+#elif defined(_AIX) || defined(__MVS__)
# include <support/ibm/xlocale.h>
#elif defined(__ANDROID__)
# include <support/android/locale_bionic.h>
@@ -30,6 +33,8 @@
# include <support/solaris/xlocale.h>
#elif defined(_NEWLIB_VERSION)
# include <support/newlib/xlocale.h>
+#elif defined(__OpenBSD__)
+# include <support/openbsd/xlocale.h>
#elif (defined(__APPLE__) || defined(__FreeBSD__) \
|| defined(__EMSCRIPTEN__) || defined(__IBMCPP__))
# include <xlocale.h>
@@ -76,7 +81,7 @@ struct __libcpp_locale_guard {
// locale name, otherwise it will be a semicolon-separated string listing
// each category. In the second case, we know at least one category won't
// be what we want, so we only have to check the first case.
- if (strcmp(__l.__get_locale(), __lc) != 0) {
+ if (_VSTD::strcmp(__l.__get_locale(), __lc) != 0) {
__locale_all = _strdup(__lc);
if (__locale_all == nullptr)
__throw_bad_alloc();
@@ -105,7 +110,6 @@ struct __libcpp_locale_guard {
};
#endif
-
class _LIBCPP_TYPE_VIS locale;
template <class _Facet>
@@ -335,8 +339,8 @@ collate<_CharT>::do_hash(const char_type* __lo, const char_type* __hi) const
return static_cast<long>(__h);
}
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<char>)
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<wchar_t>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<char>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<wchar_t>)
// template <class CharT> class collate_byname;
@@ -396,7 +400,26 @@ locale::operator()(const basic_string<_CharT, _Traits, _Allocator>& __x,
class _LIBCPP_TYPE_VIS ctype_base
{
public:
-#if defined(__GLIBC__)
+#if defined(_LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE)
+ typedef unsigned long mask;
+ static const mask space = 1<<0;
+ static const mask print = 1<<1;
+ static const mask cntrl = 1<<2;
+ static const mask upper = 1<<3;
+ static const mask lower = 1<<4;
+ static const mask alpha = 1<<5;
+ static const mask digit = 1<<6;
+ static const mask punct = 1<<7;
+ static const mask xdigit = 1<<8;
+ static const mask blank = 1<<9;
+#if defined(__BIONIC__)
+ // Historically this was a part of regex_traits rather than ctype_base. The
+ // historical value of the constant is preserved for ABI compatibility.
+ static const mask __regex_word = 0x8000;
+#else
+ static const mask __regex_word = 1<<10;
+#endif // defined(__BIONIC__)
+#elif defined(__GLIBC__)
typedef unsigned short mask;
static const mask space = _ISspace;
static const mask print = _ISprint;
@@ -485,24 +508,7 @@ public:
# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA
# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT
#else
- typedef unsigned long mask;
- static const mask space = 1<<0;
- static const mask print = 1<<1;
- static const mask cntrl = 1<<2;
- static const mask upper = 1<<3;
- static const mask lower = 1<<4;
- static const mask alpha = 1<<5;
- static const mask digit = 1<<6;
- static const mask punct = 1<<7;
- static const mask xdigit = 1<<8;
- static const mask blank = 1<<9;
-#if defined(__BIONIC__)
- // Historically this was a part of regex_traits rather than ctype_base. The
- // historical value of the constant is preserved for ABI compatibility.
- static const mask __regex_word = 0x8000;
-#else
- static const mask __regex_word = 1<<10;
-#endif // defined(__BIONIC__)
+# error unknown rune table for this platform -- do you mean to define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE?
#endif
static const mask alnum = alpha | digit;
static const mask graph = alnum | punct;
@@ -623,7 +629,7 @@ class _LIBCPP_TYPE_VIS ctype<char>
public:
typedef char char_type;
- explicit ctype(const mask* __tab = 0, bool __del = false, size_t __refs = 0);
+ explicit ctype(const mask* __tab = nullptr, bool __del = false, size_t __refs = 0);
_LIBCPP_INLINE_VISIBILITY
bool is(mask __m, char_type __c) const
@@ -1069,10 +1075,10 @@ protected:
virtual int do_max_length() const _NOEXCEPT;
};
-// template <> class codecvt<char16_t, char, mbstate_t>
+// template <> class codecvt<char16_t, char, mbstate_t> // deprecated in C++20
template <>
-class _LIBCPP_TYPE_VIS codecvt<char16_t, char, mbstate_t>
+class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_TYPE_VIS codecvt<char16_t, char, mbstate_t>
: public locale::facet,
public codecvt_base
{
@@ -1155,10 +1161,100 @@ protected:
virtual int do_max_length() const _NOEXCEPT;
};
-// template <> class codecvt<char32_t, char, mbstate_t>
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+
+// template <> class codecvt<char16_t, char8_t, mbstate_t> // C++20
+
+template <>
+class _LIBCPP_TYPE_VIS codecvt<char16_t, char8_t, mbstate_t>
+ : public locale::facet,
+ public codecvt_base
+{
+public:
+ typedef char16_t intern_type;
+ typedef char8_t extern_type;
+ typedef mbstate_t state_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit codecvt(size_t __refs = 0)
+ : locale::facet(__refs) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result out(state_type& __st,
+ const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
+ {
+ return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ result unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
+ {
+ return do_unshift(__st, __to, __to_end, __to_nxt);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ result in(state_type& __st,
+ const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+ intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
+ {
+ return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ int encoding() const _NOEXCEPT
+ {
+ return do_encoding();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool always_noconv() const _NOEXCEPT
+ {
+ return do_always_noconv();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
+ {
+ return do_length(__st, __frm, __end, __mx);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ int max_length() const _NOEXCEPT
+ {
+ return do_max_length();
+ }
+
+ static locale::id id;
+
+protected:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit codecvt(const char*, size_t __refs = 0)
+ : locale::facet(__refs) {}
+
+ ~codecvt();
+
+ virtual result do_out(state_type& __st,
+ const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual result do_in(state_type& __st,
+ const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+ intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+ virtual result do_unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual int do_encoding() const _NOEXCEPT;
+ virtual bool do_always_noconv() const _NOEXCEPT;
+ virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
+ virtual int do_max_length() const _NOEXCEPT;
+};
+
+#endif
+
+// template <> class codecvt<char32_t, char, mbstate_t> // deprecated in C++20
template <>
-class _LIBCPP_TYPE_VIS codecvt<char32_t, char, mbstate_t>
+class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_TYPE_VIS codecvt<char32_t, char, mbstate_t>
: public locale::facet,
public codecvt_base
{
@@ -1241,6 +1337,96 @@ protected:
virtual int do_max_length() const _NOEXCEPT;
};
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+
+// template <> class codecvt<char32_t, char8_t, mbstate_t> // C++20
+
+template <>
+class _LIBCPP_TYPE_VIS codecvt<char32_t, char8_t, mbstate_t>
+ : public locale::facet,
+ public codecvt_base
+{
+public:
+ typedef char32_t intern_type;
+ typedef char8_t extern_type;
+ typedef mbstate_t state_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit codecvt(size_t __refs = 0)
+ : locale::facet(__refs) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result out(state_type& __st,
+ const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
+ {
+ return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ result unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
+ {
+ return do_unshift(__st, __to, __to_end, __to_nxt);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ result in(state_type& __st,
+ const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+ intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
+ {
+ return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ int encoding() const _NOEXCEPT
+ {
+ return do_encoding();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool always_noconv() const _NOEXCEPT
+ {
+ return do_always_noconv();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
+ {
+ return do_length(__st, __frm, __end, __mx);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ int max_length() const _NOEXCEPT
+ {
+ return do_max_length();
+ }
+
+ static locale::id id;
+
+protected:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit codecvt(const char*, size_t __refs = 0)
+ : locale::facet(__refs) {}
+
+ ~codecvt();
+
+ virtual result do_out(state_type& __st,
+ const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual result do_in(state_type& __st,
+ const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+ intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+ virtual result do_unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual int do_encoding() const _NOEXCEPT;
+ virtual bool do_always_noconv() const _NOEXCEPT;
+ virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
+ virtual int do_max_length() const _NOEXCEPT;
+};
+
+#endif
+
// template <class _InternT, class _ExternT, class _StateT> class codecvt_byname
template <class _InternT, class _ExternT, class _StateT>
@@ -1258,15 +1444,21 @@ protected:
~codecvt_byname();
};
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <class _InternT, class _ExternT, class _StateT>
codecvt_byname<_InternT, _ExternT, _StateT>::~codecvt_byname()
{
}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char, char, mbstate_t>)
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>)
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>)
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char, char, mbstate_t>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>) // deprecated in C++20
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>) // deprecated in C++20
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char8_t, mbstate_t>) // C++20
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char8_t, mbstate_t>) // C++20
+#endif
template <size_t _Np>
struct __narrow_to_utf8
@@ -1290,12 +1482,14 @@ struct __narrow_to_utf8<8>
}
};
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <>
struct _LIBCPP_TEMPLATE_VIS __narrow_to_utf8<16>
: public codecvt<char16_t, char, mbstate_t>
{
_LIBCPP_INLINE_VISIBILITY
__narrow_to_utf8() : codecvt<char16_t, char, mbstate_t>(1) {}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
_LIBCPP_EXPORTED_FROM_ABI ~__narrow_to_utf8();
@@ -1324,12 +1518,14 @@ struct _LIBCPP_TEMPLATE_VIS __narrow_to_utf8<16>
}
};
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <>
struct _LIBCPP_TEMPLATE_VIS __narrow_to_utf8<32>
: public codecvt<char32_t, char, mbstate_t>
{
_LIBCPP_INLINE_VISIBILITY
__narrow_to_utf8() : codecvt<char32_t, char, mbstate_t>(1) {}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
_LIBCPP_EXPORTED_FROM_ABI ~__narrow_to_utf8();
@@ -1380,12 +1576,14 @@ struct __widen_from_utf8<8>
}
};
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <>
struct _LIBCPP_TEMPLATE_VIS __widen_from_utf8<16>
: public codecvt<char16_t, char, mbstate_t>
{
_LIBCPP_INLINE_VISIBILITY
__widen_from_utf8() : codecvt<char16_t, char, mbstate_t>(1) {}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
_LIBCPP_EXPORTED_FROM_ABI ~__widen_from_utf8();
@@ -1407,19 +1605,21 @@ struct _LIBCPP_TEMPLATE_VIS __widen_from_utf8<16>
if (__r == codecvt_base::error || __nn == __nb)
__throw_runtime_error("locale not supported");
for (const char16_t* __p = __buf; __p < __bn; ++__p, ++__s)
- *__s = (wchar_t)*__p;
+ *__s = *__p;
__nb = __nn;
}
return __s;
}
};
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <>
struct _LIBCPP_TEMPLATE_VIS __widen_from_utf8<32>
: public codecvt<char32_t, char, mbstate_t>
{
_LIBCPP_INLINE_VISIBILITY
__widen_from_utf8() : codecvt<char32_t, char, mbstate_t>(1) {}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
_LIBCPP_EXPORTED_FROM_ABI ~__widen_from_utf8();
@@ -1441,7 +1641,7 @@ struct _LIBCPP_TEMPLATE_VIS __widen_from_utf8<32>
if (__r == codecvt_base::error || __nn == __nb)
__throw_runtime_error("locale not supported");
for (const char32_t* __p = __buf; __p < __bn; ++__p, ++__s)
- *__s = (wchar_t)*__p;
+ *__s = *__p;
__nb = __nn;
}
return __s;
diff --git a/libcxx/include/__memory/allocator_traits.h b/libcxx/include/__memory/allocator_traits.h
new file mode 100644
index 000000000000..9443f61b71bc
--- /dev/null
+++ b/libcxx/include/__memory/allocator_traits.h
@@ -0,0 +1,401 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___MEMORY_ALLOCATOR_TRAITS_H
+#define _LIBCPP___MEMORY_ALLOCATOR_TRAITS_H
+
+#include <__config>
+#include <__memory/base.h>
+#include <__memory/pointer_traits.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#define _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(NAME, PROPERTY) \
+ template <class _Tp, class = void> struct NAME : false_type { }; \
+ template <class _Tp> struct NAME<_Tp, typename __void_t<typename _Tp:: PROPERTY >::type> : true_type { }
+
+// __pointer
+_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_pointer, pointer);
+template <class _Tp, class _Alloc,
+ class _RawAlloc = typename remove_reference<_Alloc>::type,
+ bool = __has_pointer<_RawAlloc>::value>
+struct __pointer {
+ using type _LIBCPP_NODEBUG_TYPE = typename _RawAlloc::pointer;
+};
+template <class _Tp, class _Alloc, class _RawAlloc>
+struct __pointer<_Tp, _Alloc, _RawAlloc, false> {
+ using type _LIBCPP_NODEBUG_TYPE = _Tp*;
+};
+
+// __const_pointer
+_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_const_pointer, const_pointer);
+template <class _Tp, class _Ptr, class _Alloc,
+ bool = __has_const_pointer<_Alloc>::value>
+struct __const_pointer {
+ using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::const_pointer;
+};
+template <class _Tp, class _Ptr, class _Alloc>
+struct __const_pointer<_Tp, _Ptr, _Alloc, false> {
+#ifdef _LIBCPP_CXX03_LANG
+ using type = typename pointer_traits<_Ptr>::template rebind<const _Tp>::other;
+#else
+ using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::template rebind<const _Tp>;
+#endif
+};
+
+// __void_pointer
+_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_void_pointer, void_pointer);
+template <class _Ptr, class _Alloc,
+ bool = __has_void_pointer<_Alloc>::value>
+struct __void_pointer {
+ using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::void_pointer;
+};
+template <class _Ptr, class _Alloc>
+struct __void_pointer<_Ptr, _Alloc, false> {
+#ifdef _LIBCPP_CXX03_LANG
+ using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::template rebind<void>::other;
+#else
+ using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::template rebind<void>;
+#endif
+};
+
+// __const_void_pointer
+_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_const_void_pointer, const_void_pointer);
+template <class _Ptr, class _Alloc,
+ bool = __has_const_void_pointer<_Alloc>::value>
+struct __const_void_pointer {
+ using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::const_void_pointer;
+};
+template <class _Ptr, class _Alloc>
+struct __const_void_pointer<_Ptr, _Alloc, false> {
+#ifdef _LIBCPP_CXX03_LANG
+ using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::template rebind<const void>::other;
+#else
+ using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::template rebind<const void>;
+#endif
+};
+
+// __size_type
+_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_size_type, size_type);
+template <class _Alloc, class _DiffType, bool = __has_size_type<_Alloc>::value>
+struct __size_type : make_unsigned<_DiffType> { };
+template <class _Alloc, class _DiffType>
+struct __size_type<_Alloc, _DiffType, true> {
+ using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::size_type;
+};
+
+// __alloc_traits_difference_type
+_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_alloc_traits_difference_type, difference_type);
+template <class _Alloc, class _Ptr, bool = __has_alloc_traits_difference_type<_Alloc>::value>
+struct __alloc_traits_difference_type {
+ using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::difference_type;
+};
+template <class _Alloc, class _Ptr>
+struct __alloc_traits_difference_type<_Alloc, _Ptr, true> {
+ using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::difference_type;
+};
+
+// __propagate_on_container_copy_assignment
+_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_propagate_on_container_copy_assignment, propagate_on_container_copy_assignment);
+template <class _Alloc, bool = __has_propagate_on_container_copy_assignment<_Alloc>::value>
+struct __propagate_on_container_copy_assignment : false_type { };
+template <class _Alloc>
+struct __propagate_on_container_copy_assignment<_Alloc, true> {
+ using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::propagate_on_container_copy_assignment;
+};
+
+// __propagate_on_container_move_assignment
+_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_propagate_on_container_move_assignment, propagate_on_container_move_assignment);
+template <class _Alloc, bool = __has_propagate_on_container_move_assignment<_Alloc>::value>
+struct __propagate_on_container_move_assignment : false_type { };
+template <class _Alloc>
+struct __propagate_on_container_move_assignment<_Alloc, true> {
+ using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::propagate_on_container_move_assignment;
+};
+
+// __propagate_on_container_swap
+_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_propagate_on_container_swap, propagate_on_container_swap);
+template <class _Alloc, bool = __has_propagate_on_container_swap<_Alloc>::value>
+struct __propagate_on_container_swap : false_type { };
+template <class _Alloc>
+struct __propagate_on_container_swap<_Alloc, true> {
+ using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::propagate_on_container_swap;
+};
+
+// __is_always_equal
+_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_is_always_equal, is_always_equal);
+template <class _Alloc, bool = __has_is_always_equal<_Alloc>::value>
+struct __is_always_equal : is_empty<_Alloc> { };
+template <class _Alloc>
+struct __is_always_equal<_Alloc, true> {
+ using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::is_always_equal;
+};
+
+// __allocator_traits_rebind
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <class _Tp, class _Up, class = void>
+struct __has_rebind_other : false_type { };
+template <class _Tp, class _Up>
+struct __has_rebind_other<_Tp, _Up, typename __void_t<
+ typename _Tp::template rebind<_Up>::other
+>::type> : true_type { };
+
+template <class _Tp, class _Up, bool = __has_rebind_other<_Tp, _Up>::value>
+struct __allocator_traits_rebind {
+ using type _LIBCPP_NODEBUG_TYPE = typename _Tp::template rebind<_Up>::other;
+};
+template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up>
+struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, true> {
+ using type _LIBCPP_NODEBUG_TYPE = typename _Alloc<_Tp, _Args...>::template rebind<_Up>::other;
+};
+template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up>
+struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, false> {
+ using type _LIBCPP_NODEBUG_TYPE = _Alloc<_Up, _Args...>;
+};
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+
+template<class _Alloc, class _Tp>
+using __allocator_traits_rebind_t = typename __allocator_traits_rebind<_Alloc, _Tp>::type;
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+
+// __has_allocate_hint
+template <class _Alloc, class _SizeType, class _ConstVoidPtr, class = void>
+struct __has_allocate_hint : false_type { };
+
+template <class _Alloc, class _SizeType, class _ConstVoidPtr>
+struct __has_allocate_hint<_Alloc, _SizeType, _ConstVoidPtr, decltype(
+ (void)declval<_Alloc>().allocate(declval<_SizeType>(), declval<_ConstVoidPtr>())
+)> : true_type { };
+
+// __has_construct
+template <class, class _Alloc, class ..._Args>
+struct __has_construct_impl : false_type { };
+
+template <class _Alloc, class ..._Args>
+struct __has_construct_impl<decltype(
+ (void)declval<_Alloc>().construct(declval<_Args>()...)
+), _Alloc, _Args...> : true_type { };
+
+template <class _Alloc, class ..._Args>
+struct __has_construct : __has_construct_impl<void, _Alloc, _Args...> { };
+
+// __has_destroy
+template <class _Alloc, class _Pointer, class = void>
+struct __has_destroy : false_type { };
+
+template <class _Alloc, class _Pointer>
+struct __has_destroy<_Alloc, _Pointer, decltype(
+ (void)declval<_Alloc>().destroy(declval<_Pointer>())
+)> : true_type { };
+
+// __has_max_size
+template <class _Alloc, class = void>
+struct __has_max_size : false_type { };
+
+template <class _Alloc>
+struct __has_max_size<_Alloc, decltype(
+ (void)declval<_Alloc&>().max_size()
+)> : true_type { };
+
+// __has_select_on_container_copy_construction
+template <class _Alloc, class = void>
+struct __has_select_on_container_copy_construction : false_type { };
+
+template <class _Alloc>
+struct __has_select_on_container_copy_construction<_Alloc, decltype(
+ (void)declval<_Alloc>().select_on_container_copy_construction()
+)> : true_type { };
+
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+
+template <class _Alloc>
+struct _LIBCPP_TEMPLATE_VIS allocator_traits
+{
+ using allocator_type = _Alloc;
+ using value_type = typename allocator_type::value_type;
+ using pointer = typename __pointer<value_type, allocator_type>::type;
+ using const_pointer = typename __const_pointer<value_type, pointer, allocator_type>::type;
+ using void_pointer = typename __void_pointer<pointer, allocator_type>::type;
+ using const_void_pointer = typename __const_void_pointer<pointer, allocator_type>::type;
+ using difference_type = typename __alloc_traits_difference_type<allocator_type, pointer>::type;
+ using size_type = typename __size_type<allocator_type, difference_type>::type;
+ using propagate_on_container_copy_assignment = typename __propagate_on_container_copy_assignment<allocator_type>::type;
+ using propagate_on_container_move_assignment = typename __propagate_on_container_move_assignment<allocator_type>::type;
+ using propagate_on_container_swap = typename __propagate_on_container_swap<allocator_type>::type;
+ using is_always_equal = typename __is_always_equal<allocator_type>::type;
+
+#ifndef _LIBCPP_CXX03_LANG
+ template <class _Tp>
+ using rebind_alloc = __allocator_traits_rebind_t<allocator_type, _Tp>;
+ template <class _Tp>
+ using rebind_traits = allocator_traits<rebind_alloc<_Tp> >;
+#else // _LIBCPP_CXX03_LANG
+ template <class _Tp>
+ struct rebind_alloc {
+ using other = __allocator_traits_rebind_t<allocator_type, _Tp>;
+ };
+ template <class _Tp>
+ struct rebind_traits {
+ using other = allocator_traits<typename rebind_alloc<_Tp>::other>;
+ };
+#endif // _LIBCPP_CXX03_LANG
+
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static pointer allocate(allocator_type& __a, size_type __n) {
+ return __a.allocate(__n);
+ }
+
+ template <class _Ap = _Alloc, class =
+ _EnableIf<__has_allocate_hint<_Ap, size_type, const_void_pointer>::value> >
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static pointer allocate(allocator_type& __a, size_type __n, const_void_pointer __hint) {
+ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
+ return __a.allocate(__n, __hint);
+ _LIBCPP_SUPPRESS_DEPRECATED_POP
+ }
+ template <class _Ap = _Alloc, class = void, class =
+ _EnableIf<!__has_allocate_hint<_Ap, size_type, const_void_pointer>::value> >
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static pointer allocate(allocator_type& __a, size_type __n, const_void_pointer) {
+ return __a.allocate(__n);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static void deallocate(allocator_type& __a, pointer __p, size_type __n) _NOEXCEPT {
+ __a.deallocate(__p, __n);
+ }
+
+ template <class _Tp, class... _Args, class =
+ _EnableIf<__has_construct<allocator_type, _Tp*, _Args...>::value> >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static void construct(allocator_type& __a, _Tp* __p, _Args&&... __args) {
+ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
+ __a.construct(__p, _VSTD::forward<_Args>(__args)...);
+ _LIBCPP_SUPPRESS_DEPRECATED_POP
+ }
+ template <class _Tp, class... _Args, class = void, class =
+ _EnableIf<!__has_construct<allocator_type, _Tp*, _Args...>::value> >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static void construct(allocator_type&, _Tp* __p, _Args&&... __args) {
+#if _LIBCPP_STD_VER > 17
+ _VSTD::construct_at(__p, _VSTD::forward<_Args>(__args)...);
+#else
+ ::new ((void*)__p) _Tp(_VSTD::forward<_Args>(__args)...);
+#endif
+ }
+
+ template <class _Tp, class =
+ _EnableIf<__has_destroy<allocator_type, _Tp*>::value> >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static void destroy(allocator_type& __a, _Tp* __p) {
+ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
+ __a.destroy(__p);
+ _LIBCPP_SUPPRESS_DEPRECATED_POP
+ }
+ template <class _Tp, class = void, class =
+ _EnableIf<!__has_destroy<allocator_type, _Tp*>::value> >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static void destroy(allocator_type&, _Tp* __p) {
+#if _LIBCPP_STD_VER > 17
+ _VSTD::destroy_at(__p);
+#else
+ __p->~_Tp();
+#endif
+ }
+
+ template <class _Ap = _Alloc, class =
+ _EnableIf<__has_max_size<const _Ap>::value> >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static size_type max_size(const allocator_type& __a) _NOEXCEPT {
+ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
+ return __a.max_size();
+ _LIBCPP_SUPPRESS_DEPRECATED_POP
+ }
+ template <class _Ap = _Alloc, class = void, class =
+ _EnableIf<!__has_max_size<const _Ap>::value> >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static size_type max_size(const allocator_type&) _NOEXCEPT {
+ return numeric_limits<size_type>::max() / sizeof(value_type);
+ }
+
+ template <class _Ap = _Alloc, class =
+ _EnableIf<__has_select_on_container_copy_construction<const _Ap>::value> >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static allocator_type select_on_container_copy_construction(const allocator_type& __a) {
+ return __a.select_on_container_copy_construction();
+ }
+ template <class _Ap = _Alloc, class = void, class =
+ _EnableIf<!__has_select_on_container_copy_construction<const _Ap>::value> >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static allocator_type select_on_container_copy_construction(const allocator_type& __a) {
+ return __a;
+ }
+};
+
+template <class _Traits, class _Tp>
+struct __rebind_alloc_helper {
+#ifndef _LIBCPP_CXX03_LANG
+ using type _LIBCPP_NODEBUG_TYPE = typename _Traits::template rebind_alloc<_Tp>;
+#else
+ using type = typename _Traits::template rebind_alloc<_Tp>::other;
+#endif
+};
+
+// __is_default_allocator
+template <class _Tp>
+struct __is_default_allocator : false_type { };
+
+template <class _Tp>
+struct __is_default_allocator<_VSTD::allocator<_Tp> > : true_type { };
+
+// __is_cpp17_move_insertable
+template <class _Alloc, class = void>
+struct __is_cpp17_move_insertable
+ : is_move_constructible<typename _Alloc::value_type>
+{ };
+
+template <class _Alloc>
+struct __is_cpp17_move_insertable<_Alloc, _EnableIf<
+ !__is_default_allocator<_Alloc>::value &&
+ __has_construct<_Alloc, typename _Alloc::value_type*, typename _Alloc::value_type&&>::value
+> > : true_type { };
+
+// __is_cpp17_copy_insertable
+template <class _Alloc, class = void>
+struct __is_cpp17_copy_insertable
+ : integral_constant<bool,
+ is_copy_constructible<typename _Alloc::value_type>::value &&
+ __is_cpp17_move_insertable<_Alloc>::value
+ >
+{ };
+
+template <class _Alloc>
+struct __is_cpp17_copy_insertable<_Alloc, _EnableIf<
+ !__is_default_allocator<_Alloc>::value &&
+ __has_construct<_Alloc, typename _Alloc::value_type*, const typename _Alloc::value_type&>::value
+> >
+ : __is_cpp17_move_insertable<_Alloc>
+{ };
+
+#undef _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___MEMORY_ALLOCATOR_TRAITS_H
diff --git a/libcxx/include/__memory/base.h b/libcxx/include/__memory/base.h
new file mode 100644
index 000000000000..70728bd7f8ef
--- /dev/null
+++ b/libcxx/include/__memory/base.h
@@ -0,0 +1,127 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___MEMORY_BASE_H
+#define _LIBCPP___MEMORY_BASE_H
+
+#include <__config>
+#include <__debug>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// addressof
+#ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
+
+template <class _Tp>
+inline _LIBCPP_CONSTEXPR_AFTER_CXX14
+_LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
+_Tp*
+addressof(_Tp& __x) _NOEXCEPT
+{
+ return __builtin_addressof(__x);
+}
+
+#else
+
+template <class _Tp>
+inline _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
+_Tp*
+addressof(_Tp& __x) _NOEXCEPT
+{
+ return reinterpret_cast<_Tp *>(
+ const_cast<char *>(&reinterpret_cast<const volatile char &>(__x)));
+}
+
+#endif // _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
+
+#if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF)
+// Objective-C++ Automatic Reference Counting uses qualified pointers
+// that require special addressof() signatures. When
+// _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler
+// itself is providing these definitions. Otherwise, we provide them.
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+__strong _Tp*
+addressof(__strong _Tp& __x) _NOEXCEPT
+{
+ return &__x;
+}
+
+#ifdef _LIBCPP_HAS_OBJC_ARC_WEAK
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+__weak _Tp*
+addressof(__weak _Tp& __x) _NOEXCEPT
+{
+ return &__x;
+}
+#endif
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+__autoreleasing _Tp*
+addressof(__autoreleasing _Tp& __x) _NOEXCEPT
+{
+ return &__x;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+__unsafe_unretained _Tp*
+addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT
+{
+ return &__x;
+}
+#endif
+
+#if !defined(_LIBCPP_CXX03_LANG)
+template <class _Tp> _Tp* addressof(const _Tp&&) noexcept = delete;
+#endif
+
+// construct_at
+
+#if _LIBCPP_STD_VER > 17
+
+template<class _Tp, class ..._Args, class = decltype(
+ ::new (_VSTD::declval<void*>()) _Tp(_VSTD::declval<_Args>()...)
+)>
+_LIBCPP_INLINE_VISIBILITY
+constexpr _Tp* construct_at(_Tp* __location, _Args&& ...__args) {
+ _LIBCPP_ASSERT(__location, "null pointer given to construct_at");
+ return ::new ((void*)__location) _Tp(_VSTD::forward<_Args>(__args)...);
+}
+
+#endif
+
+// destroy_at
+
+#if _LIBCPP_STD_VER > 14
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+void destroy_at(_Tp* __loc) {
+ _LIBCPP_ASSERT(__loc, "null pointer given to destroy_at");
+ __loc->~_Tp();
+}
+
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___MEMORY_BASE_H
diff --git a/libcxx/include/__memory/pointer_traits.h b/libcxx/include/__memory/pointer_traits.h
new file mode 100644
index 000000000000..b2c5d34cb082
--- /dev/null
+++ b/libcxx/include/__memory/pointer_traits.h
@@ -0,0 +1,169 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___MEMORY_POINTER_TRAITS_H
+#define _LIBCPP___MEMORY_POINTER_TRAITS_H
+
+#include <__config>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp, class = void>
+struct __has_element_type : false_type {};
+
+template <class _Tp>
+struct __has_element_type<_Tp,
+ typename __void_t<typename _Tp::element_type>::type> : true_type {};
+
+template <class _Ptr, bool = __has_element_type<_Ptr>::value>
+struct __pointer_traits_element_type;
+
+template <class _Ptr>
+struct __pointer_traits_element_type<_Ptr, true>
+{
+ typedef _LIBCPP_NODEBUG_TYPE typename _Ptr::element_type type;
+};
+
+template <template <class, class...> class _Sp, class _Tp, class ..._Args>
+struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, true>
+{
+ typedef _LIBCPP_NODEBUG_TYPE typename _Sp<_Tp, _Args...>::element_type type;
+};
+
+template <template <class, class...> class _Sp, class _Tp, class ..._Args>
+struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, false>
+{
+ typedef _LIBCPP_NODEBUG_TYPE _Tp type;
+};
+
+template <class _Tp, class = void>
+struct __has_difference_type : false_type {};
+
+template <class _Tp>
+struct __has_difference_type<_Tp,
+ typename __void_t<typename _Tp::difference_type>::type> : true_type {};
+
+template <class _Ptr, bool = __has_difference_type<_Ptr>::value>
+struct __pointer_traits_difference_type
+{
+ typedef _LIBCPP_NODEBUG_TYPE ptrdiff_t type;
+};
+
+template <class _Ptr>
+struct __pointer_traits_difference_type<_Ptr, true>
+{
+ typedef _LIBCPP_NODEBUG_TYPE typename _Ptr::difference_type type;
+};
+
+template <class _Tp, class _Up>
+struct __has_rebind
+{
+private:
+ struct __two {char __lx; char __lxx;};
+ template <class _Xp> static __two __test(...);
+ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
+ template <class _Xp> static char __test(typename _Xp::template rebind<_Up>* = 0);
+ _LIBCPP_SUPPRESS_DEPRECATED_POP
+public:
+ static const bool value = sizeof(__test<_Tp>(0)) == 1;
+};
+
+template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value>
+struct __pointer_traits_rebind
+{
+#ifndef _LIBCPP_CXX03_LANG
+ typedef _LIBCPP_NODEBUG_TYPE typename _Tp::template rebind<_Up> type;
+#else
+ typedef _LIBCPP_NODEBUG_TYPE typename _Tp::template rebind<_Up>::other type;
+#endif
+};
+
+template <template <class, class...> class _Sp, class _Tp, class ..._Args, class _Up>
+struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, true>
+{
+#ifndef _LIBCPP_CXX03_LANG
+ typedef _LIBCPP_NODEBUG_TYPE typename _Sp<_Tp, _Args...>::template rebind<_Up> type;
+#else
+ typedef _LIBCPP_NODEBUG_TYPE typename _Sp<_Tp, _Args...>::template rebind<_Up>::other type;
+#endif
+};
+
+template <template <class, class...> class _Sp, class _Tp, class ..._Args, class _Up>
+struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, false>
+{
+ typedef _Sp<_Up, _Args...> type;
+};
+
+template <class _Ptr>
+struct _LIBCPP_TEMPLATE_VIS pointer_traits
+{
+ typedef _Ptr pointer;
+ typedef typename __pointer_traits_element_type<pointer>::type element_type;
+ typedef typename __pointer_traits_difference_type<pointer>::type difference_type;
+
+#ifndef _LIBCPP_CXX03_LANG
+ template <class _Up> using rebind = typename __pointer_traits_rebind<pointer, _Up>::type;
+#else
+ template <class _Up> struct rebind
+ {typedef typename __pointer_traits_rebind<pointer, _Up>::type other;};
+#endif // _LIBCPP_CXX03_LANG
+
+private:
+ struct __nat {};
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ static pointer pointer_to(typename conditional<is_void<element_type>::value,
+ __nat, element_type>::type& __r)
+ {return pointer::pointer_to(__r);}
+};
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS pointer_traits<_Tp*>
+{
+ typedef _Tp* pointer;
+ typedef _Tp element_type;
+ typedef ptrdiff_t difference_type;
+
+#ifndef _LIBCPP_CXX03_LANG
+ template <class _Up> using rebind = _Up*;
+#else
+ template <class _Up> struct rebind {typedef _Up* other;};
+#endif
+
+private:
+ struct __nat {};
+public:
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static pointer pointer_to(typename conditional<is_void<element_type>::value,
+ __nat, element_type>::type& __r) _NOEXCEPT
+ {return _VSTD::addressof(__r);}
+};
+
+template <class _From, class _To>
+struct __rebind_pointer {
+#ifndef _LIBCPP_CXX03_LANG
+ typedef typename pointer_traits<_From>::template rebind<_To> type;
+#else
+ typedef typename pointer_traits<_From>::template rebind<_To>::other type;
+#endif
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___MEMORY_POINTER_TRAITS_H
diff --git a/libcxx/include/__memory/utilities.h b/libcxx/include/__memory/utilities.h
new file mode 100644
index 000000000000..aac3d11cab57
--- /dev/null
+++ b/libcxx/include/__memory/utilities.h
@@ -0,0 +1,88 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___MEMORY_UTILITIES_H
+#define _LIBCPP___MEMORY_UTILITIES_H
+
+#include <__config>
+#include <__memory/allocator_traits.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// Helper class to allocate memory using an Allocator in an exception safe
+// manner.
+//
+// The intended usage of this class is as follows:
+//
+// 0
+// 1 __allocation_guard<SomeAllocator> guard(alloc, 10);
+// 2 do_some_initialization_that_may_throw(guard.__get());
+// 3 save_allocated_pointer_in_a_noexcept_operation(guard.__release_ptr());
+// 4
+//
+// If line (2) throws an exception during initialization of the memory, the
+// guard's destructor will be called, and the memory will be released using
+// Allocator deallocation. Otherwise, we release the memory from the guard on
+// line (3) in an operation that can't throw -- after that, the guard is not
+// responsible for the memory anymore.
+//
+// This is similar to a unique_ptr, except it's easier to use with a
+// custom allocator.
+template<class _Alloc>
+struct __allocation_guard {
+ using _Pointer = typename allocator_traits<_Alloc>::pointer;
+ using _Size = typename allocator_traits<_Alloc>::size_type;
+
+ template<class _AllocT> // we perform the allocator conversion inside the constructor
+ _LIBCPP_HIDE_FROM_ABI
+ explicit __allocation_guard(_AllocT __alloc, _Size __n)
+ : __alloc_(_VSTD::move(__alloc))
+ , __n_(__n)
+ , __ptr_(allocator_traits<_Alloc>::allocate(__alloc_, __n_)) // initialization order is important
+ { }
+
+ _LIBCPP_HIDE_FROM_ABI
+ ~__allocation_guard() _NOEXCEPT {
+ if (__ptr_ != nullptr) {
+ allocator_traits<_Alloc>::deallocate(__alloc_, __ptr_, __n_);
+ }
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ _Pointer __release_ptr() _NOEXCEPT { // not called __release() because it's a keyword in objective-c++
+ _Pointer __tmp = __ptr_;
+ __ptr_ = nullptr;
+ return __tmp;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ _Pointer __get() const _NOEXCEPT {
+ return __ptr_;
+ }
+
+private:
+ _Alloc __alloc_;
+ _Size __n_;
+ _Pointer __ptr_;
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___MEMORY_UTILITIES_H
diff --git a/libcxx/include/__mutex_base b/libcxx/include/__mutex_base
index 8b4b74802b19..96454ace9f4d 100644
--- a/libcxx/include/__mutex_base
+++ b/libcxx/include/__mutex_base
@@ -146,7 +146,6 @@ private:
unique_lock& operator=(unique_lock const&); // = delete;
public:
-#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
unique_lock(unique_lock&& __u) _NOEXCEPT
: __m_(__u.__m_), __owns_(__u.__owns_)
@@ -163,8 +162,6 @@ public:
return *this;
}
-#endif // _LIBCPP_CXX03_LANG
-
void lock();
bool try_lock();
@@ -382,12 +379,12 @@ __safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d)
using __ratio = ratio_divide<_Period, nano>;
using __ns_rep = nanoseconds::rep;
- __ns_rep __result_max = std::numeric_limits<__ns_rep>::max();
+ __ns_rep __result_max = numeric_limits<__ns_rep>::max();
if (__d.count() > 0 && __d.count() > __result_max / __ratio::num) {
return nanoseconds::max();
}
- __ns_rep __result_min = std::numeric_limits<__ns_rep>::min();
+ __ns_rep __result_min = numeric_limits<__ns_rep>::min();
if (__d.count() < 0 && __d.count() < __result_min / __ratio::num) {
return nanoseconds::min();
}
@@ -421,7 +418,7 @@ condition_variable::wait_until(unique_lock<mutex>& __lk,
if (__t <= __now)
return cv_status::timeout;
- __clock_tp_ns __t_ns = __clock_tp_ns(__safe_nanosecond_cast(__t.time_since_epoch()));
+ __clock_tp_ns __t_ns = __clock_tp_ns(_VSTD::__safe_nanosecond_cast(__t.time_since_epoch()));
__do_timed_wait(__lk, __t_ns);
return _Clock::now() < __t ? cv_status::no_timeout : cv_status::timeout;
@@ -454,13 +451,13 @@ condition_variable::wait_for(unique_lock<mutex>& __lk,
#if defined(_LIBCPP_HAS_COND_CLOCKWAIT)
using __clock_tp_ns = time_point<steady_clock, nanoseconds>;
- __ns_rep __now_count_ns = __safe_nanosecond_cast(__c_now.time_since_epoch()).count();
+ __ns_rep __now_count_ns = _VSTD::__safe_nanosecond_cast(__c_now.time_since_epoch()).count();
#else
using __clock_tp_ns = time_point<system_clock, nanoseconds>;
- __ns_rep __now_count_ns = __safe_nanosecond_cast(system_clock::now().time_since_epoch()).count();
+ __ns_rep __now_count_ns = _VSTD::__safe_nanosecond_cast(system_clock::now().time_since_epoch()).count();
#endif
- __ns_rep __d_ns_count = __safe_nanosecond_cast(__d).count();
+ __ns_rep __d_ns_count = _VSTD::__safe_nanosecond_cast(__d).count();
if (__now_count_ns > numeric_limits<__ns_rep>::max() - __d_ns_count) {
__do_timed_wait(__lk, __clock_tp_ns::max());
diff --git a/libcxx/include/__split_buffer b/libcxx/include/__split_buffer
index fce209f8287e..20480d19d31b 100644
--- a/libcxx/include/__split_buffer
+++ b/libcxx/include/__split_buffer
@@ -68,7 +68,6 @@ public:
__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a);
~__split_buffer();
-#ifndef _LIBCPP_CXX03_LANG
__split_buffer(__split_buffer&& __c)
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
__split_buffer(__split_buffer&& __c, const __alloc_rr& __a);
@@ -76,7 +75,6 @@ public:
_NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&
is_nothrow_move_assignable<allocator_type>::value) ||
!__alloc_traits::propagate_on_container_move_assignment::value);
-#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT {return __begin_;}
_LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT {return __begin_;}
@@ -101,12 +99,10 @@ public:
void shrink_to_fit() _NOEXCEPT;
void push_front(const_reference __x);
_LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
-#ifndef _LIBCPP_CXX03_LANG
void push_front(value_type&& __x);
void push_back(value_type&& __x);
template <class... _Args>
void emplace_back(_Args&&... __args);
-#endif // !defined(_LIBCPP_CXX03_LANG)
_LIBCPP_INLINE_VISIBILITY void pop_front() {__destruct_at_begin(__begin_+1);}
_LIBCPP_INLINE_VISIBILITY void pop_back() {__destruct_at_end(__end_-1);}
@@ -270,7 +266,7 @@ typename enable_if
>::type
__split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last)
{
- _ConstructTransaction __tx(&this->__end_, std::distance(__first, __last));
+ _ConstructTransaction __tx(&this->__end_, _VSTD::distance(__first, __last));
for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_, ++__first) {
__alloc_traits::construct(this->__alloc(),
_VSTD::__to_address(__tx.__pos_), *__first);
@@ -283,7 +279,7 @@ void
__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type)
{
while (__begin_ != __new_begin)
- __alloc_traits::destroy(__alloc(), __to_address(__begin_++));
+ __alloc_traits::destroy(__alloc(), _VSTD::__to_address(__begin_++));
}
template <class _Tp, class _Allocator>
@@ -300,7 +296,7 @@ void
__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT
{
while (__new_last != __end_)
- __alloc_traits::destroy(__alloc(), __to_address(--__end_));
+ __alloc_traits::destroy(__alloc(), _VSTD::__to_address(--__end_));
}
template <class _Tp, class _Allocator>
@@ -350,8 +346,6 @@ __split_buffer<_Tp, _Allocator>::~__split_buffer()
__alloc_traits::deallocate(__alloc(), __first_, capacity());
}
-#ifndef _LIBCPP_CXX03_LANG
-
template <class _Tp, class _Allocator>
__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c)
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
@@ -412,8 +406,6 @@ __split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c)
return *this;
}
-#endif // _LIBCPP_CXX03_LANG
-
template <class _Tp, class _Allocator>
void
__split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)
@@ -424,7 +416,7 @@ __split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)
_VSTD::swap(__begin_, __x.__begin_);
_VSTD::swap(__end_, __x.__end_);
_VSTD::swap(__end_cap(), __x.__end_cap());
- __swap_allocator(__alloc(), __x.__alloc());
+ _VSTD::__swap_allocator(__alloc(), __x.__alloc());
}
template <class _Tp, class _Allocator>
@@ -499,8 +491,6 @@ __split_buffer<_Tp, _Allocator>::push_front(const_reference __x)
--__begin_;
}
-#ifndef _LIBCPP_CXX03_LANG
-
template <class _Tp, class _Allocator>
void
__split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)
@@ -531,8 +521,6 @@ __split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)
--__begin_;
}
-#endif // _LIBCPP_CXX03_LANG
-
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
@@ -563,8 +551,6 @@ __split_buffer<_Tp, _Allocator>::push_back(const_reference __x)
++__end_;
}
-#ifndef _LIBCPP_CXX03_LANG
-
template <class _Tp, class _Allocator>
void
__split_buffer<_Tp, _Allocator>::push_back(value_type&& __x)
@@ -626,8 +612,6 @@ __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args)
++__end_;
}
-#endif // _LIBCPP_CXX03_LANG
-
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
diff --git a/libcxx/include/__sso_allocator b/libcxx/include/__sso_allocator
index 393012873848..c50ae24c9212 100644
--- a/libcxx/include/__sso_allocator
+++ b/libcxx/include/__sso_allocator
@@ -11,8 +11,9 @@
#define _LIBCPP___SSO_ALLOCATOR
#include <__config>
-#include <type_traits>
+#include <memory>
#include <new>
+#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -47,21 +48,21 @@ public:
private:
__sso_allocator& operator=(const __sso_allocator&);
public:
- _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, typename __sso_allocator<void, _Np>::const_pointer = 0)
+ _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, typename __sso_allocator<void, _Np>::const_pointer = nullptr)
{
if (!__allocated_ && __n <= _Np)
{
__allocated_ = true;
return (pointer)&buf_;
}
- return static_cast<pointer>(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)));
+ return allocator<_Tp>().allocate(__n);
}
_LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type __n)
{
if (__p == (pointer)&buf_)
__allocated_ = false;
else
- _VSTD::__libcpp_deallocate(__p, __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));
+ allocator<_Tp>().deallocate(__p, __n);
}
_LIBCPP_INLINE_VISIBILITY size_type max_size() const throw() {return size_type(~0) / sizeof(_Tp);}
diff --git a/libcxx/include/__string b/libcxx/include/__string
index 9060bf98ad89..d8b672e4c1be 100644
--- a/libcxx/include/__string
+++ b/libcxx/include/__string
@@ -55,7 +55,9 @@ template <> struct char_traits<char8_t>; // c++20
#include <__config>
#include <algorithm> // for search and min
-#include <cstdio> // For EOF.
+#include <cstdio> // for EOF
+#include <cstring> // for memcpy
+#include <cwchar> // for wmemcpy
#include <memory> // for __murmur2_or_cityhash
#include <__debug>
@@ -92,7 +94,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
_Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type, size_type)) \
_Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&)) \
_Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, std::allocator<_CharType> const&)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, allocator<_CharType> const&)) \
_Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_not_of(value_type const*, size_type, size_type) const) \
_Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::~basic_string()) \
_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
_Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*, size_type)) \
_Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(basic_string const&, size_type, size_type)) \
_Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::copy(value_type*, size_type, size_type) const) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, size_type, size_type, std::allocator<_CharType> const&)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, size_type, size_type, allocator<_CharType> const&)) \
_Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type, size_type) const) \
_Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(size_type, value_type)) \
_Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*)) \
@@ -158,7 +160,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
_Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*, size_type)) \
_Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(basic_string const&, size_type, size_type)) \
_Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::copy(value_type*, size_type, size_type) const) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, size_type, size_type, std::allocator<_CharType> const&)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, size_type, size_type, allocator<_CharType> const&)) \
_Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type, size_type) const) \
_Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(size_type, value_type)) \
_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
return __s;
++__s;
}
- return 0;
+ return nullptr;
}
template <class _CharT>
@@ -318,7 +320,7 @@ char_traits<_CharT>::assign(char_type* __s, size_t __n, char_type __a)
// constexpr versions of move/copy/assign.
template <class _CharT>
-static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
+static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
_CharT* __move_constexpr(_CharT* __s1, const _CharT* __s2, size_t __n) _NOEXCEPT
{
if (__n == 0) return __s1;
@@ -331,7 +333,7 @@ _CharT* __move_constexpr(_CharT* __s1, const _CharT* __s2, size_t __n) _NOEXCEPT
}
template <class _CharT>
-static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
+static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
_CharT* __copy_constexpr(_CharT* __s1, const _CharT* __s2, size_t __n) _NOEXCEPT
{
_VSTD::copy_n(__s2, __n, __s1);
@@ -339,7 +341,7 @@ _CharT* __copy_constexpr(_CharT* __s1, const _CharT* __s2, size_t __n) _NOEXCEPT
}
template <class _CharT>
-static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
+static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
_CharT* __assign_constexpr(_CharT* __s, size_t __n, _CharT __a) _NOEXCEPT
{
_VSTD::fill_n(__s, __n, __a);
@@ -370,27 +372,27 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char>
length(const char_type* __s) _NOEXCEPT {return __builtin_strlen(__s);}
static _LIBCPP_CONSTEXPR_AFTER_CXX14
const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
- static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
+ static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{
return __libcpp_is_constant_evaluated()
- ? __move_constexpr(__s1, __s2, __n)
- : __n == 0 ? __s1 : (char_type*)memmove(__s1, __s2, __n);
+ ? _VSTD::__move_constexpr(__s1, __s2, __n)
+ : __n == 0 ? __s1 : (char_type*)_VSTD::memmove(__s1, __s2, __n);
}
- static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
+ static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{
_LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
return __libcpp_is_constant_evaluated()
- ? __copy_constexpr(__s1, __s2, __n)
- : __n == 0 ? __s1 : (char_type*)memcpy(__s1, __s2, __n);
+ ? _VSTD::__copy_constexpr(__s1, __s2, __n)
+ : __n == 0 ? __s1 : (char_type*)_VSTD::memcpy(__s1, __s2, __n);
}
- static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
+ static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
{
return __libcpp_is_constant_evaluated()
- ? __assign_constexpr(__s, __n, __a)
- : __n == 0 ? __s : (char_type*)memset(__s, to_int_type(__a), __n);
+ ? _VSTD::__assign_constexpr(__s, __n, __a)
+ : __n == 0 ? __s : (char_type*)_VSTD::memset(__s, to_int_type(__a), __n);
}
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
#if __has_feature(cxx_constexpr_string_builtins)
return __builtin_memcmp(__s1, __s2, __n);
#elif _LIBCPP_STD_VER <= 14
- return memcmp(__s1, __s2, __n);
+ return _VSTD::memcmp(__s1, __s2, __n);
#else
for (; __n; --__n, ++__s1, ++__s2)
{
@@ -436,7 +438,7 @@ char_traits<char>::find(const char_type* __s, size_t __n, const char_type& __a)
#if __has_feature(cxx_constexpr_string_builtins)
return __builtin_char_memchr(__s, to_int_type(__a), __n);
#elif _LIBCPP_STD_VER <= 14
- return (const char_type*) memchr(__s, to_int_type(__a), __n);
+ return (const char_type*) _VSTD::memchr(__s, to_int_type(__a), __n);
#else
for (; __n; --__n)
{
@@ -473,27 +475,27 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t>
size_t length(const char_type* __s) _NOEXCEPT;
static _LIBCPP_CONSTEXPR_AFTER_CXX14
const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
- static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
+ static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{
return __libcpp_is_constant_evaluated()
- ? __move_constexpr(__s1, __s2, __n)
- : __n == 0 ? __s1 : wmemmove(__s1, __s2, __n);
+ ? _VSTD::__move_constexpr(__s1, __s2, __n)
+ : __n == 0 ? __s1 : _VSTD::wmemmove(__s1, __s2, __n);
}
- static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
+ static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{
_LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
return __libcpp_is_constant_evaluated()
- ? __copy_constexpr(__s1, __s2, __n)
- : __n == 0 ? __s1 : wmemcpy(__s1, __s2, __n);
+ ? _VSTD::__copy_constexpr(__s1, __s2, __n)
+ : __n == 0 ? __s1 : _VSTD::wmemcpy(__s1, __s2, __n);
}
- static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
+ static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
{
return __libcpp_is_constant_evaluated()
- ? __assign_constexpr(__s, __n, __a)
- : __n == 0 ? __s : wmemset(__s, __a, __n);
+ ? _VSTD::__assign_constexpr(__s, __n, __a)
+ : __n == 0 ? __s : _VSTD::wmemset(__s, __a, __n);
}
static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
{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
#if __has_feature(cxx_constexpr_string_builtins)
return __builtin_wmemcmp(__s1, __s2, __n);
#elif _LIBCPP_STD_VER <= 14
- return wmemcmp(__s1, __s2, __n);
+ return _VSTD::wmemcmp(__s1, __s2, __n);
#else
for (; __n; --__n, ++__s1, ++__s2)
{
@@ -548,7 +550,7 @@ char_traits<wchar_t>::length(const char_type* __s) _NOEXCEPT
#if __has_feature(cxx_constexpr_string_builtins)
return __builtin_wcslen(__s);
#elif _LIBCPP_STD_VER <= 14
- return wcslen(__s);
+ return _VSTD::wcslen(__s);
#else
size_t __len = 0;
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& __
#if __has_feature(cxx_constexpr_string_builtins)
return __builtin_wmemchr(__s, __a, __n);
#elif _LIBCPP_STD_VER <= 14
- return wmemchr(__s, __a, __n);
+ return _VSTD::wmemchr(__s, __a, __n);
#else
for (; __n; --__n)
{
@@ -606,29 +608,29 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>
_LIBCPP_INLINE_VISIBILITY static constexpr
const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
- static _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
+ static _LIBCPP_CONSTEXPR_AFTER_CXX17
char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{
return __libcpp_is_constant_evaluated()
- ? __move_constexpr(__s1, __s2, __n)
- : __n == 0 ? __s1 : (char_type*)memmove(__s1, __s2, __n);
+ ? _VSTD::__move_constexpr(__s1, __s2, __n)
+ : __n == 0 ? __s1 : (char_type*)_VSTD::memmove(__s1, __s2, __n);
}
- static _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
+ static _LIBCPP_CONSTEXPR_AFTER_CXX17
char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{
_LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
return __libcpp_is_constant_evaluated()
- ? __copy_constexpr(__s1, __s2, __n)
- : __n == 0 ? __s1 : (char_type*)memcpy(__s1, __s2, __n);
+ ? _VSTD::__copy_constexpr(__s1, __s2, __n)
+ : __n == 0 ? __s1 : (char_type*)_VSTD::memcpy(__s1, __s2, __n);
}
- static _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
+ static _LIBCPP_CONSTEXPR_AFTER_CXX17
char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
{
return __libcpp_is_constant_evaluated()
- ? __assign_constexpr(__s, __n, __a)
- : __n == 0 ? __s : (char_type*)memset(__s, to_int_type(__a), __n);
+ ? _VSTD::__assign_constexpr(__s, __n, __a)
+ : __n == 0 ? __s : (char_type*)_VSTD::memset(__s, to_int_type(__a), __n);
}
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& __
return __s;
++__s;
}
- return 0;
+ return nullptr;
}
#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& _
return __s;
++__s;
}
- return 0;
+ return nullptr;
}
inline _LIBCPP_CONSTEXPR_AFTER_CXX17
@@ -885,7 +887,7 @@ char_traits<char32_t>::find(const char_type* __s, size_t __n, const char_type& _
return __s;
++__s;
}
- return 0;
+ return nullptr;
}
inline _LIBCPP_CONSTEXPR_AFTER_CXX17
@@ -943,7 +945,7 @@ __str_find(const _CharT *__p, _SizeT __sz,
if (__pos >= __sz)
return __npos;
const _CharT* __r = _Traits::find(__p + __pos, __sz - __pos, __c);
- if (__r == 0)
+ if (__r == nullptr)
return __npos;
return static_cast<_SizeT>(__r - __p);
}
@@ -972,7 +974,7 @@ __search_substring(const _CharT *__first1, const _CharT *__last1,
// Find __f2 the first byte matching in __first1.
__first1 = _Traits::find(__first1, __len1 - __len2 + 1, __f2);
- if (__first1 == 0)
+ if (__first1 == nullptr)
return __last1;
// 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,
{
const _CharT* __pe = __p + __sz;
for (const _CharT* __ps = __p + __pos; __ps != __pe; ++__ps)
- if (_Traits::find(__s, __n, *__ps) == 0)
+ if (_Traits::find(__s, __n, *__ps) == nullptr)
return static_cast<_SizeT>(__ps - __p);
}
return __npos;
@@ -1129,7 +1131,7 @@ __str_find_last_not_of(const _CharT *__p, _SizeT __sz,
else
__pos = __sz;
for (const _CharT* __ps = __p + __pos; __ps != __p;)
- if (_Traits::find(__s, __n, *--__ps) == 0)
+ if (_Traits::find(__s, __n, *--__ps) == nullptr)
return static_cast<_SizeT>(__ps - __p);
return __npos;
}
diff --git a/libcxx/include/__threading_support b/libcxx/include/__threading_support
index 072c4c7bcc89..473c9c3bbe49 100644
--- a/libcxx/include/__threading_support
+++ b/libcxx/include/__threading_support
@@ -11,10 +11,15 @@
#define _LIBCPP_THREADING_SUPPORT
#include <__config>
+#include <__availability>
#include <chrono>
#include <iosfwd>
#include <errno.h>
+#ifdef __MVS__
+# include <support/ibm/nanosleep.h>
+#endif
+
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
#pragma GCC system_header
#endif
@@ -26,7 +31,7 @@
#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
# include <pthread.h>
# include <sched.h>
-# ifdef __APPLE__
+# if defined(__APPLE__) || defined(__MVS__)
# define _LIBCPP_NO_NATIVE_SEMAPHORES
# endif
# ifndef _LIBCPP_NO_NATIVE_SEMAPHORES
@@ -82,11 +87,14 @@ typedef pthread_once_t __libcpp_exec_once_flag;
#define _LIBCPP_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT
// Thread id
-typedef pthread_t __libcpp_thread_id;
+#if defined(__MVS__)
+ typedef unsigned long long __libcpp_thread_id;
+#else
+ typedef pthread_t __libcpp_thread_id;
+#endif
// Thread
-#define _LIBCPP_NULL_THREAD 0U
-
+#define _LIBCPP_NULL_THREAD ((__libcpp_thread_t()))
typedef pthread_t __libcpp_thread_t;
// Thread Local Storage
@@ -278,24 +286,21 @@ int __libcpp_tls_set(__libcpp_tls_key __key, void *__p);
#endif // !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
struct __libcpp_timed_backoff_policy {
- _LIBCPP_THREAD_ABI_VISIBILITY
- bool operator()(chrono::nanoseconds __elapsed) const;
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(chrono::nanoseconds __elapsed) const
+ {
+ if(__elapsed > chrono::milliseconds(128))
+ __libcpp_thread_sleep_for(chrono::milliseconds(8));
+ else if(__elapsed > chrono::microseconds(64))
+ __libcpp_thread_sleep_for(__elapsed / 2);
+ else if(__elapsed > chrono::microseconds(4))
+ __libcpp_thread_yield();
+ else
+ {} // poll
+ return false;
+ }
};
-inline _LIBCPP_INLINE_VISIBILITY
-bool __libcpp_timed_backoff_policy::operator()(chrono::nanoseconds __elapsed) const
-{
- if(__elapsed > chrono::milliseconds(128))
- __libcpp_thread_sleep_for(chrono::milliseconds(8));
- else if(__elapsed > chrono::microseconds(64))
- __libcpp_thread_sleep_for(__elapsed / 2);
- else if(__elapsed > chrono::microseconds(4))
- __libcpp_thread_yield();
- else
- ; // poll
- return false;
-}
-
static _LIBCPP_CONSTEXPR const int __libcpp_polling_count = 64;
template<class _Fn, class _BFn>
@@ -484,7 +489,7 @@ int __libcpp_execute_once(__libcpp_exec_once_flag *flag,
// Returns non-zero if the thread ids are equal, otherwise 0
bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2)
{
- return pthread_equal(t1, t2) != 0;
+ return t1 == t2;
}
// 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)
// Thread
bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) {
- return *__t == 0;
+ return *__t == __libcpp_thread_t();
}
int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
void *__arg)
{
- return pthread_create(__t, 0, __func, __arg);
+ return pthread_create(__t, nullptr, __func, __arg);
}
__libcpp_thread_id __libcpp_thread_get_current_id()
{
- return pthread_self();
+ const __libcpp_thread_t thread = pthread_self();
+ return __libcpp_thread_get_id(&thread);
}
__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t)
{
+#if defined(__MVS__)
+ return __t->__;
+#else
return *__t;
+#endif
}
int __libcpp_thread_join(__libcpp_thread_t *__t)
{
- return pthread_join(*__t, 0);
+ return pthread_join(*__t, nullptr);
}
int __libcpp_thread_detach(__libcpp_thread_t *__t)
@@ -651,7 +661,7 @@ bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2)
// Thread
bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) {
- return *__t == 0;
+ return __libcpp_thread_get_id(__t) == 0;
}
int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
diff --git a/libcxx/include/__tree b/libcxx/include/__tree
index cb7a1022e626..0f6e4ec37921 100644
--- a/libcxx/include/__tree
+++ b/libcxx/include/__tree
@@ -108,10 +108,10 @@ __tree_sub_invariant(_NodePtr __x)
if (__x->__right_ && !__x->__right_->__is_black_)
return 0;
}
- unsigned __h = __tree_sub_invariant(__x->__left_);
+ unsigned __h = _VSTD::__tree_sub_invariant(__x->__left_);
if (__h == 0)
return 0; // invalid left subtree
- if (__h != __tree_sub_invariant(__x->__right_))
+ if (__h != _VSTD::__tree_sub_invariant(__x->__right_))
return 0; // invalid or different height right subtree
return __h + __x->__is_black_; // return black height of this node
}
@@ -128,13 +128,13 @@ __tree_invariant(_NodePtr __root)
// check __x->__parent_ consistency
if (__root->__parent_ == nullptr)
return false;
- if (!__tree_is_left_child(__root))
+ if (!_VSTD::__tree_is_left_child(__root))
return false;
// root must be black
if (!__root->__is_black_)
return false;
// do normal node checks
- return __tree_sub_invariant(__root) != 0;
+ return _VSTD::__tree_sub_invariant(__root) != 0;
}
// Returns: pointer to the left-most node under __x.
@@ -168,8 +168,8 @@ _NodePtr
__tree_next(_NodePtr __x) _NOEXCEPT
{
if (__x->__right_ != nullptr)
- return __tree_min(__x->__right_);
- while (!__tree_is_left_child(__x))
+ return _VSTD::__tree_min(__x->__right_);
+ while (!_VSTD::__tree_is_left_child(__x))
__x = __x->__parent_unsafe();
return __x->__parent_unsafe();
}
@@ -180,8 +180,8 @@ _EndNodePtr
__tree_next_iter(_NodePtr __x) _NOEXCEPT
{
if (__x->__right_ != nullptr)
- return static_cast<_EndNodePtr>(__tree_min(__x->__right_));
- while (!__tree_is_left_child(__x))
+ return static_cast<_EndNodePtr>(_VSTD::__tree_min(__x->__right_));
+ while (!_VSTD::__tree_is_left_child(__x))
__x = __x->__parent_unsafe();
return static_cast<_EndNodePtr>(__x->__parent_);
}
@@ -195,9 +195,9 @@ _NodePtr
__tree_prev_iter(_EndNodePtr __x) _NOEXCEPT
{
if (__x->__left_ != nullptr)
- return __tree_max(__x->__left_);
+ return _VSTD::__tree_max(__x->__left_);
_NodePtr __xx = static_cast<_NodePtr>(__x);
- while (__tree_is_left_child(__xx))
+ while (_VSTD::__tree_is_left_child(__xx))
__xx = __xx->__parent_unsafe();
return __xx->__parent_unsafe();
}
@@ -237,7 +237,7 @@ __tree_left_rotate(_NodePtr __x) _NOEXCEPT
if (__x->__right_ != nullptr)
__x->__right_->__set_parent(__x);
__y->__parent_ = __x->__parent_;
- if (__tree_is_left_child(__x))
+ if (_VSTD::__tree_is_left_child(__x))
__x->__parent_->__left_ = __y;
else
__x->__parent_unsafe()->__right_ = __y;
@@ -257,7 +257,7 @@ __tree_right_rotate(_NodePtr __x) _NOEXCEPT
if (__x->__left_ != nullptr)
__x->__left_->__set_parent(__x);
__y->__parent_ = __x->__parent_;
- if (__tree_is_left_child(__x))
+ if (_VSTD::__tree_is_left_child(__x))
__x->__parent_->__left_ = __y;
else
__x->__parent_unsafe()->__right_ = __y;
@@ -281,7 +281,7 @@ __tree_balance_after_insert(_NodePtr __root, _NodePtr __x) _NOEXCEPT
while (__x != __root && !__x->__parent_unsafe()->__is_black_)
{
// __x->__parent_ != __root because __x->__parent_->__is_black == false
- if (__tree_is_left_child(__x->__parent_unsafe()))
+ if (_VSTD::__tree_is_left_child(__x->__parent_unsafe()))
{
_NodePtr __y = __x->__parent_unsafe()->__parent_unsafe()->__right_;
if (__y != nullptr && !__y->__is_black_)
@@ -294,16 +294,16 @@ __tree_balance_after_insert(_NodePtr __root, _NodePtr __x) _NOEXCEPT
}
else
{
- if (!__tree_is_left_child(__x))
+ if (!_VSTD::__tree_is_left_child(__x))
{
__x = __x->__parent_unsafe();
- __tree_left_rotate(__x);
+ _VSTD::__tree_left_rotate(__x);
}
__x = __x->__parent_unsafe();
__x->__is_black_ = true;
__x = __x->__parent_unsafe();
__x->__is_black_ = false;
- __tree_right_rotate(__x);
+ _VSTD::__tree_right_rotate(__x);
break;
}
}
@@ -320,16 +320,16 @@ __tree_balance_after_insert(_NodePtr __root, _NodePtr __x) _NOEXCEPT
}
else
{
- if (__tree_is_left_child(__x))
+ if (_VSTD::__tree_is_left_child(__x))
{
__x = __x->__parent_unsafe();
- __tree_right_rotate(__x);
+ _VSTD::__tree_right_rotate(__x);
}
__x = __x->__parent_unsafe();
__x->__is_black_ = true;
__x = __x->__parent_unsafe();
__x->__is_black_ = false;
- __tree_left_rotate(__x);
+ _VSTD::__tree_left_rotate(__x);
break;
}
}
@@ -352,7 +352,7 @@ __tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEPT
// __y will have at most one child.
// __y will be the initial hole in the tree (make the hole at a leaf)
_NodePtr __y = (__z->__left_ == nullptr || __z->__right_ == nullptr) ?
- __z : __tree_next(__z);
+ __z : _VSTD::__tree_next(__z);
// __x is __y's possibly null single child
_NodePtr __x = __y->__left_ != nullptr ? __y->__left_ : __y->__right_;
// __w is __x's possibly null uncle (will become __x's sibling)
@@ -360,7 +360,7 @@ __tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEPT
// link __x to __y's parent, and find __w
if (__x != nullptr)
__x->__parent_ = __y->__parent_;
- if (__tree_is_left_child(__y))
+ if (_VSTD::__tree_is_left_child(__y))
{
__y->__parent_->__left_ = __x;
if (__y != __root)
@@ -381,7 +381,7 @@ __tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEPT
{
// __z->__left_ != nulptr but __z->__right_ might == __x == nullptr
__y->__parent_ = __z->__parent_;
- if (__tree_is_left_child(__z))
+ if (_VSTD::__tree_is_left_child(__z))
__y->__parent_->__left_ = __y;
else
__y->__parent_unsafe()->__right_ = __y;
@@ -421,13 +421,13 @@ __tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEPT
// with a non-null black child).
while (true)
{
- if (!__tree_is_left_child(__w)) // if x is left child
+ if (!_VSTD::__tree_is_left_child(__w)) // if x is left child
{
if (!__w->__is_black_)
{
__w->__is_black_ = true;
__w->__parent_unsafe()->__is_black_ = false;
- __tree_left_rotate(__w->__parent_unsafe());
+ _VSTD::__tree_left_rotate(__w->__parent_unsafe());
// __x is still valid
// reset __root only if necessary
if (__root == __w->__left_)
@@ -448,7 +448,7 @@ __tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEPT
break;
}
// reset sibling, and it still can't be null
- __w = __tree_is_left_child(__x) ?
+ __w = _VSTD::__tree_is_left_child(__x) ?
__x->__parent_unsafe()->__right_ :
__x->__parent_->__left_;
// continue;
@@ -460,7 +460,7 @@ __tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEPT
// __w left child is non-null and red
__w->__left_->__is_black_ = true;
__w->__is_black_ = false;
- __tree_right_rotate(__w);
+ _VSTD::__tree_right_rotate(__w);
// __w is known not to be root, so root hasn't changed
// reset sibling, and it still can't be null
__w = __w->__parent_unsafe();
@@ -469,7 +469,7 @@ __tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEPT
__w->__is_black_ = __w->__parent_unsafe()->__is_black_;
__w->__parent_unsafe()->__is_black_ = true;
__w->__right_->__is_black_ = true;
- __tree_left_rotate(__w->__parent_unsafe());
+ _VSTD::__tree_left_rotate(__w->__parent_unsafe());
break;
}
}
@@ -479,7 +479,7 @@ __tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEPT
{
__w->__is_black_ = true;
__w->__parent_unsafe()->__is_black_ = false;
- __tree_right_rotate(__w->__parent_unsafe());
+ _VSTD::__tree_right_rotate(__w->__parent_unsafe());
// __x is still valid
// reset __root only if necessary
if (__root == __w->__right_)
@@ -500,7 +500,7 @@ __tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEPT
break;
}
// reset sibling, and it still can't be null
- __w = __tree_is_left_child(__x) ?
+ __w = _VSTD::__tree_is_left_child(__x) ?
__x->__parent_unsafe()->__right_ :
__x->__parent_->__left_;
// continue;
@@ -512,7 +512,7 @@ __tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEPT
// __w right child is non-null and red
__w->__right_->__is_black_ = true;
__w->__is_black_ = false;
- __tree_left_rotate(__w);
+ _VSTD::__tree_left_rotate(__w);
// __w is known not to be root, so root hasn't changed
// reset sibling, and it still can't be null
__w = __w->__parent_unsafe();
@@ -521,7 +521,7 @@ __tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEPT
__w->__is_black_ = __w->__parent_unsafe()->__is_black_;
__w->__parent_unsafe()->__is_black_ = true;
__w->__left_->__is_black_ = true;
- __tree_right_rotate(__w->__parent_unsafe());
+ _VSTD::__tree_right_rotate(__w->__parent_unsafe());
break;
}
}
@@ -533,19 +533,17 @@ __tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEPT
// node traits
-#ifndef _LIBCPP_CXX03_LANG
template <class _Tp>
struct __is_tree_value_type_imp : false_type {};
template <class _Key, class _Value>
-struct __is_tree_value_type_imp<__value_type<_Key, _Value>> : true_type {};
+struct __is_tree_value_type_imp<__value_type<_Key, _Value> > : true_type {};
template <class ..._Args>
struct __is_tree_value_type : false_type {};
template <class _One>
struct __is_tree_value_type<_One> : __is_tree_value_type_imp<typename __uncvref<_One>::type> {};
-#endif
template <class _Tp>
struct __tree_key_value_types {
@@ -566,12 +564,10 @@ struct __tree_key_value_types {
static __container_value_type* __get_ptr(__node_value_type& __n) {
return _VSTD::addressof(__n);
}
-#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
static __container_value_type&& __move(__node_value_type& __v) {
return _VSTD::move(__v);
}
-#endif
};
template <class _Key, class _Tp>
@@ -616,12 +612,10 @@ struct __tree_key_value_types<__value_type<_Key, _Tp> > {
return _VSTD::addressof(__n.__get_value());
}
-#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
static pair<key_type&&, mapped_type&&> __move(__node_value_type& __v) {
return __v.__move();
}
-#endif
};
template <class _VoidPtr>
@@ -845,7 +839,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
__tree_iterator& operator++() {
__ptr_ = static_cast<__iter_pointer>(
- __tree_next_iter<__end_node_pointer>(static_cast<__node_base_pointer>(__ptr_)));
+ _VSTD::__tree_next_iter<__end_node_pointer>(static_cast<__node_base_pointer>(__ptr_)));
return *this;
}
_LIBCPP_INLINE_VISIBILITY
@@ -854,7 +848,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
__tree_iterator& operator--() {
- __ptr_ = static_cast<__iter_pointer>(__tree_prev_iter<__node_base_pointer>(
+ __ptr_ = static_cast<__iter_pointer>(_VSTD::__tree_prev_iter<__node_base_pointer>(
static_cast<__end_node_pointer>(__ptr_)));
return *this;
}
@@ -926,7 +920,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
__tree_const_iterator& operator++() {
__ptr_ = static_cast<__iter_pointer>(
- __tree_next_iter<__end_node_pointer>(static_cast<__node_base_pointer>(__ptr_)));
+ _VSTD::__tree_next_iter<__end_node_pointer>(static_cast<__node_base_pointer>(__ptr_)));
return *this;
}
@@ -936,7 +930,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
__tree_const_iterator& operator--() {
- __ptr_ = static_cast<__iter_pointer>(__tree_prev_iter<__node_base_pointer>(
+ __ptr_ = static_cast<__iter_pointer>(_VSTD::__tree_prev_iter<__node_base_pointer>(
static_cast<__end_node_pointer>(__ptr_)));
return *this;
}
@@ -973,7 +967,7 @@ private:
template<class _Tp, class _Compare>
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_DIAGNOSE_WARNING(!std::__invokable<_Compare const&, _Tp const&, _Tp const&>::value,
+ _LIBCPP_DIAGNOSE_WARNING(!__invokable<_Compare const&, _Tp const&, _Tp const&>::value,
"the specified comparator type does not provide a viable const call operator")
#endif
int __diagnose_non_const_comparator();
@@ -1103,7 +1097,6 @@ public:
void __assign_unique(_ForwardIterator __first, _ForwardIterator __last);
template <class _InputIterator>
void __assign_multi(_InputIterator __first, _InputIterator __last);
-#ifndef _LIBCPP_CXX03_LANG
__tree(__tree&& __t)
_NOEXCEPT_(
is_nothrow_move_constructible<__node_allocator>::value &&
@@ -1114,8 +1107,6 @@ public:
__node_traits::propagate_on_container_move_assignment::value &&
is_nothrow_move_assignable<value_compare>::value &&
is_nothrow_move_assignable<__node_allocator>::value);
-#endif // _LIBCPP_CXX03_LANG
-
~__tree();
_LIBCPP_INLINE_VISIBILITY
@@ -1129,7 +1120,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
size_type max_size() const _NOEXCEPT
- {return std::min<size_type>(
+ {return _VSTD::min<size_type>(
__node_traits::max_size(__node_alloc()),
numeric_limits<difference_type >::max());}
@@ -1146,12 +1137,11 @@ public:
_NOEXCEPT_(__is_nothrow_swappable<value_compare>::value);
#endif
-#ifndef _LIBCPP_CXX03_LANG
template <class _Key, class ..._Args>
pair<iterator, bool>
__emplace_unique_key_args(_Key const&, _Args&&... __args);
template <class _Key, class ..._Args>
- iterator
+ pair<iterator, bool>
__emplace_hint_unique_key_args(const_iterator, _Key const&, _Args&&...);
template <class... _Args>
@@ -1225,7 +1215,7 @@ public:
>::type __emplace_hint_unique(const_iterator __p, _First&& __f, _Second&& __s) {
return __emplace_hint_unique_key_args(__p, __f,
_VSTD::forward<_First>(__f),
- _VSTD::forward<_Second>(__s));
+ _VSTD::forward<_Second>(__s)).first;
}
template <class... _Args>
@@ -1245,25 +1235,16 @@ public:
_LIBCPP_INLINE_VISIBILITY
iterator
__emplace_hint_unique_extract_key(const_iterator __p, _Pp&& __x, __extract_key_self_tag) {
- return __emplace_hint_unique_key_args(__p, __x, _VSTD::forward<_Pp>(__x));
+ return __emplace_hint_unique_key_args(__p, __x, _VSTD::forward<_Pp>(__x)).first;
}
template <class _Pp>
_LIBCPP_INLINE_VISIBILITY
iterator
__emplace_hint_unique_extract_key(const_iterator __p, _Pp&& __x, __extract_key_first_tag) {
- return __emplace_hint_unique_key_args(__p, __x.first, _VSTD::forward<_Pp>(__x));
+ return __emplace_hint_unique_key_args(__p, __x.first, _VSTD::forward<_Pp>(__x)).first;
}
-#else
- template <class _Key, class _Args>
- _LIBCPP_INLINE_VISIBILITY
- pair<iterator, bool> __emplace_unique_key_args(_Key const&, _Args& __args);
- template <class _Key, class _Args>
- _LIBCPP_INLINE_VISIBILITY
- iterator __emplace_hint_unique_key_args(const_iterator, _Key const&, _Args&);
-#endif
-
_LIBCPP_INLINE_VISIBILITY
pair<iterator, bool> __insert_unique(const __container_value_type& __v) {
return __emplace_unique_key_args(_NodeTypes::__get_key(__v), __v);
@@ -1271,15 +1252,9 @@ public:
_LIBCPP_INLINE_VISIBILITY
iterator __insert_unique(const_iterator __p, const __container_value_type& __v) {
- return __emplace_hint_unique_key_args(__p, _NodeTypes::__get_key(__v), __v);
+ return __emplace_hint_unique_key_args(__p, _NodeTypes::__get_key(__v), __v).first;
}
-#ifdef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
- iterator __insert_multi(const __container_value_type& __v);
- _LIBCPP_INLINE_VISIBILITY
- iterator __insert_multi(const_iterator __p, const __container_value_type& __v);
-#else
_LIBCPP_INLINE_VISIBILITY
pair<iterator, bool> __insert_unique(__container_value_type&& __v) {
return __emplace_unique_key_args(_NodeTypes::__get_key(__v), _VSTD::move(__v));
@@ -1287,7 +1262,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
iterator __insert_unique(const_iterator __p, __container_value_type&& __v) {
- return __emplace_hint_unique_key_args(__p, _NodeTypes::__get_key(__v), _VSTD::move(__v));
+ return __emplace_hint_unique_key_args(__p, _NodeTypes::__get_key(__v), _VSTD::move(__v)).first;
}
template <class _Vp, class = typename enable_if<
@@ -1332,8 +1307,6 @@ public:
return __emplace_hint_multi(__p, _VSTD::forward<_Vp>(__v));
}
-#endif // !_LIBCPP_CXX03_LANG
-
_LIBCPP_INLINE_VISIBILITY
pair<iterator, bool> __node_assign_unique(const __container_value_type& __v, __node_pointer __dest);
@@ -1455,7 +1428,7 @@ private:
__node_base_pointer&
__find_leaf(const_iterator __hint,
__parent_pointer& __parent, const key_type& __v);
- // FIXME: Make this function const qualified. Unfortunetly doing so
+ // FIXME: Make this function const qualified. Unfortunately doing so
// breaks existing code which uses non-const callable comparators.
template <class _Key>
__node_base_pointer&
@@ -1471,12 +1444,8 @@ private:
__node_base_pointer& __dummy,
const _Key& __v);
-#ifndef _LIBCPP_CXX03_LANG
template <class ..._Args>
__node_holder __construct_node(_Args&& ...__args);
-#else
- __node_holder __construct_node(const __container_value_type& __v);
-#endif
void destroy(__node_pointer __nd) _NOEXCEPT;
@@ -1621,20 +1590,20 @@ __tree<_Tp, _Compare, _Allocator>::_DetachedTreeCache::__detach_next(__node_poin
{
if (__cache->__parent_ == nullptr)
return nullptr;
- if (__tree_is_left_child(static_cast<__node_base_pointer>(__cache)))
+ if (_VSTD::__tree_is_left_child(static_cast<__node_base_pointer>(__cache)))
{
__cache->__parent_->__left_ = nullptr;
__cache = static_cast<__node_pointer>(__cache->__parent_);
if (__cache->__right_ == nullptr)
return __cache;
- return static_cast<__node_pointer>(__tree_leaf(__cache->__right_));
+ return static_cast<__node_pointer>(_VSTD::__tree_leaf(__cache->__right_));
}
// __cache is right child
__cache->__parent_unsafe()->__right_ = nullptr;
__cache = static_cast<__node_pointer>(__cache->__parent_);
if (__cache->__left_ == nullptr)
return __cache;
- return static_cast<__node_pointer>(__tree_leaf(__cache->__left_));
+ return static_cast<__node_pointer>(_VSTD::__tree_leaf(__cache->__left_));
}
template <class _Tp, class _Compare, class _Allocator>
@@ -1706,8 +1675,6 @@ __tree<_Tp, _Compare, _Allocator>::__tree(const __tree& __t)
__begin_node() = __end_node();
}
-#ifndef _LIBCPP_CXX03_LANG
-
template <class _Tp, class _Compare, class _Allocator>
__tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t)
_NOEXCEPT_(
@@ -1814,8 +1781,6 @@ __tree<_Tp, _Compare, _Allocator>::operator=(__tree&& __t)
return *this;
}
-#endif // _LIBCPP_CXX03_LANG
-
template <class _Tp, class _Compare, class _Allocator>
__tree<_Tp, _Compare, _Allocator>::~__tree()
{
@@ -1854,7 +1819,7 @@ __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t)
using _VSTD::swap;
swap(__begin_node_, __t.__begin_node_);
swap(__pair1_.first(), __t.__pair1_.first());
- __swap_allocator(__node_alloc(), __t.__node_alloc());
+ _VSTD::__swap_allocator(__node_alloc(), __t.__node_alloc());
__pair3_.swap(__t.__pair3_);
if (size() == 0)
__begin_node() = __end_node();
@@ -2113,21 +2078,14 @@ void __tree<_Tp, _Compare, _Allocator>::__insert_node_at(
__child = __new_node;
if (__begin_node()->__left_ != nullptr)
__begin_node() = static_cast<__iter_pointer>(__begin_node()->__left_);
- __tree_balance_after_insert(__end_node()->__left_, __child);
+ _VSTD::__tree_balance_after_insert(__end_node()->__left_, __child);
++size();
}
-#ifndef _LIBCPP_CXX03_LANG
template <class _Tp, class _Compare, class _Allocator>
template <class _Key, class... _Args>
pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>
__tree<_Tp, _Compare, _Allocator>::__emplace_unique_key_args(_Key const& __k, _Args&&... __args)
-#else
-template <class _Tp, class _Compare, class _Allocator>
-template <class _Key, class _Args>
-pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>
-__tree<_Tp, _Compare, _Allocator>::__emplace_unique_key_args(_Key const& __k, _Args& __args)
-#endif
{
__parent_pointer __parent;
__node_base_pointer& __child = __find_equal(__parent, __k);
@@ -2135,11 +2093,7 @@ __tree<_Tp, _Compare, _Allocator>::__emplace_unique_key_args(_Key const& __k, _A
bool __inserted = false;
if (__child == nullptr)
{
-#ifndef _LIBCPP_CXX03_LANG
__node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
-#else
- __node_holder __h = __construct_node(__args);
-#endif
__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
__r = __h.release();
__inserted = true;
@@ -2147,41 +2101,27 @@ __tree<_Tp, _Compare, _Allocator>::__emplace_unique_key_args(_Key const& __k, _A
return pair<iterator, bool>(iterator(__r), __inserted);
}
-
-#ifndef _LIBCPP_CXX03_LANG
template <class _Tp, class _Compare, class _Allocator>
template <class _Key, class... _Args>
-typename __tree<_Tp, _Compare, _Allocator>::iterator
+pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>
__tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_key_args(
const_iterator __p, _Key const& __k, _Args&&... __args)
-#else
-template <class _Tp, class _Compare, class _Allocator>
-template <class _Key, class _Args>
-typename __tree<_Tp, _Compare, _Allocator>::iterator
-__tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_key_args(
- const_iterator __p, _Key const& __k, _Args& __args)
-#endif
{
__parent_pointer __parent;
__node_base_pointer __dummy;
__node_base_pointer& __child = __find_equal(__p, __parent, __dummy, __k);
__node_pointer __r = static_cast<__node_pointer>(__child);
+ bool __inserted = false;
if (__child == nullptr)
{
-#ifndef _LIBCPP_CXX03_LANG
__node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
-#else
- __node_holder __h = __construct_node(__args);
-#endif
__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
__r = __h.release();
+ __inserted = true;
}
- return iterator(__r);
+ return pair<iterator, bool>(iterator(__r), __inserted);
}
-
-#ifndef _LIBCPP_CXX03_LANG
-
template <class _Tp, class _Compare, class _Allocator>
template <class ..._Args>
typename __tree<_Tp, _Compare, _Allocator>::__node_holder
@@ -2259,46 +2199,6 @@ __tree<_Tp, _Compare, _Allocator>::__emplace_hint_multi(const_iterator __p,
return iterator(static_cast<__node_pointer>(__h.release()));
}
-
-#else // _LIBCPP_CXX03_LANG
-
-template <class _Tp, class _Compare, class _Allocator>
-typename __tree<_Tp, _Compare, _Allocator>::__node_holder
-__tree<_Tp, _Compare, _Allocator>::__construct_node(const __container_value_type& __v)
-{
- __node_allocator& __na = __node_alloc();
- __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
- __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), __v);
- __h.get_deleter().__value_constructed = true;
- return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03
-}
-
-#endif // _LIBCPP_CXX03_LANG
-
-#ifdef _LIBCPP_CXX03_LANG
-template <class _Tp, class _Compare, class _Allocator>
-typename __tree<_Tp, _Compare, _Allocator>::iterator
-__tree<_Tp, _Compare, _Allocator>::__insert_multi(const __container_value_type& __v)
-{
- __parent_pointer __parent;
- __node_base_pointer& __child = __find_leaf_high(__parent, _NodeTypes::__get_key(__v));
- __node_holder __h = __construct_node(__v);
- __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
- return iterator(__h.release());
-}
-
-template <class _Tp, class _Compare, class _Allocator>
-typename __tree<_Tp, _Compare, _Allocator>::iterator
-__tree<_Tp, _Compare, _Allocator>::__insert_multi(const_iterator __p, const __container_value_type& __v)
-{
- __parent_pointer __parent;
- __node_base_pointer& __child = __find_leaf(__p, __parent, _NodeTypes::__get_key(__v));
- __node_holder __h = __construct_node(__v);
- __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
- return iterator(__h.release());
-}
-#endif
-
template <class _Tp, class _Compare, class _Allocator>
pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>
__tree<_Tp, _Compare, _Allocator>::__node_assign_unique(const __container_value_type& __v, __node_pointer __nd)
@@ -2348,8 +2248,8 @@ __tree<_Tp, _Compare, _Allocator>::__remove_node_pointer(__node_pointer __ptr) _
if (__begin_node() == __ptr)
__begin_node() = __r.__ptr_;
--size();
- __tree_remove(__end_node()->__left_,
- static_cast<__node_base_pointer>(__ptr));
+ _VSTD::__tree_remove(__end_node()->__left_,
+ static_cast<__node_base_pointer>(__ptr));
return __r;
}
@@ -2727,7 +2627,7 @@ __tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k)
return _Pp(iterator(__rt),
iterator(
__rt->__right_ != nullptr ?
- static_cast<__iter_pointer>(__tree_min(__rt->__right_))
+ static_cast<__iter_pointer>(_VSTD::__tree_min(__rt->__right_))
: __result));
}
return _Pp(iterator(__result), iterator(__result));
@@ -2755,7 +2655,7 @@ __tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) const
return _Pp(const_iterator(__rt),
const_iterator(
__rt->__right_ != nullptr ?
- static_cast<__iter_pointer>(__tree_min(__rt->__right_))
+ static_cast<__iter_pointer>(_VSTD::__tree_min(__rt->__right_))
: __result));
}
return _Pp(const_iterator(__result), const_iterator(__result));
@@ -2824,8 +2724,8 @@ __tree<_Tp, _Compare, _Allocator>::remove(const_iterator __p) _NOEXCEPT
__begin_node() = static_cast<__iter_pointer>(__np->__parent_);
}
--size();
- __tree_remove(__end_node()->__left_,
- static_cast<__node_base_pointer>(__np));
+ _VSTD::__tree_remove(__end_node()->__left_,
+ static_cast<__node_base_pointer>(__np));
return __node_holder(__np, _Dp(__node_alloc(), true));
}
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 83e49f19ab98..f7fb2013a757 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -47,16 +47,16 @@ template <class InputIterator, class Predicate>
find_if(InputIterator first, InputIterator last, Predicate pred);
template<class InputIterator, class Predicate>
- InputIterator // constexpr in C++20
+ constexpr InputIterator // constexpr in C++20
find_if_not(InputIterator first, InputIterator last, Predicate pred);
template <class ForwardIterator1, class ForwardIterator2>
- ForwardIterator1 // constexpr in C++20
+ constexpr ForwardIterator1 // constexpr in C++20
find_end(ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2);
template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
- ForwardIterator1 // constexpr in C++20
+ constexpr ForwardIterator1 // constexpr in C++20
find_end(ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
@@ -185,11 +185,11 @@ template <class BidirectionalIterator1, class BidirectionalIterator2>
BidirectionalIterator2 result);
template <class ForwardIterator1, class ForwardIterator2>
- ForwardIterator2
+ constexpr ForwardIterator2 // constexpr in C++20
swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2);
template <class ForwardIterator1, class ForwardIterator2>
- void
+ constexpr void // constexpr in C++20
iter_swap(ForwardIterator1 a, ForwardIterator2 b);
template <class InputIterator, class OutputIterator, class UnaryOperation>
@@ -251,23 +251,23 @@ template <class InputIterator, class OutputIterator, class Predicate>
remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred);
template <class ForwardIterator>
- ForwardIterator
+ constexpr ForwardIterator // constexpr in C++20
unique(ForwardIterator first, ForwardIterator last);
template <class ForwardIterator, class BinaryPredicate>
- ForwardIterator
+ constexpr ForwardIterator // constexpr in C++20
unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
template <class InputIterator, class OutputIterator>
- OutputIterator
+ constexpr OutputIterator // constexpr in C++20
unique_copy(InputIterator first, InputIterator last, OutputIterator result);
template <class InputIterator, class OutputIterator, class BinaryPredicate>
- OutputIterator
+ constexpr OutputIterator // constexpr in C++20
unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred);
template <class BidirectionalIterator>
- void
+ constexpr void // constexpr in C++20
reverse(BidirectionalIterator first, BidirectionalIterator last);
template <class BidirectionalIterator, class OutputIterator>
@@ -275,11 +275,11 @@ template <class BidirectionalIterator, class OutputIterator>
reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result);
template <class ForwardIterator>
- ForwardIterator
+ constexpr ForwardIterator // constexpr in C++20
rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last);
template <class ForwardIterator, class OutputIterator>
- OutputIterator
+ constexpr OutputIterator // constexpr in C++20
rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result);
template <class RandomAccessIterator>
@@ -301,12 +301,22 @@ template<class RandomAccessIterator, class UniformRandomNumberGenerator>
void shuffle(RandomAccessIterator first, RandomAccessIterator last,
UniformRandomNumberGenerator&& g);
+template<class ForwardIterator>
+ constexpr ForwardIterator
+ shift_left(ForwardIterator first, ForwardIterator last,
+ typename iterator_traits<ForwardIterator>::difference_type n); // C++20
+
+template<class ForwardIterator>
+ constexpr ForwardIterator
+ shift_right(ForwardIterator first, ForwardIterator last,
+ typename iterator_traits<ForwardIterator>::difference_type n); // C++20
+
template <class InputIterator, class Predicate>
constexpr bool // constexpr in C++20
is_partitioned(InputIterator first, InputIterator last, Predicate pred);
template <class ForwardIterator, class Predicate>
- ForwardIterator
+ constexpr ForwardIterator // constexpr in C++20
partition(ForwardIterator first, ForwardIterator last, Predicate pred);
template <class InputIterator, class OutputIterator1,
@@ -329,7 +339,7 @@ template <class ForwardIterator>
is_sorted(ForwardIterator first, ForwardIterator last);
template <class ForwardIterator, class Compare>
- bool
+ constexpr bool // constexpr in C++20
is_sorted(ForwardIterator first, ForwardIterator last, Compare comp);
template<class ForwardIterator>
@@ -415,12 +425,12 @@ template <class ForwardIterator, class T, class Compare>
binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
template <class InputIterator1, class InputIterator2, class OutputIterator>
- OutputIterator
+ constexpr OutputIterator // constexpr in C++20
merge(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2, OutputIterator result);
template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
- OutputIterator
+ constexpr OutputIterator // constexpr in C++20
merge(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
@@ -441,12 +451,12 @@ template <class InputIterator1, class InputIterator2, class Compare>
includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp);
template <class InputIterator1, class InputIterator2, class OutputIterator>
- OutputIterator
+ constexpr OutputIterator // constexpr in C++20
set_union(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2, OutputIterator result);
template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
- OutputIterator
+ constexpr OutputIterator // constexpr in C++20
set_union(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
@@ -461,22 +471,22 @@ template <class InputIterator1, class InputIterator2, class OutputIterator, clas
InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
template <class InputIterator1, class InputIterator2, class OutputIterator>
- OutputIterator
+ constexpr OutputIterator // constexpr in C++20
set_difference(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2, OutputIterator result);
template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
- OutputIterator
+ constexpr OutputIterator // constexpr in C++20
set_difference(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
template <class InputIterator1, class InputIterator2, class OutputIterator>
- OutputIterator
+ constexpr OutputIterator // constexpr in C++20
set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2, OutputIterator result);
template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
- OutputIterator
+ constexpr OutputIterator // constexpr in C++20
set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
@@ -529,82 +539,82 @@ template <class RandomAccessIterator, class Compare>
is_heap_until(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
template <class ForwardIterator>
- ForwardIterator
- min_element(ForwardIterator first, ForwardIterator last); // constexpr in C++14
+ constexpr ForwardIterator // constexpr in C++14
+ min_element(ForwardIterator first, ForwardIterator last);
template <class ForwardIterator, class Compare>
- ForwardIterator
- min_element(ForwardIterator first, ForwardIterator last, Compare comp); // constexpr in C++14
+ constexpr ForwardIterator // constexpr in C++14
+ min_element(ForwardIterator first, ForwardIterator last, Compare comp);
template <class T>
- const T&
- min(const T& a, const T& b); // constexpr in C++14
+ constexpr const T& // constexpr in C++14
+ min(const T& a, const T& b);
template <class T, class Compare>
- const T&
- min(const T& a, const T& b, Compare comp); // constexpr in C++14
+ constexpr const T& // constexpr in C++14
+ min(const T& a, const T& b, Compare comp);
template<class T>
- T
- min(initializer_list<T> t); // constexpr in C++14
+ constexpr T // constexpr in C++14
+ min(initializer_list<T> t);
template<class T, class Compare>
- T
- min(initializer_list<T> t, Compare comp); // constexpr in C++14
+ constexpr T // constexpr in C++14
+ min(initializer_list<T> t, Compare comp);
template<class T>
- constexpr const T& clamp( const T& v, const T& lo, const T& hi ); // C++17
+ constexpr const T& clamp(const T& v, const T& lo, const T& hi); // C++17
template<class T, class Compare>
- constexpr const T& clamp( const T& v, const T& lo, const T& hi, Compare comp ); // C++17
+ constexpr const T& clamp(const T& v, const T& lo, const T& hi, Compare comp); // C++17
template <class ForwardIterator>
- ForwardIterator
- max_element(ForwardIterator first, ForwardIterator last); // constexpr in C++14
+ constexpr ForwardIterator // constexpr in C++14
+ max_element(ForwardIterator first, ForwardIterator last);
template <class ForwardIterator, class Compare>
- ForwardIterator
- max_element(ForwardIterator first, ForwardIterator last, Compare comp); // constexpr in C++14
+ constexpr ForwardIterator // constexpr in C++14
+ max_element(ForwardIterator first, ForwardIterator last, Compare comp);
template <class T>
- const T&
- max(const T& a, const T& b); // constexpr in C++14
+ constexpr const T& // constexpr in C++14
+ max(const T& a, const T& b);
template <class T, class Compare>
- const T&
- max(const T& a, const T& b, Compare comp); // constexpr in C++14
+ constexpr const T& // constexpr in C++14
+ max(const T& a, const T& b, Compare comp);
template<class T>
- T
- max(initializer_list<T> t); // constexpr in C++14
+ constexpr T // constexpr in C++14
+ max(initializer_list<T> t);
template<class T, class Compare>
- T
- max(initializer_list<T> t, Compare comp); // constexpr in C++14
+ constexpr T // constexpr in C++14
+ max(initializer_list<T> t, Compare comp);
template<class ForwardIterator>
- pair<ForwardIterator, ForwardIterator>
- minmax_element(ForwardIterator first, ForwardIterator last); // constexpr in C++14
+ constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
+ minmax_element(ForwardIterator first, ForwardIterator last);
template<class ForwardIterator, class Compare>
- pair<ForwardIterator, ForwardIterator>
- minmax_element(ForwardIterator first, ForwardIterator last, Compare comp); // constexpr in C++14
+ constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
+ minmax_element(ForwardIterator first, ForwardIterator last, Compare comp);
template<class T>
- pair<const T&, const T&>
- minmax(const T& a, const T& b); // constexpr in C++14
+ constexpr pair<const T&, const T&> // constexpr in C++14
+ minmax(const T& a, const T& b);
template<class T, class Compare>
- pair<const T&, const T&>
- minmax(const T& a, const T& b, Compare comp); // constexpr in C++14
+ constexpr pair<const T&, const T&> // constexpr in C++14
+ minmax(const T& a, const T& b, Compare comp);
template<class T>
- pair<T, T>
- minmax(initializer_list<T> t); // constexpr in C++14
+ constexpr pair<T, T> // constexpr in C++14
+ minmax(initializer_list<T> t);
template<class T, class Compare>
- pair<T, T>
- minmax(initializer_list<T> t, Compare comp); // constexpr in C++14
+ constexpr pair<T, T> // constexpr in C++14
+ minmax(initializer_list<T> t, Compare comp);
template <class InputIterator1, class InputIterator2>
constexpr bool // constexpr in C++20
@@ -616,19 +626,19 @@ template <class InputIterator1, class InputIterator2, class Compare>
InputIterator2 first2, InputIterator2 last2, Compare comp);
template <class BidirectionalIterator>
- bool
+ constexpr bool // constexpr in C++20
next_permutation(BidirectionalIterator first, BidirectionalIterator last);
template <class BidirectionalIterator, class Compare>
- bool
+ constexpr bool // constexpr in C++20
next_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
template <class BidirectionalIterator>
- bool
+ constexpr bool // constexpr in C++20
prev_permutation(BidirectionalIterator first, BidirectionalIterator last);
template <class BidirectionalIterator, class Compare>
- bool
+ constexpr bool // constexpr in C++20
prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
} // std
@@ -895,7 +905,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_InputIterator
for_each_n(_InputIterator __first, _Size __orig_n, _Function __f)
{
- typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize;
+ typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
_IntegralSize __n = __orig_n;
while (__n > 0)
{
@@ -1614,7 +1624,7 @@ search_n(_ForwardIterator __first, _ForwardIterator __last,
_Size __count, const _Tp& __value_, _BinaryPredicate __pred)
{
return _VSTD::__search_n<typename add_lvalue_reference<_BinaryPredicate>::type>
- (__first, __last, __convert_to_integral(__count), __value_, __pred,
+ (__first, __last, _VSTD::__convert_to_integral(__count), __value_, __pred,
typename iterator_traits<_ForwardIterator>::iterator_category());
}
@@ -1625,13 +1635,13 @@ _ForwardIterator
search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value_)
{
typedef typename iterator_traits<_ForwardIterator>::value_type __v;
- return _VSTD::search_n(__first, __last, __convert_to_integral(__count),
+ return _VSTD::search_n(__first, __last, _VSTD::__convert_to_integral(__count),
__value_, __equal_to<__v, _Tp>());
}
// copy
template <class _Iter>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
_Iter
__unwrap_iter(_Iter __i)
{
@@ -1639,7 +1649,7 @@ __unwrap_iter(_Iter __i)
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
typename enable_if
<
is_trivially_copy_assignable<_Tp>::value,
@@ -1653,7 +1663,7 @@ __unwrap_iter(move_iterator<_Tp*> __i)
#if _LIBCPP_DEBUG_LEVEL < 2
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
typename enable_if
<
is_trivially_copy_assignable<_Tp>::value,
@@ -1665,7 +1675,7 @@ __unwrap_iter(__wrap_iter<_Tp*> __i)
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
typename enable_if
<
is_trivially_copy_assignable<_Tp>::value,
@@ -1679,7 +1689,7 @@ __unwrap_iter(__wrap_iter<const _Tp*> __i)
#else
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
typename enable_if
<
is_trivially_copy_assignable<_Tp>::value,
@@ -1707,7 +1717,7 @@ inline _LIBCPP_INLINE_VISIBILITY
_OutputIterator
__copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
{
- return __copy_constexpr(__first, __last, __result);
+ return _VSTD::__copy_constexpr(__first, __last, __result);
}
template <class _Tp, class _Up>
@@ -1727,16 +1737,16 @@ __copy(_Tp* __first, _Tp* __last, _Up* __result)
}
template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
{
if (__libcpp_is_constant_evaluated()) {
return _VSTD::__copy_constexpr(
- __unwrap_iter(__first), __unwrap_iter(__last), __unwrap_iter(__result));
+ _VSTD::__unwrap_iter(__first), _VSTD::__unwrap_iter(__last), _VSTD::__unwrap_iter(__result));
} else {
return _VSTD::__copy(
- __unwrap_iter(__first), __unwrap_iter(__last), __unwrap_iter(__result));
+ _VSTD::__unwrap_iter(__first), _VSTD::__unwrap_iter(__last), _VSTD::__unwrap_iter(__result));
}
}
@@ -1757,7 +1767,7 @@ inline _LIBCPP_INLINE_VISIBILITY
_OutputIterator
__copy_backward(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result)
{
- return __copy_backward_constexpr(__first, __last, __result);
+ return _VSTD::__copy_backward_constexpr(__first, __last, __result);
}
template <class _Tp, class _Up>
@@ -1780,19 +1790,19 @@ __copy_backward(_Tp* __first, _Tp* __last, _Up* __result)
}
template <class _BidirectionalIterator1, class _BidirectionalIterator2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_BidirectionalIterator2
copy_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last,
_BidirectionalIterator2 __result)
{
if (__libcpp_is_constant_evaluated()) {
- return _VSTD::__copy_backward_constexpr(__unwrap_iter(__first),
- __unwrap_iter(__last),
- __unwrap_iter(__result));
+ return _VSTD::__copy_backward_constexpr(_VSTD::__unwrap_iter(__first),
+ _VSTD::__unwrap_iter(__last),
+ _VSTD::__unwrap_iter(__result));
} else {
- return _VSTD::__copy_backward(__unwrap_iter(__first),
- __unwrap_iter(__last),
- __unwrap_iter(__result));
+ return _VSTD::__copy_backward(_VSTD::__unwrap_iter(__first),
+ _VSTD::__unwrap_iter(__last),
+ _VSTD::__unwrap_iter(__result));
}
}
@@ -1818,7 +1828,7 @@ copy_if(_InputIterator __first, _InputIterator __last,
// copy_n
template<class _InputIterator, class _Size, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
typename enable_if
<
__is_cpp17_input_iterator<_InputIterator>::value &&
@@ -1827,7 +1837,7 @@ typename enable_if
>::type
copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
{
- typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize;
+ typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
_IntegralSize __n = __orig_n;
if (__n > 0)
{
@@ -1844,7 +1854,7 @@ copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
}
template<class _InputIterator, class _Size, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
typename enable_if
<
__is_cpp17_random_access_iterator<_InputIterator>::value,
@@ -1852,25 +1862,35 @@ typename enable_if
>::type
copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
{
- typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize;
+ typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
_IntegralSize __n = __orig_n;
return _VSTD::copy(__first, __first + __n, __result);
}
// move
+// __move_constexpr exists so that __move doesn't call itself when delegating to the constexpr
+// version of __move.
template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
_OutputIterator
-__move(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
+__move_constexpr(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
{
for (; __first != __last; ++__first, (void) ++__result)
*__result = _VSTD::move(*__first);
return __result;
}
+template <class _InputIterator, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+_OutputIterator
+__move(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
+{
+ return _VSTD::__move_constexpr(__first, __last, __result);
+}
+
template <class _Tp, class _Up>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
typename enable_if
<
is_same<typename remove_const<_Tp>::type, _Up>::value &&
@@ -1879,6 +1899,8 @@ typename enable_if
>::type
__move(_Tp* __first, _Tp* __last, _Up* __result)
{
+ if (__libcpp_is_constant_evaluated())
+ return _VSTD::__move_constexpr(__first, __last, __result);
const size_t __n = static_cast<size_t>(__last - __first);
if (__n > 0)
_VSTD::memmove(__result, __first, __n * sizeof(_Up));
@@ -1886,27 +1908,37 @@ __move(_Tp* __first, _Tp* __last, _Up* __result)
}
template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
move(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
{
- return _VSTD::__move(__unwrap_iter(__first), __unwrap_iter(__last), __unwrap_iter(__result));
+ return _VSTD::__move(_VSTD::__unwrap_iter(__first), _VSTD::__unwrap_iter(__last), _VSTD::__unwrap_iter(__result));
}
// move_backward
+// __move_backward_constexpr exists so that __move_backward doesn't call itself when delegating to
+// the constexpr version of __move_backward.
template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
_OutputIterator
-__move_backward(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
+__move_backward_constexpr(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
{
while (__first != __last)
*--__result = _VSTD::move(*--__last);
return __result;
}
+template <class _InputIterator, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+_OutputIterator
+__move_backward(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
+{
+ return _VSTD::__move_backward_constexpr(__first, __last, __result);
+}
+
template <class _Tp, class _Up>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
typename enable_if
<
is_same<typename remove_const<_Tp>::type, _Up>::value &&
@@ -1915,6 +1947,8 @@ typename enable_if
>::type
__move_backward(_Tp* __first, _Tp* __last, _Up* __result)
{
+ if (__libcpp_is_constant_evaluated())
+ return _VSTD::__move_backward_constexpr(__first, __last, __result);
const size_t __n = static_cast<size_t>(__last - __first);
if (__n > 0)
{
@@ -1925,12 +1959,12 @@ __move_backward(_Tp* __first, _Tp* __last, _Up* __result)
}
template <class _BidirectionalIterator1, class _BidirectionalIterator2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_BidirectionalIterator2
move_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last,
_BidirectionalIterator2 __result)
{
- return _VSTD::__move_backward(__unwrap_iter(__first), __unwrap_iter(__last), __unwrap_iter(__result));
+ return _VSTD::__move_backward(_VSTD::__unwrap_iter(__first), _VSTD::__unwrap_iter(__last), _VSTD::__unwrap_iter(__result));
}
// iter_swap
@@ -2033,7 +2067,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_)
{
- return _VSTD::__fill_n(__first, __convert_to_integral(__n), __value_);
+ return _VSTD::__fill_n(__first, _VSTD::__convert_to_integral(__n), __value_);
}
// fill
@@ -2081,7 +2115,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
generate_n(_OutputIterator __first, _Size __orig_n, _Generator __gen)
{
- typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize;
+ typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
_IntegralSize __n = __orig_n;
for (; __n > 0; ++__first, (void) --__n)
*__first = __gen();
@@ -2287,7 +2321,7 @@ unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __res
// reverse
template <class _BidirectionalIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void
__reverse(_BidirectionalIterator __first, _BidirectionalIterator __last, bidirectional_iterator_tag)
{
@@ -2301,7 +2335,7 @@ __reverse(_BidirectionalIterator __first, _BidirectionalIterator __last, bidirec
}
template <class _RandomAccessIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void
__reverse(_RandomAccessIterator __first, _RandomAccessIterator __last, random_access_iterator_tag)
{
@@ -2311,7 +2345,7 @@ __reverse(_RandomAccessIterator __first, _RandomAccessIterator __last, random_ac
}
template <class _BidirectionalIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void
reverse(_BidirectionalIterator __first, _BidirectionalIterator __last)
{
@@ -2333,7 +2367,7 @@ reverse_copy(_BidirectionalIterator __first, _BidirectionalIterator __last, _Out
// rotate
template <class _ForwardIterator>
-_ForwardIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
__rotate_left(_ForwardIterator __first, _ForwardIterator __last)
{
typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
@@ -2344,7 +2378,7 @@ __rotate_left(_ForwardIterator __first, _ForwardIterator __last)
}
template <class _BidirectionalIterator>
-_BidirectionalIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _BidirectionalIterator
__rotate_right(_BidirectionalIterator __first, _BidirectionalIterator __last)
{
typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
@@ -2356,7 +2390,7 @@ __rotate_right(_BidirectionalIterator __first, _BidirectionalIterator __last)
}
template <class _ForwardIterator>
-_ForwardIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX14 _ForwardIterator
__rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last)
{
_ForwardIterator __i = __middle;
@@ -2392,7 +2426,7 @@ __rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIt
template<typename _Integral>
inline _LIBCPP_INLINE_VISIBILITY
-_Integral
+_LIBCPP_CONSTEXPR_AFTER_CXX14 _Integral
__algo_gcd(_Integral __x, _Integral __y)
{
do
@@ -2405,7 +2439,7 @@ __algo_gcd(_Integral __x, _Integral __y)
}
template<typename _RandomAccessIterator>
-_RandomAccessIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX14 _RandomAccessIterator
__rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last)
{
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
@@ -2441,7 +2475,7 @@ __rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ran
template <class _ForwardIterator>
inline _LIBCPP_INLINE_VISIBILITY
-_ForwardIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
__rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last,
_VSTD::forward_iterator_tag)
{
@@ -2456,7 +2490,7 @@ __rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator _
template <class _BidirectionalIterator>
inline _LIBCPP_INLINE_VISIBILITY
-_BidirectionalIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _BidirectionalIterator
__rotate(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
_VSTD::bidirectional_iterator_tag)
{
@@ -2473,7 +2507,7 @@ __rotate(_BidirectionalIterator __first, _BidirectionalIterator __middle, _Bidir
template <class _RandomAccessIterator>
inline _LIBCPP_INLINE_VISIBILITY
-_RandomAccessIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator
__rotate(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,
_VSTD::random_access_iterator_tag)
{
@@ -2491,7 +2525,7 @@ __rotate(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomA
template <class _ForwardIterator>
inline _LIBCPP_INLINE_VISIBILITY
-_ForwardIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last)
{
if (__first == __middle)
@@ -2505,7 +2539,7 @@ rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __l
// rotate_copy
template <class _ForwardIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
rotate_copy(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last, _OutputIterator __result)
{
@@ -2684,12 +2718,12 @@ clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi)
template <class _ForwardIterator, class _Compare>
_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX11
-std::pair<_ForwardIterator, _ForwardIterator>
+pair<_ForwardIterator, _ForwardIterator>
minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
{
static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
"std::minmax_element requires a ForwardIterator");
- std::pair<_ForwardIterator, _ForwardIterator> __result(__first, __first);
+ pair<_ForwardIterator, _ForwardIterator> __result(__first, __first);
if (__first != __last)
{
if (++__first != __last)
@@ -2735,7 +2769,7 @@ minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __com
template <class _ForwardIterator>
_LIBCPP_NODISCARD_EXT inline
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-std::pair<_ForwardIterator, _ForwardIterator>
+pair<_ForwardIterator, _ForwardIterator>
minmax_element(_ForwardIterator __first, _ForwardIterator __last)
{
return _VSTD::minmax_element(__first, __last,
@@ -2774,7 +2808,7 @@ minmax(initializer_list<_Tp> __t, _Compare __comp)
typedef typename initializer_list<_Tp>::const_iterator _Iter;
_Iter __first = __t.begin();
_Iter __last = __t.end();
- std::pair<_Tp, _Tp> __result(*__first, *__first);
+ pair<_Tp, _Tp> __result(*__first, *__first);
++__first;
if (__t.size() % 2 == 0)
@@ -3005,9 +3039,17 @@ private:
public:
// constructors and reset functions
- explicit uniform_int_distribution(result_type __a = 0,
- result_type __b = numeric_limits<result_type>::max())
+#ifndef _LIBCPP_CXX03_LANG
+ uniform_int_distribution() : uniform_int_distribution(0) {}
+ explicit uniform_int_distribution(
+ result_type __a, result_type __b = numeric_limits<result_type>::max())
: __p_(param_type(__a, __b)) {}
+#else
+ explicit uniform_int_distribution(
+ result_type __a = 0,
+ result_type __b = numeric_limits<result_type>::max())
+ : __p_(param_type(__a, __b)) {}
+#endif
explicit uniform_int_distribution(const param_type& __p) : __p_(__p) {}
void reset() {}
@@ -3050,7 +3092,7 @@ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
if (_Rp == 0)
return static_cast<result_type>(_Eng(__g, _Dt)());
size_t __w = _Dt - __libcpp_clz(_Rp) - 1;
- if ((_Rp & (std::numeric_limits<_UIntType>::max() >> (_Dt - __w))) != 0)
+ if ((_Rp & (numeric_limits<_UIntType>::max() >> (_Dt - __w))) != 0)
++__w;
_Eng __e(__g, __w);
_UIntType __u;
@@ -3227,6 +3269,111 @@ template<class _RandomAccessIterator, class _UniformRandomNumberGenerator>
}
}
+#if _LIBCPP_STD_VER > 17
+
+// shift_left, shift_right
+
+template <class _ForwardIterator>
+inline _LIBCPP_INLINE_VISIBILITY constexpr
+_ForwardIterator
+shift_left(_ForwardIterator __first, _ForwardIterator __last,
+ typename iterator_traits<_ForwardIterator>::difference_type __n)
+{
+ if (__n == 0) {
+ return __last;
+ }
+
+ _ForwardIterator __m = __first;
+ if constexpr (__is_cpp17_random_access_iterator<_ForwardIterator>::value) {
+ if (__n >= __last - __first) {
+ return __first;
+ }
+ __m += __n;
+ } else {
+ for (; __n > 0; --__n) {
+ if (__m == __last) {
+ return __first;
+ }
+ ++__m;
+ }
+ }
+ return _VSTD::move(__m, __last, __first);
+}
+
+template <class _ForwardIterator>
+inline _LIBCPP_INLINE_VISIBILITY constexpr
+_ForwardIterator
+shift_right(_ForwardIterator __first, _ForwardIterator __last,
+ typename iterator_traits<_ForwardIterator>::difference_type __n)
+{
+ if (__n == 0) {
+ return __first;
+ }
+
+ if constexpr (__is_cpp17_random_access_iterator<_ForwardIterator>::value) {
+ decltype(__n) __d = __last - __first;
+ if (__n >= __d) {
+ return __last;
+ }
+ _ForwardIterator __m = __first + (__d - __n);
+ return _VSTD::move_backward(__first, __m, __last);
+ } else if constexpr (__is_cpp17_bidirectional_iterator<_ForwardIterator>::value) {
+ _ForwardIterator __m = __last;
+ for (; __n > 0; --__n) {
+ if (__m == __first) {
+ return __last;
+ }
+ --__m;
+ }
+ return _VSTD::move_backward(__first, __m, __last);
+ } else {
+ _ForwardIterator __ret = __first;
+ for (; __n > 0; --__n) {
+ if (__ret == __last) {
+ return __last;
+ }
+ ++__ret;
+ }
+
+ // We have an __n-element scratch space from __first to __ret.
+ // Slide an __n-element window [__trail, __lead) from left to right.
+ // We're essentially doing swap_ranges(__first, __ret, __trail, __lead)
+ // over and over; but once __lead reaches __last we needn't bother
+ // to save the values of elements [__trail, __last).
+
+ auto __trail = __first;
+ auto __lead = __ret;
+ while (__trail != __ret) {
+ if (__lead == __last) {
+ _VSTD::move(__first, __trail, __ret);
+ return __ret;
+ }
+ ++__trail;
+ ++__lead;
+ }
+
+ _ForwardIterator __mid = __first;
+ while (true) {
+ if (__lead == __last) {
+ __trail = _VSTD::move(__mid, __ret, __trail);
+ _VSTD::move(__first, __mid, __trail);
+ return __ret;
+ }
+ swap(*__mid, *__trail);
+ ++__mid;
+ ++__trail;
+ ++__lead;
+ if (__mid == __ret) {
+ __mid = __first;
+ }
+ }
+ }
+}
+
+#endif // _LIBCPP_STD_VER > 17
+
+// is_partitioned
+
template <class _InputIterator, class _Predicate>
_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
is_partitioned(_InputIterator __first, _InputIterator __last, _Predicate __pred)
@@ -3246,7 +3393,7 @@ is_partitioned(_InputIterator __first, _InputIterator __last, _Predicate __pred)
// partition
template <class _Predicate, class _ForwardIterator>
-_ForwardIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
__partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, forward_iterator_tag)
{
while (true)
@@ -3269,7 +3416,7 @@ __partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred
}
template <class _Predicate, class _BidirectionalIterator>
-_BidirectionalIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _BidirectionalIterator
__partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred,
bidirectional_iterator_tag)
{
@@ -3294,7 +3441,7 @@ __partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _Pred
}
template <class _ForwardIterator, class _Predicate>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_ForwardIterator
partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
{
@@ -3380,8 +3527,8 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate
// Move the falses into the temporary buffer, and the trues to the front of the line
// Update __first to always point to the end of the trues
value_type* __t = __p.first;
- ::new(__t) value_type(_VSTD::move(*__first));
- __d.__incr((value_type*)0);
+ ::new ((void*)__t) value_type(_VSTD::move(*__first));
+ __d.template __incr<value_type>();
++__t;
_ForwardIterator __i = __first;
while (++__i != __last)
@@ -3393,8 +3540,8 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate
}
else
{
- ::new(__t) value_type(_VSTD::move(*__i));
- __d.__incr((value_type*)0);
+ ::new ((void*)__t) value_type(_VSTD::move(*__i));
+ __d.template __incr<value_type>();
++__t;
}
}
@@ -3415,7 +3562,7 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate
// F?????????????????
// f m l
typedef typename add_lvalue_reference<_Predicate>::type _PredRef;
- _ForwardIterator __first_false = __stable_partition<_PredRef>(__first, __m, __pred, __len2, __p, __fit);
+ _ForwardIterator __first_false = _VSTD::__stable_partition<_PredRef>(__first, __m, __pred, __len2, __p, __fit);
// TTTFFFFF??????????
// f ff m l
// recurse on [__m, __last], except increase __m until *(__m) is false, *__last know to be true
@@ -3430,7 +3577,7 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate
}
// TTTFFFFFTTTF??????
// f ff m m1 l
- __second_false = __stable_partition<_PredRef>(__m1, __last, __pred, __len_half, __p, __fit);
+ __second_false = _VSTD::__stable_partition<_PredRef>(__m1, __last, __pred, __len_half, __p, __fit);
__second_half_done:
// TTTFFFFFTTTTTFFFFF
// f ff m sf l
@@ -3472,7 +3619,7 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate
__p = _VSTD::get_temporary_buffer<value_type>(__len);
__h.reset(__p.first);
}
- return __stable_partition<typename add_lvalue_reference<_Predicate>::type>
+ return _VSTD::__stable_partition<typename add_lvalue_reference<_Predicate>::type>
(__first, __last, __pred, __len, __p, forward_iterator_tag());
}
@@ -3510,8 +3657,8 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last
// Move the falses into the temporary buffer, and the trues to the front of the line
// Update __first to always point to the end of the trues
value_type* __t = __p.first;
- ::new(__t) value_type(_VSTD::move(*__first));
- __d.__incr((value_type*)0);
+ ::new ((void*)__t) value_type(_VSTD::move(*__first));
+ __d.template __incr<value_type>();
++__t;
_BidirectionalIterator __i = __first;
while (++__i != __last)
@@ -3523,8 +3670,8 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last
}
else
{
- ::new(__t) value_type(_VSTD::move(*__i));
- __d.__incr((value_type*)0);
+ ::new ((void*)__t) value_type(_VSTD::move(*__i));
+ __d.template __incr<value_type>();
++__t;
}
}
@@ -3558,7 +3705,7 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last
// F???TFFF?????????T
// f m1 m l
typedef typename add_lvalue_reference<_Predicate>::type _PredRef;
- __first_false = __stable_partition<_PredRef>(__first, __m1, __pred, __len_half, __p, __bit);
+ __first_false = _VSTD::__stable_partition<_PredRef>(__first, __m1, __pred, __len_half, __p, __bit);
__first_half_done:
// TTTFFFFF?????????T
// f ff m l
@@ -3575,7 +3722,7 @@ __first_half_done:
}
// TTTFFFFFTTTF?????T
// f ff m m1 l
- __second_false = __stable_partition<_PredRef>(__m1, __last, __pred, __len_half, __p, __bit);
+ __second_false = _VSTD::__stable_partition<_PredRef>(__m1, __last, __pred, __len_half, __p, __bit);
__second_half_done:
// TTTFFFFFTTTTTFFFFF
// f ff m sf l
@@ -3620,7 +3767,7 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last
__p = _VSTD::get_temporary_buffer<value_type>(__len);
__h.reset(__p.first);
}
- return __stable_partition<typename add_lvalue_reference<_Predicate>::type>
+ return _VSTD::__stable_partition<typename add_lvalue_reference<_Predicate>::type>
(__first, __last, __pred, __len, __p, bidirectional_iterator_tag());
}
@@ -3629,7 +3776,7 @@ inline _LIBCPP_INLINE_VISIBILITY
_ForwardIterator
stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
{
- return __stable_partition<typename add_lvalue_reference<_Predicate>::type>
+ return _VSTD::__stable_partition<typename add_lvalue_reference<_Predicate>::type>
(__first, __last, __pred, typename iterator_traits<_ForwardIterator>::iterator_category());
}
@@ -3727,7 +3874,7 @@ unsigned
__sort4(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3,
_ForwardIterator __x4, _Compare __c)
{
- unsigned __r = __sort3<_Compare>(__x1, __x2, __x3, __c);
+ unsigned __r = _VSTD::__sort3<_Compare>(__x1, __x2, __x3, __c);
if (__c(*__x4, *__x3))
{
swap(*__x3, *__x4);
@@ -3754,7 +3901,7 @@ unsigned
__sort5(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3,
_ForwardIterator __x4, _ForwardIterator __x5, _Compare __c)
{
- unsigned __r = __sort4<_Compare>(__x1, __x2, __x3, __x4, __c);
+ unsigned __r = _VSTD::__sort4<_Compare>(__x1, __x2, __x3, __x4, __c);
if (__c(*__x5, *__x4))
{
swap(*__x4, *__x5);
@@ -3779,14 +3926,14 @@ __sort5(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3,
}
// Assumes size > 0
-template <class _Compare, class _BirdirectionalIterator>
+template <class _Compare, class _BidirectionalIterator>
void
-__selection_sort(_BirdirectionalIterator __first, _BirdirectionalIterator __last, _Compare __comp)
+__selection_sort(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
{
- _BirdirectionalIterator __lm1 = __last;
+ _BidirectionalIterator __lm1 = __last;
for (--__lm1; __first != __lm1; ++__first)
{
- _BirdirectionalIterator __i = _VSTD::min_element<_BirdirectionalIterator,
+ _BidirectionalIterator __i = _VSTD::min_element<_BidirectionalIterator,
typename add_lvalue_reference<_Compare>::type>
(__first, __last, __comp);
if (__i != __first)
@@ -3794,19 +3941,19 @@ __selection_sort(_BirdirectionalIterator __first, _BirdirectionalIterator __last
}
}
-template <class _Compare, class _BirdirectionalIterator>
+template <class _Compare, class _BidirectionalIterator>
void
-__insertion_sort(_BirdirectionalIterator __first, _BirdirectionalIterator __last, _Compare __comp)
+__insertion_sort(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
{
- typedef typename iterator_traits<_BirdirectionalIterator>::value_type value_type;
+ typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
if (__first != __last)
{
- _BirdirectionalIterator __i = __first;
+ _BidirectionalIterator __i = __first;
for (++__i; __i != __last; ++__i)
{
- _BirdirectionalIterator __j = __i;
+ _BidirectionalIterator __j = __i;
value_type __t(_VSTD::move(*__j));
- for (_BirdirectionalIterator __k = __i; __k != __first && __comp(__t, *--__k); --__j)
+ for (_BidirectionalIterator __k = __i; __k != __first && __comp(__t, *--__k); --__j)
*__j = _VSTD::move(*__k);
*__j = _VSTD::move(__t);
}
@@ -3819,7 +3966,7 @@ __insertion_sort_3(_RandomAccessIterator __first, _RandomAccessIterator __last,
{
typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
_RandomAccessIterator __j = __first+2;
- __sort3<_Compare>(__first, __first+1, __j, __comp);
+ _VSTD::__sort3<_Compare>(__first, __first+1, __j, __comp);
for (_RandomAccessIterator __i = __j+1; __i != __last; ++__i)
{
if (__comp(*__i, *__j))
@@ -3863,7 +4010,7 @@ __insertion_sort_incomplete(_RandomAccessIterator __first, _RandomAccessIterator
}
typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
_RandomAccessIterator __j = __first+2;
- __sort3<_Compare>(__first, __first+1, __j, __comp);
+ _VSTD::__sort3<_Compare>(__first, __first+1, __j, __comp);
const unsigned __limit = 8;
unsigned __count = 0;
for (_RandomAccessIterator __i = __j+1; __i != __last; ++__i)
@@ -3887,35 +4034,35 @@ __insertion_sort_incomplete(_RandomAccessIterator __first, _RandomAccessIterator
return true;
}
-template <class _Compare, class _BirdirectionalIterator>
+template <class _Compare, class _BidirectionalIterator>
void
-__insertion_sort_move(_BirdirectionalIterator __first1, _BirdirectionalIterator __last1,
- typename iterator_traits<_BirdirectionalIterator>::value_type* __first2, _Compare __comp)
+__insertion_sort_move(_BidirectionalIterator __first1, _BidirectionalIterator __last1,
+ typename iterator_traits<_BidirectionalIterator>::value_type* __first2, _Compare __comp)
{
- typedef typename iterator_traits<_BirdirectionalIterator>::value_type value_type;
+ typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
if (__first1 != __last1)
{
__destruct_n __d(0);
unique_ptr<value_type, __destruct_n&> __h(__first2, __d);
value_type* __last2 = __first2;
- ::new(__last2) value_type(_VSTD::move(*__first1));
- __d.__incr((value_type*)0);
+ ::new ((void*)__last2) value_type(_VSTD::move(*__first1));
+ __d.template __incr<value_type>();
for (++__last2; ++__first1 != __last1; ++__last2)
{
value_type* __j2 = __last2;
value_type* __i2 = __j2;
if (__comp(*__first1, *--__i2))
{
- ::new(__j2) value_type(_VSTD::move(*__i2));
- __d.__incr((value_type*)0);
+ ::new ((void*)__j2) value_type(_VSTD::move(*__i2));
+ __d.template __incr<value_type>();
for (--__j2; __i2 != __first2 && __comp(*__first1, *--__i2); --__j2)
*__j2 = _VSTD::move(*__i2);
*__j2 = _VSTD::move(*__first1);
}
else
{
- ::new(__j2) value_type(_VSTD::move(*__first1));
- __d.__incr((value_type*)0);
+ ::new ((void*)__j2) value_type(_VSTD::move(*__first1));
+ __d.template __incr<value_type>();
}
}
__h.release();
@@ -4032,7 +4179,7 @@ __sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __c
++__i;
}
// [__first, __i) == *__first and *__first < [__i, __last)
- // The first part is sorted, sort the secod part
+ // The first part is sorted, sort the second part
// _VSTD::__sort<_Compare>(__i, __last, __comp);
__first = __i;
goto __restart;
@@ -4138,7 +4285,7 @@ inline _LIBCPP_INLINE_VISIBILITY
void
sort(_Tp** __first, _Tp** __last)
{
- _VSTD::sort((size_t*)__first, (size_t*)__last, __less<size_t>());
+ _VSTD::sort((uintptr_t*)__first, (uintptr_t*)__last, __less<uintptr_t>());
}
template <class _Tp>
@@ -4223,7 +4370,7 @@ _ForwardIterator
lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
{
typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
- return __lower_bound<_Comp_ref>(__first, __last, __value_, __comp);
+ return _VSTD::__lower_bound<_Comp_ref>(__first, __last, __value_, __comp);
}
template <class _ForwardIterator, class _Tp>
@@ -4267,7 +4414,7 @@ _ForwardIterator
upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
{
typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
- return __upper_bound<_Comp_ref>(__first, __last, __value_, __comp);
+ return _VSTD::__upper_bound<_Comp_ref>(__first, __last, __value_, __comp);
}
template <class _ForwardIterator, class _Tp>
@@ -4308,8 +4455,8 @@ __equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va
_ForwardIterator __mp1 = __m;
return pair<_ForwardIterator, _ForwardIterator>
(
- __lower_bound<_Compare>(__first, __m, __value_, __comp),
- __upper_bound<_Compare>(++__mp1, __last, __value_, __comp)
+ _VSTD::__lower_bound<_Compare>(__first, __m, __value_, __comp),
+ _VSTD::__upper_bound<_Compare>(++__mp1, __last, __value_, __comp)
);
}
}
@@ -4323,7 +4470,7 @@ pair<_ForwardIterator, _ForwardIterator>
equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
{
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return __equal_range<_Comp_ref>(__first, __last, __value_, __comp);
+ return _VSTD::__equal_range<_Comp_ref>(__first, __last, __value_, __comp);
}
template <class _ForwardIterator, class _Tp>
@@ -4343,7 +4490,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
__binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
{
- __first = __lower_bound<_Compare>(__first, __last, __value_, __comp);
+ __first = _VSTD::__lower_bound<_Compare>(__first, __last, __value_, __comp);
return __first != __last && !__comp(__value_, *__first);
}
@@ -4354,7 +4501,7 @@ bool
binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
{
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return __binary_search<_Comp_ref>(__first, __last, __value_, __comp);
+ return _VSTD::__binary_search<_Comp_ref>(__first, __last, __value_, __comp);
}
template <class _ForwardIterator, class _Tp>
@@ -4370,6 +4517,7 @@ binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va
// merge
template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
__merge(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
@@ -4393,7 +4541,7 @@ __merge(_InputIterator1 __first1, _InputIterator1 __last1,
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
merge(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
@@ -4403,7 +4551,7 @@ merge(_InputIterator1 __first1, _InputIterator1 __last1,
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
merge(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
@@ -4456,20 +4604,21 @@ __buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator
if (__len1 <= __len2)
{
value_type* __p = __buff;
- for (_BidirectionalIterator __i = __first; __i != __middle; __d.__incr((value_type*)0), (void) ++__i, (void) ++__p)
- ::new(__p) value_type(_VSTD::move(*__i));
- __half_inplace_merge(__buff, __p, __middle, __last, __first, __comp);
+ for (_BidirectionalIterator __i = __first; __i != __middle; __d.template __incr<value_type>(), (void) ++__i, (void) ++__p)
+ ::new ((void*)__p) value_type(_VSTD::move(*__i));
+ _VSTD::__half_inplace_merge<_Compare>(__buff, __p, __middle, __last, __first, __comp);
}
else
{
value_type* __p = __buff;
- for (_BidirectionalIterator __i = __middle; __i != __last; __d.__incr((value_type*)0), (void) ++__i, (void) ++__p)
- ::new(__p) value_type(_VSTD::move(*__i));
+ for (_BidirectionalIterator __i = __middle; __i != __last; __d.template __incr<value_type>(), (void) ++__i, (void) ++__p)
+ ::new ((void*)__p) value_type(_VSTD::move(*__i));
typedef reverse_iterator<_BidirectionalIterator> _RBi;
typedef reverse_iterator<value_type*> _Rv;
- __half_inplace_merge(_Rv(__p), _Rv(__buff),
- _RBi(__middle), _RBi(__first),
- _RBi(__last), __invert<_Compare>(__comp));
+ typedef __invert<_Compare> _Inverted;
+ _VSTD::__half_inplace_merge<_Inverted>(_Rv(__p), _Rv(__buff),
+ _RBi(__middle), _RBi(__first),
+ _RBi(__last), _Inverted(__comp));
}
}
@@ -4487,7 +4636,7 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,
if (__len2 == 0)
return;
if (__len1 <= __buff_size || __len2 <= __buff_size)
- return __buffered_inplace_merge<_Compare>
+ return _VSTD::__buffered_inplace_merge<_Compare>
(__first, __middle, __last, __comp, __len1, __len2, __buff);
// shrink [__first, __middle) as much as possible (with no moves), returning if it shrinks to 0
for (; true; ++__first, (void) --__len1)
@@ -4515,7 +4664,7 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,
__len21 = __len2 / 2;
__m2 = __middle;
_VSTD::advance(__m2, __len21);
- __m1 = __upper_bound<_Compare>(__first, __middle, *__m2, __comp);
+ __m1 = _VSTD::__upper_bound<_Compare>(__first, __middle, *__m2, __comp);
__len11 = _VSTD::distance(__first, __m1);
}
else
@@ -4530,7 +4679,7 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,
__len11 = __len1 / 2;
__m1 = __first;
_VSTD::advance(__m1, __len11);
- __m2 = __lower_bound<_Compare>(__middle, __last, *__m1, __comp);
+ __m2 = _VSTD::__lower_bound<_Compare>(__middle, __last, *__m1, __comp);
__len21 = _VSTD::distance(__middle, __m2);
}
difference_type __len12 = __len1 - __len11; // distance(__m1, __middle)
@@ -4539,11 +4688,11 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,
// swap middle two partitions
__middle = _VSTD::rotate(__m1, __middle, __m2);
// __len12 and __len21 now have swapped meanings
- // merge smaller range with recurisve call and larger with tail recursion elimination
+ // merge smaller range with recursive call and larger with tail recursion elimination
if (__len11 + __len21 < __len12 + __len22)
{
- __inplace_merge<_Compare>(__first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size);
-// __inplace_merge<_Compare>(__middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size);
+ _VSTD::__inplace_merge<_Compare>(__first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size);
+// _VSTD::__inplace_merge<_Compare>(__middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size);
__first = __middle;
__middle = __m2;
__len1 = __len12;
@@ -4551,8 +4700,8 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,
}
else
{
- __inplace_merge<_Compare>(__middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size);
-// __inplace_merge<_Compare>(__first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size);
+ _VSTD::__inplace_merge<_Compare>(__middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size);
+// _VSTD::__inplace_merge<_Compare>(__first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size);
__last = __middle;
__middle = __m1;
__len1 = __len11;
@@ -4603,28 +4752,28 @@ __merge_move_construct(_InputIterator1 __first1, _InputIterator1 __last1,
{
if (__first1 == __last1)
{
- for (; __first2 != __last2; ++__first2, ++__result, (void) __d.__incr((value_type*)0))
- ::new (__result) value_type(_VSTD::move(*__first2));
+ for (; __first2 != __last2; ++__first2, ++__result, (void)__d.template __incr<value_type>())
+ ::new ((void*)__result) value_type(_VSTD::move(*__first2));
__h.release();
return;
}
if (__first2 == __last2)
{
- for (; __first1 != __last1; ++__first1, ++__result, (void) __d.__incr((value_type*)0))
- ::new (__result) value_type(_VSTD::move(*__first1));
+ for (; __first1 != __last1; ++__first1, ++__result, (void)__d.template __incr<value_type>())
+ ::new ((void*)__result) value_type(_VSTD::move(*__first1));
__h.release();
return;
}
if (__comp(*__first2, *__first1))
{
- ::new (__result) value_type(_VSTD::move(*__first2));
- __d.__incr((value_type*)0);
+ ::new ((void*)__result) value_type(_VSTD::move(*__first2));
+ __d.template __incr<value_type>();
++__first2;
}
else
{
- ::new (__result) value_type(_VSTD::move(*__first1));
- __d.__incr((value_type*)0);
+ ::new ((void*)__result) value_type(_VSTD::move(*__first1));
+ __d.template __incr<value_type>();
++__first1;
}
}
@@ -4677,38 +4826,38 @@ __stable_sort_move(_RandomAccessIterator __first1, _RandomAccessIterator __last1
case 0:
return;
case 1:
- ::new(__first2) value_type(_VSTD::move(*__first1));
+ ::new ((void*)__first2) value_type(_VSTD::move(*__first1));
return;
case 2:
__destruct_n __d(0);
unique_ptr<value_type, __destruct_n&> __h2(__first2, __d);
if (__comp(*--__last1, *__first1))
{
- ::new(__first2) value_type(_VSTD::move(*__last1));
- __d.__incr((value_type*)0);
+ ::new ((void*)__first2) value_type(_VSTD::move(*__last1));
+ __d.template __incr<value_type>();
++__first2;
- ::new(__first2) value_type(_VSTD::move(*__first1));
+ ::new ((void*)__first2) value_type(_VSTD::move(*__first1));
}
else
{
- ::new(__first2) value_type(_VSTD::move(*__first1));
- __d.__incr((value_type*)0);
+ ::new ((void*)__first2) value_type(_VSTD::move(*__first1));
+ __d.template __incr<value_type>();
++__first2;
- ::new(__first2) value_type(_VSTD::move(*__last1));
+ ::new ((void*)__first2) value_type(_VSTD::move(*__last1));
}
__h2.release();
return;
}
if (__len <= 8)
{
- __insertion_sort_move<_Compare>(__first1, __last1, __first2, __comp);
+ _VSTD::__insertion_sort_move<_Compare>(__first1, __last1, __first2, __comp);
return;
}
typename iterator_traits<_RandomAccessIterator>::difference_type __l2 = __len / 2;
_RandomAccessIterator __m = __first1 + __l2;
- __stable_sort<_Compare>(__first1, __m, __comp, __l2, __first2, __l2);
- __stable_sort<_Compare>(__m, __last1, __comp, __len - __l2, __first2 + __l2, __len - __l2);
- __merge_move_construct<_Compare>(__first1, __m, __m, __last1, __first2, __comp);
+ _VSTD::__stable_sort<_Compare>(__first1, __m, __comp, __l2, __first2, __l2);
+ _VSTD::__stable_sort<_Compare>(__m, __last1, __comp, __len - __l2, __first2 + __l2, __len - __l2);
+ _VSTD::__merge_move_construct<_Compare>(__first1, __m, __m, __last1, __first2, __comp);
}
template <class _Tp>
@@ -4737,7 +4886,7 @@ __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp
}
if (__len <= static_cast<difference_type>(__stable_sort_switch<value_type>::value))
{
- __insertion_sort<_Compare>(__first, __last, __comp);
+ _VSTD::__insertion_sort<_Compare>(__first, __last, __comp);
return;
}
typename iterator_traits<_RandomAccessIterator>::difference_type __l2 = __len / 2;
@@ -4746,21 +4895,21 @@ __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp
{
__destruct_n __d(0);
unique_ptr<value_type, __destruct_n&> __h2(__buff, __d);
- __stable_sort_move<_Compare>(__first, __m, __comp, __l2, __buff);
- __d.__set(__l2, (value_type*)0);
- __stable_sort_move<_Compare>(__m, __last, __comp, __len - __l2, __buff + __l2);
- __d.__set(__len, (value_type*)0);
- __merge_move_assign<_Compare>(__buff, __buff + __l2, __buff + __l2, __buff + __len, __first, __comp);
-// __merge<_Compare>(move_iterator<value_type*>(__buff),
-// move_iterator<value_type*>(__buff + __l2),
-// move_iterator<_RandomAccessIterator>(__buff + __l2),
-// move_iterator<_RandomAccessIterator>(__buff + __len),
-// __first, __comp);
+ _VSTD::__stable_sort_move<_Compare>(__first, __m, __comp, __l2, __buff);
+ __d.__set(__l2, (value_type*)nullptr);
+ _VSTD::__stable_sort_move<_Compare>(__m, __last, __comp, __len - __l2, __buff + __l2);
+ __d.__set(__len, (value_type*)nullptr);
+ _VSTD::__merge_move_assign<_Compare>(__buff, __buff + __l2, __buff + __l2, __buff + __len, __first, __comp);
+// _VSTD::__merge<_Compare>(move_iterator<value_type*>(__buff),
+// move_iterator<value_type*>(__buff + __l2),
+// move_iterator<_RandomAccessIterator>(__buff + __l2),
+// move_iterator<_RandomAccessIterator>(__buff + __len),
+// __first, __comp);
return;
}
- __stable_sort<_Compare>(__first, __m, __comp, __l2, __buff, __buff_size);
- __stable_sort<_Compare>(__m, __last, __comp, __len - __l2, __buff, __buff_size);
- __inplace_merge<_Compare>(__first, __m, __last, __comp, __l2, __len - __l2, __buff, __buff_size);
+ _VSTD::__stable_sort<_Compare>(__first, __m, __comp, __l2, __buff, __buff_size);
+ _VSTD::__stable_sort<_Compare>(__m, __last, __comp, __len - __l2, __buff, __buff_size);
+ _VSTD::__inplace_merge<_Compare>(__first, __m, __last, __comp, __l2, __len - __l2, __buff, __buff_size);
}
template <class _RandomAccessIterator, class _Compare>
@@ -4779,7 +4928,7 @@ stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compar
__h.reset(__buf.first);
}
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- __stable_sort<_Comp_ref>(__first, __last, __comp, __len, __buf.first, __buf.second);
+ _VSTD::__stable_sort<_Comp_ref>(__first, __last, __comp, __len, __buf.first, __buf.second);
}
template <class _RandomAccessIterator>
@@ -4883,7 +5032,7 @@ void
push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
{
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- __sift_up<_Comp_ref>(__first, __last, __comp, __last - __first);
+ _VSTD::__sift_up<_Comp_ref>(__first, __last, __comp, __last - __first);
}
template <class _RandomAccessIterator>
@@ -4960,7 +5109,7 @@ __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare
if (__len > 1)
{
swap(*__first, *--__last);
- __sift_down<_Compare>(__first, __last, __comp, __len - 1, __first);
+ _VSTD::__sift_down<_Compare>(__first, __last, __comp, __len - 1, __first);
}
}
@@ -4970,7 +5119,7 @@ void
pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
{
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- __pop_heap<_Comp_ref>(__first, __last, __comp, __last - __first);
+ _VSTD::__pop_heap<_Comp_ref>(__first, __last, __comp, __last - __first);
}
template <class _RandomAccessIterator>
@@ -4994,7 +5143,7 @@ __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compar
// start from the first parent, there is no need to consider children
for (difference_type __start = (__n - 2) / 2; __start >= 0; --__start)
{
- __sift_down<_Compare>(__first, __last, __comp, __n, __first + __start);
+ _VSTD::__sift_down<_Compare>(__first, __last, __comp, __n, __first + __start);
}
}
}
@@ -5005,7 +5154,7 @@ void
make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
{
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- __make_heap<_Comp_ref>(__first, __last, __comp);
+ _VSTD::__make_heap<_Comp_ref>(__first, __last, __comp);
}
template <class _RandomAccessIterator>
@@ -5024,7 +5173,7 @@ __sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compar
{
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
for (difference_type __n = __last - __first; __n > 1; --__last, (void) --__n)
- __pop_heap<_Compare>(__first, __last, __comp, __n);
+ _VSTD::__pop_heap<_Compare>(__first, __last, __comp, __n);
}
template <class _RandomAccessIterator, class _Compare>
@@ -5033,7 +5182,7 @@ void
sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
{
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- __sort_heap<_Comp_ref>(__first, __last, __comp);
+ _VSTD::__sort_heap<_Comp_ref>(__first, __last, __comp);
}
template <class _RandomAccessIterator>
@@ -5051,17 +5200,17 @@ void
__partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,
_Compare __comp)
{
- __make_heap<_Compare>(__first, __middle, __comp);
+ _VSTD::__make_heap<_Compare>(__first, __middle, __comp);
typename iterator_traits<_RandomAccessIterator>::difference_type __len = __middle - __first;
for (_RandomAccessIterator __i = __middle; __i != __last; ++__i)
{
if (__comp(*__i, *__first))
{
swap(*__i, *__first);
- __sift_down<_Compare>(__first, __middle, __comp, __len, __first);
+ _VSTD::__sift_down<_Compare>(__first, __middle, __comp, __len, __first);
}
}
- __sort_heap<_Compare>(__first, __middle, __comp);
+ _VSTD::__sort_heap<_Compare>(__first, __middle, __comp);
}
template <class _RandomAccessIterator, class _Compare>
@@ -5071,7 +5220,7 @@ partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ran
_Compare __comp)
{
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- __partial_sort<_Comp_ref>(__first, __middle, __last, __comp);
+ _VSTD::__partial_sort<_Comp_ref>(__first, __middle, __last, __comp);
}
template <class _RandomAccessIterator>
@@ -5095,15 +5244,15 @@ __partial_sort_copy(_InputIterator __first, _InputIterator __last,
{
for (; __first != __last && __r != __result_last; ++__first, (void) ++__r)
*__r = *__first;
- __make_heap<_Compare>(__result_first, __r, __comp);
+ _VSTD::__make_heap<_Compare>(__result_first, __r, __comp);
typename iterator_traits<_RandomAccessIterator>::difference_type __len = __r - __result_first;
for (; __first != __last; ++__first)
if (__comp(*__first, *__result_first))
{
*__result_first = *__first;
- __sift_down<_Compare>(__result_first, __r, __comp, __len, __result_first);
+ _VSTD::__sift_down<_Compare>(__result_first, __r, __comp, __len, __result_first);
}
- __sort_heap<_Compare>(__result_first, __r, __comp);
+ _VSTD::__sort_heap<_Compare>(__result_first, __r, __comp);
}
return __r;
}
@@ -5115,7 +5264,7 @@ partial_sort_copy(_InputIterator __first, _InputIterator __last,
_RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp)
{
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return __partial_sort_copy<_Comp_ref>(__first, __last, __result_first, __result_last, __comp);
+ return _VSTD::__partial_sort_copy<_Comp_ref>(__first, __last, __result_first, __result_last, __comp);
}
template <class _InputIterator, class _RandomAccessIterator>
@@ -5161,7 +5310,7 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando
}
if (__len <= __limit)
{
- __selection_sort<_Compare>(__first, __last, __comp);
+ _VSTD::__selection_sort<_Compare>(__first, __last, __comp);
return;
}
// __len > __limit >= 3
@@ -5185,7 +5334,7 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando
if (__i == --__j)
{
// *__first == *__m, *__m <= all other elements
- // Parition instead into [__first, __i) == *__first and *__first < [__i, __last)
+ // Partition instead into [__first, __i) == *__first and *__first < [__i, __last)
++__i; // __first + 1
__j = __last;
if (!__comp(*__first, *--__j)) // we need a guard if *__first == *(__last-1)
@@ -5223,8 +5372,8 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando
// The first part is sorted,
if (__nth < __i)
return;
- // __nth_element the secod part
- // __nth_element<_Compare>(__i, __nth, __last, __comp);
+ // __nth_element the second part
+ // _VSTD::__nth_element<_Compare>(__i, __nth, __last, __comp);
__first = __i;
goto __restart;
}
@@ -5306,12 +5455,12 @@ not_sorted:
// __nth_element on range containing __nth
if (__nth < __i)
{
- // __nth_element<_Compare>(__first, __nth, __i, __comp);
+ // _VSTD::__nth_element<_Compare>(__first, __nth, __i, __comp);
__last = __i;
}
else
{
- // __nth_element<_Compare>(__i+1, __nth, __last, __comp);
+ // _VSTD::__nth_element<_Compare>(__i+1, __nth, __last, __comp);
__first = ++__i;
}
}
@@ -5323,7 +5472,7 @@ void
nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp)
{
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- __nth_element<_Comp_ref>(__first, __nth, __last, __comp);
+ _VSTD::__nth_element<_Comp_ref>(__first, __nth, __last, __comp);
}
template <class _RandomAccessIterator>
@@ -5359,7 +5508,7 @@ includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __fi
_Compare __comp)
{
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return __includes<_Comp_ref>(__first1, __last1, __first2, __last2, __comp);
+ return _VSTD::__includes<_Comp_ref>(__first1, __last1, __first2, __last2, __comp);
}
template <class _InputIterator1, class _InputIterator2>
@@ -5376,7 +5525,7 @@ includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __fi
// set_union
template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
-_OutputIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
__set_union(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
{
@@ -5401,17 +5550,17 @@ __set_union(_InputIterator1 __first1, _InputIterator1 __last1,
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
set_union(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
{
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return __set_union<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
+ return _VSTD::__set_union<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
set_union(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
@@ -5453,7 +5602,7 @@ set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
{
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return __set_intersection<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
+ return _VSTD::__set_intersection<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
@@ -5470,7 +5619,7 @@ set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
// set_difference
template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
-_OutputIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
__set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
{
@@ -5495,17 +5644,17 @@ __set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
{
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return __set_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
+ return _VSTD::__set_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
@@ -5518,7 +5667,7 @@ set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
// set_symmetric_difference
template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
-_OutputIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
__set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
{
@@ -5548,17 +5697,17 @@ __set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
{
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return __set_symmetric_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
+ return _VSTD::__set_symmetric_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
@@ -5593,7 +5742,7 @@ lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp)
{
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return __lexicographical_compare<_Comp_ref>(__first1, __last1, __first2, __last2, __comp);
+ return _VSTD::__lexicographical_compare<_Comp_ref>(__first1, __last1, __first2, __last2, __comp);
}
template <class _InputIterator1, class _InputIterator2>
@@ -5611,7 +5760,7 @@ lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
// next_permutation
template <class _Compare, class _BidirectionalIterator>
-bool
+_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
__next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
{
_BidirectionalIterator __i = __last;
@@ -5638,16 +5787,16 @@ __next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last
}
template <class _BidirectionalIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
{
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return __next_permutation<_Comp_ref>(__first, __last, __comp);
+ return _VSTD::__next_permutation<_Comp_ref>(__first, __last, __comp);
}
template <class _BidirectionalIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last)
{
@@ -5658,7 +5807,7 @@ next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last)
// prev_permutation
template <class _Compare, class _BidirectionalIterator>
-bool
+_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
__prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
{
_BidirectionalIterator __i = __last;
@@ -5685,16 +5834,16 @@ __prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last
}
template <class _BidirectionalIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
{
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return __prev_permutation<_Comp_ref>(__first, __last, __comp);
+ return _VSTD::__prev_permutation<_Comp_ref>(__first, __last, __comp);
}
template <class _BidirectionalIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last)
{
diff --git a/libcxx/include/any b/libcxx/include/any
index 36b07c9d7e75..968c9769ee36 100644
--- a/libcxx/include/any
+++ b/libcxx/include/any
@@ -81,8 +81,8 @@ namespace std {
*/
#include <experimental/__config>
+#include <__availability>
#include <memory>
-#include <new>
#include <typeinfo>
#include <type_traits>
#include <cstdlib>
@@ -157,7 +157,7 @@ namespace __any_imp
template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
constexpr const void* __get_fallback_typeid() {
- return &__unique_typeinfo<decay_t<_Tp>>::__id;
+ return &__unique_typeinfo<remove_cv_t<remove_reference_t<_Tp>>>::__id;
}
template <class _Tp>
@@ -368,7 +368,11 @@ namespace __any_imp
template <class ..._Args>
_LIBCPP_INLINE_VISIBILITY
static _Tp& __create(any & __dest, _Args&&... __args) {
- _Tp* __ret = ::new (static_cast<void*>(&__dest.__s.__buf)) _Tp(_VSTD::forward<_Args>(__args)...);
+ typedef allocator<_Tp> _Alloc;
+ typedef allocator_traits<_Alloc> _ATraits;
+ _Alloc __a;
+ _Tp * __ret = static_cast<_Tp*>(static_cast<void*>(&__dest.__s.__buf));
+ _ATraits::construct(__a, __ret, _VSTD::forward<_Args>(__args)...);
__dest.__h = &_SmallHandler::__handle;
return *__ret;
}
@@ -376,8 +380,11 @@ namespace __any_imp
private:
_LIBCPP_INLINE_VISIBILITY
static void __destroy(any & __this) {
- _Tp & __value = *static_cast<_Tp *>(static_cast<void*>(&__this.__s.__buf));
- __value.~_Tp();
+ typedef allocator<_Tp> _Alloc;
+ typedef allocator_traits<_Alloc> _ATraits;
+ _Alloc __a;
+ _Tp * __p = static_cast<_Tp *>(static_cast<void*>(&__this.__s.__buf));
+ _ATraits::destroy(__a, __p);
__this.__h = nullptr;
}
@@ -445,10 +452,12 @@ namespace __any_imp
_LIBCPP_INLINE_VISIBILITY
static _Tp& __create(any & __dest, _Args&&... __args) {
typedef allocator<_Tp> _Alloc;
+ typedef allocator_traits<_Alloc> _ATraits;
typedef __allocator_destructor<_Alloc> _Dp;
_Alloc __a;
- unique_ptr<_Tp, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
- _Tp* __ret = ::new ((void*)__hold.get()) _Tp(_VSTD::forward<_Args>(__args)...);
+ unique_ptr<_Tp, _Dp> __hold(_ATraits::allocate(__a, 1), _Dp(__a, 1));
+ _Tp * __ret = __hold.get();
+ _ATraits::construct(__a, __ret, _VSTD::forward<_Args>(__args)...);
__dest.__s.__ptr = __hold.release();
__dest.__h = &_LargeHandler::__handle;
return *__ret;
@@ -458,7 +467,12 @@ namespace __any_imp
_LIBCPP_INLINE_VISIBILITY
static void __destroy(any & __this){
- delete static_cast<_Tp*>(__this.__s.__ptr);
+ typedef allocator<_Tp> _Alloc;
+ typedef allocator_traits<_Alloc> _ATraits;
+ _Alloc __a;
+ _Tp * __p = static_cast<_Tp *>(__this.__s.__ptr);
+ _ATraits::destroy(__a, __p);
+ _ATraits::deallocate(__a, __p, 1);
__this.__h = nullptr;
}
diff --git a/libcxx/include/array b/libcxx/include/array
index e73bbe7fea5f..9a479f7cd1f7 100644
--- a/libcxx/include/array
+++ b/libcxx/include/array
@@ -142,8 +142,8 @@ struct _LIBCPP_TEMPLATE_VIS array
typedef const value_type* const_pointer;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
- typedef std::reverse_iterator<iterator> reverse_iterator;
- typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+ typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
+ typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
_Tp __elems_[_Size];
@@ -155,7 +155,7 @@ struct _LIBCPP_TEMPLATE_VIS array
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void swap(array& __a) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) {
- std::swap_ranges(data(), data() + _Size, __a.data());
+ _VSTD::swap_ranges(data(), data() + _Size, __a.data());
}
// iterators:
@@ -245,8 +245,8 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0>
typedef const value_type* const_pointer;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
- typedef std::reverse_iterator<iterator> reverse_iterator;
- typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+ typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
+ typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
typedef typename conditional<is_const<_Tp>::value, const char,
char>::type _CharType;
@@ -459,8 +459,6 @@ get(const array<_Tp, _Size>& __a) _NOEXCEPT
return __a.__elems_[_Ip];
}
-#ifndef _LIBCPP_CXX03_LANG
-
template <size_t _Ip, class _Tp, size_t _Size>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_Tp&&
@@ -479,8 +477,6 @@ get(const array<_Tp, _Size>&& __a) _NOEXCEPT
return _VSTD::move(__a.__elems_[_Ip]);
}
-#endif // !_LIBCPP_CXX03_LANG
-
#if _LIBCPP_STD_VER > 17
template <typename _Tp, size_t _Size, size_t... _Index>
@@ -504,7 +500,7 @@ to_array(_Tp (&__arr)[_Size]) noexcept(is_nothrow_constructible_v<_Tp, _Tp&>) {
static_assert(
is_constructible_v<_Tp, _Tp&>,
"[array.creation]/1: to_array requires copy constructible elements.");
- return __to_array_lvalue_impl(__arr, make_index_sequence<_Size>());
+ return _VSTD::__to_array_lvalue_impl(__arr, make_index_sequence<_Size>());
}
template <typename _Tp, size_t _Size>
@@ -516,8 +512,8 @@ to_array(_Tp(&&__arr)[_Size]) noexcept(is_nothrow_move_constructible_v<_Tp>) {
static_assert(
is_move_constructible_v<_Tp>,
"[array.creation]/4: to_array requires move constructible elements.");
- return __to_array_rvalue_impl(_VSTD::move(__arr),
- make_index_sequence<_Size>());
+ return _VSTD::__to_array_rvalue_impl(_VSTD::move(__arr),
+ make_index_sequence<_Size>());
}
#endif // _LIBCPP_STD_VER > 17
diff --git a/libcxx/include/atomic b/libcxx/include/atomic
index 9c2898653788..0fc799a24319 100644
--- a/libcxx/include/atomic
+++ b/libcxx/include/atomic
@@ -16,9 +16,12 @@
namespace std
{
-// feature test macro
+// feature test macro [version.syn]
-#define __cpp_lib_atomic_is_always_lock_free // as specified by SG10
+#define __cpp_lib_atomic_is_always_lock_free
+#define __cpp_lib_atomic_flag_test
+#define __cpp_lib_atomic_lock_free_type_aliases
+#define __cpp_lib_atomic_wait
// order and consistency
@@ -45,6 +48,7 @@ template <class T> T kill_dependency(T y) noexcept;
#define ATOMIC_BOOL_LOCK_FREE unspecified
#define ATOMIC_CHAR_LOCK_FREE unspecified
+#define ATOMIC_CHAR8_T_LOCK_FREE unspecified // C++20
#define ATOMIC_CHAR16_T_LOCK_FREE unspecified
#define ATOMIC_CHAR32_T_LOCK_FREE unspecified
#define ATOMIC_WCHAR_T_LOCK_FREE unspecified
@@ -108,6 +112,7 @@ template <>
struct atomic<integral>
{
using value_type = integral;
+ using difference_type = value_type;
static constexpr bool is_always_lock_free;
bool is_lock_free() const volatile noexcept;
@@ -190,6 +195,7 @@ template <class T>
struct atomic<T*>
{
using value_type = T*;
+ using difference_type = ptrdiff_t;
static constexpr bool is_always_lock_free;
bool is_lock_free() const volatile noexcept;
@@ -460,6 +466,7 @@ typedef atomic<long> atomic_long;
typedef atomic<unsigned long> atomic_ulong;
typedef atomic<long long> atomic_llong;
typedef atomic<unsigned long long> atomic_ullong;
+typedef atomic<char8_t> atomic_char8_t; // C++20
typedef atomic<char16_t> atomic_char16_t;
typedef atomic<char32_t> atomic_char32_t;
typedef atomic<wchar_t> atomic_wchar_t;
@@ -477,7 +484,7 @@ typedef atomic<int_fast8_t> atomic_int_fast8_t;
typedef atomic<uint_fast8_t> atomic_uint_fast8_t;
typedef atomic<int_fast16_t> atomic_int_fast16_t;
typedef atomic<uint_fast16_t> atomic_uint_fast16_t;
-typedef atomic<int_fast32_t> atomic_int_fast32_t;
+typedef atomic<int_fast32_t> atomic_int_fast32_t;
typedef atomic<uint_fast32_t> atomic_uint_fast32_t;
typedef atomic<int_fast64_t> atomic_int_fast64_t;
typedef atomic<uint_fast64_t> atomic_uint_fast64_t;
@@ -568,6 +575,7 @@ template <class T>
*/
#include <__config>
+#include <__availability>
#include <__threading_support>
#include <cstddef>
#include <cstdint>
@@ -654,7 +662,7 @@ typedef enum memory_order {
template <typename _Tp> _LIBCPP_INLINE_VISIBILITY
bool __cxx_nonatomic_compare_equal(_Tp const& __lhs, _Tp const& __rhs) {
- return memcmp(&__lhs, &__rhs, sizeof(_Tp)) == 0;
+ return _VSTD::memcmp(&__lhs, &__rhs, sizeof(_Tp)) == 0;
}
static_assert((is_same<underlying_type<memory_order>::type, __memory_order_underlying_t>::value),
@@ -1119,6 +1127,9 @@ _Tp kill_dependency(_Tp __y) _NOEXCEPT
#if defined(__CLANG_ATOMIC_BOOL_LOCK_FREE)
# define ATOMIC_BOOL_LOCK_FREE __CLANG_ATOMIC_BOOL_LOCK_FREE
# define ATOMIC_CHAR_LOCK_FREE __CLANG_ATOMIC_CHAR_LOCK_FREE
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+# define ATOMIC_CHAR8_T_LOCK_FREE __CLANG_ATOMIC_CHAR8_T_LOCK_FREE
+#endif
# define ATOMIC_CHAR16_T_LOCK_FREE __CLANG_ATOMIC_CHAR16_T_LOCK_FREE
# define ATOMIC_CHAR32_T_LOCK_FREE __CLANG_ATOMIC_CHAR32_T_LOCK_FREE
# define ATOMIC_WCHAR_T_LOCK_FREE __CLANG_ATOMIC_WCHAR_T_LOCK_FREE
@@ -1130,6 +1141,9 @@ _Tp kill_dependency(_Tp __y) _NOEXCEPT
#elif defined(__GCC_ATOMIC_BOOL_LOCK_FREE)
# define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE
# define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+# define ATOMIC_CHAR8_T_LOCK_FREE __GCC_ATOMIC_CHAR8_T_LOCK_FREE
+#endif
# define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE
# define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE
# define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE
@@ -1245,10 +1259,10 @@ template <typename _Tp>
_LIBCPP_INLINE_VISIBILITY
bool __cxx_atomic_compare_exchange_strong(volatile __cxx_atomic_lock_impl<_Tp>* __a,
_Tp* __expected, _Tp __value, memory_order, memory_order) {
- __a->__lock();
_Tp __temp;
+ __a->__lock();
__cxx_atomic_assign_volatile(__temp, __a->__a_value);
- bool __ret = __temp == *__expected;
+ bool __ret = (_VSTD::memcmp(&__temp, __expected, sizeof(_Tp)) == 0);
if(__ret)
__cxx_atomic_assign_volatile(__a->__a_value, __value);
else
@@ -1261,11 +1275,11 @@ _LIBCPP_INLINE_VISIBILITY
bool __cxx_atomic_compare_exchange_strong(__cxx_atomic_lock_impl<_Tp>* __a,
_Tp* __expected, _Tp __value, memory_order, memory_order) {
__a->__lock();
- bool __ret = __a->__a_value == *__expected;
+ bool __ret = (_VSTD::memcmp(&__a->__a_value, __expected, sizeof(_Tp)) == 0);
if(__ret)
- __a->__a_value = __value;
+ _VSTD::memcpy(&__a->__a_value, &__value, sizeof(_Tp));
else
- *__expected = __a->__a_value;
+ _VSTD::memcpy(__expected, &__a->__a_value, sizeof(_Tp));
__a->__unlock();
return __ret;
}
@@ -1274,10 +1288,10 @@ template <typename _Tp>
_LIBCPP_INLINE_VISIBILITY
bool __cxx_atomic_compare_exchange_weak(volatile __cxx_atomic_lock_impl<_Tp>* __a,
_Tp* __expected, _Tp __value, memory_order, memory_order) {
- __a->__lock();
_Tp __temp;
+ __a->__lock();
__cxx_atomic_assign_volatile(__temp, __a->__a_value);
- bool __ret = __temp == *__expected;
+ bool __ret = (_VSTD::memcmp(&__temp, __expected, sizeof(_Tp)) == 0);
if(__ret)
__cxx_atomic_assign_volatile(__a->__a_value, __value);
else
@@ -1290,11 +1304,11 @@ _LIBCPP_INLINE_VISIBILITY
bool __cxx_atomic_compare_exchange_weak(__cxx_atomic_lock_impl<_Tp>* __a,
_Tp* __expected, _Tp __value, memory_order, memory_order) {
__a->__lock();
- bool __ret = __a->__a_value == *__expected;
+ bool __ret = (_VSTD::memcmp(&__a->__a_value, __expected, sizeof(_Tp)) == 0);
if(__ret)
- __a->__a_value = __value;
+ _VSTD::memcpy(&__a->__a_value, &__value, sizeof(_Tp));
else
- *__expected = __a->__a_value;
+ _VSTD::memcpy(__expected, &__a->__a_value, sizeof(_Tp));
__a->__unlock();
return __ret;
}
@@ -1444,6 +1458,9 @@ template<> struct __cxx_is_always_lock_free<bool> { enum { __value = 2 == ATOMIC
template<> struct __cxx_is_always_lock_free<char> { enum { __value = 2 == ATOMIC_CHAR_LOCK_FREE }; };
template<> struct __cxx_is_always_lock_free<signed char> { enum { __value = 2 == ATOMIC_CHAR_LOCK_FREE }; };
template<> struct __cxx_is_always_lock_free<unsigned char> { enum { __value = 2 == ATOMIC_CHAR_LOCK_FREE }; };
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+template<> struct __cxx_is_always_lock_free<char8_t> { enum { __value = 2 == ATOMIC_CHAR8_T_LOCK_FREE }; };
+#endif
template<> struct __cxx_is_always_lock_free<char16_t> { enum { __value = 2 == ATOMIC_CHAR16_T_LOCK_FREE }; };
template<> struct __cxx_is_always_lock_free<char32_t> { enum { __value = 2 == ATOMIC_CHAR32_T_LOCK_FREE }; };
template<> 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 {
using __cxx_contention_t = int64_t;
#endif //__linux__
-#if _LIBCPP_STD_VER >= 11
-
using __cxx_atomic_contention_t = __cxx_atomic_impl<__cxx_contention_t>;
#ifndef _LIBCPP_HAS_NO_PLATFORM_WAIT
@@ -1519,7 +1534,7 @@ struct __libcpp_atomic_wait_backoff_impl {
else if(__elapsed > chrono::microseconds(4))
__libcpp_thread_yield();
else
- ; // poll
+ {} // poll
return false;
}
};
@@ -1565,8 +1580,6 @@ _LIBCPP_INLINE_VISIBILITY bool __cxx_atomic_wait(_Atp* __a, _Tp const __val, mem
return __cxx_atomic_wait(__a, __test_fn);
}
-#endif //_LIBCPP_STD_VER >= 11
-
// general atomic<T>
template <class _Tp, bool = is_integral<_Tp>::value && !is_same<_Tp, bool>::value>
@@ -1775,6 +1788,7 @@ struct atomic
{
typedef __atomic_base<_Tp> __base;
typedef _Tp value_type;
+ typedef value_type difference_type;
_LIBCPP_INLINE_VISIBILITY
atomic() _NOEXCEPT _LIBCPP_DEFAULT
_LIBCPP_INLINE_VISIBILITY
@@ -1796,6 +1810,7 @@ struct atomic<_Tp*>
{
typedef __atomic_base<_Tp*> __base;
typedef _Tp* value_type;
+ typedef ptrdiff_t difference_type;
_LIBCPP_INLINE_VISIBILITY
atomic() _NOEXCEPT _LIBCPP_DEFAULT
_LIBCPP_INLINE_VISIBILITY
@@ -1872,7 +1887,7 @@ atomic_is_lock_free(const atomic<_Tp>* __o) _NOEXCEPT
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
void
-atomic_init(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
+atomic_init(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d) _NOEXCEPT
{
__cxx_atomic_init(&__o->__a_, __d);
}
@@ -1880,7 +1895,7 @@ atomic_init(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
void
-atomic_init(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
+atomic_init(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d) _NOEXCEPT
{
__cxx_atomic_init(&__o->__a_, __d);
}
@@ -1890,7 +1905,7 @@ atomic_init(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
void
-atomic_store(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
+atomic_store(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d) _NOEXCEPT
{
__o->store(__d);
}
@@ -1898,7 +1913,7 @@ atomic_store(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
void
-atomic_store(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
+atomic_store(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d) _NOEXCEPT
{
__o->store(__d);
}
@@ -1908,7 +1923,7 @@ atomic_store(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
void
-atomic_store_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
+atomic_store_explicit(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d, memory_order __m) _NOEXCEPT
_LIBCPP_CHECK_STORE_MEMORY_ORDER(__m)
{
__o->store(__d, __m);
@@ -1917,7 +1932,7 @@ atomic_store_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOE
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
void
-atomic_store_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
+atomic_store_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d, memory_order __m) _NOEXCEPT
_LIBCPP_CHECK_STORE_MEMORY_ORDER(__m)
{
__o->store(__d, __m);
@@ -1966,7 +1981,7 @@ atomic_load_explicit(const atomic<_Tp>* __o, memory_order __m) _NOEXCEPT
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
_Tp
-atomic_exchange(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
+atomic_exchange(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d) _NOEXCEPT
{
return __o->exchange(__d);
}
@@ -1974,7 +1989,7 @@ atomic_exchange(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
_Tp
-atomic_exchange(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
+atomic_exchange(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d) _NOEXCEPT
{
return __o->exchange(__d);
}
@@ -1984,7 +1999,7 @@ atomic_exchange(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
_Tp
-atomic_exchange_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
+atomic_exchange_explicit(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d, memory_order __m) _NOEXCEPT
{
return __o->exchange(__d, __m);
}
@@ -1992,7 +2007,7 @@ atomic_exchange_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
_Tp
-atomic_exchange_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
+atomic_exchange_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d, memory_order __m) _NOEXCEPT
{
return __o->exchange(__d, __m);
}
@@ -2002,7 +2017,7 @@ atomic_exchange_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
bool
-atomic_compare_exchange_weak(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
+atomic_compare_exchange_weak(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type* __e, typename atomic<_Tp>::value_type __d) _NOEXCEPT
{
return __o->compare_exchange_weak(*__e, __d);
}
@@ -2010,7 +2025,7 @@ atomic_compare_exchange_weak(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEX
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
bool
-atomic_compare_exchange_weak(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
+atomic_compare_exchange_weak(atomic<_Tp>* __o, typename atomic<_Tp>::value_type* __e, typename atomic<_Tp>::value_type __d) _NOEXCEPT
{
return __o->compare_exchange_weak(*__e, __d);
}
@@ -2020,7 +2035,7 @@ atomic_compare_exchange_weak(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
bool
-atomic_compare_exchange_strong(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
+atomic_compare_exchange_strong(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type* __e, typename atomic<_Tp>::value_type __d) _NOEXCEPT
{
return __o->compare_exchange_strong(*__e, __d);
}
@@ -2028,7 +2043,7 @@ atomic_compare_exchange_strong(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NO
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
bool
-atomic_compare_exchange_strong(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
+atomic_compare_exchange_strong(atomic<_Tp>* __o, typename atomic<_Tp>::value_type* __e, typename atomic<_Tp>::value_type __d) _NOEXCEPT
{
return __o->compare_exchange_strong(*__e, __d);
}
@@ -2038,8 +2053,8 @@ atomic_compare_exchange_strong(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
bool
-atomic_compare_exchange_weak_explicit(volatile atomic<_Tp>* __o, _Tp* __e,
- _Tp __d,
+atomic_compare_exchange_weak_explicit(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type* __e,
+ typename atomic<_Tp>::value_type __d,
memory_order __s, memory_order __f) _NOEXCEPT
_LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
{
@@ -2049,7 +2064,7 @@ atomic_compare_exchange_weak_explicit(volatile atomic<_Tp>* __o, _Tp* __e,
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
bool
-atomic_compare_exchange_weak_explicit(atomic<_Tp>* __o, _Tp* __e, _Tp __d,
+atomic_compare_exchange_weak_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::value_type* __e, typename atomic<_Tp>::value_type __d,
memory_order __s, memory_order __f) _NOEXCEPT
_LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
{
@@ -2062,7 +2077,7 @@ template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
bool
atomic_compare_exchange_strong_explicit(volatile atomic<_Tp>* __o,
- _Tp* __e, _Tp __d,
+ typename atomic<_Tp>::value_type* __e, typename atomic<_Tp>::value_type __d,
memory_order __s, memory_order __f) _NOEXCEPT
_LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
{
@@ -2072,8 +2087,8 @@ atomic_compare_exchange_strong_explicit(volatile atomic<_Tp>* __o,
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
bool
-atomic_compare_exchange_strong_explicit(atomic<_Tp>* __o, _Tp* __e,
- _Tp __d,
+atomic_compare_exchange_strong_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::value_type* __e,
+ typename atomic<_Tp>::value_type __d,
memory_order __s, memory_order __f) _NOEXCEPT
_LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
{
@@ -2156,10 +2171,10 @@ template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
typename enable_if
<
- is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+ is_integral<_Tp>::value && !is_same<_Tp, bool>::value && !is_const<_Tp>::value,
_Tp
>::type
-atomic_fetch_add(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
+atomic_fetch_add(volatile atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op) _NOEXCEPT
{
return __o->fetch_add(__op);
}
@@ -2168,10 +2183,10 @@ template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
typename enable_if
<
- is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+ is_integral<_Tp>::value && !is_same<_Tp, bool>::value && !is_const<_Tp>::value,
_Tp
>::type
-atomic_fetch_add(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
+atomic_fetch_add(atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op) _NOEXCEPT
{
return __o->fetch_add(__op);
}
@@ -2179,7 +2194,7 @@ atomic_fetch_add(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
_Tp*
-atomic_fetch_add(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
+atomic_fetch_add(volatile atomic<_Tp*>* __o, typename atomic<_Tp*>::difference_type __op) _NOEXCEPT
{
return __o->fetch_add(__op);
}
@@ -2187,7 +2202,7 @@ atomic_fetch_add(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
_Tp*
-atomic_fetch_add(atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
+atomic_fetch_add(atomic<_Tp*>* __o, typename atomic<_Tp*>::difference_type __op) _NOEXCEPT
{
return __o->fetch_add(__op);
}
@@ -2198,10 +2213,10 @@ template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
typename enable_if
<
- is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+ is_integral<_Tp>::value && !is_same<_Tp, bool>::value && !is_const<_Tp>::value,
_Tp
>::type
-atomic_fetch_add_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
+atomic_fetch_add_explicit(volatile atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op, memory_order __m) _NOEXCEPT
{
return __o->fetch_add(__op, __m);
}
@@ -2210,10 +2225,10 @@ template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
typename enable_if
<
- is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+ is_integral<_Tp>::value && !is_same<_Tp, bool>::value && !is_const<_Tp>::value,
_Tp
>::type
-atomic_fetch_add_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
+atomic_fetch_add_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op, memory_order __m) _NOEXCEPT
{
return __o->fetch_add(__op, __m);
}
@@ -2221,8 +2236,7 @@ atomic_fetch_add_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEP
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
_Tp*
-atomic_fetch_add_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op,
- memory_order __m) _NOEXCEPT
+atomic_fetch_add_explicit(volatile atomic<_Tp*>* __o, typename atomic<_Tp*>::difference_type __op, memory_order __m) _NOEXCEPT
{
return __o->fetch_add(__op, __m);
}
@@ -2230,7 +2244,7 @@ atomic_fetch_add_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op,
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
_Tp*
-atomic_fetch_add_explicit(atomic<_Tp*>* __o, ptrdiff_t __op, memory_order __m) _NOEXCEPT
+atomic_fetch_add_explicit(atomic<_Tp*>* __o, typename atomic<_Tp*>::difference_type __op, memory_order __m) _NOEXCEPT
{
return __o->fetch_add(__op, __m);
}
@@ -2241,10 +2255,10 @@ template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
typename enable_if
<
- is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+ is_integral<_Tp>::value && !is_same<_Tp, bool>::value && !is_const<_Tp>::value,
_Tp
>::type
-atomic_fetch_sub(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
+atomic_fetch_sub(volatile atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op) _NOEXCEPT
{
return __o->fetch_sub(__op);
}
@@ -2253,10 +2267,10 @@ template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
typename enable_if
<
- is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+ is_integral<_Tp>::value && !is_same<_Tp, bool>::value && !is_const<_Tp>::value,
_Tp
>::type
-atomic_fetch_sub(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
+atomic_fetch_sub(atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op) _NOEXCEPT
{
return __o->fetch_sub(__op);
}
@@ -2264,7 +2278,7 @@ atomic_fetch_sub(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
_Tp*
-atomic_fetch_sub(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
+atomic_fetch_sub(volatile atomic<_Tp*>* __o, typename atomic<_Tp*>::difference_type __op) _NOEXCEPT
{
return __o->fetch_sub(__op);
}
@@ -2272,7 +2286,7 @@ atomic_fetch_sub(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
_Tp*
-atomic_fetch_sub(atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
+atomic_fetch_sub(atomic<_Tp*>* __o, typename atomic<_Tp*>::difference_type __op) _NOEXCEPT
{
return __o->fetch_sub(__op);
}
@@ -2283,10 +2297,10 @@ template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
typename enable_if
<
- is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+ is_integral<_Tp>::value && !is_same<_Tp, bool>::value && !is_const<_Tp>::value,
_Tp
>::type
-atomic_fetch_sub_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
+atomic_fetch_sub_explicit(volatile atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op, memory_order __m) _NOEXCEPT
{
return __o->fetch_sub(__op, __m);
}
@@ -2295,10 +2309,10 @@ template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
typename enable_if
<
- is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+ is_integral<_Tp>::value && !is_same<_Tp, bool>::value && !is_const<_Tp>::value,
_Tp
>::type
-atomic_fetch_sub_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
+atomic_fetch_sub_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op, memory_order __m) _NOEXCEPT
{
return __o->fetch_sub(__op, __m);
}
@@ -2306,8 +2320,7 @@ atomic_fetch_sub_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEP
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
_Tp*
-atomic_fetch_sub_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op,
- memory_order __m) _NOEXCEPT
+atomic_fetch_sub_explicit(volatile atomic<_Tp*>* __o, typename atomic<_Tp*>::difference_type __op, memory_order __m) _NOEXCEPT
{
return __o->fetch_sub(__op, __m);
}
@@ -2315,7 +2328,7 @@ atomic_fetch_sub_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op,
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
_Tp*
-atomic_fetch_sub_explicit(atomic<_Tp*>* __o, ptrdiff_t __op, memory_order __m) _NOEXCEPT
+atomic_fetch_sub_explicit(atomic<_Tp*>* __o, typename atomic<_Tp*>::difference_type __op, memory_order __m) _NOEXCEPT
{
return __o->fetch_sub(__op, __m);
}
@@ -2329,7 +2342,7 @@ typename enable_if
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
_Tp
>::type
-atomic_fetch_and(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
+atomic_fetch_and(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op) _NOEXCEPT
{
return __o->fetch_and(__op);
}
@@ -2341,7 +2354,7 @@ typename enable_if
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
_Tp
>::type
-atomic_fetch_and(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
+atomic_fetch_and(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op) _NOEXCEPT
{
return __o->fetch_and(__op);
}
@@ -2355,7 +2368,7 @@ typename enable_if
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
_Tp
>::type
-atomic_fetch_and_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
+atomic_fetch_and_explicit(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op, memory_order __m) _NOEXCEPT
{
return __o->fetch_and(__op, __m);
}
@@ -2367,7 +2380,7 @@ typename enable_if
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
_Tp
>::type
-atomic_fetch_and_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
+atomic_fetch_and_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op, memory_order __m) _NOEXCEPT
{
return __o->fetch_and(__op, __m);
}
@@ -2381,7 +2394,7 @@ typename enable_if
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
_Tp
>::type
-atomic_fetch_or(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
+atomic_fetch_or(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op) _NOEXCEPT
{
return __o->fetch_or(__op);
}
@@ -2393,7 +2406,7 @@ typename enable_if
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
_Tp
>::type
-atomic_fetch_or(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
+atomic_fetch_or(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op) _NOEXCEPT
{
return __o->fetch_or(__op);
}
@@ -2407,7 +2420,7 @@ typename enable_if
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
_Tp
>::type
-atomic_fetch_or_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
+atomic_fetch_or_explicit(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op, memory_order __m) _NOEXCEPT
{
return __o->fetch_or(__op, __m);
}
@@ -2419,7 +2432,7 @@ typename enable_if
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
_Tp
>::type
-atomic_fetch_or_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
+atomic_fetch_or_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op, memory_order __m) _NOEXCEPT
{
return __o->fetch_or(__op, __m);
}
@@ -2433,7 +2446,7 @@ typename enable_if
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
_Tp
>::type
-atomic_fetch_xor(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
+atomic_fetch_xor(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op) _NOEXCEPT
{
return __o->fetch_xor(__op);
}
@@ -2445,7 +2458,7 @@ typename enable_if
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
_Tp
>::type
-atomic_fetch_xor(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
+atomic_fetch_xor(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op) _NOEXCEPT
{
return __o->fetch_xor(__op);
}
@@ -2459,7 +2472,7 @@ typename enable_if
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
_Tp
>::type
-atomic_fetch_xor_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
+atomic_fetch_xor_explicit(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op, memory_order __m) _NOEXCEPT
{
return __o->fetch_xor(__op, __m);
}
@@ -2471,7 +2484,7 @@ typename enable_if
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
_Tp
>::type
-atomic_fetch_xor_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
+atomic_fetch_xor_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op, memory_order __m) _NOEXCEPT
{
return __o->fetch_xor(__op, __m);
}
@@ -2715,6 +2728,9 @@ typedef atomic<long> atomic_long;
typedef atomic<unsigned long> atomic_ulong;
typedef atomic<long long> atomic_llong;
typedef atomic<unsigned long long> atomic_ullong;
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+typedef atomic<char8_t> atomic_char8_t;
+#endif
typedef atomic<char16_t> atomic_char16_t;
typedef atomic<char32_t> atomic_char32_t;
typedef atomic<wchar_t> atomic_wchar_t;
diff --git a/libcxx/include/barrier b/libcxx/include/barrier
index 58e3eef9cfe5..be213a6895ef 100644
--- a/libcxx/include/barrier
+++ b/libcxx/include/barrier
@@ -22,6 +22,8 @@ namespace std
public:
using arrival_token = see below;
+ static constexpr ptrdiff_t max() noexcept;
+
constexpr explicit barrier(ptrdiff_t phase_count,
CompletionFunction f = CompletionFunction());
~barrier();
@@ -44,6 +46,7 @@ namespace std
*/
#include <__config>
+#include <__availability>
#include <atomic>
#ifndef _LIBCPP_HAS_NO_TREE_BARRIER
# include <memory>
@@ -57,6 +60,9 @@ namespace std
# error <barrier> is not supported on this single threaded system
#endif
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
#if _LIBCPP_STD_VER >= 14
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -287,7 +293,7 @@ public:
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
barrier(ptrdiff_t __count, _CompletionF __completion = _CompletionF())
- : __b(__count, std::move(__completion)) {
+ : __b(__count, _VSTD::move(__completion)) {
}
barrier(barrier const&) = delete;
@@ -301,7 +307,7 @@ public:
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void wait(arrival_token&& __phase) const
{
- __b.wait(std::move(__phase));
+ __b.wait(_VSTD::move(__phase));
}
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void arrive_and_wait()
@@ -319,4 +325,6 @@ _LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_STD_VER >= 14
+_LIBCPP_POP_MACROS
+
#endif //_LIBCPP_BARRIER
diff --git a/libcxx/include/bit b/libcxx/include/bit
index ae4605b19166..fe360179c5ca 100644
--- a/libcxx/include/bit
+++ b/libcxx/include/bit
@@ -17,13 +17,13 @@ namespace std {
// [bit.pow.two], integral powers of 2
template <class T>
- constexpr bool ispow2(T x) noexcept; // C++20
+ constexpr bool has_single_bit(T x) noexcept; // C++20
template <class T>
- constexpr T ceil2(T x); // C++20
+ constexpr T bit_ceil(T x); // C++20
template <class T>
- constexpr T floor2(T x) noexcept; // C++20
+ constexpr T bit_floor(T x) noexcept; // C++20
template <class T>
- constexpr T log2p1(T x) noexcept; // C++20
+ constexpr T bit_width(T x) noexcept; // C++20
// [bit.rotate], rotating
template<class T>
@@ -55,6 +55,7 @@ namespace std {
*/
#include <__config>
+#include <__bits>
#include <limits>
#include <type_traits>
#include <version>
@@ -76,122 +77,6 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
-#ifndef _LIBCPP_COMPILER_MSVC
-
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-int __libcpp_ctz(unsigned __x) _NOEXCEPT { return __builtin_ctz(__x); }
-
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-int __libcpp_ctz(unsigned long __x) _NOEXCEPT { return __builtin_ctzl(__x); }
-
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-int __libcpp_ctz(unsigned long long __x) _NOEXCEPT { return __builtin_ctzll(__x); }
-
-
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-int __libcpp_clz(unsigned __x) _NOEXCEPT { return __builtin_clz(__x); }
-
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-int __libcpp_clz(unsigned long __x) _NOEXCEPT { return __builtin_clzl(__x); }
-
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-int __libcpp_clz(unsigned long long __x) _NOEXCEPT { return __builtin_clzll(__x); }
-
-
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-int __libcpp_popcount(unsigned __x) _NOEXCEPT { return __builtin_popcount(__x); }
-
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-int __libcpp_popcount(unsigned long __x) _NOEXCEPT { return __builtin_popcountl(__x); }
-
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-int __libcpp_popcount(unsigned long long __x) _NOEXCEPT { return __builtin_popcountll(__x); }
-
-#else // _LIBCPP_COMPILER_MSVC
-
-// Precondition: __x != 0
-inline _LIBCPP_INLINE_VISIBILITY
-int __libcpp_ctz(unsigned __x) {
- static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
- static_assert(sizeof(unsigned long) == 4, "");
- unsigned long __where;
- if (_BitScanForward(&__where, __x))
- return static_cast<int>(__where);
- return 32;
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-int __libcpp_ctz(unsigned long __x) {
- static_assert(sizeof(unsigned long) == sizeof(unsigned), "");
- return __ctz(static_cast<unsigned>(__x));
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-int __libcpp_ctz(unsigned long long __x) {
- unsigned long __where;
-#if defined(_LIBCPP_HAS_BITSCAN64)
- (defined(_M_AMD64) || defined(__x86_64__))
- if (_BitScanForward64(&__where, __x))
- return static_cast<int>(__where);
-#else
- // Win32 doesn't have _BitScanForward64 so emulate it with two 32 bit calls.
- if (_BitScanForward(&__where, static_cast<unsigned long>(__x)))
- return static_cast<int>(__where);
- if (_BitScanForward(&__where, static_cast<unsigned long>(__x >> 32)))
- return static_cast<int>(__where + 32);
-#endif
- return 64;
-}
-
-// Precondition: __x != 0
-inline _LIBCPP_INLINE_VISIBILITY
-int __libcpp_clz(unsigned __x) {
- static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
- static_assert(sizeof(unsigned long) == 4, "");
- unsigned long __where;
- if (_BitScanReverse(&__where, __x))
- return static_cast<int>(31 - __where);
- return 32; // Undefined Behavior.
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-int __libcpp_clz(unsigned long __x) {
- static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
- return __libcpp_clz(static_cast<unsigned>(__x));
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-int __libcpp_clz(unsigned long long __x) {
- unsigned long __where;
-#if defined(_LIBCPP_HAS_BITSCAN64)
- if (_BitScanReverse64(&__where, __x))
- return static_cast<int>(63 - __where);
-#else
- // Win32 doesn't have _BitScanReverse64 so emulate it with two 32 bit calls.
- if (_BitScanReverse(&__where, static_cast<unsigned long>(__x >> 32)))
- return static_cast<int>(63 - (__where + 32));
- if (_BitScanReverse(&__where, static_cast<unsigned long>(__x)))
- return static_cast<int>(63 - __where);
-#endif
- return 64; // Undefined Behavior.
-}
-
-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_popcount(unsigned __x) {
- static_assert(sizeof(unsigned) == 4, "");
- return __popcnt(__x);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_popcount(unsigned long __x) {
- static_assert(sizeof(unsigned long) == 4, "");
- return __popcnt(__x);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_popcount(unsigned long long __x) {
- static_assert(sizeof(unsigned long long) == 8, "");
- return __popcnt64(__x);
-}
-
-#endif // _LIBCPP_COMPILER_MSVC
template <class _Tp>
using __bitop_unsigned_integer _LIBCPP_NODEBUG_TYPE = integral_constant<bool,
@@ -343,14 +228,14 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
unsigned __bit_log2(_Tp __t) _NOEXCEPT
{
static_assert(__bitop_unsigned_integer<_Tp>::value, "__bit_log2 requires unsigned");
- return std::numeric_limits<_Tp>::digits - 1 - __countl_zero(__t);
+ return numeric_limits<_Tp>::digits - 1 - __countl_zero(__t);
}
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-bool __ispow2(_Tp __t) _NOEXCEPT
+bool __has_single_bit(_Tp __t) _NOEXCEPT
{
- static_assert(__bitop_unsigned_integer<_Tp>::value, "__ispow2 requires unsigned");
+ static_assert(__bitop_unsigned_integer<_Tp>::value, "__has_single_bit requires unsigned");
return __t != 0 && (((__t & (__t - 1)) == 0));
}
@@ -399,7 +284,7 @@ _LIBCPP_INLINE_VISIBILITY constexpr
enable_if_t<__bitop_unsigned_integer<_Tp>::value, int>
countr_zero(_Tp __t) noexcept
{
- return __countr_zero(__t);
+ return __countr_zero(__t);
}
@@ -424,15 +309,15 @@ popcount(_Tp __t) noexcept
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY constexpr
enable_if_t<__bitop_unsigned_integer<_Tp>::value, bool>
-ispow2(_Tp __t) noexcept
+has_single_bit(_Tp __t) noexcept
{
- return __ispow2(__t);
+ return __has_single_bit(__t);
}
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY constexpr
enable_if_t<__bitop_unsigned_integer<_Tp>::value, _Tp>
-floor2(_Tp __t) noexcept
+bit_floor(_Tp __t) noexcept
{
return __t == 0 ? 0 : _Tp{1} << __bit_log2(__t);
}
@@ -440,11 +325,11 @@ floor2(_Tp __t) noexcept
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY constexpr
enable_if_t<__bitop_unsigned_integer<_Tp>::value, _Tp>
-ceil2(_Tp __t) noexcept
+bit_ceil(_Tp __t) noexcept
{
if (__t < 2) return 1;
const unsigned __n = numeric_limits<_Tp>::digits - countl_zero((_Tp)(__t - 1u));
- _LIBCPP_DEBUG_ASSERT(__libcpp_is_constant_evaluated() || __n != numeric_limits<_Tp>::digits, "Bad input to ceil2");
+ _LIBCPP_DEBUG_ASSERT(__libcpp_is_constant_evaluated() || __n != numeric_limits<_Tp>::digits, "Bad input to bit_ceil");
if constexpr (sizeof(_Tp) >= sizeof(unsigned))
return _Tp{1} << __n;
@@ -459,12 +344,11 @@ ceil2(_Tp __t) noexcept
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY constexpr
enable_if_t<__bitop_unsigned_integer<_Tp>::value, _Tp>
-log2p1(_Tp __t) noexcept
+bit_width(_Tp __t) noexcept
{
return __t == 0 ? 0 : __bit_log2(__t) + 1;
}
-
enum class endian
{
little = 0xDEAD,
diff --git a/libcxx/include/bitset b/libcxx/include/bitset
index 4755fbeb2152..00503fe1c141 100644
--- a/libcxx/include/bitset
+++ b/libcxx/include/bitset
@@ -380,7 +380,7 @@ unsigned long long
__bitset<_N_words, _Size>::to_ullong(true_type, true_type) const
{
unsigned long long __r = __first_[0];
- for (std::size_t __i = 1; __i < sizeof(unsigned long long) / sizeof(__storage_type); ++__i)
+ for (size_t __i = 1; __i < sizeof(unsigned long long) / sizeof(__storage_type); ++__i)
__r |= static_cast<unsigned long long>(__first_[__i]) << (sizeof(__storage_type) * CHAR_BIT);
return __r;
}
@@ -625,13 +625,13 @@ protected:
explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long) _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t) _NOEXCEPT
- {return reference(0, 1);}
+ {return reference(nullptr, 1);}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t) const _NOEXCEPT
- {return const_reference(0, 1);}
+ {return const_reference(nullptr, 1);}
_LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_t) _NOEXCEPT
- {return iterator(0, 0);}
+ {return iterator(nullptr, 0);}
_LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t) const _NOEXCEPT
- {return const_iterator(0, 0);}
+ {return const_iterator(nullptr, 0);}
_LIBCPP_INLINE_VISIBILITY void operator&=(const __bitset&) _NOEXCEPT {}
_LIBCPP_INLINE_VISIBILITY void operator|=(const __bitset&) _NOEXCEPT {}
@@ -990,7 +990,7 @@ inline
size_t
bitset<_Size>::count() const _NOEXCEPT
{
- return static_cast<size_t>(__count_bool_true(base::__make_iter(0), _Size));
+ return static_cast<size_t>(_VSTD::__count_bool_true(base::__make_iter(0), _Size));
}
template <size_t _Size>
diff --git a/libcxx/include/charconv b/libcxx/include/charconv
index b64000242a7e..4666c5c51db6 100644
--- a/libcxx/include/charconv
+++ b/libcxx/include/charconv
@@ -74,12 +74,13 @@ namespace std {
*/
#include <__config>
+#include <__availability>
#include <__errc>
-#include <type_traits>
+#include <cmath> // for log2f
+#include <cstdint>
+#include <cstring>
#include <limits>
-#include <stdint.h>
-#include <string.h>
-#include <math.h>
+#include <type_traits>
#include <__debug>
@@ -206,7 +207,7 @@ __mul_overflowed(unsigned char __a, _Tp __b, unsigned char& __r)
{
auto __c = __a * __b;
__r = __c;
- return __c > (numeric_limits<unsigned char>::max)();
+ return __c > numeric_limits<unsigned char>::max();
}
template <typename _Tp>
@@ -215,7 +216,7 @@ __mul_overflowed(unsigned short __a, _Tp __b, unsigned short& __r)
{
auto __c = __a * __b;
__r = __c;
- return __c > (numeric_limits<unsigned short>::max)();
+ return __c > numeric_limits<unsigned short>::max();
}
template <typename _Tp>
@@ -226,7 +227,7 @@ __mul_overflowed(_Tp __a, _Tp __b, _Tp& __r)
#if !defined(_LIBCPP_COMPILER_MSVC)
return __builtin_mul_overflow(__a, __b, &__r);
#else
- bool __did = __b && ((numeric_limits<_Tp>::max)() / __b) < __a;
+ bool __did = __b && (numeric_limits<_Tp>::max() / __b) < __a;
__r = __a * __b;
return __did;
#endif
@@ -332,7 +333,7 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type)
auto __len = __p - __buf;
if (__len <= __diff)
{
- memcpy(__first, __buf, __len);
+ _VSTD::memcpy(__first, __buf, __len);
return {__first + __len, {}};
}
else
@@ -381,7 +382,7 @@ __to_chars_integral(char* __first, char* __last, _Tp __value, int __base,
return {__last, errc::value_too_large};
else
{
- memmove(__first, __p, __len);
+ _VSTD::memmove(__first, __p, __len);
return {__first + __len, {}};
}
}
@@ -428,13 +429,13 @@ __sign_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts... __args)
if (__x <= __complement(__to_unsigned(__tl::min())))
{
__x = __complement(__x);
- memcpy(&__value, &__x, sizeof(__x));
+ _VSTD::memcpy(&__value, &__x, sizeof(__x));
return __r;
}
}
else
{
- if (__x <= (__tl::max)())
+ if (__x <= __tl::max())
{
__value = __x;
return __r;
@@ -525,7 +526,7 @@ __from_chars_atoi(const char* __first, const char* __last, _Tp& __value)
auto __p = __tx::__read(__first, __last, __a, __b);
if (__p == __last || !__in_pattern(*__p))
{
- __output_type __m = (numeric_limits<_Tp>::max)();
+ __output_type __m = numeric_limits<_Tp>::max();
if (__m >= __a && __m - __a >= __b)
{
__value = __a + __b;
@@ -580,7 +581,7 @@ __from_chars_integral(const char* __first, const char* __last, _Tp& __value,
if (__p == __last || !__in_pattern(*__p, __base))
{
- if ((__tl::max)() - __a >= __b)
+ if (__tl::max() - __a >= __b)
{
__value = __a + __b;
return {__p, {}};
diff --git a/libcxx/include/chrono b/libcxx/include/chrono
index 117aab31907f..53e4546010cd 100644
--- a/libcxx/include/chrono
+++ b/libcxx/include/chrono
@@ -824,6 +824,7 @@ constexpr chrono::year operator ""y(unsigned lo
*/
#include <__config>
+#include <__availability>
#include <ctime>
#include <type_traits>
#include <ratio>
@@ -1076,7 +1077,7 @@ public:
is_convertible<_Rep2, rep>::value &&
(treat_as_floating_point<rep>::value ||
!treat_as_floating_point<_Rep2>::value)
- >::type* = 0)
+ >::type* = nullptr)
: __rep_(__r) {}
// conversions
@@ -1089,7 +1090,7 @@ public:
treat_as_floating_point<rep>::value ||
(__no_overflow<_Period2, period>::type::den == 1 &&
!treat_as_floating_point<_Rep2>::value))
- >::type* = 0)
+ >::type* = nullptr)
: __rep_(_VSTD::chrono::duration_cast<duration>(__d).count()) {}
// observer
@@ -1375,7 +1376,7 @@ public:
typename enable_if
<
is_convertible<_Duration2, duration>::value
- >::type* = 0)
+ >::type* = nullptr)
: __d_(t.time_since_epoch()) {}
// observer
diff --git a/libcxx/include/cmath b/libcxx/include/cmath
index 0901a23a2498..138ae6f99aad 100644
--- a/libcxx/include/cmath
+++ b/libcxx/include/cmath
@@ -660,8 +660,8 @@ _LIBCPP_CONSTEXPR _IntT __max_representable_int_for_float() _NOEXCEPT {
template <class _IntT, class _RealT>
_LIBCPP_INLINE_VISIBILITY
_IntT __clamp_to_integral(_RealT __r) _NOEXCEPT {
- using _Lim = std::numeric_limits<_IntT>;
- const _IntT _MaxVal = std::__max_representable_int_for_float<_IntT, _RealT>();
+ using _Lim = numeric_limits<_IntT>;
+ const _IntT _MaxVal = __max_representable_int_for_float<_IntT, _RealT>();
if (__r >= ::nextafter(static_cast<_RealT>(_MaxVal), INFINITY)) {
return _Lim::max();
} else if (__r <= _Lim::lowest()) {
diff --git a/libcxx/include/codecvt b/libcxx/include/codecvt
index 05fa765c3180..2befa1b0af72 100644
--- a/libcxx/include/codecvt
+++ b/libcxx/include/codecvt
@@ -109,6 +109,7 @@ protected:
virtual int do_max_length() const _NOEXCEPT;
};
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <>
class _LIBCPP_TYPE_VIS __codecvt_utf8<char16_t>
: public codecvt<char16_t, char, mbstate_t>
@@ -125,6 +126,8 @@ public:
codecvt_mode _Mode)
: codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
_Mode_(_Mode) {}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+
protected:
virtual result
do_out(state_type& __st,
@@ -144,6 +147,7 @@ protected:
virtual int do_max_length() const _NOEXCEPT;
};
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <>
class _LIBCPP_TYPE_VIS __codecvt_utf8<char32_t>
: public codecvt<char32_t, char, mbstate_t>
@@ -160,6 +164,8 @@ public:
codecvt_mode _Mode)
: codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
_Mode_(_Mode) {}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+
protected:
virtual result
do_out(state_type& __st,
@@ -267,6 +273,7 @@ protected:
virtual int do_max_length() const _NOEXCEPT;
};
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <>
class _LIBCPP_TYPE_VIS __codecvt_utf16<char16_t, false>
: public codecvt<char16_t, char, mbstate_t>
@@ -283,6 +290,8 @@ public:
codecvt_mode _Mode)
: codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
_Mode_(_Mode) {}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+
protected:
virtual result
do_out(state_type& __st,
@@ -302,6 +311,7 @@ protected:
virtual int do_max_length() const _NOEXCEPT;
};
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <>
class _LIBCPP_TYPE_VIS __codecvt_utf16<char16_t, true>
: public codecvt<char16_t, char, mbstate_t>
@@ -318,6 +328,8 @@ public:
codecvt_mode _Mode)
: codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
_Mode_(_Mode) {}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+
protected:
virtual result
do_out(state_type& __st,
@@ -337,6 +349,7 @@ protected:
virtual int do_max_length() const _NOEXCEPT;
};
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <>
class _LIBCPP_TYPE_VIS __codecvt_utf16<char32_t, false>
: public codecvt<char32_t, char, mbstate_t>
@@ -353,6 +366,8 @@ public:
codecvt_mode _Mode)
: codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
_Mode_(_Mode) {}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+
protected:
virtual result
do_out(state_type& __st,
@@ -372,6 +387,7 @@ protected:
virtual int do_max_length() const _NOEXCEPT;
};
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <>
class _LIBCPP_TYPE_VIS __codecvt_utf16<char32_t, true>
: public codecvt<char32_t, char, mbstate_t>
@@ -388,6 +404,8 @@ public:
codecvt_mode _Mode)
: codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
_Mode_(_Mode) {}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+
protected:
virtual result
do_out(state_type& __st,
@@ -460,6 +478,7 @@ protected:
virtual int do_max_length() const _NOEXCEPT;
};
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <>
class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<char32_t>
: public codecvt<char32_t, char, mbstate_t>
@@ -476,6 +495,8 @@ public:
codecvt_mode _Mode)
: codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
_Mode_(_Mode) {}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+
protected:
virtual result
do_out(state_type& __st,
@@ -495,6 +516,7 @@ protected:
virtual int do_max_length() const _NOEXCEPT;
};
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <>
class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<char16_t>
: public codecvt<char16_t, char, mbstate_t>
@@ -511,6 +533,8 @@ public:
codecvt_mode _Mode)
: codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
_Mode_(_Mode) {}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+
protected:
virtual result
do_out(state_type& __st,
diff --git a/libcxx/include/compare b/libcxx/include/compare
index 717859a1e3af..048f4821dd4e 100644
--- a/libcxx/include/compare
+++ b/libcxx/include/compare
@@ -154,8 +154,13 @@ enum class _LIBCPP_ENUM_VIS _NCmpResult : signed char {
__unordered = -127
};
-struct _CmpUnspecifiedType;
-using _CmpUnspecifiedParam = void (_CmpUnspecifiedType::*)();
+struct _CmpUnspecifiedParam {
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEVAL
+ _CmpUnspecifiedParam(int _CmpUnspecifiedParam::*) noexcept {}
+
+ template<typename _Tp, typename = _VSTD::enable_if_t<!_VSTD::is_same_v<_Tp, int>>>
+ _CmpUnspecifiedParam(_Tp) = delete;
+};
class weak_equality {
_LIBCPP_INLINE_VISIBILITY
@@ -696,8 +701,8 @@ constexpr _ClassifyCompCategory __type_to_enum() noexcept {
template <size_t _Size>
constexpr _ClassifyCompCategory
-__compute_comp_type(std::array<_ClassifyCompCategory, _Size> __types) {
- std::array<int, _CCC_Size> __seen = {};
+__compute_comp_type(array<_ClassifyCompCategory, _Size> __types) {
+ array<int, _CCC_Size> __seen = {};
for (auto __type : __types)
++__seen[__type];
if (__seen[_None])
diff --git a/libcxx/include/complex b/libcxx/include/complex
index 36c66db50e68..93b7bb5dd53e 100644
--- a/libcxx/include/complex
+++ b/libcxx/include/complex
@@ -227,14 +227,6 @@ template<class T> complex<T> sqrt (const complex<T>&);
template<class T> complex<T> tan (const complex<T>&);
template<class T> complex<T> tanh (const complex<T>&);
-template<class T, class charT, class traits>
- basic_istream<charT, traits>&
- operator>>(basic_istream<charT, traits>& is, complex<T>& x);
-
-template<class T, class charT, class traits>
- basic_ostream<charT, traits>&
- operator<<(basic_ostream<charT, traits>& o, const complex<T>& x);
-
} // std
*/
@@ -244,9 +236,12 @@ template<class T, class charT, class traits>
#include <stdexcept>
#include <cmath>
#include <iosfwd>
-#include <sstream>
#include <version>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+# include <sstream> // for std::basic_ostringstream
+#endif
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
@@ -955,7 +950,7 @@ inline _LIBCPP_INLINE_VISIBILITY
complex<_Tp>
proj(const complex<_Tp>& __c)
{
- std::complex<_Tp> __r = __c;
+ complex<_Tp> __r = __c;
if (__libcpp_isinf_or_builtin(__c.real()) || __libcpp_isinf_or_builtin(__c.imag()))
__r = complex<_Tp>(INFINITY, copysign(_Tp(0), __c.imag()));
return __r;
@@ -1438,6 +1433,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x)
return __is;
}
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
template<class _Tp, class _CharT, class _Traits>
basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x)
@@ -1449,6 +1445,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x)
__s << '(' << __x.real() << ',' << __x.imag() << ')';
return __os << __s.str();
}
+#endif // !_LIBCPP_HAS_NO_LOCALIZATION
#if _LIBCPP_STD_VER > 11
// Literal suffix for complex number literals [complex.literals]
diff --git a/libcxx/include/concepts b/libcxx/include/concepts
index 047e2c290f4e..cf5f9d63971f 100644
--- a/libcxx/include/concepts
+++ b/libcxx/include/concepts
@@ -157,6 +157,11 @@ concept __same_as_impl = _VSTD::_IsSame<_Tp, _Up>::value;
template<class _Tp, class _Up>
concept same_as = __same_as_impl<_Tp, _Up> && __same_as_impl<_Up, _Tp>;
+// [concept.destructible]
+
+template<class _Tp>
+concept destructible = _VSTD::is_nothrow_destructible_v<_Tp>;
+
#endif //_LIBCPP_STD_VER > 17 && defined(__cpp_concepts) && __cpp_concepts >= 201811L
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/ctime b/libcxx/include/ctime
index f9f2f1659d0e..b0e6c65af5d5 100644
--- a/libcxx/include/ctime
+++ b/libcxx/include/ctime
@@ -52,6 +52,20 @@ int timespec_get( struct timespec *ts, int base); // C++17
#pragma GCC system_header
#endif
+// FIXME:
+// Apple SDKs don't define ::timespec_get unconditionally in C++ mode. This
+// should be fixed in future SDKs, but for the time being we need to avoid
+// trying to use that declaration when the SDK doesn't provide it. Note that
+// we're detecting this here instead of in <__config> because we can't include
+// system headers from <__config>, since it leads to circular module dependencies.
+// This is also meant to be a very temporary workaround until the SDKs are fixed.
+#if defined(__APPLE__)
+# include <sys/cdefs.h>
+# if defined(_LIBCPP_HAS_TIMESPEC_GET) && (__DARWIN_C_LEVEL < __DARWIN_C_FULL)
+# define _LIBCPP_HAS_TIMESPEC_GET_NOT_ACTUALLY_PROVIDED
+# endif
+#endif
+
_LIBCPP_BEGIN_NAMESPACE_STD
using ::clock_t;
@@ -72,7 +86,7 @@ using ::gmtime;
using ::localtime;
#endif
using ::strftime;
-#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_TIMESPEC_GET)
+#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_TIMESPEC_GET) && !defined(_LIBCPP_HAS_TIMESPEC_GET_NOT_ACTUALLY_PROVIDED)
using ::timespec_get;
#endif
diff --git a/libcxx/include/deque b/libcxx/include/deque
index c2ea5f2dbe6d..c6517d170f34 100644
--- a/libcxx/include/deque
+++ b/libcxx/include/deque
@@ -1237,7 +1237,7 @@ __deque_base<_Tp, _Allocator>::swap(__deque_base& __c)
__map_.swap(__c.__map_);
_VSTD::swap(__start_, __c.__start_);
_VSTD::swap(size(), __c.size());
- __swap_allocator(__alloc(), __c.__alloc());
+ _VSTD::__swap_allocator(__alloc(), __c.__alloc());
}
template <class _Tp, class _Allocator>
@@ -1393,7 +1393,7 @@ public:
size_type size() const _NOEXCEPT {return __base::size();}
_LIBCPP_INLINE_VISIBILITY
size_type max_size() const _NOEXCEPT
- {return std::min<size_type>(
+ {return _VSTD::min<size_type>(
__alloc_traits::max_size(__base::__alloc()),
numeric_limits<difference_type>::max());}
void resize(size_type __n);
@@ -1586,7 +1586,7 @@ public:
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
template<class _InputIterator,
- class _Alloc = typename std::allocator<typename iterator_traits<_InputIterator>::value_type>,
+ class _Alloc = allocator<typename iterator_traits<_InputIterator>::value_type>,
class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
>
deque(_InputIterator, _InputIterator)
@@ -2376,7 +2376,7 @@ deque<_Tp, _Allocator>::__append(_ForIter __f, _ForIter __l,
for (__deque_block_range __br : __deque_range(__base::end(), __base::end() + __n)) {
_ConstructTransaction __tx(this, __br);
for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_, (void)++__f) {
- __alloc_traits::construct(__a, std::__to_address(__tx.__pos_), *__f);
+ __alloc_traits::construct(__a, _VSTD::__to_address(__tx.__pos_), *__f);
}
}
}
@@ -2393,7 +2393,7 @@ deque<_Tp, _Allocator>::__append(size_type __n)
for (__deque_block_range __br : __deque_range(__base::end(), __base::end() + __n)) {
_ConstructTransaction __tx(this, __br);
for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) {
- __alloc_traits::construct(__a, std::__to_address(__tx.__pos_));
+ __alloc_traits::construct(__a, _VSTD::__to_address(__tx.__pos_));
}
}
}
@@ -2410,7 +2410,7 @@ deque<_Tp, _Allocator>::__append(size_type __n, const value_type& __v)
for (__deque_block_range __br : __deque_range(__base::end(), __base::end() + __n)) {
_ConstructTransaction __tx(this, __br);
for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) {
- __alloc_traits::construct(__a, std::__to_address(__tx.__pos_), __v);
+ __alloc_traits::construct(__a, _VSTD::__to_address(__tx.__pos_), __v);
}
}
@@ -2708,7 +2708,7 @@ void
deque<_Tp, _Allocator>::pop_front()
{
allocator_type& __a = __base::__alloc();
- __alloc_traits::destroy(__a, __to_address(*(__base::__map_.begin() +
+ __alloc_traits::destroy(__a, _VSTD::__to_address(*(__base::__map_.begin() +
__base::__start_ / __base::__block_size) +
__base::__start_ % __base::__block_size));
--__base::size();
@@ -2723,7 +2723,7 @@ deque<_Tp, _Allocator>::pop_back()
_LIBCPP_ASSERT(!empty(), "deque::pop_back called for empty deque");
allocator_type& __a = __base::__alloc();
size_type __p = __base::size() + __base::__start_ - 1;
- __alloc_traits::destroy(__a, __to_address(*(__base::__map_.begin() +
+ __alloc_traits::destroy(__a, _VSTD::__to_address(*(__base::__map_.begin() +
__p / __base::__block_size) +
__p % __base::__block_size));
--__base::size();
diff --git a/libcxx/include/exception b/libcxx/include/exception
index 8e32979f5749..4bf4049f3325 100644
--- a/libcxx/include/exception
+++ b/libcxx/include/exception
@@ -77,6 +77,8 @@ template <class E> void rethrow_if_nested(const E& e);
*/
#include <__config>
+#include <__availability>
+#include <__memory/base.h>
#include <cstddef>
#include <cstdlib>
#include <type_traits>
diff --git a/libcxx/include/experimental/memory_resource b/libcxx/include/experimental/memory_resource
index f999fb9befda..816d21f51368 100644
--- a/libcxx/include/experimental/memory_resource
+++ b/libcxx/include/experimental/memory_resource
@@ -116,7 +116,7 @@ public:
{ return do_is_equal(__other); }
// 8.5.3, memory.resource.priv
-protected:
+private:
virtual void* do_allocate(size_t, size_t) = 0;
virtual void do_deallocate(void*, size_t, size_t) = 0;
virtual bool do_is_equal(memory_resource const &) const _NOEXCEPT = 0;
@@ -381,7 +381,7 @@ public:
{ return __alloc_; }
// 8.7.3, memory.resource.adaptor.mem
-protected:
+private:
virtual void * do_allocate(size_t __bytes, size_t)
{
if (__bytes > __max_size()) {
@@ -407,7 +407,6 @@ protected:
return __p ? __alloc_ == __p->__alloc_ : false;
}
-private:
_LIBCPP_INLINE_VISIBILITY
size_t __max_size() const _NOEXCEPT {
return numeric_limits<size_t>::max() - _MaxAlign;
diff --git a/libcxx/include/experimental/simd b/libcxx/include/experimental/simd
index 39ac35e4eb0a..41f8f799a0b0 100644
--- a/libcxx/include/experimental/simd
+++ b/libcxx/include/experimental/simd
@@ -659,6 +659,9 @@ public:
#pragma GCC system_header
#endif
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD
#if _LIBCPP_STD_VER >= 17
@@ -1566,4 +1569,6 @@ public:
_LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD
+_LIBCPP_POP_MACROS
+
#endif /* _LIBCPP_EXPERIMENTAL_SIMD */
diff --git a/libcxx/include/ext/hash_map b/libcxx/include/ext/hash_map
index 7478d7410064..2d6024cb9036 100644
--- a/libcxx/include/ext/hash_map
+++ b/libcxx/include/ext/hash_map
@@ -671,7 +671,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(const key_type& __k)
__h.get_deleter().__first_constructed = true;
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.second));
__h.get_deleter().__second_constructed = true;
- return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03
+ return __h;
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
diff --git a/libcxx/include/filesystem b/libcxx/include/filesystem
index 1363b630271a..92e37e183def 100644
--- a/libcxx/include/filesystem
+++ b/libcxx/include/filesystem
@@ -230,23 +230,31 @@
*/
#include <__config>
+#include <__availability>
#include <cstddef>
#include <cstdlib>
#include <chrono>
#include <iterator>
#include <iosfwd>
-#include <locale>
#include <memory>
#include <stack>
#include <string>
#include <system_error>
#include <utility>
-#include <iomanip> // for quoted
#include <string_view>
#include <version>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+# include <locale>
+# include <iomanip> // for quoted
+#endif
+
#include <__debug>
+#if defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
+# error "The Filesystem library is not supported by this configuration of libc++"
+#endif
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
@@ -543,6 +551,13 @@ struct __can_convert_char<wchar_t> {
static const bool value = true;
using __char_type = wchar_t;
};
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+template <>
+struct __can_convert_char<char8_t> {
+ static const bool value = true;
+ using __char_type = char8_t;
+};
+#endif
template <>
struct __can_convert_char<char16_t> {
static const bool value = true;
@@ -557,10 +572,20 @@ struct __can_convert_char<char32_t> {
template <class _ECharT>
typename enable_if<__can_convert_char<_ECharT>::value, bool>::type
__is_separator(_ECharT __e) {
+#if defined(_LIBCPP_WIN32API)
+ return __e == _ECharT('/') || __e == _ECharT('\\');
+#else
return __e == _ECharT('/');
+#endif
}
-struct _NullSentinal {};
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+typedef u8string __u8_string;
+#else
+typedef string __u8_string;
+#endif
+
+struct _NullSentinel {};
template <class _Tp>
using _Void = void;
@@ -615,9 +640,9 @@ struct __is_pathable_char_array<_Source, _ECharT*, _UPtr, true>
static _ECharT const* __range_begin(const _ECharT* __b) { return __b; }
static _ECharT const* __range_end(const _ECharT* __b) {
using _Iter = const _ECharT*;
- const _ECharT __sentinal = _ECharT{};
+ const _ECharT __sentinel = _ECharT{};
_Iter __e = __b;
- for (; *__e != __sentinal; ++__e)
+ for (; *__e != __sentinel; ++__e)
;
return __e;
}
@@ -639,7 +664,7 @@ struct __is_pathable_iter<
using _Base = __can_convert_char<_ECharT>;
static _Iter __range_begin(_Iter __b) { return __b; }
- static _NullSentinal __range_end(_Iter) { return _NullSentinal{}; }
+ static _NullSentinel __range_end(_Iter) { return _NullSentinel{}; }
static _ECharT __first_or_null(_Iter __b) { return *__b; }
};
@@ -661,80 +686,219 @@ struct __is_pathable<_Tp, false, true, false> : __is_pathable_char_array<_Tp> {
template <class _Tp>
struct __is_pathable<_Tp, false, false, true> : __is_pathable_iter<_Tp> {};
+#if defined(_LIBCPP_WIN32API)
+typedef wstring __path_string;
+typedef wchar_t __path_value;
+#else
+typedef string __path_string;
+typedef char __path_value;
+#endif
+
+#if defined(_LIBCPP_WIN32API)
+_LIBCPP_FUNC_VIS
+size_t __wide_to_char(const wstring&, char*, size_t);
+_LIBCPP_FUNC_VIS
+size_t __char_to_wide(const string&, wchar_t*, size_t);
+#endif
+
+template <class _ECharT>
+struct _PathCVT;
+
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
template <class _ECharT>
struct _PathCVT {
static_assert(__can_convert_char<_ECharT>::value,
"Char type not convertible");
typedef __narrow_to_utf8<sizeof(_ECharT) * __CHAR_BIT__> _Narrower;
+#if defined(_LIBCPP_WIN32API)
+ typedef __widen_from_utf8<sizeof(wchar_t) * __CHAR_BIT__> _Widener;
+#endif
- static void __append_range(string& __dest, _ECharT const* __b,
+ static void __append_range(__path_string& __dest, _ECharT const* __b,
_ECharT const* __e) {
+#if defined(_LIBCPP_WIN32API)
+ string __utf8;
+ _Narrower()(back_inserter(__utf8), __b, __e);
+ _Widener()(back_inserter(__dest), __utf8.data(), __utf8.data() + __utf8.size());
+#else
_Narrower()(back_inserter(__dest), __b, __e);
+#endif
}
template <class _Iter>
- static void __append_range(string& __dest, _Iter __b, _Iter __e) {
+ static void __append_range(__path_string& __dest, _Iter __b, _Iter __e) {
static_assert(!is_same<_Iter, _ECharT*>::value, "Call const overload");
if (__b == __e)
return;
basic_string<_ECharT> __tmp(__b, __e);
+#if defined(_LIBCPP_WIN32API)
+ string __utf8;
+ _Narrower()(back_inserter(__utf8), __tmp.data(),
+ __tmp.data() + __tmp.length());
+ _Widener()(back_inserter(__dest), __utf8.data(), __utf8.data() + __utf8.size());
+#else
_Narrower()(back_inserter(__dest), __tmp.data(),
__tmp.data() + __tmp.length());
+#endif
}
template <class _Iter>
- static void __append_range(string& __dest, _Iter __b, _NullSentinal) {
+ static void __append_range(__path_string& __dest, _Iter __b, _NullSentinel) {
static_assert(!is_same<_Iter, _ECharT*>::value, "Call const overload");
- const _ECharT __sentinal = _ECharT{};
- if (*__b == __sentinal)
+ const _ECharT __sentinel = _ECharT{};
+ if (*__b == __sentinel)
return;
basic_string<_ECharT> __tmp;
- for (; *__b != __sentinal; ++__b)
+ for (; *__b != __sentinel; ++__b)
__tmp.push_back(*__b);
+#if defined(_LIBCPP_WIN32API)
+ string __utf8;
+ _Narrower()(back_inserter(__utf8), __tmp.data(),
+ __tmp.data() + __tmp.length());
+ _Widener()(back_inserter(__dest), __utf8.data(), __utf8.data() + __utf8.size());
+#else
_Narrower()(back_inserter(__dest), __tmp.data(),
__tmp.data() + __tmp.length());
+#endif
}
template <class _Source>
- static void __append_source(string& __dest, _Source const& __s) {
+ static void __append_source(__path_string& __dest, _Source const& __s) {
using _Traits = __is_pathable<_Source>;
__append_range(__dest, _Traits::__range_begin(__s),
_Traits::__range_end(__s));
}
};
+#endif // !_LIBCPP_HAS_NO_LOCALIZATION
template <>
-struct _PathCVT<char> {
+struct _PathCVT<__path_value> {
template <class _Iter>
static typename enable_if<__is_exactly_cpp17_input_iterator<_Iter>::value>::type
- __append_range(string& __dest, _Iter __b, _Iter __e) {
+ __append_range(__path_string& __dest, _Iter __b, _Iter __e) {
for (; __b != __e; ++__b)
__dest.push_back(*__b);
}
template <class _Iter>
static typename enable_if<__is_cpp17_forward_iterator<_Iter>::value>::type
- __append_range(string& __dest, _Iter __b, _Iter __e) {
+ __append_range(__path_string& __dest, _Iter __b, _Iter __e) {
__dest.__append_forward_unsafe(__b, __e);
}
template <class _Iter>
- static void __append_range(string& __dest, _Iter __b, _NullSentinal) {
- const char __sentinal = char{};
- for (; *__b != __sentinal; ++__b)
+ static void __append_range(__path_string& __dest, _Iter __b, _NullSentinel) {
+ const char __sentinel = char{};
+ for (; *__b != __sentinel; ++__b)
__dest.push_back(*__b);
}
template <class _Source>
- static void __append_source(string& __dest, _Source const& __s) {
+ static void __append_source(__path_string& __dest, _Source const& __s) {
+ using _Traits = __is_pathable<_Source>;
+ __append_range(__dest, _Traits::__range_begin(__s),
+ _Traits::__range_end(__s));
+ }
+};
+
+#if defined(_LIBCPP_WIN32API)
+template <>
+struct _PathCVT<char> {
+
+ static void
+ __append_string(__path_string& __dest, const basic_string<char> &__str) {
+ size_t __size = __char_to_wide(__str, nullptr, 0);
+ size_t __pos = __dest.size();
+ __dest.resize(__pos + __size);
+ __char_to_wide(__str, const_cast<__path_value*>(__dest.data()) + __pos, __size);
+ }
+
+ template <class _Iter>
+ static typename enable_if<__is_exactly_cpp17_input_iterator<_Iter>::value>::type
+ __append_range(__path_string& __dest, _Iter __b, _Iter __e) {
+ basic_string<char> __tmp(__b, __e);
+ __append_string(__dest, __tmp);
+ }
+
+ template <class _Iter>
+ static typename enable_if<__is_cpp17_forward_iterator<_Iter>::value>::type
+ __append_range(__path_string& __dest, _Iter __b, _Iter __e) {
+ basic_string<char> __tmp(__b, __e);
+ __append_string(__dest, __tmp);
+ }
+
+ template <class _Iter>
+ static void __append_range(__path_string& __dest, _Iter __b, _NullSentinel) {
+ const char __sentinel = char{};
+ basic_string<char> __tmp;
+ for (; *__b != __sentinel; ++__b)
+ __tmp.push_back(*__b);
+ __append_string(__dest, __tmp);
+ }
+
+ template <class _Source>
+ static void __append_source(__path_string& __dest, _Source const& __s) {
using _Traits = __is_pathable<_Source>;
__append_range(__dest, _Traits::__range_begin(__s),
_Traits::__range_end(__s));
}
};
+template <class _ECharT>
+struct _PathExport {
+ typedef __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__> _Narrower;
+ typedef __widen_from_utf8<sizeof(_ECharT) * __CHAR_BIT__> _Widener;
+
+ template <class _Str>
+ static void __append(_Str& __dest, const __path_string& __src) {
+ string __utf8;
+ _Narrower()(back_inserter(__utf8), __src.data(), __src.data() + __src.size());
+ _Widener()(back_inserter(__dest), __utf8.data(), __utf8.data() + __utf8.size());
+ }
+};
+
+template <>
+struct _PathExport<char> {
+ template <class _Str>
+ static void __append(_Str& __dest, const __path_string& __src) {
+ size_t __size = __wide_to_char(__src, nullptr, 0);
+ size_t __pos = __dest.size();
+ __dest.resize(__size);
+ __wide_to_char(__src, const_cast<char*>(__dest.data()) + __pos, __size);
+ }
+};
+
+template <>
+struct _PathExport<wchar_t> {
+ template <class _Str>
+ static void __append(_Str& __dest, const __path_string& __src) {
+ __dest.append(__src.begin(), __src.end());
+ }
+};
+
+template <>
+struct _PathExport<char16_t> {
+ template <class _Str>
+ static void __append(_Str& __dest, const __path_string& __src) {
+ __dest.append(__src.begin(), __src.end());
+ }
+};
+
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+template <>
+struct _PathExport<char8_t> {
+ typedef __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__> _Narrower;
+
+ template <class _Str>
+ static void __append(_Str& __dest, const __path_string& __src) {
+ _Narrower()(back_inserter(__dest), __src.data(), __src.data() + __src.size());
+ }
+};
+#endif /* !_LIBCPP_NO_HAS_CHAR8_T */
+#endif /* _LIBCPP_WIN32API */
+
class _LIBCPP_TYPE_VIS path {
template <class _SourceOrIter, class _Tp = path&>
using _EnableIfPathable =
@@ -747,10 +911,15 @@ class _LIBCPP_TYPE_VIS path {
using _SourceCVT = _PathCVT<_SourceChar<_Tp> >;
public:
+#if defined(_LIBCPP_WIN32API)
+ typedef wchar_t value_type;
+ static constexpr value_type preferred_separator = L'\\';
+#else
typedef char value_type;
- typedef basic_string<value_type> string_type;
- typedef _VSTD::string_view __string_view;
static constexpr value_type preferred_separator = '/';
+#endif
+ typedef basic_string<value_type> string_type;
+ typedef basic_string_view<value_type> __string_view;
enum class _LIBCPP_ENUM_VIS format : unsigned char {
auto_format,
@@ -779,12 +948,14 @@ public:
_PathCVT<_ItVal>::__append_range(__pn_, __first, __last);
}
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
// TODO Implement locale conversions.
template <class _Source, class = _EnableIfPathable<_Source, void> >
path(const _Source& __src, const locale& __loc, format = format::auto_format);
template <class _InputIt>
path(_InputIt __first, _InputIt _last, const locale& __loc,
format = format::auto_format);
+#endif
_LIBCPP_INLINE_VISIBILITY
~path() = default;
@@ -922,9 +1093,8 @@ public:
template <class _ECharT>
typename enable_if<__can_convert_char<_ECharT>::value, path&>::type
operator+=(_ECharT __x) {
- basic_string<_ECharT> __tmp;
- __tmp += __x;
- _PathCVT<_ECharT>::__append_source(__pn_, __tmp);
+ _PathCVT<_ECharT>::__append_source(__pn_,
+ basic_string_view<_ECharT>(&__x, 1));
return *this;
}
@@ -950,7 +1120,12 @@ public:
_LIBCPP_INLINE_VISIBILITY
void clear() noexcept { __pn_.clear(); }
- path& make_preferred() { return *this; }
+ path& make_preferred() {
+#if defined(_LIBCPP_WIN32API)
+ _VSTD::replace(__pn_.begin(), __pn_.end(), L'/', L'\\');
+#endif
+ return *this;
+ }
_LIBCPP_INLINE_VISIBILITY
path& remove_filename() {
@@ -983,6 +1158,64 @@ public:
_LIBCPP_INLINE_VISIBILITY operator string_type() const { return __pn_; }
+#if defined(_LIBCPP_WIN32API)
+ _LIBCPP_INLINE_VISIBILITY _VSTD::wstring wstring() const { return __pn_; }
+
+ _VSTD::wstring generic_wstring() const { return __pn_; }
+
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+ template <class _ECharT, class _Traits = char_traits<_ECharT>,
+ class _Allocator = allocator<_ECharT> >
+ basic_string<_ECharT, _Traits, _Allocator>
+ string(const _Allocator& __a = _Allocator()) const {
+ using _Str = basic_string<_ECharT, _Traits, _Allocator>;
+ _Str __s(__a);
+ __s.reserve(__pn_.size());
+ _PathExport<_ECharT>::__append(__s, __pn_);
+ return __s;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY _VSTD::string string() const {
+ return string<char>();
+ }
+ _LIBCPP_INLINE_VISIBILITY __u8_string u8string() const {
+ using _CVT = __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__>;
+ __u8_string __s;
+ __s.reserve(__pn_.size());
+ _CVT()(back_inserter(__s), __pn_.data(), __pn_.data() + __pn_.size());
+ return __s;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY _VSTD::u16string u16string() const {
+ return string<char16_t>();
+ }
+ _LIBCPP_INLINE_VISIBILITY _VSTD::u32string u32string() const {
+ return string<char32_t>();
+ }
+
+ // generic format observers
+ template <class _ECharT, class _Traits = char_traits<_ECharT>,
+ class _Allocator = allocator<_ECharT> >
+ basic_string<_ECharT, _Traits, _Allocator>
+ generic_string(const _Allocator& __a = _Allocator()) const {
+ return string<_ECharT, _Traits, _Allocator>(__a);
+ }
+
+ _VSTD::string generic_string() const { return generic_string<char>(); }
+ _VSTD::u16string generic_u16string() const { return generic_string<char16_t>(); }
+ _VSTD::u32string generic_u32string() const { return generic_string<char32_t>(); }
+ __u8_string generic_u8string() const { return u8string(); }
+#endif /* !_LIBCPP_HAS_NO_LOCALIZATION */
+#else /* _LIBCPP_WIN32API */
+
+ _LIBCPP_INLINE_VISIBILITY _VSTD::string string() const { return __pn_; }
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+ _LIBCPP_INLINE_VISIBILITY _VSTD::u8string u8string() const { return _VSTD::u8string(__pn_.begin(), __pn_.end()); }
+#else
+ _LIBCPP_INLINE_VISIBILITY _VSTD::string u8string() const { return __pn_; }
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
template <class _ECharT, class _Traits = char_traits<_ECharT>,
class _Allocator = allocator<_ECharT> >
basic_string<_ECharT, _Traits, _Allocator>
@@ -995,19 +1228,26 @@ public:
return __s;
}
- _LIBCPP_INLINE_VISIBILITY std::string string() const { return __pn_; }
- _LIBCPP_INLINE_VISIBILITY std::wstring wstring() const {
+ _LIBCPP_INLINE_VISIBILITY _VSTD::wstring wstring() const {
return string<wchar_t>();
}
- _LIBCPP_INLINE_VISIBILITY std::string u8string() const { return __pn_; }
- _LIBCPP_INLINE_VISIBILITY std::u16string u16string() const {
+ _LIBCPP_INLINE_VISIBILITY _VSTD::u16string u16string() const {
return string<char16_t>();
}
- _LIBCPP_INLINE_VISIBILITY std::u32string u32string() const {
+ _LIBCPP_INLINE_VISIBILITY _VSTD::u32string u32string() const {
return string<char32_t>();
}
+#endif /* !_LIBCPP_HAS_NO_LOCALIZATION */
// generic format observers
+ _VSTD::string generic_string() const { return __pn_; }
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+ _VSTD::u8string generic_u8string() const { return _VSTD::u8string(__pn_.begin(), __pn_.end()); }
+#else
+ _VSTD::string generic_u8string() const { return __pn_; }
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
template <class _ECharT, class _Traits = char_traits<_ECharT>,
class _Allocator = allocator<_ECharT> >
basic_string<_ECharT, _Traits, _Allocator>
@@ -1015,11 +1255,11 @@ public:
return string<_ECharT, _Traits, _Allocator>(__a);
}
- std::string generic_string() const { return __pn_; }
- std::wstring generic_wstring() const { return string<wchar_t>(); }
- std::string generic_u8string() const { return __pn_; }
- std::u16string generic_u16string() const { return string<char16_t>(); }
- std::u32string generic_u32string() const { return string<char32_t>(); }
+ _VSTD::wstring generic_wstring() const { return string<wchar_t>(); }
+ _VSTD::u16string generic_u16string() const { return string<char16_t>(); }
+ _VSTD::u32string generic_u32string() const { return string<char32_t>(); }
+#endif /* !_LIBCPP_HAS_NO_LOCALIZATION */
+#endif /* !_LIBCPP_WIN32API */
private:
int __compare(__string_view) const;
@@ -1123,23 +1363,24 @@ public:
iterator begin() const;
iterator end() const;
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
template <class _CharT, class _Traits>
_LIBCPP_INLINE_VISIBILITY friend
- typename enable_if<is_same<_CharT, char>::value &&
- is_same<_Traits, char_traits<char> >::value,
+ typename enable_if<is_same<_CharT, value_type>::value &&
+ is_same<_Traits, char_traits<value_type> >::value,
basic_ostream<_CharT, _Traits>&>::type
operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) {
- __os << std::__quoted(__p.native());
+ __os << _VSTD::__quoted(__p.native());
return __os;
}
template <class _CharT, class _Traits>
_LIBCPP_INLINE_VISIBILITY friend
- typename enable_if<!is_same<_CharT, char>::value ||
- !is_same<_Traits, char_traits<char> >::value,
+ typename enable_if<!is_same<_CharT, value_type>::value ||
+ !is_same<_Traits, char_traits<value_type> >::value,
basic_ostream<_CharT, _Traits>&>::type
operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) {
- __os << std::__quoted(__p.string<_CharT, _Traits>());
+ __os << _VSTD::__quoted(__p.string<_CharT, _Traits>());
return __os;
}
@@ -1151,6 +1392,7 @@ public:
__p = __tmp;
return __is;
}
+#endif // !_LIBCPP_HAS_NO_LOCALIZATION
friend _LIBCPP_INLINE_VISIBILITY bool operator==(const path& __lhs, const path& __rhs) noexcept {
return __lhs.compare(__rhs) == 0;
@@ -1193,25 +1435,70 @@ inline _LIBCPP_INLINE_VISIBILITY void swap(path& __lhs, path& __rhs) noexcept {
_LIBCPP_FUNC_VIS
size_t hash_value(const path& __p) noexcept;
-template <class _Source>
-_LIBCPP_INLINE_VISIBILITY
- typename enable_if<__is_pathable<_Source>::value, path>::type
- u8path(const _Source& __s) {
+template <class _InputIt>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_WITH_CHAR8_T
+ typename enable_if<__is_pathable<_InputIt>::value, path>::type
+ u8path(_InputIt __f, _InputIt __l) {
static_assert(
- is_same<typename __is_pathable<_Source>::__char_type, char>::value,
- "u8path(Source const&) requires Source have a character type of type "
- "'char'");
- return path(__s);
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+ is_same<typename __is_pathable<_InputIt>::__char_type, char8_t>::value ||
+#endif
+ is_same<typename __is_pathable<_InputIt>::__char_type, char>::value,
+ "u8path(Iter, Iter) requires Iter have a value_type of type 'char'"
+ " or 'char8_t'");
+#if defined(_LIBCPP_WIN32API)
+ string __tmp(__f, __l);
+ using _CVT = __widen_from_utf8<sizeof(wchar_t) * __CHAR_BIT__>;
+ _VSTD::wstring __w;
+ __w.reserve(__tmp.size());
+ _CVT()(back_inserter(__w), __tmp.data(), __tmp.data() + __tmp.size());
+ return path(__w);
+#else
+ return path(__f, __l);
+#endif /* !_LIBCPP_WIN32API */
}
+#if defined(_LIBCPP_WIN32API)
template <class _InputIt>
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_WITH_CHAR8_T
typename enable_if<__is_pathable<_InputIt>::value, path>::type
- u8path(_InputIt __f, _InputIt __l) {
+ u8path(_InputIt __f, _NullSentinel) {
static_assert(
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+ is_same<typename __is_pathable<_InputIt>::__char_type, char8_t>::value ||
+#endif
is_same<typename __is_pathable<_InputIt>::__char_type, char>::value,
- "u8path(Iter, Iter) requires Iter have a value_type of type 'char'");
- return path(__f, __l);
+ "u8path(Iter, Iter) requires Iter have a value_type of type 'char'"
+ " or 'char8_t'");
+ string __tmp;
+ const char __sentinel = char{};
+ for (; *__f != __sentinel; ++__f)
+ __tmp.push_back(*__f);
+ using _CVT = __widen_from_utf8<sizeof(wchar_t) * __CHAR_BIT__>;
+ _VSTD::wstring __w;
+ __w.reserve(__tmp.size());
+ _CVT()(back_inserter(__w), __tmp.data(), __tmp.data() + __tmp.size());
+ return path(__w);
+}
+#endif /* _LIBCPP_WIN32API */
+
+template <class _Source>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_WITH_CHAR8_T
+ typename enable_if<__is_pathable<_Source>::value, path>::type
+ u8path(const _Source& __s) {
+ static_assert(
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+ is_same<typename __is_pathable<_Source>::__char_type, char8_t>::value ||
+#endif
+ is_same<typename __is_pathable<_Source>::__char_type, char>::value,
+ "u8path(Source const&) requires Source have a character type of type "
+ "'char' or 'char8_t'");
+#if defined(_LIBCPP_WIN32API)
+ using _Traits = __is_pathable<_Source>;
+ return u8path(__unwrap_iter(_Traits::__range_begin(__s)), __unwrap_iter(_Traits::__range_end(__s)));
+#else
+ return path(__s);
+#endif
}
class _LIBCPP_TYPE_VIS path::iterator {
@@ -1230,7 +1517,7 @@ public:
typedef bidirectional_iterator_tag iterator_category;
typedef path value_type;
- typedef std::ptrdiff_t difference_type;
+ typedef ptrdiff_t difference_type;
typedef const path* pointer;
typedef const path& reference;
@@ -1374,7 +1661,7 @@ template <class... _Args>
_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
#ifndef _LIBCPP_NO_EXCEPTIONS
void __throw_filesystem_error(_Args&&... __args) {
- throw filesystem_error(std::forward<_Args>(__args)...);
+ throw filesystem_error(_VSTD::forward<_Args>(__args)...);
}
#else
void __throw_filesystem_error(_Args&&...) {
@@ -2204,7 +2491,7 @@ private:
_LIBCPP_INLINE_VISIBILITY
void __assign_iter_entry(_Path&& __p, __cached_data __dt) {
- __p_ = std::move(__p);
+ __p_ = _VSTD::move(__p);
__data_ = __dt;
}
@@ -2505,10 +2792,10 @@ end(const directory_iterator&) noexcept {
class recursive_directory_iterator {
public:
using value_type = directory_entry;
- using difference_type = std::ptrdiff_t;
+ using difference_type = ptrdiff_t;
using pointer = directory_entry const*;
using reference = directory_entry const&;
- using iterator_category = std::input_iterator_tag;
+ using iterator_category = input_iterator_tag;
public:
// constructors and destructor
diff --git a/libcxx/include/forward_list b/libcxx/include/forward_list
index 3bd8db8b7d4d..d3d6b8238f6b 100644
--- a/libcxx/include/forward_list
+++ b/libcxx/include/forward_list
@@ -603,7 +603,7 @@ __forward_list_base<_Tp, _Alloc>::swap(__forward_list_base& __x)
__is_nothrow_swappable<__node_allocator>::value)
#endif
{
- __swap_allocator(__alloc(), __x.__alloc(),
+ _VSTD::__swap_allocator(__alloc(), __x.__alloc(),
integral_constant<bool, __node_traits::propagate_on_container_swap::value>());
using _VSTD::swap;
swap(__before_begin()->__next_, __x.__before_begin()->__next_);
@@ -758,7 +758,7 @@ public:
{return base::__before_begin()->__next_ == nullptr;}
_LIBCPP_INLINE_VISIBILITY
size_type max_size() const _NOEXCEPT {
- return std::min<size_type>(
+ return _VSTD::min<size_type>(
__node_traits::max_size(base::__alloc()),
numeric_limits<difference_type>::max());
}
@@ -871,7 +871,7 @@ private:
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
template<class _InputIterator,
- class _Alloc = typename std::allocator<typename iterator_traits<_InputIterator>::value_type>,
+ class _Alloc = allocator<typename iterator_traits<_InputIterator>::value_type>,
class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
>
forward_list(_InputIterator, _InputIterator)
diff --git a/libcxx/include/fstream b/libcxx/include/fstream
index e9138998bf11..d7d6b46c32d9 100644
--- a/libcxx/include/fstream
+++ b/libcxx/include/fstream
@@ -180,12 +180,16 @@ typedef basic_fstream<wchar_t> wfstream;
*/
#include <__config>
+#include <__availability>
#include <ostream>
#include <istream>
#include <__locale>
#include <cstdio>
#include <cstdlib>
-#include <filesystem>
+
+#if !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
+# include <filesystem>
+#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -234,13 +238,13 @@ public:
_LIBCPP_INLINE_VISIBILITY
basic_filebuf* open(const string& __s, ios_base::openmode __mode);
-#if _LIBCPP_STD_VER >= 17
+#if _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
_LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_INLINE_VISIBILITY
basic_filebuf* open(const _VSTD_FS::path& __p, ios_base::openmode __mode) {
return open(__p.c_str(), __mode);
}
#endif
- _LIBCPP_INLINE_VISIBILITY
+ inline _LIBCPP_INLINE_VISIBILITY
basic_filebuf* __open(int __fd, ios_base::openmode __mode);
#endif
basic_filebuf* close();
@@ -286,13 +290,13 @@ private:
template <class _CharT, class _Traits>
basic_filebuf<_CharT, _Traits>::basic_filebuf()
- : __extbuf_(0),
- __extbufnext_(0),
- __extbufend_(0),
+ : __extbuf_(nullptr),
+ __extbufnext_(nullptr),
+ __extbufend_(nullptr),
__ebs_(0),
- __intbuf_(0),
+ __intbuf_(nullptr),
__ibs_(0),
- __file_(0),
+ __file_(nullptr),
__cv_(nullptr),
__st_(),
__st_last_(),
@@ -307,7 +311,7 @@ basic_filebuf<_CharT, _Traits>::basic_filebuf()
__cv_ = &use_facet<codecvt<char_type, char, state_type> >(this->getloc());
__always_noconv_ = __cv_->always_noconv();
}
- setbuf(0, 4096);
+ setbuf(nullptr, 4096);
}
#ifndef _LIBCPP_CXX03_LANG
@@ -359,13 +363,13 @@ basic_filebuf<_CharT, _Traits>::basic_filebuf(basic_filebuf&& __rhs)
(char_type*)__extbuf_ + (__rhs.gptr() - __rhs.eback()),
(char_type*)__extbuf_ + (__rhs.egptr() - __rhs.eback()));
}
- __rhs.__extbuf_ = 0;
- __rhs.__extbufnext_ = 0;
- __rhs.__extbufend_ = 0;
+ __rhs.__extbuf_ = nullptr;
+ __rhs.__extbufnext_ = nullptr;
+ __rhs.__extbufend_ = nullptr;
__rhs.__ebs_ = 0;
__rhs.__intbuf_ = 0;
__rhs.__ibs_ = 0;
- __rhs.__file_ = 0;
+ __rhs.__file_ = nullptr;
__rhs.__st_ = state_type();
__rhs.__st_last_ = state_type();
__rhs.__om_ = 0;
@@ -499,7 +503,7 @@ inline
bool
basic_filebuf<_CharT, _Traits>::is_open() const
{
- return __file_ != 0;
+ return __file_ != nullptr;
}
template <class _CharT, class _Traits>
@@ -547,8 +551,8 @@ template <class _CharT, class _Traits>
basic_filebuf<_CharT, _Traits>*
basic_filebuf<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
{
- basic_filebuf<_CharT, _Traits>* __rt = 0;
- if (__file_ == 0)
+ basic_filebuf<_CharT, _Traits>* __rt = nullptr;
+ if (__file_ == nullptr)
{
if (const char* __mdstr = __make_mdstring(__mode)) {
__rt = this;
@@ -558,22 +562,23 @@ basic_filebuf<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
if (__mode & ios_base::ate) {
if (fseek(__file_, 0, SEEK_END)) {
fclose(__file_);
- __file_ = 0;
- __rt = 0;
+ __file_ = nullptr;
+ __rt = nullptr;
}
}
} else
- __rt = 0;
+ __rt = nullptr;
}
}
return __rt;
}
template <class _CharT, class _Traits>
-_LIBCPP_INLINE_VISIBILITY basic_filebuf<_CharT, _Traits>*
+inline _LIBCPP_INLINE_VISIBILITY
+basic_filebuf<_CharT, _Traits>*
basic_filebuf<_CharT, _Traits>::__open(int __fd, ios_base::openmode __mode) {
- basic_filebuf<_CharT, _Traits>* __rt = 0;
- if (__file_ == 0) {
+ basic_filebuf<_CharT, _Traits>* __rt = nullptr;
+ if (__file_ == nullptr) {
if (const char* __mdstr = __make_mdstring(__mode)) {
__rt = this;
__file_ = fdopen(__fd, __mdstr);
@@ -582,12 +587,12 @@ basic_filebuf<_CharT, _Traits>::__open(int __fd, ios_base::openmode __mode) {
if (__mode & ios_base::ate) {
if (fseek(__file_, 0, SEEK_END)) {
fclose(__file_);
- __file_ = 0;
- __rt = 0;
+ __file_ = nullptr;
+ __rt = nullptr;
}
}
} else
- __rt = 0;
+ __rt = nullptr;
}
}
return __rt;
@@ -600,8 +605,8 @@ template <class _CharT, class _Traits>
basic_filebuf<_CharT, _Traits>*
basic_filebuf<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode)
{
- basic_filebuf<_CharT, _Traits>* __rt = 0;
- if (__file_ == 0)
+ basic_filebuf<_CharT, _Traits>* __rt = nullptr;
+ if (__file_ == nullptr)
{
__rt = this;
const wchar_t* __mdstr;
@@ -650,7 +655,7 @@ basic_filebuf<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mo
__mdstr = L"a+b";
break;
default:
- __rt = 0;
+ __rt = nullptr;
break;
}
if (__rt)
@@ -664,13 +669,13 @@ basic_filebuf<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mo
if (fseek(__file_, 0, SEEK_END))
{
fclose(__file_);
- __file_ = 0;
- __rt = 0;
+ __file_ = nullptr;
+ __rt = nullptr;
}
}
}
else
- __rt = 0;
+ __rt = nullptr;
}
}
return __rt;
@@ -690,16 +695,16 @@ template <class _CharT, class _Traits>
basic_filebuf<_CharT, _Traits>*
basic_filebuf<_CharT, _Traits>::close()
{
- basic_filebuf<_CharT, _Traits>* __rt = 0;
+ basic_filebuf<_CharT, _Traits>* __rt = nullptr;
if (__file_)
{
__rt = this;
unique_ptr<FILE, int(*)(FILE*)> __h(__file_, fclose);
if (sync())
- __rt = 0;
+ __rt = nullptr;
if (fclose(__h.release()))
- __rt = 0;
- __file_ = 0;
+ __rt = nullptr;
+ __file_ = nullptr;
setbuf(0, 0);
}
return __rt;
@@ -709,17 +714,17 @@ template <class _CharT, class _Traits>
typename basic_filebuf<_CharT, _Traits>::int_type
basic_filebuf<_CharT, _Traits>::underflow()
{
- if (__file_ == 0)
+ if (__file_ == nullptr)
return traits_type::eof();
bool __initial = __read_mode();
char_type __1buf;
- if (this->gptr() == 0)
+ if (this->gptr() == nullptr)
this->setg(&__1buf, &__1buf+1, &__1buf+1);
const size_t __unget_sz = __initial ? 0 : min<size_t>((this->egptr() - this->eback()) / 2, 4);
int_type __c = traits_type::eof();
if (this->gptr() == this->egptr())
{
- memmove(this->eback(), this->egptr() - __unget_sz, __unget_sz * sizeof(char_type));
+ _VSTD::memmove(this->eback(), this->egptr() - __unget_sz, __unget_sz * sizeof(char_type));
if (__always_noconv_)
{
size_t __nmemb = static_cast<size_t>(this->egptr() - this->eback() - __unget_sz);
@@ -736,7 +741,7 @@ basic_filebuf<_CharT, _Traits>::underflow()
{
_LIBCPP_ASSERT ( !(__extbufnext_ == NULL && (__extbufend_ != __extbufnext_)), "underflow moving from NULL" );
if (__extbufend_ != __extbufnext_)
- memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);
+ _VSTD::memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);
__extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_);
__extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? sizeof(__extbuf_min_) : __ebs_);
size_t __nmemb = _VSTD::min(static_cast<size_t>(__ibs_ - __unget_sz),
@@ -771,7 +776,7 @@ basic_filebuf<_CharT, _Traits>::underflow()
else
__c = traits_type::to_int_type(*this->gptr());
if (this->eback() == &__1buf)
- this->setg(0, 0, 0);
+ this->setg(nullptr, nullptr, nullptr);
return __c;
}
@@ -801,7 +806,7 @@ template <class _CharT, class _Traits>
typename basic_filebuf<_CharT, _Traits>::int_type
basic_filebuf<_CharT, _Traits>::overflow(int_type __c)
{
- if (__file_ == 0)
+ if (__file_ == nullptr)
return traits_type::eof();
__write_mode();
char_type __1buf;
@@ -809,7 +814,7 @@ basic_filebuf<_CharT, _Traits>::overflow(int_type __c)
char_type* __epb_save = this->epptr();
if (!traits_type::eq_int_type(__c, traits_type::eof()))
{
- if (this->pptr() == 0)
+ if (this->pptr() == nullptr)
this->setp(&__1buf, &__1buf+1);
*this->pptr() = traits_type::to_char_type(__c);
this->pbump(1);
@@ -866,8 +871,8 @@ template <class _CharT, class _Traits>
basic_streambuf<_CharT, _Traits>*
basic_filebuf<_CharT, _Traits>::setbuf(char_type* __s, streamsize __n)
{
- this->setg(0, 0, 0);
- this->setp(0, 0);
+ this->setg(nullptr, nullptr, nullptr);
+ this->setp(nullptr, nullptr);
if (__owns_eb_)
delete [] __extbuf_;
if (__owns_ib_)
@@ -909,7 +914,7 @@ basic_filebuf<_CharT, _Traits>::setbuf(char_type* __s, streamsize __n)
else
{
__ibs_ = 0;
- __intbuf_ = 0;
+ __intbuf_ = nullptr;
__owns_ib_ = false;
}
return this;
@@ -924,7 +929,7 @@ basic_filebuf<_CharT, _Traits>::seekoff(off_type __off, ios_base::seekdir __way,
__throw_bad_cast();
int __width = __cv_->encoding();
- if (__file_ == 0 || (__width <= 0 && __off != 0) || sync())
+ if (__file_ == nullptr || (__width <= 0 && __off != 0) || sync())
return pos_type(off_type(-1));
// __width > 0 || __off == 0
int __whence;
@@ -959,7 +964,7 @@ template <class _CharT, class _Traits>
typename basic_filebuf<_CharT, _Traits>::pos_type
basic_filebuf<_CharT, _Traits>::seekpos(pos_type __sp, ios_base::openmode)
{
- if (__file_ == 0 || sync())
+ if (__file_ == nullptr || sync())
return pos_type(off_type(-1));
#if defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS)
if (fseek(__file_, __sp, SEEK_SET))
@@ -976,7 +981,7 @@ template <class _CharT, class _Traits>
int
basic_filebuf<_CharT, _Traits>::sync()
{
- if (__file_ == 0)
+ if (__file_ == nullptr)
return 0;
if (!__cv_)
__throw_bad_cast();
@@ -1035,7 +1040,7 @@ basic_filebuf<_CharT, _Traits>::sync()
if (__update_st)
__st_ = __state;
__extbufnext_ = __extbufend_ = __extbuf_;
- this->setg(0, 0, 0);
+ this->setg(nullptr, nullptr, nullptr);
__cm_ = 0;
}
return 0;
@@ -1051,8 +1056,8 @@ basic_filebuf<_CharT, _Traits>::imbue(const locale& __loc)
__always_noconv_ = __cv_->always_noconv();
if (__old_anc != __always_noconv_)
{
- this->setg(0, 0, 0);
- this->setp(0, 0);
+ this->setg(nullptr, nullptr, nullptr);
+ this->setp(nullptr, nullptr);
// invariant, char_type is char, else we couldn't get here
if (__always_noconv_) // need to dump __intbuf_
{
@@ -1062,7 +1067,7 @@ basic_filebuf<_CharT, _Traits>::imbue(const locale& __loc)
__ebs_ = __ibs_;
__extbuf_ = (char*)__intbuf_;
__ibs_ = 0;
- __intbuf_ = 0;
+ __intbuf_ = nullptr;
__owns_ib_ = false;
}
else // need to obtain an __intbuf_.
@@ -1091,7 +1096,7 @@ basic_filebuf<_CharT, _Traits>::__read_mode()
{
if (!(__cm_ & ios_base::in))
{
- this->setp(0, 0);
+ this->setp(nullptr, nullptr);
if (__always_noconv_)
this->setg((char_type*)__extbuf_,
(char_type*)__extbuf_ + __ebs_,
@@ -1110,7 +1115,7 @@ basic_filebuf<_CharT, _Traits>::__write_mode()
{
if (!(__cm_ & ios_base::out))
{
- this->setg(0, 0, 0);
+ this->setg(nullptr, nullptr, nullptr);
if (__ebs_ > sizeof(__extbuf_min_))
{
if (__always_noconv_)
@@ -1120,7 +1125,7 @@ basic_filebuf<_CharT, _Traits>::__write_mode()
this->setp(__intbuf_, __intbuf_ + (__ibs_ - 1));
}
else
- this->setp(0, 0);
+ this->setp(nullptr, nullptr);
__cm_ = ios_base::out;
}
}
@@ -1149,7 +1154,7 @@ public:
#endif
_LIBCPP_INLINE_VISIBILITY
explicit basic_ifstream(const string& __s, ios_base::openmode __mode = ios_base::in);
-#if _LIBCPP_STD_VER >= 17
+#if _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
_LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_INLINE_VISIBILITY
explicit basic_ifstream(const filesystem::path& __p, ios_base::openmode __mode = ios_base::in)
: basic_ifstream(__p.c_str(), __mode) {}
@@ -1175,7 +1180,7 @@ public:
void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::in);
#endif
void open(const string& __s, ios_base::openmode __mode = ios_base::in);
-#if _LIBCPP_STD_VER >= 17
+#if _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
_LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_INLINE_VISIBILITY
void open(const filesystem::path& __p,
ios_base::openmode __mode = ios_base::in) {
@@ -1206,7 +1211,7 @@ inline
basic_ifstream<_CharT, _Traits>::basic_ifstream(const char* __s, ios_base::openmode __mode)
: basic_istream<char_type, traits_type>(&__sb_)
{
- if (__sb_.open(__s, __mode | ios_base::in) == 0)
+ if (__sb_.open(__s, __mode | ios_base::in) == nullptr)
this->setstate(ios_base::failbit);
}
@@ -1216,7 +1221,7 @@ inline
basic_ifstream<_CharT, _Traits>::basic_ifstream(const wchar_t* __s, ios_base::openmode __mode)
: basic_istream<char_type, traits_type>(&__sb_)
{
- if (__sb_.open(__s, __mode | ios_base::in) == 0)
+ if (__sb_.open(__s, __mode | ios_base::in) == nullptr)
this->setstate(ios_base::failbit);
}
#endif
@@ -1226,7 +1231,7 @@ inline
basic_ifstream<_CharT, _Traits>::basic_ifstream(const string& __s, ios_base::openmode __mode)
: basic_istream<char_type, traits_type>(&__sb_)
{
- if (__sb_.open(__s, __mode | ios_base::in) == 0)
+ if (__sb_.open(__s, __mode | ios_base::in) == nullptr)
this->setstate(ios_base::failbit);
}
#endif
@@ -1363,7 +1368,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
explicit basic_ofstream(const string& __s, ios_base::openmode __mode = ios_base::out);
-#if _LIBCPP_STD_VER >= 17
+#if _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
_LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_INLINE_VISIBILITY
explicit basic_ofstream(const filesystem::path& __p, ios_base::openmode __mode = ios_base::out)
: basic_ofstream(__p.c_str(), __mode) {}
@@ -1390,7 +1395,7 @@ public:
#endif
void open(const string& __s, ios_base::openmode __mode = ios_base::out);
-#if _LIBCPP_STD_VER >= 17
+#if _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
_LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_INLINE_VISIBILITY
void open(const filesystem::path& __p, ios_base::openmode __mode = ios_base::out)
{ return open(__p.c_str(), __mode); }
@@ -1419,7 +1424,7 @@ inline
basic_ofstream<_CharT, _Traits>::basic_ofstream(const char* __s, ios_base::openmode __mode)
: basic_ostream<char_type, traits_type>(&__sb_)
{
- if (__sb_.open(__s, __mode | ios_base::out) == 0)
+ if (__sb_.open(__s, __mode | ios_base::out) == nullptr)
this->setstate(ios_base::failbit);
}
@@ -1429,7 +1434,7 @@ inline
basic_ofstream<_CharT, _Traits>::basic_ofstream(const wchar_t* __s, ios_base::openmode __mode)
: basic_ostream<char_type, traits_type>(&__sb_)
{
- if (__sb_.open(__s, __mode | ios_base::out) == 0)
+ if (__sb_.open(__s, __mode | ios_base::out) == nullptr)
this->setstate(ios_base::failbit);
}
#endif
@@ -1439,7 +1444,7 @@ inline
basic_ofstream<_CharT, _Traits>::basic_ofstream(const string& __s, ios_base::openmode __mode)
: basic_ostream<char_type, traits_type>(&__sb_)
{
- if (__sb_.open(__s, __mode | ios_base::out) == 0)
+ if (__sb_.open(__s, __mode | ios_base::out) == nullptr)
this->setstate(ios_base::failbit);
}
#endif
@@ -1548,7 +1553,7 @@ inline
void
basic_ofstream<_CharT, _Traits>::close()
{
- if (__sb_.close() == 0)
+ if (__sb_.close() == nullptr)
this->setstate(ios_base::failbit);
}
@@ -1577,7 +1582,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
explicit basic_fstream(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
-#if _LIBCPP_STD_VER >= 17
+#if _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
_LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_INLINE_VISIBILITY
explicit basic_fstream(const filesystem::path& __p, ios_base::openmode __mode = ios_base::in | ios_base::out)
: basic_fstream(__p.c_str(), __mode) {}
@@ -1605,7 +1610,7 @@ public:
#endif
void open(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
-#if _LIBCPP_STD_VER >= 17
+#if _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
_LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_INLINE_VISIBILITY
void open(const filesystem::path& __p, ios_base::openmode __mode = ios_base::in|ios_base::out)
{ return open(__p.c_str(), __mode); }
@@ -1632,7 +1637,7 @@ inline
basic_fstream<_CharT, _Traits>::basic_fstream(const char* __s, ios_base::openmode __mode)
: basic_iostream<char_type, traits_type>(&__sb_)
{
- if (__sb_.open(__s, __mode) == 0)
+ if (__sb_.open(__s, __mode) == nullptr)
this->setstate(ios_base::failbit);
}
@@ -1642,7 +1647,7 @@ inline
basic_fstream<_CharT, _Traits>::basic_fstream(const wchar_t* __s, ios_base::openmode __mode)
: basic_iostream<char_type, traits_type>(&__sb_)
{
- if (__sb_.open(__s, __mode) == 0)
+ if (__sb_.open(__s, __mode) == nullptr)
this->setstate(ios_base::failbit);
}
#endif
@@ -1652,7 +1657,7 @@ inline
basic_fstream<_CharT, _Traits>::basic_fstream(const string& __s, ios_base::openmode __mode)
: basic_iostream<char_type, traits_type>(&__sb_)
{
- if (__sb_.open(__s, __mode) == 0)
+ if (__sb_.open(__s, __mode) == nullptr)
this->setstate(ios_base::failbit);
}
#endif
@@ -1752,10 +1757,16 @@ inline
void
basic_fstream<_CharT, _Traits>::close()
{
- if (__sb_.close() == 0)
+ if (__sb_.close() == nullptr)
this->setstate(ios_base::failbit);
}
+#if defined(_LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1)
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ifstream<char>)
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ofstream<char>)
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_filebuf<char>)
+#endif
+
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
diff --git a/libcxx/include/functional b/libcxx/include/functional
index 3e9425320fc3..67baa5bd4b77 100644
--- a/libcxx/include/functional
+++ b/libcxx/include/functional
@@ -213,7 +213,8 @@ public:
template <class Predicate> // deprecated in C++17
binary_negate<Predicate> not2(const Predicate& pred);
-template <class F> unspecified not_fn(F&& f); // C++17
+template <class F>
+constexpr unspecified not_fn(F&& f); // C++17, constexpr in C++20
template<class T> struct is_bind_expression;
template<class T> struct is_placeholder;
@@ -226,11 +227,12 @@ template <class T> inline constexpr int is_placeholder_v
template<class Fn, class... BoundArgs>
- unspecified bind(Fn&&, BoundArgs&&...);
+ constexpr unspecified bind(Fn&&, BoundArgs&&...); // constexpr in C++20
template<class R, class Fn, class... BoundArgs>
- unspecified bind(Fn&&, BoundArgs&&...);
+ constexpr unspecified bind(Fn&&, BoundArgs&&...); // constexpr in C++20
template<class F, class... Args>
+ constexpr // constexpr in C++20
invoke_result_t<F, Args...> invoke(F&& f, Args&&... args) // C++17
noexcept(is_nothrow_invocable_v<F, Args...>);
@@ -376,7 +378,8 @@ public:
template <class S, class T> const_mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)() const); // deprecated in C++11, removed in C++17
template <class S, class T, class A> const_mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A) const); // deprecated in C++11, removed in C++17
-template<class R, class T> unspecified mem_fn(R T::*);
+template<class R, class T>
+constexpr unspecified mem_fn(R T::*); // constexpr in C++20
class bad_function_call
: public exception
@@ -470,6 +473,7 @@ template <> struct hash<bool>;
template <> struct hash<char>;
template <> struct hash<signed char>;
template <> struct hash<unsigned char>;
+template <> struct hash<char8_t>; // since C++20
template <> struct hash<char16_t>;
template <> struct hash<char32_t>;
template <> struct hash<wchar_t>;
@@ -508,10 +512,6 @@ POLICY: For non-variadic implementations, the number of arguments is limited
#include <__functional_base>
-#if defined(_LIBCPP_HAS_BLOCKS_RUNTIME) && !defined(_LIBCPP_HAS_OBJC_ARC)
-#include <Block.h>
-#endif
-
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
@@ -1291,15 +1291,16 @@ private:
type __f_;
public:
- _LIBCPP_INLINE_VISIBILITY __mem_fn(type __f) _NOEXCEPT : __f_(__f) {}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ __mem_fn(type __f) _NOEXCEPT : __f_(__f) {}
#ifndef _LIBCPP_CXX03_LANG
// invoke
template <class... _ArgTypes>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
typename __invoke_return<type, _ArgTypes...>::type
operator() (_ArgTypes&&... __args) const {
- return __invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...);
+ return _VSTD::__invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...);
}
#else
@@ -1307,104 +1308,104 @@ public:
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return0<type, _A0>::type
operator() (_A0& __a0) const {
- return __invoke(__f_, __a0);
+ return _VSTD::__invoke(__f_, __a0);
}
template <class _A0>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return0<type, _A0 const>::type
operator() (_A0 const& __a0) const {
- return __invoke(__f_, __a0);
+ return _VSTD::__invoke(__f_, __a0);
}
template <class _A0, class _A1>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return1<type, _A0, _A1>::type
operator() (_A0& __a0, _A1& __a1) const {
- return __invoke(__f_, __a0, __a1);
+ return _VSTD::__invoke(__f_, __a0, __a1);
}
template <class _A0, class _A1>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return1<type, _A0 const, _A1>::type
operator() (_A0 const& __a0, _A1& __a1) const {
- return __invoke(__f_, __a0, __a1);
+ return _VSTD::__invoke(__f_, __a0, __a1);
}
template <class _A0, class _A1>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return1<type, _A0, _A1 const>::type
operator() (_A0& __a0, _A1 const& __a1) const {
- return __invoke(__f_, __a0, __a1);
+ return _VSTD::__invoke(__f_, __a0, __a1);
}
template <class _A0, class _A1>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return1<type, _A0 const, _A1 const>::type
operator() (_A0 const& __a0, _A1 const& __a1) const {
- return __invoke(__f_, __a0, __a1);
+ return _VSTD::__invoke(__f_, __a0, __a1);
}
template <class _A0, class _A1, class _A2>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return2<type, _A0, _A1, _A2>::type
operator() (_A0& __a0, _A1& __a1, _A2& __a2) const {
- return __invoke(__f_, __a0, __a1, __a2);
+ return _VSTD::__invoke(__f_, __a0, __a1, __a2);
}
template <class _A0, class _A1, class _A2>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return2<type, _A0 const, _A1, _A2>::type
operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const {
- return __invoke(__f_, __a0, __a1, __a2);
+ return _VSTD::__invoke(__f_, __a0, __a1, __a2);
}
template <class _A0, class _A1, class _A2>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return2<type, _A0, _A1 const, _A2>::type
operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const {
- return __invoke(__f_, __a0, __a1, __a2);
+ return _VSTD::__invoke(__f_, __a0, __a1, __a2);
}
template <class _A0, class _A1, class _A2>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return2<type, _A0, _A1, _A2 const>::type
operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const {
- return __invoke(__f_, __a0, __a1, __a2);
+ return _VSTD::__invoke(__f_, __a0, __a1, __a2);
}
template <class _A0, class _A1, class _A2>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return2<type, _A0 const, _A1 const, _A2>::type
operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const {
- return __invoke(__f_, __a0, __a1, __a2);
+ return _VSTD::__invoke(__f_, __a0, __a1, __a2);
}
template <class _A0, class _A1, class _A2>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return2<type, _A0 const, _A1, _A2 const>::type
operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const {
- return __invoke(__f_, __a0, __a1, __a2);
+ return _VSTD::__invoke(__f_, __a0, __a1, __a2);
}
template <class _A0, class _A1, class _A2>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return2<type, _A0, _A1 const, _A2 const>::type
operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const {
- return __invoke(__f_, __a0, __a1, __a2);
+ return _VSTD::__invoke(__f_, __a0, __a1, __a2);
}
template <class _A0, class _A1, class _A2>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return2<type, _A0 const, _A1 const, _A2 const>::type
operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const {
- return __invoke(__f_, __a0, __a1, __a2);
+ return _VSTD::__invoke(__f_, __a0, __a1, __a2);
}
#endif
};
template<class _Rp, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__mem_fn<_Rp _Tp::*>
mem_fn(_Rp _Tp::* __pm) _NOEXCEPT
{
@@ -1596,7 +1597,7 @@ public:
const _Target& __target() const { return __f_; }
_LIBCPP_INLINE_VISIBILITY
- explicit __default_alloc_func(_Target&& __f) : __f_(std::move(__f)) {}
+ explicit __default_alloc_func(_Target&& __f) : __f_(_VSTD::move(__f)) {}
_LIBCPP_INLINE_VISIBILITY
explicit __default_alloc_func(const _Target& __f) : __f_(__f) {}
@@ -1612,7 +1613,7 @@ public:
__builtin_new_allocator::__holder_t __hold =
__builtin_new_allocator::__allocate_type<__default_alloc_func>(1);
__default_alloc_func* __res =
- ::new (__hold.get()) __default_alloc_func(__f_);
+ ::new ((void*)__hold.get()) __default_alloc_func(__f_);
(void)__hold.release();
return __res;
}
@@ -1703,7 +1704,7 @@ template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
void
__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone(__base<_Rp(_ArgTypes...)>* __p) const
{
- ::new (__p) __func(__f_.__target(), __f_.__get_allocator());
+ ::new ((void*)__p) __func(__f_.__target(), __f_.__get_allocator());
}
template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
@@ -1739,7 +1740,7 @@ __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOE
{
if (__ti == typeid(_Fp))
return &__f_.__target();
- return (const void*)0;
+ return nullptr;
}
template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
@@ -1769,11 +1770,11 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
public:
_LIBCPP_INLINE_VISIBILITY
- __value_func() _NOEXCEPT : __f_(0) {}
+ __value_func() _NOEXCEPT : __f_(nullptr) {}
template <class _Fp, class _Alloc>
_LIBCPP_INLINE_VISIBILITY __value_func(_Fp&& __f, const _Alloc& __a)
- : __f_(0)
+ : __f_(nullptr)
{
typedef allocator_traits<_Alloc> __alloc_traits;
typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _Fun;
@@ -1803,13 +1804,13 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
template <class _Fp,
class = typename enable_if<!is_same<typename decay<_Fp>::type, __value_func>::value>::type>
_LIBCPP_INLINE_VISIBILITY explicit __value_func(_Fp&& __f)
- : __value_func(std::forward<_Fp>(__f), allocator<_Fp>()) {}
+ : __value_func(_VSTD::forward<_Fp>(__f), allocator<_Fp>()) {}
_LIBCPP_INLINE_VISIBILITY
__value_func(const __value_func& __f)
{
- if (__f.__f_ == 0)
- __f_ = 0;
+ if (__f.__f_ == nullptr)
+ __f_ = nullptr;
else if ((void*)__f.__f_ == &__f.__buf_)
{
__f_ = __as_base(&__buf_);
@@ -1822,8 +1823,8 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
_LIBCPP_INLINE_VISIBILITY
__value_func(__value_func&& __f) _NOEXCEPT
{
- if (__f.__f_ == 0)
- __f_ = 0;
+ if (__f.__f_ == nullptr)
+ __f_ = nullptr;
else if ((void*)__f.__f_ == &__f.__buf_)
{
__f_ = __as_base(&__buf_);
@@ -1832,7 +1833,7 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
else
{
__f_ = __f.__f_;
- __f.__f_ = 0;
+ __f.__f_ = nullptr;
}
}
@@ -1849,8 +1850,8 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
__value_func& operator=(__value_func&& __f)
{
*this = nullptr;
- if (__f.__f_ == 0)
- __f_ = 0;
+ if (__f.__f_ == nullptr)
+ __f_ = nullptr;
else if ((void*)__f.__f_ == &__f.__buf_)
{
__f_ = __as_base(&__buf_);
@@ -1859,7 +1860,7 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
else
{
__f_ = __f.__f_;
- __f.__f_ = 0;
+ __f.__f_ = nullptr;
}
return *this;
}
@@ -1868,7 +1869,7 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
__value_func& operator=(nullptr_t)
{
__func* __f = __f_;
- __f_ = 0;
+ __f_ = nullptr;
if ((void*)__f == &__buf_)
__f->destroy();
else if (__f)
@@ -1879,7 +1880,7 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
_LIBCPP_INLINE_VISIBILITY
_Rp operator()(_ArgTypes&&... __args) const
{
- if (__f_ == 0)
+ if (__f_ == nullptr)
__throw_bad_function_call();
return (*__f_)(_VSTD::forward<_ArgTypes>(__args)...);
}
@@ -1895,10 +1896,10 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
__func* __t = __as_base(&__tempbuf);
__f_->__clone(__t);
__f_->destroy();
- __f_ = 0;
+ __f_ = nullptr;
__f.__f_->__clone(__as_base(&__buf_));
__f.__f_->destroy();
- __f.__f_ = 0;
+ __f.__f_ = nullptr;
__f_ = __as_base(&__buf_);
__t->__clone(__as_base(&__f.__buf_));
__t->destroy();
@@ -1923,13 +1924,13 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
}
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT { return __f_ != 0; }
+ _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT { return __f_ != nullptr; }
#ifndef _LIBCPP_NO_RTTI
_LIBCPP_INLINE_VISIBILITY
const std::type_info& target_type() const _NOEXCEPT
{
- if (__f_ == 0)
+ if (__f_ == nullptr)
return typeid(void);
return __f_->target_type();
}
@@ -1937,8 +1938,8 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
template <typename _Tp>
_LIBCPP_INLINE_VISIBILITY const _Tp* target() const _NOEXCEPT
{
- if (__f_ == 0)
- return 0;
+ if (__f_ == nullptr)
+ return nullptr;
return (const _Tp*)__f_->target(typeid(_Tp));
}
#endif // _LIBCPP_NO_RTTI
@@ -2157,7 +2158,7 @@ template <class _Rp, class... _ArgTypes> class __policy_func<_Rp(_ArgTypes...)>
} else {
__builtin_new_allocator::__holder_t __hold =
__builtin_new_allocator::__allocate_type<_Fun>(1);
- __buf_.__large = ::new (__hold.get()) _Fun(_VSTD::move(__f));
+ __buf_.__large = ::new ((void*)__hold.get()) _Fun(_VSTD::move(__f));
(void)__hold.release();
}
}
@@ -2257,6 +2258,9 @@ template <class _Rp, class... _ArgTypes> class __policy_func<_Rp(_ArgTypes...)>
#if defined(_LIBCPP_HAS_BLOCKS_RUNTIME) && !defined(_LIBCPP_HAS_OBJC_ARC)
+extern "C" void *_Block_copy(const void *);
+extern "C" void _Block_release(const void *);
+
template<class _Rp1, class ..._ArgTypes1, class _Alloc, class _Rp, class ..._ArgTypes>
class __func<_Rp1(^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)>
: public __base<_Rp(_ArgTypes...)>
@@ -2267,14 +2271,14 @@ class __func<_Rp1(^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)>
public:
_LIBCPP_INLINE_VISIBILITY
explicit __func(__block_type const& __f)
- : __f_(__f ? Block_copy(__f) : (__block_type)0)
+ : __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr))
{ }
// [TODO] add && to save on a retain
_LIBCPP_INLINE_VISIBILITY
explicit __func(__block_type __f, const _Alloc& /* unused */)
- : __f_(__f ? Block_copy(__f) : (__block_type)0)
+ : __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr))
{ }
virtual __base<_Rp(_ArgTypes...)>* __clone() const {
@@ -2286,12 +2290,12 @@ public:
}
virtual void __clone(__base<_Rp(_ArgTypes...)>* __p) const {
- ::new (__p) __func(__f_);
+ ::new ((void*)__p) __func(__f_);
}
virtual void destroy() _NOEXCEPT {
if (__f_)
- Block_release(__f_);
+ _Block_release(__f_);
__f_ = 0;
}
@@ -2303,7 +2307,7 @@ public:
}
virtual _Rp operator()(_ArgTypes&& ... __arg) {
- return __invoke(__f_, _VSTD::forward<_ArgTypes>(__arg)...);
+ return _VSTD::__invoke(__f_, _VSTD::forward<_ArgTypes>(__arg)...);
}
#ifndef _LIBCPP_NO_RTTI
@@ -2344,9 +2348,9 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>
template <class _Fp>
struct __callable<_Fp, true>
{
- static const bool value = is_same<void, _Rp>::value ||
- is_convertible<typename __invoke_of<_Fp, _ArgTypes...>::type,
- _Rp>::value;
+ static const bool value = is_void<_Rp>::value ||
+ __is_core_convertible<typename __invoke_of<_Fp, _ArgTypes...>::type,
+ _Rp>::value;
};
template <class _Fp>
struct __callable<_Fp, false>
@@ -2518,7 +2522,7 @@ template<class _Rp, class ..._ArgTypes>
function<_Rp(_ArgTypes...)>&
function<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT
{
- __f_ = std::move(__f.__f_);
+ __f_ = _VSTD::move(__f.__f_);
return *this;
}
@@ -2701,7 +2705,7 @@ typename _EnableIf
__mu(_Ti& __ti, tuple<_Uj...>& __uj)
{
typedef typename __make_tuple_indices<sizeof...(_Uj)>::type __indices;
- return __mu_expand(__ti, __uj, __indices());
+ return _VSTD::__mu_expand(__ti, __uj, __indices());
}
template <bool IsPh, class _Ti, class _Uj>
@@ -2873,13 +2877,13 @@ public:
!is_same<typename remove_reference<_Gp>::type,
__bind>::value
>::type>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
explicit __bind(_Gp&& __f, _BA&& ...__bound_args)
: __f_(_VSTD::forward<_Gp>(__f)),
__bound_args_(_VSTD::forward<_BA>(__bound_args)...) {}
template <class ..._Args>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type
operator()(_Args&& ...__args)
{
@@ -2888,7 +2892,7 @@ public:
}
template <class ..._Args>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type
operator()(_Args&& ...__args) const
{
@@ -2918,13 +2922,13 @@ public:
!is_same<typename remove_reference<_Gp>::type,
__bind_r>::value
>::type>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args)
: base(_VSTD::forward<_Gp>(__f),
_VSTD::forward<_BA>(__bound_args)...) {}
template <class ..._Args>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
typename enable_if
<
is_convertible<typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type,
@@ -2938,7 +2942,7 @@ public:
}
template <class ..._Args>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
typename enable_if
<
is_convertible<typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type,
@@ -2956,7 +2960,7 @@ template<class _Rp, class _Fp, class ..._BoundArgs>
struct __is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {};
template<class _Fp, class ..._BoundArgs>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__bind<_Fp, _BoundArgs...>
bind(_Fp&& __f, _BoundArgs&&... __bound_args)
{
@@ -2965,7 +2969,7 @@ bind(_Fp&& __f, _BoundArgs&&... __bound_args)
}
template<class _Rp, class _Fp, class ..._BoundArgs>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__bind_r<_Rp, _Fp, _BoundArgs...>
bind(_Fp&& __f, _BoundArgs&&... __bound_args)
{
@@ -2978,7 +2982,7 @@ bind(_Fp&& __f, _BoundArgs&&... __bound_args)
#if _LIBCPP_STD_VER > 14
template <class _Fn, class ..._Args>
-invoke_result_t<_Fn, _Args...>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 invoke_result_t<_Fn, _Args...>
invoke(_Fn&& __f, _Args&&... __args)
noexcept(is_nothrow_invocable_v<_Fn, _Args...>)
{
@@ -2993,21 +2997,21 @@ public:
__not_fn_imp() = delete;
template <class ..._Args>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
auto operator()(_Args&& ...__args) &
noexcept(noexcept(!_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...)))
-> decltype( !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...))
{ return !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...); }
template <class ..._Args>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
auto operator()(_Args&& ...__args) &&
noexcept(noexcept(!_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...)))
-> decltype( !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...))
{ return !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...); }
template <class ..._Args>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
auto operator()(_Args&& ...__args) const&
noexcept(noexcept(!_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...)))
-> decltype( !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...))
@@ -3015,7 +3019,7 @@ public:
template <class ..._Args>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
auto operator()(_Args&& ...__args) const&&
noexcept(noexcept(!_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...)))
-> decltype( !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...))
@@ -3024,17 +3028,17 @@ public:
private:
template <class _RawFunc,
class = enable_if_t<!is_same<decay_t<_RawFunc>, __not_fn_imp>::value>>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
explicit __not_fn_imp(_RawFunc&& __rf)
: __fd(_VSTD::forward<_RawFunc>(__rf)) {}
template <class _RawFunc>
- friend inline _LIBCPP_INLINE_VISIBILITY
+ friend inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__not_fn_imp<decay_t<_RawFunc>> not_fn(_RawFunc&&);
};
template <class _RawFunc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__not_fn_imp<decay_t<_RawFunc>> not_fn(_RawFunc&& __fn) {
return __not_fn_imp<decay_t<_RawFunc>>(_VSTD::forward<_RawFunc>(__fn));
}
@@ -3131,13 +3135,13 @@ __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
template<class _ForwardIterator, class _BinaryPredicate = equal_to<>>
class _LIBCPP_TYPE_VIS default_searcher {
public:
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
default_searcher(_ForwardIterator __f, _ForwardIterator __l,
_BinaryPredicate __p = _BinaryPredicate())
: __first_(__f), __last_(__l), __pred_(__p) {}
template <typename _ForwardIterator2>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
pair<_ForwardIterator2, _ForwardIterator2>
operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const
{
diff --git a/libcxx/include/future b/libcxx/include/future
index bdf74e3055c0..db60ab69ecad 100644
--- a/libcxx/include/future
+++ b/libcxx/include/future
@@ -362,6 +362,7 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;
*/
#include <__config>
+#include <__availability>
#include <system_error>
#include <memory>
#include <chrono>
@@ -624,18 +625,10 @@ protected:
public:
template <class _Arg>
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- void set_value(_Arg&& __arg);
-#else
- void set_value(_Arg& __arg);
-#endif
+ void set_value(_Arg&& __arg);
template <class _Arg>
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- void set_value_at_thread_exit(_Arg&& __arg);
-#else
- void set_value_at_thread_exit(_Arg& __arg);
-#endif
+ void set_value_at_thread_exit(_Arg&& __arg);
_Rp move();
typename add_lvalue_reference<_Rp>::type copy();
@@ -654,16 +647,12 @@ template <class _Rp>
template <class _Arg>
_LIBCPP_AVAILABILITY_FUTURE
void
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
__assoc_state<_Rp>::set_value(_Arg&& __arg)
-#else
-__assoc_state<_Rp>::set_value(_Arg& __arg)
-#endif
{
unique_lock<mutex> __lk(this->__mut_);
if (this->__has_value())
__throw_future_error(future_errc::promise_already_satisfied);
- ::new(&__value_) _Rp(_VSTD::forward<_Arg>(__arg));
+ ::new ((void*)&__value_) _Rp(_VSTD::forward<_Arg>(__arg));
this->__state_ |= base::__constructed | base::ready;
__cv_.notify_all();
}
@@ -671,16 +660,12 @@ __assoc_state<_Rp>::set_value(_Arg& __arg)
template <class _Rp>
template <class _Arg>
void
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
__assoc_state<_Rp>::set_value_at_thread_exit(_Arg&& __arg)
-#else
-__assoc_state<_Rp>::set_value_at_thread_exit(_Arg& __arg)
-#endif
{
unique_lock<mutex> __lk(this->__mut_);
if (this->__has_value())
__throw_future_error(future_errc::promise_already_satisfied);
- ::new(&__value_) _Rp(_VSTD::forward<_Arg>(__arg));
+ ::new ((void*)&__value_) _Rp(_VSTD::forward<_Arg>(__arg));
this->__state_ |= base::__constructed;
__thread_local_data()->__make_ready_at_thread_exit(this);
}
@@ -856,16 +841,12 @@ class _LIBCPP_AVAILABILITY_FUTURE __deferred_assoc_state
_Fp __func_;
public:
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
explicit __deferred_assoc_state(_Fp&& __f);
-#endif
virtual void __execute();
};
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
template <class _Rp, class _Fp>
inline
__deferred_assoc_state<_Rp, _Fp>::__deferred_assoc_state(_Fp&& __f)
@@ -874,8 +855,6 @@ __deferred_assoc_state<_Rp, _Fp>::__deferred_assoc_state(_Fp&& __f)
this->__set_deferred();
}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
template <class _Rp, class _Fp>
void
__deferred_assoc_state<_Rp, _Fp>::__execute()
@@ -903,16 +882,12 @@ class _LIBCPP_AVAILABILITY_FUTURE __deferred_assoc_state<void, _Fp>
_Fp __func_;
public:
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
explicit __deferred_assoc_state(_Fp&& __f);
-#endif
virtual void __execute();
};
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
template <class _Fp>
inline
__deferred_assoc_state<void, _Fp>::__deferred_assoc_state(_Fp&& __f)
@@ -921,8 +896,6 @@ __deferred_assoc_state<void, _Fp>::__deferred_assoc_state(_Fp&& __f)
this->__set_deferred();
}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
template <class _Fp>
void
__deferred_assoc_state<void, _Fp>::__execute()
@@ -952,16 +925,12 @@ class _LIBCPP_AVAILABILITY_FUTURE __async_assoc_state
virtual void __on_zero_shared() _NOEXCEPT;
public:
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
explicit __async_assoc_state(_Fp&& __f);
-#endif
virtual void __execute();
};
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
template <class _Rp, class _Fp>
inline
__async_assoc_state<_Rp, _Fp>::__async_assoc_state(_Fp&& __f)
@@ -969,8 +938,6 @@ __async_assoc_state<_Rp, _Fp>::__async_assoc_state(_Fp&& __f)
{
}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
template <class _Rp, class _Fp>
void
__async_assoc_state<_Rp, _Fp>::__execute()
@@ -1007,16 +974,12 @@ class _LIBCPP_AVAILABILITY_FUTURE __async_assoc_state<void, _Fp>
virtual void __on_zero_shared() _NOEXCEPT;
public:
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
explicit __async_assoc_state(_Fp&& __f);
-#endif
virtual void __execute();
};
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
template <class _Fp>
inline
__async_assoc_state<void, _Fp>::__async_assoc_state(_Fp&& __f)
@@ -1024,8 +987,6 @@ __async_assoc_state<void, _Fp>::__async_assoc_state(_Fp&& __f)
{
}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
template <class _Fp>
void
__async_assoc_state<void, _Fp>::__execute()
@@ -1062,19 +1023,11 @@ template <class _Rp> class _LIBCPP_TEMPLATE_VIS future;
template <class _Rp, class _Fp>
_LIBCPP_INLINE_VISIBILITY future<_Rp>
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
__make_deferred_assoc_state(_Fp&& __f);
-#else
-__make_deferred_assoc_state(_Fp __f);
-#endif
template <class _Rp, class _Fp>
_LIBCPP_INLINE_VISIBILITY future<_Rp>
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
__make_async_assoc_state(_Fp&& __f);
-#else
-__make_async_assoc_state(_Fp __f);
-#endif
template <class _Rp>
class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FUTURE future
@@ -1086,22 +1039,14 @@ class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FUTURE future
template <class> friend class promise;
template <class> friend class shared_future;
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _R1, class _Fp>
friend future<_R1> __make_deferred_assoc_state(_Fp&& __f);
template <class _R1, class _Fp>
friend future<_R1> __make_async_assoc_state(_Fp&& __f);
-#else
- template <class _R1, class _Fp>
- friend future<_R1> __make_deferred_assoc_state(_Fp __f);
- template <class _R1, class _Fp>
- friend future<_R1> __make_async_assoc_state(_Fp __f);
-#endif
public:
_LIBCPP_INLINE_VISIBILITY
future() _NOEXCEPT : __state_(nullptr) {}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
future(future&& __rhs) _NOEXCEPT
: __state_(__rhs.__state_) {__rhs.__state_ = nullptr;}
@@ -1110,15 +1055,10 @@ public:
_LIBCPP_INLINE_VISIBILITY
future& operator=(future&& __rhs) _NOEXCEPT
{
- future(std::move(__rhs)).swap(*this);
+ future(_VSTD::move(__rhs)).swap(*this);
return *this;
}
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-private:
- future(const future&);
- future& operator=(const future&);
-public:
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
~future();
_LIBCPP_INLINE_VISIBILITY
shared_future<_Rp> share() _NOEXCEPT;
@@ -1186,22 +1126,14 @@ class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FUTURE future<_Rp&>
template <class> friend class promise;
template <class> friend class shared_future;
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _R1, class _Fp>
friend future<_R1> __make_deferred_assoc_state(_Fp&& __f);
template <class _R1, class _Fp>
friend future<_R1> __make_async_assoc_state(_Fp&& __f);
-#else
- template <class _R1, class _Fp>
- friend future<_R1> __make_deferred_assoc_state(_Fp __f);
- template <class _R1, class _Fp>
- friend future<_R1> __make_async_assoc_state(_Fp __f);
-#endif
public:
_LIBCPP_INLINE_VISIBILITY
future() _NOEXCEPT : __state_(nullptr) {}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
future(future&& __rhs) _NOEXCEPT
: __state_(__rhs.__state_) {__rhs.__state_ = nullptr;}
@@ -1210,15 +1142,10 @@ public:
_LIBCPP_INLINE_VISIBILITY
future& operator=(future&& __rhs) _NOEXCEPT
{
- future(std::move(__rhs)).swap(*this);
+ future(_VSTD::move(__rhs)).swap(*this);
return *this;
}
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-private:
- future(const future&);
- future& operator=(const future&);
-public:
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
~future();
_LIBCPP_INLINE_VISIBILITY
shared_future<_Rp&> share() _NOEXCEPT;
@@ -1281,22 +1208,14 @@ class _LIBCPP_TYPE_VIS _LIBCPP_AVAILABILITY_FUTURE future<void>
template <class> friend class promise;
template <class> friend class shared_future;
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _R1, class _Fp>
friend future<_R1> __make_deferred_assoc_state(_Fp&& __f);
template <class _R1, class _Fp>
friend future<_R1> __make_async_assoc_state(_Fp&& __f);
-#else
- template <class _R1, class _Fp>
- friend future<_R1> __make_deferred_assoc_state(_Fp __f);
- template <class _R1, class _Fp>
- friend future<_R1> __make_async_assoc_state(_Fp __f);
-#endif
public:
_LIBCPP_INLINE_VISIBILITY
future() _NOEXCEPT : __state_(nullptr) {}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
future(future&& __rhs) _NOEXCEPT
: __state_(__rhs.__state_) {__rhs.__state_ = nullptr;}
@@ -1305,15 +1224,10 @@ public:
_LIBCPP_INLINE_VISIBILITY
future& operator=(future&& __rhs) _NOEXCEPT
{
- future(std::move(__rhs)).swap(*this);
+ future(_VSTD::move(__rhs)).swap(*this);
return *this;
}
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-private:
- future(const future&);
- future& operator=(const future&);
-public:
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
~future();
_LIBCPP_INLINE_VISIBILITY
shared_future<void> share() _NOEXCEPT;
@@ -1367,32 +1281,21 @@ public:
promise();
template <class _Alloc>
promise(allocator_arg_t, const _Alloc& __a);
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
promise(promise&& __rhs) _NOEXCEPT
: __state_(__rhs.__state_) {__rhs.__state_ = nullptr;}
promise(const promise& __rhs) = delete;
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-private:
- promise(const promise& __rhs);
-public:
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
~promise();
// assignment
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
promise& operator=(promise&& __rhs) _NOEXCEPT
{
- promise(std::move(__rhs)).swap(*this);
+ promise(_VSTD::move(__rhs)).swap(*this);
return *this;
}
promise& operator=(const promise& __rhs) = delete;
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-private:
- promise& operator=(const promise& __rhs);
-public:
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
_LIBCPP_INLINE_VISIBILITY
void swap(promise& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);}
@@ -1401,16 +1304,12 @@ public:
// setting the result
void set_value(const _Rp& __r);
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
void set_value(_Rp&& __r);
-#endif
void set_exception(exception_ptr __p);
// setting the result with deferred notification
void set_value_at_thread_exit(const _Rp& __r);
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
void set_value_at_thread_exit(_Rp&& __r);
-#endif
void set_exception_at_thread_exit(exception_ptr __p);
};
@@ -1429,7 +1328,7 @@ promise<_Rp>::promise(allocator_arg_t, const _Alloc& __a0)
typedef __allocator_destructor<_A2> _D2;
_A2 __a(__a0);
unique_ptr<_State, _D2> __hold(__a.allocate(1), _D2(__a, 1));
- ::new(static_cast<void*>(_VSTD::addressof(*__hold.get()))) _State(__a0);
+ ::new ((void*)_VSTD::addressof(*__hold.get())) _State(__a0);
__state_ = _VSTD::addressof(*__hold.release());
}
@@ -1464,8 +1363,6 @@ promise<_Rp>::set_value(const _Rp& __r)
__state_->set_value(__r);
}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
template <class _Rp>
void
promise<_Rp>::set_value(_Rp&& __r)
@@ -1475,8 +1372,6 @@ promise<_Rp>::set_value(_Rp&& __r)
__state_->set_value(_VSTD::move(__r));
}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
template <class _Rp>
void
promise<_Rp>::set_exception(exception_ptr __p)
@@ -1496,8 +1391,6 @@ promise<_Rp>::set_value_at_thread_exit(const _Rp& __r)
__state_->set_value_at_thread_exit(__r);
}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
template <class _Rp>
void
promise<_Rp>::set_value_at_thread_exit(_Rp&& __r)
@@ -1507,8 +1400,6 @@ promise<_Rp>::set_value_at_thread_exit(_Rp&& __r)
__state_->set_value_at_thread_exit(_VSTD::move(__r));
}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
template <class _Rp>
void
promise<_Rp>::set_exception_at_thread_exit(exception_ptr __p)
@@ -1535,32 +1426,21 @@ public:
promise();
template <class _Allocator>
promise(allocator_arg_t, const _Allocator& __a);
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
promise(promise&& __rhs) _NOEXCEPT
: __state_(__rhs.__state_) {__rhs.__state_ = nullptr;}
promise(const promise& __rhs) = delete;
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-private:
- promise(const promise& __rhs);
-public:
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
~promise();
// assignment
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
promise& operator=(promise&& __rhs) _NOEXCEPT
{
- promise(std::move(__rhs)).swap(*this);
+ promise(_VSTD::move(__rhs)).swap(*this);
return *this;
}
promise& operator=(const promise& __rhs) = delete;
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-private:
- promise& operator=(const promise& __rhs);
-public:
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
_LIBCPP_INLINE_VISIBILITY
void swap(promise& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);}
@@ -1591,7 +1471,7 @@ promise<_Rp&>::promise(allocator_arg_t, const _Alloc& __a0)
typedef __allocator_destructor<_A2> _D2;
_A2 __a(__a0);
unique_ptr<_State, _D2> __hold(__a.allocate(1), _D2(__a, 1));
- ::new(static_cast<void*>(_VSTD::addressof(*__hold.get()))) _State(__a0);
+ ::new ((void*)_VSTD::addressof(*__hold.get())) _State(__a0);
__state_ = _VSTD::addressof(*__hold.release());
}
@@ -1672,32 +1552,21 @@ public:
template <class _Allocator>
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
promise(allocator_arg_t, const _Allocator& __a);
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
promise(promise&& __rhs) _NOEXCEPT
: __state_(__rhs.__state_) {__rhs.__state_ = nullptr;}
promise(const promise& __rhs) = delete;
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-private:
- promise(const promise& __rhs);
-public:
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
~promise();
// assignment
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
promise& operator=(promise&& __rhs) _NOEXCEPT
{
- promise(std::move(__rhs)).swap(*this);
+ promise(_VSTD::move(__rhs)).swap(*this);
return *this;
}
promise& operator=(const promise& __rhs) = delete;
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-private:
- promise& operator=(const promise& __rhs);
-public:
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
_LIBCPP_INLINE_VISIBILITY
void swap(promise& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);}
@@ -1721,7 +1590,7 @@ promise<void>::promise(allocator_arg_t, const _Alloc& __a0)
typedef __allocator_destructor<_A2> _D2;
_A2 __a(__a0);
unique_ptr<_State, _D2> __hold(__a.allocate(1), _D2(__a, 1));
- ::new(static_cast<void*>(_VSTD::addressof(*__hold.get()))) _State(__a0);
+ ::new ((void*)_VSTD::addressof(*__hold.get())) _State(__a0);
__state_ = _VSTD::addressof(*__hold.release());
}
@@ -1737,8 +1606,6 @@ template <class _Rp, class _Alloc>
struct _LIBCPP_TEMPLATE_VIS uses_allocator<promise<_Rp>, _Alloc>
: public true_type {};
-#ifndef _LIBCPP_HAS_NO_VARIADICS
-
// packaged_task
template<class _Fp> class __packaged_task_base;
@@ -1788,7 +1655,7 @@ void
__packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__move_to(
__packaged_task_base<_Rp(_ArgTypes...)>* __p) _NOEXCEPT
{
- ::new (__p) __packaged_task_func(_VSTD::move(__f_.first()), _VSTD::move(__f_.second()));
+ ::new ((void*)__p) __packaged_task_func(_VSTD::move(__f_.first()), _VSTD::move(__f_.second()));
}
template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
@@ -1814,7 +1681,7 @@ template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
_Rp
__packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&& ... __arg)
{
- return __invoke(__f_.first(), _VSTD::forward<_ArgTypes>(__arg)...);
+ return _VSTD::__invoke(__f_.first(), _VSTD::forward<_ArgTypes>(__arg)...);
}
template <class _Callable> class __packaged_task_function;
@@ -1823,6 +1690,10 @@ template<class _Rp, class ..._ArgTypes>
class _LIBCPP_AVAILABILITY_FUTURE __packaged_task_function<_Rp(_ArgTypes...)>
{
typedef __packaged_task_base<_Rp(_ArgTypes...)> __base;
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_NO_CFI
+ __base* __get_buf() { return (__base*)&__buf_; }
+
typename aligned_storage<3*sizeof(void*)>::type __buf_;
__base* __f_;
@@ -1856,10 +1727,10 @@ __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(__packaged
{
if (__f.__f_ == nullptr)
__f_ = nullptr;
- else if (__f.__f_ == (__base*)&__f.__buf_)
+ else if (__f.__f_ == __f.__get_buf())
{
+ __f.__f_->__move_to(__get_buf());
__f_ = (__base*)&__buf_;
- __f.__f_->__move_to(__f_);
}
else
{
@@ -1877,8 +1748,8 @@ __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(_Fp&& __f)
typedef __packaged_task_func<_FR, allocator<_FR>, _Rp(_ArgTypes...)> _FF;
if (sizeof(_FF) <= sizeof(__buf_))
{
+ ::new ((void*)&__buf_) _FF(_VSTD::forward<_Fp>(__f));
__f_ = (__base*)&__buf_;
- ::new (__f_) _FF(_VSTD::forward<_Fp>(__f));
}
else
{
@@ -1886,7 +1757,7 @@ __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(_Fp&& __f)
_Ap __a;
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
- ::new (__hold.get()) _FF(_VSTD::forward<_Fp>(__f), allocator<_FR>(__a));
+ ::new ((void*)__hold.get()) _FF(_VSTD::forward<_Fp>(__f), allocator<_FR>(__a));
__f_ = __hold.release();
}
}
@@ -1902,7 +1773,7 @@ __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(
if (sizeof(_FF) <= sizeof(__buf_))
{
__f_ = (__base*)&__buf_;
- ::new (__f_) _FF(_VSTD::forward<_Fp>(__f));
+ ::new ((void*)__f_) _FF(_VSTD::forward<_Fp>(__f));
}
else
{
@@ -1910,7 +1781,7 @@ __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(
_Ap __a(__a0);
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
- ::new (static_cast<void*>(_VSTD::addressof(*__hold.get())))
+ ::new ((void*)_VSTD::addressof(*__hold.get()))
_FF(_VSTD::forward<_Fp>(__f), _Alloc(__a));
__f_ = _VSTD::addressof(*__hold.release());
}
@@ -1920,17 +1791,17 @@ template<class _Rp, class ..._ArgTypes>
__packaged_task_function<_Rp(_ArgTypes...)>&
__packaged_task_function<_Rp(_ArgTypes...)>::operator=(__packaged_task_function&& __f) _NOEXCEPT
{
- if (__f_ == (__base*)&__buf_)
+ if (__f_ == __get_buf())
__f_->destroy();
else if (__f_)
__f_->destroy_deallocate();
__f_ = nullptr;
if (__f.__f_ == nullptr)
__f_ = nullptr;
- else if (__f.__f_ == (__base*)&__f.__buf_)
+ else if (__f.__f_ == __f.__get_buf())
{
- __f_ = (__base*)&__buf_;
- __f.__f_->__move_to(__f_);
+ __f.__f_->__move_to(__get_buf());
+ __f_ = __get_buf();
}
else
{
@@ -1943,13 +1814,14 @@ __packaged_task_function<_Rp(_ArgTypes...)>::operator=(__packaged_task_function&
template<class _Rp, class ..._ArgTypes>
__packaged_task_function<_Rp(_ArgTypes...)>::~__packaged_task_function()
{
- if (__f_ == (__base*)&__buf_)
+ if (__f_ == __get_buf())
__f_->destroy();
else if (__f_)
__f_->destroy_deallocate();
}
template<class _Rp, class ..._ArgTypes>
+_LIBCPP_NO_CFI
void
__packaged_task_function<_Rp(_ArgTypes...)>::swap(__packaged_task_function& __f) _NOEXCEPT
{
@@ -2268,11 +2140,7 @@ struct _LIBCPP_TEMPLATE_VIS uses_allocator<packaged_task<_Callable>, _Alloc>
template <class _Rp, class _Fp>
_LIBCPP_INLINE_VISIBILITY future<_Rp>
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
__make_deferred_assoc_state(_Fp&& __f)
-#else
-__make_deferred_assoc_state(_Fp __f)
-#endif
{
unique_ptr<__deferred_assoc_state<_Rp, _Fp>, __release_shared_count>
__h(new __deferred_assoc_state<_Rp, _Fp>(_VSTD::forward<_Fp>(__f)));
@@ -2281,11 +2149,7 @@ __make_deferred_assoc_state(_Fp __f)
template <class _Rp, class _Fp>
_LIBCPP_INLINE_VISIBILITY future<_Rp>
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
__make_async_assoc_state(_Fp&& __f)
-#else
-__make_async_assoc_state(_Fp __f)
-#endif
{
unique_ptr<__async_assoc_state<_Rp, _Fp>, __release_shared_count>
__h(new __async_assoc_state<_Rp, _Fp>(_VSTD::forward<_Fp>(__f)));
@@ -2293,6 +2157,8 @@ __make_async_assoc_state(_Fp __f)
return future<_Rp>(__h.get());
}
+#ifndef _LIBCPP_CXX03_LANG
+
template <class _Fp, class... _Args>
class _LIBCPP_HIDDEN __async_func
{
@@ -2318,7 +2184,7 @@ private:
_Rp
__execute(__tuple_indices<_Indices...>)
{
- return __invoke(_VSTD::move(_VSTD::get<0>(__f_)), _VSTD::move(_VSTD::get<_Indices>(__f_))...);
+ return _VSTD::__invoke(_VSTD::move(_VSTD::get<0>(__f_)), _VSTD::move(_VSTD::get<_Indices>(__f_))...);
}
};
@@ -2338,16 +2204,16 @@ async(launch __policy, _Fp&& __f, _Args&&... __args)
{
#endif
if (__does_policy_contain(__policy, launch::async))
- return _VSTD::__make_async_assoc_state<_Rp>(_BF(__decay_copy(_VSTD::forward<_Fp>(__f)),
- __decay_copy(_VSTD::forward<_Args>(__args))...));
+ return _VSTD::__make_async_assoc_state<_Rp>(_BF(_VSTD::__decay_copy(_VSTD::forward<_Fp>(__f)),
+ _VSTD::__decay_copy(_VSTD::forward<_Args>(__args))...));
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch ( ... ) { if (__policy == launch::async) throw ; }
#endif
if (__does_policy_contain(__policy, launch::deferred))
- return _VSTD::__make_deferred_assoc_state<_Rp>(_BF(__decay_copy(_VSTD::forward<_Fp>(__f)),
- __decay_copy(_VSTD::forward<_Args>(__args))...));
+ return _VSTD::__make_deferred_assoc_state<_Rp>(_BF(_VSTD::__decay_copy(_VSTD::forward<_Fp>(__f)),
+ _VSTD::__decay_copy(_VSTD::forward<_Args>(__args))...));
return future<_Rp>{};
}
@@ -2360,7 +2226,7 @@ async(_Fp&& __f, _Args&&... __args)
_VSTD::forward<_Args>(__args)...);
}
-#endif // _LIBCPP_HAS_NO_VARIADICS
+#endif // C++03
// shared_future
@@ -2375,24 +2241,20 @@ public:
_LIBCPP_INLINE_VISIBILITY
shared_future(const shared_future& __rhs) _NOEXCEPT : __state_(__rhs.__state_)
{if (__state_) __state_->__add_shared();}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
shared_future(future<_Rp>&& __f) _NOEXCEPT : __state_(__f.__state_)
{__f.__state_ = nullptr;}
_LIBCPP_INLINE_VISIBILITY
shared_future(shared_future&& __rhs) _NOEXCEPT : __state_(__rhs.__state_)
{__rhs.__state_ = nullptr;}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
~shared_future();
shared_future& operator=(const shared_future& __rhs) _NOEXCEPT;
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
shared_future& operator=(shared_future&& __rhs) _NOEXCEPT
{
- shared_future(std::move(__rhs)).swap(*this);
+ shared_future(_VSTD::move(__rhs)).swap(*this);
return *this;
}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
// retrieving the value
_LIBCPP_INLINE_VISIBILITY
@@ -2449,24 +2311,20 @@ public:
_LIBCPP_INLINE_VISIBILITY
shared_future(const shared_future& __rhs) : __state_(__rhs.__state_)
{if (__state_) __state_->__add_shared();}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
shared_future(future<_Rp&>&& __f) _NOEXCEPT : __state_(__f.__state_)
{__f.__state_ = nullptr;}
_LIBCPP_INLINE_VISIBILITY
shared_future(shared_future&& __rhs) _NOEXCEPT : __state_(__rhs.__state_)
{__rhs.__state_ = nullptr;}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
~shared_future();
shared_future& operator=(const shared_future& __rhs);
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
shared_future& operator=(shared_future&& __rhs) _NOEXCEPT
{
- shared_future(std::move(__rhs)).swap(*this);
+ shared_future(_VSTD::move(__rhs)).swap(*this);
return *this;
}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
// retrieving the value
_LIBCPP_INLINE_VISIBILITY
@@ -2523,24 +2381,20 @@ public:
_LIBCPP_INLINE_VISIBILITY
shared_future(const shared_future& __rhs) : __state_(__rhs.__state_)
{if (__state_) __state_->__add_shared();}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
shared_future(future<void>&& __f) _NOEXCEPT : __state_(__f.__state_)
{__f.__state_ = nullptr;}
_LIBCPP_INLINE_VISIBILITY
shared_future(shared_future&& __rhs) _NOEXCEPT : __state_(__rhs.__state_)
{__rhs.__state_ = nullptr;}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
~shared_future();
shared_future& operator=(const shared_future& __rhs);
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
shared_future& operator=(shared_future&& __rhs) _NOEXCEPT
{
- shared_future(std::move(__rhs)).swap(*this);
+ shared_future(_VSTD::move(__rhs)).swap(*this);
return *this;
}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
// retrieving the value
_LIBCPP_INLINE_VISIBILITY
@@ -2591,8 +2445,6 @@ future<_Rp&>::share() _NOEXCEPT
return shared_future<_Rp&>(_VSTD::move(*this));
}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
inline
shared_future<void>
future<void>::share() _NOEXCEPT
@@ -2600,8 +2452,6 @@ future<void>::share() _NOEXCEPT
return shared_future<void>(_VSTD::move(*this));
}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
_LIBCPP_END_NAMESPACE_STD
#endif // !_LIBCPP_HAS_NO_THREADS
diff --git a/libcxx/include/iomanip b/libcxx/include/iomanip
index 3f78f4d02b3c..4b6418bc0b7e 100644
--- a/libcxx/include/iomanip
+++ b/libcxx/include/iomanip
@@ -514,7 +514,7 @@ put_time(const tm* __tm, const _CharT* __fmt)
}
template <class _CharT, class _Traits, class _ForwardIterator>
-std::basic_ostream<_CharT, _Traits> &
+basic_ostream<_CharT, _Traits> &
__quoted_output ( basic_ostream<_CharT, _Traits> &__os,
_ForwardIterator __first, _ForwardIterator __last, _CharT __delim, _CharT __escape )
{
@@ -527,7 +527,7 @@ __quoted_output ( basic_ostream<_CharT, _Traits> &__os,
__str.push_back(*__first);
}
__str.push_back(__delim);
- return __put_character_sequence(__os, __str.data(), __str.size());
+ return _VSTD::__put_character_sequence(__os, __str.data(), __str.size());
}
template <class _CharT, class _Traits, class _String>
diff --git a/libcxx/include/ios b/libcxx/include/ios
index 7f0e2d65e640..653e3a95fc7e 100644
--- a/libcxx/include/ios
+++ b/libcxx/include/ios
@@ -710,7 +710,7 @@ void
basic_ios<_CharT, _Traits>::init(basic_streambuf<char_type, traits_type>* __sb)
{
ios_base::init(__sb);
- __tie_ = 0;
+ __tie_ = nullptr;
__fill_ = traits_type::eof();
}
@@ -821,7 +821,7 @@ basic_ios<_CharT, _Traits>::move(basic_ios& __rhs)
{
ios_base::move(__rhs);
__tie_ = __rhs.__tie_;
- __rhs.__tie_ = 0;
+ __rhs.__tie_ = nullptr;
__fill_ = __rhs.__fill_;
}
@@ -1035,33 +1035,6 @@ defaultfloat(ios_base& __str)
return __str;
}
-template <class _CharT, class _Traits>
-class __save_flags
-{
- typedef basic_ios<_CharT, _Traits> __stream_type;
- typedef typename __stream_type::fmtflags fmtflags;
-
- __stream_type& __stream_;
- fmtflags __fmtflags_;
- _CharT __fill_;
-
- __save_flags(const __save_flags&);
- __save_flags& operator=(const __save_flags&);
-public:
- _LIBCPP_INLINE_VISIBILITY
- explicit __save_flags(__stream_type& __stream)
- : __stream_(__stream),
- __fmtflags_(__stream.flags()),
- __fill_(__stream.fill())
- {}
- _LIBCPP_INLINE_VISIBILITY
- ~__save_flags()
- {
- __stream_.flags(__fmtflags_);
- __stream_.fill(__fill_);
- }
-};
-
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_IOS
diff --git a/libcxx/include/iosfwd b/libcxx/include/iosfwd
index 0ffe75f197c3..0a0de99ff3a7 100644
--- a/libcxx/include/iosfwd
+++ b/libcxx/include/iosfwd
@@ -185,6 +185,36 @@ typedef basic_ifstream<wchar_t> wifstream;
typedef basic_ofstream<wchar_t> wofstream;
typedef basic_fstream<wchar_t> wfstream;
+template <class _CharT, class _Traits>
+ class _LIBCPP_PREFERRED_NAME(ios) _LIBCPP_PREFERRED_NAME(wios) basic_ios;
+
+template <class _CharT, class _Traits>
+ class _LIBCPP_PREFERRED_NAME(streambuf) _LIBCPP_PREFERRED_NAME(wstreambuf) basic_streambuf;
+template <class _CharT, class _Traits>
+ class _LIBCPP_PREFERRED_NAME(istream) _LIBCPP_PREFERRED_NAME(wistream) basic_istream;
+template <class _CharT, class _Traits>
+ class _LIBCPP_PREFERRED_NAME(ostream) _LIBCPP_PREFERRED_NAME(wostream) basic_ostream;
+template <class _CharT, class _Traits>
+ class _LIBCPP_PREFERRED_NAME(iostream) _LIBCPP_PREFERRED_NAME(wiostream) basic_iostream;
+
+template <class _CharT, class _Traits, class _Allocator>
+ class _LIBCPP_PREFERRED_NAME(stringbuf) _LIBCPP_PREFERRED_NAME(wstringbuf) basic_stringbuf;
+template <class _CharT, class _Traits, class _Allocator>
+ class _LIBCPP_PREFERRED_NAME(istringstream) _LIBCPP_PREFERRED_NAME(wistringstream) basic_istringstream;
+template <class _CharT, class _Traits, class _Allocator>
+ class _LIBCPP_PREFERRED_NAME(ostringstream) _LIBCPP_PREFERRED_NAME(wostringstream) basic_ostringstream;
+template <class _CharT, class _Traits, class _Allocator>
+ class _LIBCPP_PREFERRED_NAME(stringstream) _LIBCPP_PREFERRED_NAME(wstringstream) basic_stringstream;
+
+template <class _CharT, class _Traits>
+ class _LIBCPP_PREFERRED_NAME(filebuf) _LIBCPP_PREFERRED_NAME(wfilebuf) basic_filebuf;
+template <class _CharT, class _Traits>
+ class _LIBCPP_PREFERRED_NAME(ifstream) _LIBCPP_PREFERRED_NAME(wifstream) basic_ifstream;
+template <class _CharT, class _Traits>
+ class _LIBCPP_PREFERRED_NAME(ofstream) _LIBCPP_PREFERRED_NAME(wofstream) basic_ofstream;
+template <class _CharT, class _Traits>
+ class _LIBCPP_PREFERRED_NAME(fstream) _LIBCPP_PREFERRED_NAME(wfstream) basic_fstream;
+
template <class _State> class _LIBCPP_TEMPLATE_VIS fpos;
typedef fpos<mbstate_t> streampos;
typedef fpos<mbstate_t> wstreampos;
@@ -210,11 +240,40 @@ template <class _CharT, // for <stdexcept>
typedef basic_string<char, char_traits<char>, allocator<char> > string;
typedef basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wstring;
+template <class _CharT, class _Traits, class _Allocator>
+ class _LIBCPP_PREFERRED_NAME(string) _LIBCPP_PREFERRED_NAME(wstring) basic_string;
// Include other forward declarations here
template <class _Tp, class _Alloc = allocator<_Tp> >
class _LIBCPP_TEMPLATE_VIS vector;
+template <class _CharT, class _Traits>
+class __save_flags
+{
+ typedef basic_ios<_CharT, _Traits> __stream_type;
+ typedef typename __stream_type::fmtflags fmtflags;
+
+ __stream_type& __stream_;
+ fmtflags __fmtflags_;
+ _CharT __fill_;
+
+ __save_flags(const __save_flags&);
+ __save_flags& operator=(const __save_flags&);
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __save_flags(__stream_type& __stream)
+ : __stream_(__stream),
+ __fmtflags_(__stream.flags()),
+ __fill_(__stream.fill())
+ {}
+ _LIBCPP_INLINE_VISIBILITY
+ ~__save_flags()
+ {
+ __stream_.flags(__fmtflags_);
+ __stream_.fill(__fill_);
+ }
+};
+
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_IOSFWD
diff --git a/libcxx/include/istream b/libcxx/include/istream
index bfbe5f24728e..5e984909f878 100644
--- a/libcxx/include/istream
+++ b/libcxx/include/istream
@@ -150,9 +150,9 @@ template <class charT, class traits>
basic_istream<charT,traits>&
ws(basic_istream<charT,traits>& is);
-template <class charT, class traits, class T>
- basic_istream<charT, traits>&
- operator>>(basic_istream<charT, traits>&& is, T& x);
+// rvalue stream extraction
+template <class Stream, class T>
+ Stream&& operator>>(Stream&& is, T&& x);
} // std
@@ -1142,7 +1142,7 @@ basic_istream<_CharT, _Traits>::putback(char_type __c)
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
- if (this->rdbuf() == 0 || this->rdbuf()->sputbackc(__c) == traits_type::eof())
+ if (this->rdbuf() == nullptr || this->rdbuf()->sputbackc(__c) == traits_type::eof())
__state |= ios_base::badbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
}
@@ -1179,7 +1179,7 @@ basic_istream<_CharT, _Traits>::unget()
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
- if (this->rdbuf() == 0 || this->rdbuf()->sungetc() == traits_type::eof())
+ if (this->rdbuf() == nullptr || this->rdbuf()->sungetc() == traits_type::eof())
__state |= ios_base::badbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
}
@@ -1215,7 +1215,7 @@ basic_istream<_CharT, _Traits>::sync()
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
- if (this->rdbuf() == 0)
+ if (this->rdbuf() == nullptr)
return -1;
if (this->rdbuf()->pubsync() == -1)
{
@@ -1378,13 +1378,23 @@ ws(basic_istream<_CharT, _Traits>& __is)
#ifndef _LIBCPP_CXX03_LANG
-template <class _CharT, class _Traits, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-basic_istream<_CharT, _Traits>&
-operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp&& __x)
+template <class _Stream, class _Tp, class = void>
+struct __is_istreamable : false_type { };
+
+template <class _Stream, class _Tp>
+struct __is_istreamable<_Stream, _Tp, decltype(
+ _VSTD::declval<_Stream>() >> _VSTD::declval<_Tp>(), void()
+)> : true_type { };
+
+template <class _Stream, class _Tp, class = typename enable_if<
+ _And<is_base_of<ios_base, _Stream>,
+ __is_istreamable<_Stream&, _Tp&&>>::value
+>::type>
+_LIBCPP_INLINE_VISIBILITY
+_Stream&& operator>>(_Stream&& __is, _Tp&& __x)
{
__is >> _VSTD::forward<_Tp>(__x);
- return __is;
+ return _VSTD::move(__is);
}
#endif // _LIBCPP_CXX03_LANG
@@ -1638,11 +1648,9 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)
return __is;
}
-#ifndef _LIBCPP_DO_NOT_ASSUME_STREAMS_EXPLICIT_INSTANTIATION_IN_DYLIB
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<char>)
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<wchar_t>)
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_iostream<char>)
-#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/iterator b/libcxx/include/iterator
index a13214fca5e4..00a3451e7a21 100644
--- a/libcxx/include/iterator
+++ b/libcxx/include/iterator
@@ -420,10 +420,8 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept;
#include <type_traits>
#include <cstddef>
#include <initializer_list>
+#include <__memory/base.h>
#include <version>
-#ifdef __APPLE__
-#include <Availability.h>
-#endif
#include <__debug>
@@ -498,12 +496,11 @@ struct __has_iterator_typedefs
private:
struct __two {char __lx; char __lxx;};
template <class _Up> static __two __test(...);
- template <class _Up> static char __test(typename std::__void_t<typename _Up::iterator_category>::type* = 0,
- typename std::__void_t<typename _Up::difference_type>::type* = 0,
- typename std::__void_t<typename _Up::value_type>::type* = 0,
- typename std::__void_t<typename _Up::reference>::type* = 0,
- typename std::__void_t<typename _Up::pointer>::type* = 0
- );
+ template <class _Up> static char __test(typename __void_t<typename _Up::iterator_category>::type* = 0,
+ typename __void_t<typename _Up::difference_type>::type* = 0,
+ typename __void_t<typename _Up::value_type>::type* = 0,
+ typename __void_t<typename _Up::reference>::type* = 0,
+ typename __void_t<typename _Up::pointer>::type* = 0);
public:
static const bool value = sizeof(__test<_Tp>(0,0,0,0,0)) == 1;
};
@@ -515,9 +512,9 @@ struct __has_iterator_category
private:
struct __two {char __lx; char __lxx;};
template <class _Up> static __two __test(...);
- template <class _Up> static char __test(typename _Up::iterator_category* = 0);
+ template <class _Up> static char __test(typename _Up::iterator_category* = nullptr);
public:
- static const bool value = sizeof(__test<_Tp>(0)) == 1;
+ static const bool value = sizeof(__test<_Tp>(nullptr)) == 1;
};
template <class _Iter, bool> struct __iterator_traits_impl {};
@@ -667,9 +664,9 @@ void advance(_InputIter& __i, _Distance __orig_n)
{
_LIBCPP_ASSERT(__orig_n >= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value,
"Attempt to advance(it, n) with negative n on a non-bidirectional iterator");
- typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize;
+ typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
_IntegralSize __n = __orig_n;
- __advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category());
+ _VSTD::__advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category());
}
template <class _InputIter>
@@ -696,7 +693,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
typename iterator_traits<_InputIter>::difference_type
distance(_InputIter __first, _InputIter __last)
{
- return __distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category());
+ return _VSTD::__distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category());
}
template <class _InputIter>
@@ -998,11 +995,11 @@ private:
istream_type* __in_stream_;
_Tp __value_;
public:
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istream_iterator() : __in_stream_(0), __value_() {}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istream_iterator() : __in_stream_(nullptr), __value_() {}
_LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) : __in_stream_(_VSTD::addressof(__s))
{
if (!(*__in_stream_ >> __value_))
- __in_stream_ = 0;
+ __in_stream_ = nullptr;
}
_LIBCPP_INLINE_VISIBILITY const _Tp& operator*() const {return __value_;}
@@ -1010,7 +1007,7 @@ public:
_LIBCPP_INLINE_VISIBILITY istream_iterator& operator++()
{
if (!(*__in_stream_ >> __value_))
- __in_stream_ = 0;
+ __in_stream_ = nullptr;
return *this;
}
_LIBCPP_INLINE_VISIBILITY istream_iterator operator++(int)
@@ -1052,15 +1049,25 @@ class _LIBCPP_TEMPLATE_VIS ostream_iterator
: public iterator<output_iterator_tag, void, void, void, void>
{
public:
- typedef _CharT char_type;
- typedef _Traits traits_type;
- typedef basic_ostream<_CharT,_Traits> ostream_type;
+ typedef output_iterator_tag iterator_category;
+ typedef void value_type;
+#if _LIBCPP_STD_VER > 17
+ typedef std::ptrdiff_t difference_type;
+#else
+ typedef void difference_type;
+#endif
+ typedef void pointer;
+ typedef void reference;
+ typedef _CharT char_type;
+ typedef _Traits traits_type;
+ typedef basic_ostream<_CharT, _Traits> ostream_type;
+
private:
ostream_type* __out_stream_;
const char_type* __delim_;
public:
_LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s) _NOEXCEPT
- : __out_stream_(_VSTD::addressof(__s)), __delim_(0) {}
+ : __out_stream_(_VSTD::addressof(__s)), __delim_(nullptr) {}
_LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s, const _CharT* __delimiter) _NOEXCEPT
: __out_stream_(_VSTD::addressof(__s)), __delim_(__delimiter) {}
_LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const _Tp& __value_)
@@ -1106,11 +1113,11 @@ private:
bool __test_for_eof() const
{
if (__sbuf_ && traits_type::eq_int_type(__sbuf_->sgetc(), traits_type::eof()))
- __sbuf_ = 0;
- return __sbuf_ == 0;
+ __sbuf_ = nullptr;
+ return __sbuf_ == nullptr;
}
public:
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istreambuf_iterator() _NOEXCEPT : __sbuf_(0) {}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istreambuf_iterator() _NOEXCEPT : __sbuf_(nullptr) {}
_LIBCPP_INLINE_VISIBILITY istreambuf_iterator(istream_type& __s) _NOEXCEPT
: __sbuf_(__s.rdbuf()) {}
_LIBCPP_INLINE_VISIBILITY istreambuf_iterator(streambuf_type* __s) _NOEXCEPT
@@ -1151,10 +1158,20 @@ class _LIBCPP_TEMPLATE_VIS ostreambuf_iterator
: public iterator<output_iterator_tag, void, void, void, void>
{
public:
- typedef _CharT char_type;
- typedef _Traits traits_type;
- typedef basic_streambuf<_CharT,_Traits> streambuf_type;
- typedef basic_ostream<_CharT,_Traits> ostream_type;
+ typedef output_iterator_tag iterator_category;
+ typedef void value_type;
+#if _LIBCPP_STD_VER > 17
+ typedef std::ptrdiff_t difference_type;
+#else
+ typedef void difference_type;
+#endif
+ typedef void pointer;
+ typedef void reference;
+ typedef _CharT char_type;
+ typedef _Traits traits_type;
+ typedef basic_streambuf<_CharT, _Traits> streambuf_type;
+ typedef basic_ostream<_CharT, _Traits> ostream_type;
+
private:
streambuf_type* __sbuf_;
public:
@@ -1165,13 +1182,13 @@ public:
_LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator=(_CharT __c)
{
if (__sbuf_ && traits_type::eq_int_type(__sbuf_->sputc(__c), traits_type::eof()))
- __sbuf_ = 0;
+ __sbuf_ = nullptr;
return *this;
}
_LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator*() {return *this;}
_LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator++() {return *this;}
_LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator++(int) {return *this;}
- _LIBCPP_INLINE_VISIBILITY bool failed() const _NOEXCEPT {return __sbuf_ == 0;}
+ _LIBCPP_INLINE_VISIBILITY bool failed() const _NOEXCEPT {return __sbuf_ == nullptr;}
template <class _Ch, class _Tr>
friend
@@ -1373,13 +1390,13 @@ operator+(typename __wrap_iter<_Iter>::difference_type, __wrap_iter<_Iter>) _NOE
template <class _Ip, class _Op> _Op _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 copy(_Ip, _Ip, _Op);
template <class _B1, class _B2> _B2 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 copy_backward(_B1, _B1, _B2);
-template <class _Ip, class _Op> _Op _LIBCPP_INLINE_VISIBILITY move(_Ip, _Ip, _Op);
-template <class _B1, class _B2> _B2 _LIBCPP_INLINE_VISIBILITY move_backward(_B1, _B1, _B2);
+template <class _Ip, class _Op> _Op _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 move(_Ip, _Ip, _Op);
+template <class _B1, class _B2> _B2 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 move_backward(_B1, _B1, _B2);
#if _LIBCPP_DEBUG_LEVEL < 2
template <class _Tp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
typename enable_if
<
is_trivially_copy_assignable<_Tp>::value,
@@ -1390,7 +1407,7 @@ __unwrap_iter(__wrap_iter<_Tp*>);
#else
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
typename enable_if
<
is_trivially_copy_assignable<_Tp>::value,
@@ -1418,20 +1435,20 @@ public:
: __i{}
#endif
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_i(this);
#endif
}
template <class _Up> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
__wrap_iter(const __wrap_iter<_Up>& __u,
- typename enable_if<is_convertible<_Up, iterator_type>::value>::type* = 0) _NOEXCEPT
+ typename enable_if<is_convertible<_Up, iterator_type>::value>::type* = nullptr) _NOEXCEPT
: __i(__u.base())
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__iterator_copy(this, &__u);
#endif
}
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
__wrap_iter(const __wrap_iter& __x)
: __i(__x.base())
@@ -1456,7 +1473,7 @@ public:
#endif
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG reference operator*() const _NOEXCEPT
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
"Attempted to dereference a non-dereferenceable iterator");
#endif
@@ -1464,7 +1481,7 @@ public:
}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG pointer operator->() const _NOEXCEPT
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
"Attempted to dereference a non-dereferenceable iterator");
#endif
@@ -1472,7 +1489,7 @@ public:
}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator++() _NOEXCEPT
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
"Attempted to increment non-incrementable iterator");
#endif
@@ -1484,7 +1501,7 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator--() _NOEXCEPT
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__decrementable(this),
"Attempted to decrement non-decrementable iterator");
#endif
@@ -1497,7 +1514,7 @@ public:
{__wrap_iter __w(*this); __w += __n; return __w;}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator+=(difference_type __n) _NOEXCEPT
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__addable(this, __n),
"Attempted to add/subtract iterator outside of valid range");
#endif
@@ -1510,7 +1527,7 @@ public:
{*this += -__n; return *this;}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG reference operator[](difference_type __n) const _NOEXCEPT
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__subscriptable(this, __n),
"Attempted to subscript iterator outside of valid range");
#endif
@@ -1520,7 +1537,7 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG iterator_type base() const _NOEXCEPT {return __i;}
private:
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(const void* __p, iterator_type __x) : __i(__x)
{
__get_db()->__insert_ic(this, __p);
@@ -1584,12 +1601,12 @@ private:
template <class _Ip, class _Op> friend _LIBCPP_CONSTEXPR_AFTER_CXX17 _Op copy(_Ip, _Ip, _Op);
template <class _B1, class _B2> friend _LIBCPP_CONSTEXPR_AFTER_CXX17 _B2 copy_backward(_B1, _B1, _B2);
- template <class _Ip, class _Op> friend _Op move(_Ip, _Ip, _Op);
- template <class _B1, class _B2> friend _B2 move_backward(_B1, _B1, _B2);
+ template <class _Ip, class _Op> friend _LIBCPP_CONSTEXPR_AFTER_CXX17 _Op move(_Ip, _Ip, _Op);
+ template <class _B1, class _B2> friend _LIBCPP_CONSTEXPR_AFTER_CXX17 _B2 move_backward(_B1, _B1, _B2);
#if _LIBCPP_DEBUG_LEVEL < 2
template <class _Tp>
- _LIBCPP_CONSTEXPR_IF_NODEBUG friend
+ _LIBCPP_CONSTEXPR friend
typename enable_if
<
is_trivially_copy_assignable<_Tp>::value,
@@ -1598,7 +1615,7 @@ private:
__unwrap_iter(__wrap_iter<_Tp*>);
#else
template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
+ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR friend
typename enable_if
<
is_trivially_copy_assignable<_Tp>::value,
@@ -1621,7 +1638,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
bool
operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y),
"Attempted to compare incomparable iterators");
#endif
@@ -1699,7 +1716,7 @@ auto
operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
-> decltype(__x.base() - __y.base())
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y),
"Attempted to subtract incompatible iterators");
#endif
@@ -1711,7 +1728,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
typename __wrap_iter<_Iter1>::difference_type
operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y),
"Attempted to subtract incompatible iterators");
#endif
diff --git a/libcxx/include/latch b/libcxx/include/latch
index f669f5860d34..a894f8cafd1c 100644
--- a/libcxx/include/latch
+++ b/libcxx/include/latch
@@ -19,6 +19,8 @@ namespace std
class latch
{
public:
+ static constexpr ptrdiff_t max() noexcept;
+
constexpr explicit latch(ptrdiff_t __expected);
~latch();
@@ -39,6 +41,7 @@ namespace std
*/
#include <__config>
+#include <__availability>
#include <atomic>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -49,6 +52,9 @@ namespace std
# error <latch> is not supported on this single threaded system
#endif
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
#if _LIBCPP_STD_VER >= 14
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -101,4 +107,6 @@ _LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_STD_VER >= 14
+_LIBCPP_POP_MACROS
+
#endif //_LIBCPP_LATCH
diff --git a/libcxx/include/list b/libcxx/include/list
index 55b45f1a67d4..a18514d74eaf 100644
--- a/libcxx/include/list
+++ b/libcxx/include/list
@@ -293,7 +293,7 @@ class _LIBCPP_TEMPLATE_VIS __list_iterator
__link_pointer __ptr_;
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY
explicit __list_iterator(__link_pointer __p, const void* __c) _NOEXCEPT
: __ptr_(__p)
@@ -320,12 +320,12 @@ public:
_LIBCPP_INLINE_VISIBILITY
__list_iterator() _NOEXCEPT : __ptr_(nullptr)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_i(this);
#endif
}
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY
__list_iterator(const __list_iterator& __p)
@@ -351,12 +351,12 @@ public:
return *this;
}
-#endif // _LIBCPP_DEBUG_LEVEL >= 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY
reference operator*() const
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
"Attempted to dereference a non-dereferenceable list::iterator");
#endif
@@ -365,7 +365,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
pointer operator->() const
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
"Attempted to dereference a non-dereferenceable list::iterator");
#endif
@@ -375,7 +375,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
__list_iterator& operator++()
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
"Attempted to increment non-incrementable list::iterator");
#endif
@@ -388,7 +388,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
__list_iterator& operator--()
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__decrementable(this),
"Attempted to decrement non-decrementable list::iterator");
#endif
@@ -416,7 +416,7 @@ class _LIBCPP_TEMPLATE_VIS __list_const_iterator
__link_pointer __ptr_;
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY
explicit __list_const_iterator(__link_pointer __p, const void* __c) _NOEXCEPT
: __ptr_(__p)
@@ -440,7 +440,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
__list_const_iterator() _NOEXCEPT : __ptr_(nullptr)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_i(this);
#endif
}
@@ -448,12 +448,12 @@ public:
__list_const_iterator(const __list_iterator<_Tp, _VoidPtr>& __p) _NOEXCEPT
: __ptr_(__p.__ptr_)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__iterator_copy(this, &__p);
#endif
}
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY
__list_const_iterator(const __list_const_iterator& __p)
@@ -479,11 +479,11 @@ public:
return *this;
}
-#endif // _LIBCPP_DEBUG_LEVEL >= 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY
reference operator*() const
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
"Attempted to dereference a non-dereferenceable list::const_iterator");
#endif
@@ -492,7 +492,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
pointer operator->() const
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
"Attempted to dereference a non-dereferenceable list::const_iterator");
#endif
@@ -502,7 +502,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
__list_const_iterator& operator++()
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
"Attempted to increment non-incrementable list::const_iterator");
#endif
@@ -515,7 +515,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
__list_const_iterator& operator--()
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__decrementable(this),
"Attempted to decrement non-decrementable list::const_iterator");
#endif
@@ -614,7 +614,7 @@ protected:
_LIBCPP_INLINE_VISIBILITY
iterator begin() _NOEXCEPT
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
return iterator(__end_.__next_, this);
#else
return iterator(__end_.__next_);
@@ -623,7 +623,7 @@ protected:
_LIBCPP_INLINE_VISIBILITY
const_iterator begin() const _NOEXCEPT
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
return const_iterator(__end_.__next_, this);
#else
return const_iterator(__end_.__next_);
@@ -632,7 +632,7 @@ protected:
_LIBCPP_INLINE_VISIBILITY
iterator end() _NOEXCEPT
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
return iterator(__end_as_link(), this);
#else
return iterator(__end_as_link());
@@ -641,7 +641,7 @@ protected:
_LIBCPP_INLINE_VISIBILITY
const_iterator end() const _NOEXCEPT
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
return const_iterator(__end_as_link(), this);
#else
return const_iterator(__end_as_link());
@@ -696,7 +696,7 @@ private:
_LIBCPP_INLINE_VISIBILITY
void __invalidate_all_iterators() {
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__invalidate_all(this);
#endif
}
@@ -735,13 +735,13 @@ inline __list_imp<_Tp, _Alloc>::__list_imp(const __node_allocator& __a)
#ifndef _LIBCPP_CXX03_LANG
template <class _Tp, class _Alloc>
inline __list_imp<_Tp, _Alloc>::__list_imp(__node_allocator&& __a) _NOEXCEPT
- : __size_alloc_(0, std::move(__a)) {}
+ : __size_alloc_(0, _VSTD::move(__a)) {}
#endif
template <class _Tp, class _Alloc>
__list_imp<_Tp, _Alloc>::~__list_imp() {
clear();
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__erase_c(this);
#endif
}
@@ -783,7 +783,7 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
"list::swap: Either propagate_on_container_swap must be true"
" or the allocators must compare equal");
using _VSTD::swap;
- __swap_allocator(__node_alloc(), __c.__node_alloc());
+ _VSTD::__swap_allocator(__node_alloc(), __c.__node_alloc());
swap(__sz(), __c.__sz());
swap(__end_, __c.__end_);
if (__sz() == 0)
@@ -795,13 +795,13 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
else
__c.__end_.__prev_->__next_ = __c.__end_.__next_->__prev_ = __c.__end_as_link();
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__libcpp_db* __db = __get_db();
__c_node* __cn1 = __db->__find_c_and_lock(this);
__c_node* __cn2 = __db->__find_c(&__c);
- std::swap(__cn1->beg_, __cn2->beg_);
- std::swap(__cn1->end_, __cn2->end_);
- std::swap(__cn1->cap_, __cn2->cap_);
+ _VSTD::swap(__cn1->beg_, __cn2->beg_);
+ _VSTD::swap(__cn1->end_, __cn2->end_);
+ _VSTD::swap(__cn1->cap_, __cn2->cap_);
for (__i_node** __p = __cn1->end_; __p != __cn1->beg_;)
{
--__p;
@@ -810,7 +810,7 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
{
__cn2->__add(*__p);
if (--__cn1->end_ != __p)
- memmove(__p, __p+1, (__cn1->end_ - __p)*sizeof(__i_node*));
+ _VSTD::memmove(__p, __p+1, (__cn1->end_ - __p)*sizeof(__i_node*));
}
else
(*__p)->__c_ = __cn1;
@@ -823,7 +823,7 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
{
__cn1->__add(*__p);
if (--__cn2->end_ != __p)
- memmove(__p, __p+1, (__cn2->end_ - __p)*sizeof(__i_node*));
+ _VSTD::memmove(__p, __p+1, (__cn2->end_ - __p)*sizeof(__i_node*));
}
else
(*__p)->__c_ = __cn2;
@@ -870,14 +870,14 @@ public:
list()
_NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
}
_LIBCPP_INLINE_VISIBILITY
explicit list(const allocator_type& __a) : base(__a)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
}
@@ -937,7 +937,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
size_type max_size() const _NOEXCEPT
{
- return std::min<size_type>(
+ return _VSTD::min<size_type>(
base::__node_alloc_max_size(),
numeric_limits<difference_type >::max());
}
@@ -1117,14 +1117,14 @@ public:
return __hold_pointer(__p, __node_destructor(__na, 1));
}
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
bool __dereferenceable(const const_iterator* __i) const;
bool __decrementable(const const_iterator* __i) const;
bool __addable(const const_iterator* __i, ptrdiff_t __n) const;
bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;
-#endif // _LIBCPP_DEBUG_LEVEL >= 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
private:
_LIBCPP_INLINE_VISIBILITY
@@ -1144,7 +1144,7 @@ private:
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
template<class _InputIterator,
- class _Alloc = typename std::allocator<typename iterator_traits<_InputIterator>::value_type>,
+ class _Alloc = allocator<typename iterator_traits<_InputIterator>::value_type>,
class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
>
list(_InputIterator, _InputIterator)
@@ -1207,7 +1207,7 @@ list<_Tp, _Alloc>::__iterator(size_type __n)
template <class _Tp, class _Alloc>
list<_Tp, _Alloc>::list(size_type __n)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
for (; __n > 0; --__n)
@@ -1222,7 +1222,7 @@ list<_Tp, _Alloc>::list(size_type __n)
template <class _Tp, class _Alloc>
list<_Tp, _Alloc>::list(size_type __n, const allocator_type& __a) : base(__a)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
for (; __n > 0; --__n)
@@ -1233,7 +1233,7 @@ list<_Tp, _Alloc>::list(size_type __n, const allocator_type& __a) : base(__a)
template <class _Tp, class _Alloc>
list<_Tp, _Alloc>::list(size_type __n, const value_type& __x)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
for (; __n > 0; --__n)
@@ -1244,7 +1244,7 @@ template <class _Tp, class _Alloc>
list<_Tp, _Alloc>::list(size_type __n, const value_type& __x, const allocator_type& __a)
: base(__a)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
for (; __n > 0; --__n)
@@ -1256,7 +1256,7 @@ template <class _InpIter>
list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l,
typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type*)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
for (; __f != __l; ++__f)
@@ -1269,7 +1269,7 @@ list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l, const allocator_type& __a,
typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type*)
: base(__a)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
for (; __f != __l; ++__f)
@@ -1280,7 +1280,7 @@ template <class _Tp, class _Alloc>
list<_Tp, _Alloc>::list(const list& __c)
: base(__node_alloc_traits::select_on_container_copy_construction(
__c.__node_alloc())) {
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
for (const_iterator __i = __c.begin(), __e = __c.end(); __i != __e; ++__i)
@@ -1291,7 +1291,7 @@ template <class _Tp, class _Alloc>
list<_Tp, _Alloc>::list(const list& __c, const allocator_type& __a)
: base(__a)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
for (const_iterator __i = __c.begin(), __e = __c.end(); __i != __e; ++__i)
@@ -1304,7 +1304,7 @@ template <class _Tp, class _Alloc>
list<_Tp, _Alloc>::list(initializer_list<value_type> __il, const allocator_type& __a)
: base(__a)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
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&
template <class _Tp, class _Alloc>
list<_Tp, _Alloc>::list(initializer_list<value_type> __il)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
for (typename initializer_list<value_type>::const_iterator __i = __il.begin(),
@@ -1327,7 +1327,7 @@ template <class _Tp, class _Alloc>
inline list<_Tp, _Alloc>::list(list&& __c)
_NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value)
: base(_VSTD::move(__c.__node_alloc())) {
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
splice(end(), __c);
@@ -1338,7 +1338,7 @@ inline
list<_Tp, _Alloc>::list(list&& __c, const allocator_type& __a)
: base(__a)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
if (__a == __c.get_allocator())
@@ -1415,7 +1415,7 @@ list<_Tp, _Alloc>::assign(_InpIter __f, _InpIter __l,
insert(__e, __f, __l);
else
erase(__i, __e);
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__invalidate_all(this);
#endif
}
@@ -1432,7 +1432,7 @@ list<_Tp, _Alloc>::assign(size_type __n, const value_type& __x)
insert(__e, __n, __x);
else
erase(__i, __e);
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__invalidate_all(this);
#endif
}
@@ -1449,7 +1449,7 @@ template <class _Tp, class _Alloc>
typename list<_Tp, _Alloc>::iterator
list<_Tp, _Alloc>::insert(const_iterator __p, const value_type& __x)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
"list::insert(iterator, x) called with an iterator not"
" referring to this list");
@@ -1459,7 +1459,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, const value_type& __x)
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
__link_nodes(__p.__ptr_, __hold->__as_link(), __hold->__as_link());
++base::__sz();
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
return iterator(__hold.release()->__as_link(), this);
#else
return iterator(__hold.release()->__as_link());
@@ -1470,7 +1470,7 @@ template <class _Tp, class _Alloc>
typename list<_Tp, _Alloc>::iterator
list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& __x)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
"list::insert(iterator, n, x) called with an iterator not"
" referring to this list");
@@ -1485,7 +1485,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _
__hold_pointer __hold = __allocate_node(__na);
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
++__ds;
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__r = iterator(__hold->__as_link(), this);
#else
__r = iterator(__hold->__as_link());
@@ -1515,7 +1515,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _
__node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);
if (__prev == 0)
break;
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__e = iterator(__prev, this);
#else
__e = iterator(__prev);
@@ -1536,7 +1536,7 @@ typename list<_Tp, _Alloc>::iterator
list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l,
typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type*)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
"list::insert(iterator, range) called with an iterator not"
" referring to this list");
@@ -1551,7 +1551,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l,
__hold_pointer __hold = __allocate_node(__na);
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), *__f);
++__ds;
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__r = iterator(__hold.get()->__as_link(), this);
#else
__r = iterator(__hold.get()->__as_link());
@@ -1581,7 +1581,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l,
__node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);
if (__prev == 0)
break;
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__e = iterator(__prev, this);
#else
__e = iterator(__prev);
@@ -1695,7 +1695,7 @@ template <class... _Args>
typename list<_Tp, _Alloc>::iterator
list<_Tp, _Alloc>::emplace(const_iterator __p, _Args&&... __args)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
"list::emplace(iterator, args...) called with an iterator not"
" referring to this list");
@@ -1707,7 +1707,7 @@ list<_Tp, _Alloc>::emplace(const_iterator __p, _Args&&... __args)
__link_nodes(__p.__ptr_, __nl, __nl);
++base::__sz();
__hold.release();
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
return iterator(__nl, this);
#else
return iterator(__nl);
@@ -1718,7 +1718,7 @@ template <class _Tp, class _Alloc>
typename list<_Tp, _Alloc>::iterator
list<_Tp, _Alloc>::insert(const_iterator __p, value_type&& __x)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
"list::insert(iterator, x) called with an iterator not"
" referring to this list");
@@ -1730,7 +1730,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, value_type&& __x)
__link_nodes(__p.__ptr_, __nl, __nl);
++base::__sz();
__hold.release();
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
return iterator(__nl, this);
#else
return iterator(__nl);
@@ -1748,7 +1748,7 @@ list<_Tp, _Alloc>::pop_front()
__link_pointer __n = base::__end_.__next_;
base::__unlink_nodes(__n, __n);
--base::__sz();
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__c_node* __c = __get_db()->__find_c_and_lock(this);
for (__i_node** __p = __c->end_; __p != __c->beg_; )
{
@@ -1758,7 +1758,7 @@ list<_Tp, _Alloc>::pop_front()
{
(*__p)->__c_ = nullptr;
if (--__c->end_ != __p)
- memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
+ _VSTD::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
}
}
__get_db()->unlock();
@@ -1777,7 +1777,7 @@ list<_Tp, _Alloc>::pop_back()
__link_pointer __n = base::__end_.__prev_;
base::__unlink_nodes(__n, __n);
--base::__sz();
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__c_node* __c = __get_db()->__find_c_and_lock(this);
for (__i_node** __p = __c->end_; __p != __c->beg_; )
{
@@ -1787,7 +1787,7 @@ list<_Tp, _Alloc>::pop_back()
{
(*__p)->__c_ = nullptr;
if (--__c->end_ != __p)
- memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
+ _VSTD::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
}
}
__get_db()->unlock();
@@ -1801,7 +1801,7 @@ template <class _Tp, class _Alloc>
typename list<_Tp, _Alloc>::iterator
list<_Tp, _Alloc>::erase(const_iterator __p)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
"list::erase(iterator) called with an iterator not"
" referring to this list");
@@ -1813,7 +1813,7 @@ list<_Tp, _Alloc>::erase(const_iterator __p)
__link_pointer __r = __n->__next_;
base::__unlink_nodes(__n, __n);
--base::__sz();
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__c_node* __c = __get_db()->__find_c_and_lock(this);
for (__i_node** __ip = __c->end_; __ip != __c->beg_; )
{
@@ -1823,7 +1823,7 @@ list<_Tp, _Alloc>::erase(const_iterator __p)
{
(*__ip)->__c_ = nullptr;
if (--__c->end_ != __ip)
- memmove(__ip, __ip+1, (__c->end_ - __ip)*sizeof(__i_node*));
+ _VSTD::memmove(__ip, __ip+1, (__c->end_ - __ip)*sizeof(__i_node*));
}
}
__get_db()->unlock();
@@ -1831,7 +1831,7 @@ list<_Tp, _Alloc>::erase(const_iterator __p)
__node_pointer __np = __n->__as_node();
__node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_));
__node_alloc_traits::deallocate(__na, __np, 1);
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
return iterator(__r, this);
#else
return iterator(__r);
@@ -1842,7 +1842,7 @@ template <class _Tp, class _Alloc>
typename list<_Tp, _Alloc>::iterator
list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__f) == this,
"list::erase(iterator, iterator) called with an iterator not"
" referring to this list");
@@ -1859,7 +1859,7 @@ list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l)
__link_pointer __n = __f.__ptr_;
++__f;
--base::__sz();
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__c_node* __c = __get_db()->__find_c_and_lock(this);
for (__i_node** __p = __c->end_; __p != __c->beg_; )
{
@@ -1869,7 +1869,7 @@ list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l)
{
(*__p)->__c_ = nullptr;
if (--__c->end_ != __p)
- memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
+ _VSTD::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
}
}
__get_db()->unlock();
@@ -1879,7 +1879,7 @@ list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l)
__node_alloc_traits::deallocate(__na, __np, 1);
}
}
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
return iterator(__l.__ptr_, this);
#else
return iterator(__l.__ptr_);
@@ -1900,7 +1900,7 @@ list<_Tp, _Alloc>::resize(size_type __n)
__hold_pointer __hold = __allocate_node(__na);
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_));
++__ds;
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
iterator __r = iterator(__hold.release()->__as_link(), this);
#else
iterator __r = iterator(__hold.release()->__as_link());
@@ -1929,7 +1929,7 @@ list<_Tp, _Alloc>::resize(size_type __n)
__node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);
if (__prev == 0)
break;
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__e = iterator(__prev, this);
#else
__e = iterator(__prev);
@@ -1958,7 +1958,7 @@ list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x)
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
++__ds;
__link_pointer __nl = __hold.release()->__as_link();
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
iterator __r = iterator(__nl, this);
#else
iterator __r = iterator(__nl);
@@ -1987,7 +1987,7 @@ list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x)
__node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);
if (__prev == 0)
break;
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__e = iterator(__prev, this);
#else
__e = iterator(__prev);
@@ -2007,7 +2007,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c)
{
_LIBCPP_ASSERT(this != &__c,
"list::splice(iterator, list) called with this == &list");
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
"list::splice(iterator, list) called with an iterator not"
" referring to this list");
@@ -2020,7 +2020,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c)
__link_nodes(__p.__ptr_, __f, __l);
base::__sz() += __c.__sz();
__c.__sz() = 0;
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
if (&__c != this) {
__libcpp_db* __db = __get_db();
__c_node* __cn1 = __db->__find_c_and_lock(this);
@@ -2034,7 +2034,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c)
__cn1->__add(*__ip);
(*__ip)->__c_ = __cn1;
if (--__cn2->end_ != __ip)
- memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*));
+ _VSTD::memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*));
}
}
__db->unlock();
@@ -2047,7 +2047,7 @@ template <class _Tp, class _Alloc>
void
list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
"list::splice(iterator, list, iterator) called with first iterator not"
" referring to this list");
@@ -2056,7 +2056,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i)
" referring to list argument");
_LIBCPP_ASSERT(__get_const_db()->__dereferenceable(&__i),
"list::splice(iterator, list, iterator) called with second iterator not"
- " derefereceable");
+ " dereferenceable");
#endif
if (__p.__ptr_ != __i.__ptr_ && __p.__ptr_ != __i.__ptr_->__next_)
{
@@ -2065,7 +2065,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i)
__link_nodes(__p.__ptr_, __f, __f);
--__c.__sz();
++base::__sz();
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
if (&__c != this) {
__libcpp_db* __db = __get_db();
__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)
__cn1->__add(*__ip);
(*__ip)->__c_ = __cn1;
if (--__cn2->end_ != __ip)
- memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*));
+ _VSTD::memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*));
}
}
__db->unlock();
@@ -2092,7 +2092,7 @@ template <class _Tp, class _Alloc>
void
list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
"list::splice(iterator, list, iterator, iterator) called with first iterator not"
" referring to this list");
@@ -2121,7 +2121,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, con
}
base::__unlink_nodes(__first, __last);
__link_nodes(__p.__ptr_, __first, __last);
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
if (&__c != this) {
__libcpp_db* __db = __get_db();
__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
__cn1->__add(*__ip);
(*__ip)->__c_ = __cn1;
if (--__cn2->end_ != __ip)
- memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*));
+ _VSTD::memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*));
}
}
}
@@ -2258,7 +2258,7 @@ list<_Tp, _Alloc>::merge(list& __c, _Comp __comp)
++__f1;
}
splice(__e1, __c);
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__libcpp_db* __db = __get_db();
__c_node* __cn1 = __db->__find_c_and_lock(this);
__c_node* __cn2 = __db->__find_c(&__c);
@@ -2271,7 +2271,7 @@ list<_Tp, _Alloc>::merge(list& __c, _Comp __comp)
__cn1->__add(*__p);
(*__p)->__c_ = __cn1;
if (--__cn2->end_ != __p)
- memmove(__p, __p+1, (__cn2->end_ - __p)*sizeof(__i_node*));
+ _VSTD::memmove(__p, __p+1, (__cn2->end_ - __p)*sizeof(__i_node*));
}
}
__db->unlock();
@@ -2382,7 +2382,7 @@ list<_Tp, _Alloc>::__invariants() const
return size() == _VSTD::distance(begin(), end());
}
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
template <class _Tp, class _Alloc>
bool
@@ -2412,7 +2412,7 @@ list<_Tp, _Alloc>::__subscriptable(const const_iterator*, ptrdiff_t) const
return false;
}
-#endif // _LIBCPP_DEBUG_LEVEL >= 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
template <class _Tp, class _Alloc>
inline _LIBCPP_INLINE_VISIBILITY
diff --git a/libcxx/include/locale b/libcxx/include/locale
index 3fe44300227a..9a705c77cfab 100644
--- a/libcxx/include/locale
+++ b/libcxx/include/locale
@@ -92,7 +92,11 @@ public:
typedef typename Codecvt::state_type state_type;
typedef typename wide_string::traits_type::int_type int_type;
- explicit wstring_convert(Codecvt* pcvt = new Codecvt); // explicit in C++14
+ wstring_convert(Codecvt* pcvt = new Codecvt); // before C++14
+ explicit wstring_convert(Codecvt* pcvt = new Codecvt); // before C++20
+ wstring_convert() : wstring_convert(new Codecvt) {} // C++20
+ explicit wstring_convert(Codecvt* pcvt); // C++20
+
wstring_convert(Codecvt* pcvt, state_type state);
explicit wstring_convert(const byte_string& byte_err, // explicit in C++14
const wide_string& wide_err = wide_string());
@@ -121,8 +125,14 @@ class wbuffer_convert
public:
typedef typename Tr::state_type state_type;
- explicit wbuffer_convert(streambuf* bytebuf = 0, Codecvt* pcvt = new Codecvt,
- state_type state = state_type()); // explicit in C++14
+ wbuffer_convert(streambuf* bytebuf = 0, Codecvt* pcvt = new Codecvt,
+ state_type state = state_type()); // before C++14
+ explicit wbuffer_convert(streambuf* bytebuf = nullptr, Codecvt* pcvt = new Codecvt,
+ state_type state = state_type()); // before C++20
+ wbuffer_convert() : wbuffer_convert(nullptr) {} // C++20
+ explicit wbuffer_convert(streambuf* bytebuf, Codecvt* pcvt = new Codecvt,
+ state_type state = state_type()); // C++20
+
wbuffer_convert(const wbuffer_convert&) = delete; // C++14
wbuffer_convert & operator=(const wbuffer_convert &) = delete; // C++14
~wbuffer_convert(); // C++14
@@ -197,10 +207,6 @@ template <class charT> class messages_byname;
#include <nl_types.h>
#endif
-#ifdef __APPLE__
-#include <Availability.h>
-#endif
-
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
#include <__bsd_locale_defaults.h>
#else
@@ -261,11 +267,11 @@ __scan_keyword(_InputIterator& __b, _InputIterator __e,
const unsigned char __does_match = '\2';
unsigned char __statbuf[100];
unsigned char* __status = __statbuf;
- unique_ptr<unsigned char, void(*)(void*)> __stat_hold(0, free);
+ unique_ptr<unsigned char, void(*)(void*)> __stat_hold(nullptr, free);
if (__nkw > sizeof(__statbuf))
{
__status = (unsigned char*)malloc(__nkw);
- if (__status == 0)
+ if (__status == nullptr)
__throw_bad_alloc();
__stat_hold.reset(__status);
}
@@ -561,8 +567,8 @@ __num_get<_CharT>::__stage2_float_loop(_CharT __ct, bool& __in_units, char& __ex
return 0;
}
-_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<char>)
-_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<wchar_t>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<char>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<wchar_t>)
template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
class _LIBCPP_TEMPLATE_VIS num_get
@@ -877,8 +883,8 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__iob.getloc());
typedef typename numpunct<_CharT>::string_type string_type;
const string_type __names[2] = {__np.truename(), __np.falsename()};
- const string_type* __i = __scan_keyword(__b, __e, __names, __names+2,
- __ct, __err);
+ const string_type* __i = _VSTD::__scan_keyword(__b, __e, __names, __names+2,
+ __ct, __err);
__v = __i == __names;
return __b;
}
@@ -1099,8 +1105,8 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
return __b;
}
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<char>)
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<wchar_t>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<char>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<wchar_t>)
struct _LIBCPP_TYPE_VIS __num_put_base
{
@@ -1249,8 +1255,8 @@ __num_put<_CharT>::__widen_and_group_float(char* __nb, char* __np, char* __ne,
__op = __ob + (__np - __nb);
}
-_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<char>)
-_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<wchar_t>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<char>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<wchar_t>)
template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
class _LIBCPP_TEMPLATE_VIS num_put
@@ -1427,7 +1433,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
return do_put(__s, __iob, __fl, (unsigned long)__v);
const numpunct<char_type>& __np = use_facet<numpunct<char_type> >(__iob.getloc());
typedef typename numpunct<char_type>::string_type string_type;
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
string_type __tmp(__v ? __np.truename() : __np.falsename());
string_type __nm = _VSTD::move(__tmp);
#else
@@ -1564,14 +1570,14 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
(int)__iob.precision(), __v);
else
__nc = __libcpp_snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v);
- unique_ptr<char, void(*)(void*)> __nbh(0, free);
+ unique_ptr<char, void(*)(void*)> __nbh(nullptr, free);
if (__nc > static_cast<int>(__nbuf-1))
{
if (__specify_precision)
__nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);
else
__nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v);
- if (__nb == 0)
+ if (__nc == -1)
__throw_bad_alloc();
__nbh.reset(__nb);
}
@@ -1615,14 +1621,14 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
(int)__iob.precision(), __v);
else
__nc = __libcpp_snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v);
- unique_ptr<char, void(*)(void*)> __nbh(0, free);
+ unique_ptr<char, void(*)(void*)> __nbh(nullptr, free);
if (__nc > static_cast<int>(__nbuf-1))
{
if (__specify_precision)
__nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);
else
__nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v);
- if (__nb == 0)
+ if (__nc == -1)
__throw_bad_alloc();
__nbh.reset(__nb);
}
@@ -1676,8 +1682,8 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
return __pad_and_output(__s, __o, __op, __oe, __iob, __fl);
}
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<char>)
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<wchar_t>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<char>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<wchar_t>)
template <class _CharT, class _InputIterator>
_LIBCPP_HIDDEN
@@ -1916,7 +1922,7 @@ time_get<_CharT, _InputIterator>::__get_weekdayname(int& __w,
{
// Note: ignoring case comes from the POSIX strptime spec
const string_type* __wk = this->__weeks();
- ptrdiff_t __i = __scan_keyword(__b, __e, __wk, __wk+14, __ct, __err, false) - __wk;
+ ptrdiff_t __i = _VSTD::__scan_keyword(__b, __e, __wk, __wk+14, __ct, __err, false) - __wk;
if (__i < 14)
__w = __i % 7;
}
@@ -1930,7 +1936,7 @@ time_get<_CharT, _InputIterator>::__get_monthname(int& __m,
{
// Note: ignoring case comes from the POSIX strptime spec
const string_type* __month = this->__months();
- ptrdiff_t __i = __scan_keyword(__b, __e, __month, __month+24, __ct, __err, false) - __month;
+ ptrdiff_t __i = _VSTD::__scan_keyword(__b, __e, __month, __month+24, __ct, __err, false) - __month;
if (__i < 24)
__m = __i % 12;
}
@@ -1942,7 +1948,7 @@ time_get<_CharT, _InputIterator>::__get_day(int& __d,
ios_base::iostate& __err,
const ctype<char_type>& __ct) const
{
- int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 2);
+ int __t = _VSTD::__get_up_to_n_digits(__b, __e, __err, __ct, 2);
if (!(__err & ios_base::failbit) && 1 <= __t && __t <= 31)
__d = __t;
else
@@ -2102,7 +2108,7 @@ time_get<_CharT, _InputIterator>::__get_am_pm(int& __h,
__err |= ios_base::failbit;
return;
}
- ptrdiff_t __i = __scan_keyword(__b, __e, __ap, __ap+2, __ct, __err, false) - __ap;
+ ptrdiff_t __i = _VSTD::__scan_keyword(__b, __e, __ap, __ap+2, __ct, __err, false) - __ap;
if (__i == 0 && __h == 12)
__h = 0;
else if (__i == 1 && __h < 12)
@@ -2362,8 +2368,8 @@ time_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
return __b;
}
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<char>)
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<wchar_t>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<char>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<wchar_t>)
class _LIBCPP_TYPE_VIS __time_get
{
@@ -2462,8 +2468,8 @@ private:
virtual const string_type& __X() const {return this->__X_;}
};
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<char>)
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<wchar_t>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<char>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<wchar_t>)
class _LIBCPP_TYPE_VIS __time_put
{
@@ -2575,8 +2581,8 @@ time_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base&,
return _VSTD::copy(__nb, __ne, __s);
}
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<char>)
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<wchar_t>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<char>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<wchar_t>)
template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
class _LIBCPP_TEMPLATE_VIS time_put_byname
@@ -2596,8 +2602,8 @@ protected:
~time_put_byname() {}
};
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<char>)
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<wchar_t>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<char>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<wchar_t>)
// money_base
@@ -2663,10 +2669,10 @@ template <class _CharT, bool _International>
const bool
moneypunct<_CharT, _International>::intl;
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, false>)
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, true>)
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, false>)
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, true>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, false>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, true>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, false>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, true>)
// moneypunct_byname
@@ -2720,10 +2726,10 @@ template<> _LIBCPP_FUNC_VIS void moneypunct_byname<char, true>::init(const char*
template<> _LIBCPP_FUNC_VIS void moneypunct_byname<wchar_t, false>::init(const char*);
template<> _LIBCPP_FUNC_VIS void moneypunct_byname<wchar_t, true>::init(const char*);
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, false>)
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, true>)
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, false>)
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, true>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, false>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, true>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, false>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, true>)
// money_get
@@ -2779,8 +2785,8 @@ __money_get<_CharT>::__gather_info(bool __intl, const locale& __loc,
}
}
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<char>)
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<wchar_t>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<char>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<wchar_t>)
template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
class _LIBCPP_TEMPLATE_VIS money_get
@@ -3108,11 +3114,11 @@ money_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
__ct.widen(__src, __src + (sizeof(__src)-1), __atoms);
char __nbuf[__bz];
char* __nc = __nbuf;
- unique_ptr<char, void(*)(void*)> __h(0, free);
+ unique_ptr<char, void(*)(void*)> __h(nullptr, free);
if (__wn - __wb.get() > __bz-2)
{
__h.reset((char*)malloc(static_cast<size_t>(__wn - __wb.get() + 2)));
- if (__h.get() == 0)
+ if (__h.get() == nullptr)
__throw_bad_alloc();
__nc = __h.get();
}
@@ -3162,8 +3168,8 @@ money_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
return __b;
}
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<char>)
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<wchar_t>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<char>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<wchar_t>)
// money_put
@@ -3337,8 +3343,8 @@ __money_put<_CharT>::__format(char_type* __mb, char_type*& __mi, char_type*& __m
__mi = __mb;
}
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<char>)
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<wchar_t>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<char>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<wchar_t>)
template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
class _LIBCPP_TEMPLATE_VIS money_put
@@ -3396,17 +3402,17 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,
char* __bb = __buf;
char_type __digits[__bs];
char_type* __db = __digits;
- size_t __n = static_cast<size_t>(snprintf(__bb, __bs, "%.0Lf", __units));
- unique_ptr<char, void(*)(void*)> __hn(0, free);
+ int __n = snprintf(__bb, __bs, "%.0Lf", __units);
+ unique_ptr<char, void(*)(void*)> __hn(nullptr, free);
unique_ptr<char_type, void(*)(void*)> __hd(0, free);
// secure memory for digit storage
- if (__n > __bs-1)
+ if (static_cast<size_t>(__n) > __bs-1)
{
- __n = static_cast<size_t>(__libcpp_asprintf_l(&__bb, _LIBCPP_GET_C_LOCALE, "%.0Lf", __units));
- if (__bb == 0)
+ __n = __libcpp_asprintf_l(&__bb, _LIBCPP_GET_C_LOCALE, "%.0Lf", __units);
+ if (__n == -1)
__throw_bad_alloc();
__hn.reset(__bb);
- __hd.reset((char_type*)malloc(__n * sizeof(char_type)));
+ __hd.reset((char_type*)malloc(static_cast<size_t>(__n) * sizeof(char_type)));
if (__hd == nullptr)
__throw_bad_alloc();
__db = __hd.get();
@@ -3428,9 +3434,9 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,
char_type __mbuf[__bs];
char_type* __mb = __mbuf;
unique_ptr<char_type, void(*)(void*)> __hw(0, free);
- size_t __exn = static_cast<int>(__n) > __fd ?
- (__n - static_cast<size_t>(__fd)) * 2 + __sn.size() +
- __sym.size() + static_cast<size_t>(__fd) + 1
+ size_t __exn = __n > __fd ?
+ (static_cast<size_t>(__n) - static_cast<size_t>(__fd)) * 2 +
+ __sn.size() + __sym.size() + static_cast<size_t>(__fd) + 1
: __sn.size() + __sym.size() + static_cast<size_t>(__fd) + 2;
if (__exn > __bs)
{
@@ -3490,8 +3496,8 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,
return __pad_and_output(__s, __mb, __mi, __me, __iob, __fl);
}
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<char>)
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<wchar_t>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<char>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<wchar_t>)
// messages
@@ -3582,7 +3588,7 @@ messages<_CharT>::do_get(catalog __c, int __set, int __msgid,
char* __n = catgets(__cat, __set, __msgid, __ndflt.c_str());
string_type __w;
__widen_from_utf8<sizeof(char_type)*__CHAR_BIT__>()(back_inserter(__w),
- __n, __n + strlen(__n));
+ __n, __n + _VSTD::strlen(__n));
return __w;
#else // !_LIBCPP_HAS_CATOPEN
_LIBCPP_UNUSED_VAR(__c);
@@ -3606,8 +3612,8 @@ messages<_CharT>::do_close(catalog __c) const
#endif // _LIBCPP_HAS_CATOPEN
}
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<char>)
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<wchar_t>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<char>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<wchar_t>)
template <class _CharT>
class _LIBCPP_TEMPLATE_VIS messages_byname
@@ -3630,8 +3636,8 @@ protected:
~messages_byname() {}
};
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<char>)
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<wchar_t>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<char>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<wchar_t>)
template<class _Codecvt, class _Elem = wchar_t,
class _Wide_alloc = allocator<_Elem>,
@@ -3654,8 +3660,17 @@ private:
wstring_convert(const wstring_convert& __wc);
wstring_convert& operator=(const wstring_convert& __wc);
public:
+#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_EXPLICIT_AFTER_CXX11 wstring_convert(_Codecvt* __pcvt = new _Codecvt);
+ wstring_convert() : wstring_convert(new _Codecvt) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit wstring_convert(_Codecvt* __pcvt);
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_EXPLICIT_AFTER_CXX11
+ wstring_convert(_Codecvt* __pcvt = new _Codecvt);
+#endif
+
_LIBCPP_INLINE_VISIBILITY
wstring_convert(_Codecvt* __pcvt, state_type __state);
_LIBCPP_EXPLICIT_AFTER_CXX11 wstring_convert(const byte_string& __byte_err,
@@ -3922,9 +3937,20 @@ private:
wbuffer_convert(const wbuffer_convert&);
wbuffer_convert& operator=(const wbuffer_convert&);
+
public:
- _LIBCPP_EXPLICIT_AFTER_CXX11 wbuffer_convert(streambuf* __bytebuf = 0,
- _Codecvt* __pcvt = new _Codecvt, state_type __state = state_type());
+#ifndef _LIBCPP_CXX03_LANG
+ wbuffer_convert() : wbuffer_convert(nullptr) {}
+ explicit wbuffer_convert(streambuf* __bytebuf,
+ _Codecvt* __pcvt = new _Codecvt,
+ state_type __state = state_type());
+#else
+ _LIBCPP_EXPLICIT_AFTER_CXX11
+ wbuffer_convert(streambuf* __bytebuf = nullptr,
+ _Codecvt* __pcvt = new _Codecvt,
+ state_type __state = state_type());
+#endif
+
~wbuffer_convert();
_LIBCPP_INLINE_VISIBILITY
@@ -3961,9 +3987,9 @@ private:
template <class _Codecvt, class _Elem, class _Tr>
wbuffer_convert<_Codecvt, _Elem, _Tr>::
wbuffer_convert(streambuf* __bytebuf, _Codecvt* __pcvt, state_type __state)
- : __extbuf_(0),
- __extbufnext_(0),
- __extbufend_(0),
+ : __extbuf_(nullptr),
+ __extbufnext_(nullptr),
+ __extbufend_(nullptr),
__ebs_(0),
__intbuf_(0),
__ibs_(0),
@@ -4003,7 +4029,7 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::underflow()
int_type __c = traits_type::eof();
if (this->gptr() == this->egptr())
{
- memmove(this->eback(), this->egptr() - __unget_sz, __unget_sz * sizeof(char_type));
+ _VSTD::memmove(this->eback(), this->egptr() - __unget_sz, __unget_sz * sizeof(char_type));
if (__always_noconv_)
{
streamsize __nmemb = static_cast<streamsize>(this->egptr() - this->eback() - __unget_sz);
@@ -4020,7 +4046,7 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::underflow()
{
_LIBCPP_ASSERT(!(__extbufnext_ == NULL && (__extbufend_ != __extbufnext_)), "underflow moving from NULL" );
if (__extbufend_ != __extbufnext_)
- memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);
+ _VSTD::memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);
__extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_);
__extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? sizeof(__extbuf_min_) : __ebs_);
streamsize __nmemb = _VSTD::min(static_cast<streamsize>(this->egptr() - this->eback() - __unget_sz),
@@ -4336,12 +4362,12 @@ template <class _Codecvt, class _Elem, class _Tr>
wbuffer_convert<_Codecvt, _Elem, _Tr>*
wbuffer_convert<_Codecvt, _Elem, _Tr>::__close()
{
- wbuffer_convert* __rt = 0;
- if (__cv_ != 0 && __bufptr_ != 0)
+ wbuffer_convert* __rt = nullptr;
+ if (__cv_ != nullptr && __bufptr_ != nullptr)
{
__rt = this;
if ((__cm_ & ios_base::out) && sync())
- __rt = 0;
+ __rt = nullptr;
}
return __rt;
}
diff --git a/libcxx/include/locale.h b/libcxx/include/locale.h
index a21ee385c331..81cfcee57fd7 100644
--- a/libcxx/include/locale.h
+++ b/libcxx/include/locale.h
@@ -35,8 +35,12 @@ Functions:
#include <__config>
+#if defined(_LIBCPP_HAS_NO_LOCALIZATION)
+# error "Localization is not supported by this configuration of libc++"
+#endif
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#include_next <locale.h>
diff --git a/libcxx/include/map b/libcxx/include/map
index d2b82591368b..a27002c279ec 100644
--- a/libcxx/include/map
+++ b/libcxx/include/map
@@ -1230,7 +1230,7 @@ public:
return __tree_.__emplace_hint_unique_key_args(__h.__i_, __k,
_VSTD::piecewise_construct,
_VSTD::forward_as_tuple(__k),
- _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
+ _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)).first;
}
template <class... _Args>
@@ -1240,7 +1240,7 @@ public:
return __tree_.__emplace_hint_unique_key_args(__h.__i_, __k,
_VSTD::piecewise_construct,
_VSTD::forward_as_tuple(_VSTD::move(__k)),
- _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
+ _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)).first;
}
template <class _Vp>
@@ -1270,30 +1270,30 @@ public:
}
template <class _Vp>
- _LIBCPP_INLINE_VISIBILITY
- iterator insert_or_assign(const_iterator __h, const key_type& __k, _Vp&& __v)
- {
- iterator __p = lower_bound(__k);
- if ( __p != end() && !key_comp()(__k, __p->first))
- {
- __p->second = _VSTD::forward<_Vp>(__v);
- return __p;
- }
- return emplace_hint(__h, __k, _VSTD::forward<_Vp>(__v));
- }
+ _LIBCPP_INLINE_VISIBILITY iterator insert_or_assign(const_iterator __h,
+ const key_type& __k,
+ _Vp&& __v) {
+ auto [__r, __inserted] = __tree_.__emplace_hint_unique_key_args(
+ __h.__i_, __k, __k, _VSTD::forward<_Vp>(__v));
+
+ if (!__inserted)
+ __r->__get_value().second = _VSTD::forward<_Vp>(__v);
+
+ return __r;
+ }
template <class _Vp>
- _LIBCPP_INLINE_VISIBILITY
- iterator insert_or_assign(const_iterator __h, key_type&& __k, _Vp&& __v)
- {
- iterator __p = lower_bound(__k);
- if ( __p != end() && !key_comp()(__k, __p->first))
- {
- __p->second = _VSTD::forward<_Vp>(__v);
- return __p;
- }
- return emplace_hint(__h, _VSTD::move(__k), _VSTD::forward<_Vp>(__v));
- }
+ _LIBCPP_INLINE_VISIBILITY iterator insert_or_assign(const_iterator __h,
+ key_type&& __k,
+ _Vp&& __v) {
+ auto [__r, __inserted] = __tree_.__emplace_hint_unique_key_args(
+ __h.__i_, __k, _VSTD::move(__k), _VSTD::forward<_Vp>(__v));
+
+ if (!__inserted)
+ __r->__get_value().second = _VSTD::forward<_Vp>(__v);
+
+ return __r;
+ }
#endif // _LIBCPP_STD_VER > 14
@@ -1546,7 +1546,7 @@ map<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(const key_type&
__h.get_deleter().__first_constructed = true;
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.__get_value().second));
__h.get_deleter().__second_constructed = true;
- return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03
+ return __h;
}
template <class _Key, class _Tp, class _Compare, class _Allocator>
diff --git a/libcxx/include/memory b/libcxx/include/memory
index 1f9f36c5bbbb..a00916c8c03f 100644
--- a/libcxx/include/memory
+++ b/libcxx/include/memory
@@ -46,7 +46,7 @@ struct pointer_traits<T*>
};
template <class T> constexpr T* to_address(T* p) noexcept; // C++20
-template <class Ptr> auto to_address(const Ptr& p) noexcept; // C++20
+template <class Ptr> constexpr auto to_address(const Ptr& p) noexcept; // C++20
template <class Alloc>
struct allocator_traits
@@ -83,21 +83,19 @@ struct allocator_traits
template <class T> using rebind_alloc = Alloc::rebind<T>::other | Alloc<T, Args...>;
template <class T> using rebind_traits = allocator_traits<rebind_alloc<T>>;
- static pointer allocate(allocator_type& a, size_type n); // [[nodiscard]] in C++20
- static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint); // [[nodiscard]] in C++20
+ static pointer allocate(allocator_type& a, size_type n); // constexpr and [[nodiscard]] in C++20
+ static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint); // constexpr and [[nodiscard]] in C++20
- static void deallocate(allocator_type& a, pointer p, size_type n) noexcept;
+ static void deallocate(allocator_type& a, pointer p, size_type n) noexcept; // constexpr in C++20
template <class T, class... Args>
- static void construct(allocator_type& a, T* p, Args&&... args);
+ static void construct(allocator_type& a, T* p, Args&&... args); // constexpr in C++20
template <class T>
- static void destroy(allocator_type& a, T* p);
+ static void destroy(allocator_type& a, T* p); // constexpr in C++20
- static size_type max_size(const allocator_type& a); // noexcept in C++14
-
- static allocator_type
- select_on_container_copy_construction(const allocator_type& a);
+ static size_type max_size(const allocator_type& a); // noexcept in C++14, constexpr in C++20
+ static allocator_type select_on_container_copy_construction(const allocator_type& a); // constexpr in C++20
};
template <>
@@ -115,8 +113,8 @@ template <class T>
class allocator
{
public:
- typedef size_t size_type; // deprecated in C++17, removed in C++20
- typedef ptrdiff_t difference_type; // deprecated in C++17, removed in C++20
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
typedef T* pointer; // deprecated in C++17, removed in C++20
typedef const T* const_pointer; // deprecated in C++17, removed in C++20
typedef typename add_lvalue_reference<T>::type
@@ -135,12 +133,12 @@ public:
constexpr allocator(const allocator&) noexcept; // constexpr in C++20
template <class U>
constexpr allocator(const allocator<U>&) noexcept; // constexpr in C++20
- ~allocator();
+ ~allocator(); // constexpr in C++20
pointer address(reference x) const noexcept; // deprecated in C++17, removed in C++20
const_pointer address(const_reference x) const noexcept; // deprecated in C++17, removed in C++20
T* allocate(size_t n, const void* hint); // deprecated in C++17, removed in C++20
- T* allocate(size_t n);
- void deallocate(T* p, size_t n) noexcept;
+ T* allocate(size_t n); // constexpr in C++20
+ void deallocate(T* p, size_t n) noexcept; // constexpr in C++20
size_type max_size() const noexcept; // deprecated in C++17, removed in C++20
template<class U, class... Args>
void construct(U* p, Args&&... args); // deprecated in C++17, removed in C++20
@@ -149,10 +147,10 @@ public:
};
template <class T, class U>
-bool operator==(const allocator<T>&, const allocator<U>&) noexcept;
+bool operator==(const allocator<T>&, const allocator<U>&) noexcept; // constexpr in C++20
template <class T, class U>
-bool operator!=(const allocator<T>&, const allocator<U>&) noexcept;
+bool operator!=(const allocator<T>&, const allocator<U>&) noexcept; // constexpr in C++20
template <class OutputIterator, class T>
class raw_storage_iterator
@@ -191,14 +189,17 @@ template <class ForwardIterator, class Size, class T>
ForwardIterator
uninitialized_fill_n(ForwardIterator first, Size n, const T& x);
+template <class T, class ...Args>
+constexpr T* construct_at(T* location, Args&& ...args); // since C++20
+
template <class T>
-void destroy_at(T* location);
+void destroy_at(T* location); // constexpr in C++20
template <class ForwardIterator>
- void destroy(ForwardIterator first, ForwardIterator last);
+void destroy(ForwardIterator first, ForwardIterator last); // constexpr in C++20
template <class ForwardIterator, class Size>
- ForwardIterator destroy_n(ForwardIterator first, Size n);
+ForwardIterator destroy_n(ForwardIterator first, Size n); // constexpr in C++20
template <class InputIterator, class ForwardIterator>
ForwardIterator uninitialized_move(InputIterator first, InputIterator last, ForwardIterator result);
@@ -338,7 +339,7 @@ public:
pointer release() noexcept;
void reset(pointer p = pointer()) noexcept;
void reset(nullptr_t) noexcept;
- template <class U> void reset(U) = delete;
+ template <class U> void reset(U) = delete;
void swap(unique_ptr& u) noexcept;
};
@@ -664,6 +665,7 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
*/
#include <__config>
+#include <__availability>
#include <type_traits>
#include <typeinfo>
#include <cstddef>
@@ -677,6 +679,10 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
#include <tuple>
#include <stdexcept>
#include <cstring>
+#include <__memory/allocator_traits.h>
+#include <__memory/base.h>
+#include <__memory/pointer_traits.h>
+#include <__memory/utilities.h>
#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
# include <atomic>
#endif
@@ -716,413 +722,11 @@ _ValueType __libcpp_acquire_load(_ValueType const* __value) {
#endif
}
-// addressof moved to <type_traits>
-
-template <class _Tp> class allocator;
-
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
-template <>
-class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 allocator<void>
-{
-public:
- typedef void* pointer;
- typedef const void* const_pointer;
- typedef void value_type;
-
- template <class _Up> struct rebind {typedef allocator<_Up> other;};
-};
-
-template <>
-class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 allocator<const void>
-{
-public:
- typedef const void* pointer;
- typedef const void* const_pointer;
- typedef const void value_type;
-
- template <class _Up> struct rebind {typedef allocator<_Up> other;};
-};
-#endif
-
-// pointer_traits
-
-template <class _Tp, class = void>
-struct __has_element_type : false_type {};
-
-template <class _Tp>
-struct __has_element_type<_Tp,
- typename __void_t<typename _Tp::element_type>::type> : true_type {};
-
-template <class _Ptr, bool = __has_element_type<_Ptr>::value>
-struct __pointer_traits_element_type;
-
-template <class _Ptr>
-struct __pointer_traits_element_type<_Ptr, true>
-{
- typedef _LIBCPP_NODEBUG_TYPE typename _Ptr::element_type type;
-};
-
-#ifndef _LIBCPP_HAS_NO_VARIADICS
-
-template <template <class, class...> class _Sp, class _Tp, class ..._Args>
-struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, true>
-{
- typedef _LIBCPP_NODEBUG_TYPE typename _Sp<_Tp, _Args...>::element_type type;
-};
-
-template <template <class, class...> class _Sp, class _Tp, class ..._Args>
-struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, false>
-{
- typedef _LIBCPP_NODEBUG_TYPE _Tp type;
-};
-
-#else // _LIBCPP_HAS_NO_VARIADICS
-
-template <template <class> class _Sp, class _Tp>
-struct __pointer_traits_element_type<_Sp<_Tp>, true>
-{
- typedef typename _Sp<_Tp>::element_type type;
-};
-
-template <template <class> class _Sp, class _Tp>
-struct __pointer_traits_element_type<_Sp<_Tp>, false>
-{
- typedef _Tp type;
-};
-
-template <template <class, class> class _Sp, class _Tp, class _A0>
-struct __pointer_traits_element_type<_Sp<_Tp, _A0>, true>
-{
- typedef typename _Sp<_Tp, _A0>::element_type type;
-};
-
-template <template <class, class> class _Sp, class _Tp, class _A0>
-struct __pointer_traits_element_type<_Sp<_Tp, _A0>, false>
-{
- typedef _Tp type;
-};
-
-template <template <class, class, class> class _Sp, class _Tp, class _A0, class _A1>
-struct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1>, true>
-{
- typedef typename _Sp<_Tp, _A0, _A1>::element_type type;
-};
-
-template <template <class, class, class> class _Sp, class _Tp, class _A0, class _A1>
-struct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1>, false>
-{
- typedef _Tp type;
-};
-
-template <template <class, class, class, class> class _Sp, class _Tp, class _A0,
- class _A1, class _A2>
-struct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1, _A2>, true>
-{
- typedef typename _Sp<_Tp, _A0, _A1, _A2>::element_type type;
-};
-
-template <template <class, class, class, class> class _Sp, class _Tp, class _A0,
- class _A1, class _A2>
-struct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1, _A2>, false>
-{
- typedef _Tp type;
-};
-
-#endif // _LIBCPP_HAS_NO_VARIADICS
-
-template <class _Tp, class = void>
-struct __has_difference_type : false_type {};
-
-template <class _Tp>
-struct __has_difference_type<_Tp,
- typename __void_t<typename _Tp::difference_type>::type> : true_type {};
-
-template <class _Ptr, bool = __has_difference_type<_Ptr>::value>
-struct __pointer_traits_difference_type
-{
- typedef _LIBCPP_NODEBUG_TYPE ptrdiff_t type;
-};
-
-template <class _Ptr>
-struct __pointer_traits_difference_type<_Ptr, true>
-{
- typedef _LIBCPP_NODEBUG_TYPE typename _Ptr::difference_type type;
-};
-
-template <class _Tp, class _Up>
-struct __has_rebind
-{
-private:
- struct __two {char __lx; char __lxx;};
- template <class _Xp> static __two __test(...);
- _LIBCPP_SUPPRESS_DEPRECATED_PUSH
- template <class _Xp> static char __test(typename _Xp::template rebind<_Up>* = 0);
- _LIBCPP_SUPPRESS_DEPRECATED_POP
-public:
- static const bool value = sizeof(__test<_Tp>(0)) == 1;
-};
-
-template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value>
-struct __pointer_traits_rebind
-{
-#ifndef _LIBCPP_CXX03_LANG
- typedef _LIBCPP_NODEBUG_TYPE typename _Tp::template rebind<_Up> type;
-#else
- typedef _LIBCPP_NODEBUG_TYPE typename _Tp::template rebind<_Up>::other type;
-#endif
-};
-
-#ifndef _LIBCPP_HAS_NO_VARIADICS
-
-template <template <class, class...> class _Sp, class _Tp, class ..._Args, class _Up>
-struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, true>
-{
-#ifndef _LIBCPP_CXX03_LANG
- typedef _LIBCPP_NODEBUG_TYPE typename _Sp<_Tp, _Args...>::template rebind<_Up> type;
-#else
- typedef _LIBCPP_NODEBUG_TYPE typename _Sp<_Tp, _Args...>::template rebind<_Up>::other type;
-#endif
-};
-
-template <template <class, class...> class _Sp, class _Tp, class ..._Args, class _Up>
-struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, false>
-{
- typedef _Sp<_Up, _Args...> type;
-};
-
-#else // _LIBCPP_HAS_NO_VARIADICS
-
-template <template <class> class _Sp, class _Tp, class _Up>
-struct __pointer_traits_rebind<_Sp<_Tp>, _Up, true>
-{
-#ifndef _LIBCPP_CXX03_LANG
- typedef typename _Sp<_Tp>::template rebind<_Up> type;
-#else
- typedef typename _Sp<_Tp>::template rebind<_Up>::other type;
-#endif
-};
-
-template <template <class> class _Sp, class _Tp, class _Up>
-struct __pointer_traits_rebind<_Sp<_Tp>, _Up, false>
-{
- typedef _Sp<_Up> type;
-};
-
-template <template <class, class> class _Sp, class _Tp, class _A0, class _Up>
-struct __pointer_traits_rebind<_Sp<_Tp, _A0>, _Up, true>
-{
-#ifndef _LIBCPP_CXX03_LANG
- typedef typename _Sp<_Tp, _A0>::template rebind<_Up> type;
-#else
- typedef typename _Sp<_Tp, _A0>::template rebind<_Up>::other type;
-#endif
-};
-
-template <template <class, class> class _Sp, class _Tp, class _A0, class _Up>
-struct __pointer_traits_rebind<_Sp<_Tp, _A0>, _Up, false>
-{
- typedef _Sp<_Up, _A0> type;
-};
-
-template <template <class, class, class> class _Sp, class _Tp, class _A0,
- class _A1, class _Up>
-struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1>, _Up, true>
-{
-#ifndef _LIBCPP_CXX03_LANG
- typedef typename _Sp<_Tp, _A0, _A1>::template rebind<_Up> type;
-#else
- typedef typename _Sp<_Tp, _A0, _A1>::template rebind<_Up>::other type;
-#endif
-};
-
-template <template <class, class, class> class _Sp, class _Tp, class _A0,
- class _A1, class _Up>
-struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1>, _Up, false>
-{
- typedef _Sp<_Up, _A0, _A1> type;
-};
-
-template <template <class, class, class, class> class _Sp, class _Tp, class _A0,
- class _A1, class _A2, class _Up>
-struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1, _A2>, _Up, true>
-{
-#ifndef _LIBCPP_CXX03_LANG
- typedef typename _Sp<_Tp, _A0, _A1, _A2>::template rebind<_Up> type;
-#else
- typedef typename _Sp<_Tp, _A0, _A1, _A2>::template rebind<_Up>::other type;
-#endif
-};
-
-template <template <class, class, class, class> class _Sp, class _Tp, class _A0,
- class _A1, class _A2, class _Up>
-struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1, _A2>, _Up, false>
-{
- typedef _Sp<_Up, _A0, _A1, _A2> type;
-};
-
-#endif // _LIBCPP_HAS_NO_VARIADICS
-
-template <class _Ptr>
-struct _LIBCPP_TEMPLATE_VIS pointer_traits
-{
- typedef _Ptr pointer;
- typedef typename __pointer_traits_element_type<pointer>::type element_type;
- typedef typename __pointer_traits_difference_type<pointer>::type difference_type;
-
-#ifndef _LIBCPP_CXX03_LANG
- template <class _Up> using rebind = typename __pointer_traits_rebind<pointer, _Up>::type;
-#else
- template <class _Up> struct rebind
- {typedef typename __pointer_traits_rebind<pointer, _Up>::type other;};
-#endif // _LIBCPP_CXX03_LANG
-
-private:
- struct __nat {};
-public:
- _LIBCPP_INLINE_VISIBILITY
- static pointer pointer_to(typename conditional<is_void<element_type>::value,
- __nat, element_type>::type& __r)
- {return pointer::pointer_to(__r);}
-};
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS pointer_traits<_Tp*>
-{
- typedef _Tp* pointer;
- typedef _Tp element_type;
- typedef ptrdiff_t difference_type;
-
-#ifndef _LIBCPP_CXX03_LANG
- template <class _Up> using rebind = _Up*;
-#else
- template <class _Up> struct rebind {typedef _Up* other;};
-#endif
-
-private:
- struct __nat {};
-public:
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- static pointer pointer_to(typename conditional<is_void<element_type>::value,
- __nat, element_type>::type& __r) _NOEXCEPT
- {return _VSTD::addressof(__r);}
-};
-
-template <class _From, class _To>
-struct __rebind_pointer {
-#ifndef _LIBCPP_CXX03_LANG
- typedef typename pointer_traits<_From>::template rebind<_To> type;
-#else
- typedef typename pointer_traits<_From>::template rebind<_To>::other type;
-#endif
-};
-
-// allocator_traits
-
-template <class _Tp, class = void>
-struct __has_pointer_type : false_type {};
-
-template <class _Tp>
-struct __has_pointer_type<_Tp,
- typename __void_t<typename _Tp::pointer>::type> : true_type {};
-
-namespace __pointer_type_imp
-{
-
-template <class _Tp, class _Dp, bool = __has_pointer_type<_Dp>::value>
-struct __pointer_type
-{
- typedef _LIBCPP_NODEBUG_TYPE typename _Dp::pointer type;
-};
-
-template <class _Tp, class _Dp>
-struct __pointer_type<_Tp, _Dp, false>
-{
- typedef _LIBCPP_NODEBUG_TYPE _Tp* type;
-};
-
-} // __pointer_type_imp
-
-template <class _Tp, class _Dp>
-struct __pointer_type
-{
- typedef _LIBCPP_NODEBUG_TYPE typename __pointer_type_imp::__pointer_type<_Tp, typename remove_reference<_Dp>::type>::type type;
-};
-
-template <class _Tp, class = void>
-struct __has_const_pointer : false_type {};
-
-template <class _Tp>
-struct __has_const_pointer<_Tp,
- typename __void_t<typename _Tp::const_pointer>::type> : true_type {};
-
-template <class _Tp, class _Ptr, class _Alloc, bool = __has_const_pointer<_Alloc>::value>
-struct __const_pointer
-{
- typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::const_pointer type;
-};
-
-template <class _Tp, class _Ptr, class _Alloc>
-struct __const_pointer<_Tp, _Ptr, _Alloc, false>
-{
-#ifndef _LIBCPP_CXX03_LANG
- typedef _LIBCPP_NODEBUG_TYPE typename pointer_traits<_Ptr>::template rebind<const _Tp> type;
-#else
- typedef typename pointer_traits<_Ptr>::template rebind<const _Tp>::other type;
-#endif
-};
-
-template <class _Tp, class = void>
-struct __has_void_pointer : false_type {};
-
-template <class _Tp>
-struct __has_void_pointer<_Tp,
- typename __void_t<typename _Tp::void_pointer>::type> : true_type {};
-
-template <class _Ptr, class _Alloc, bool = __has_void_pointer<_Alloc>::value>
-struct __void_pointer
-{
- typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::void_pointer type;
-};
-
-template <class _Ptr, class _Alloc>
-struct __void_pointer<_Ptr, _Alloc, false>
-{
-#ifndef _LIBCPP_CXX03_LANG
- typedef _LIBCPP_NODEBUG_TYPE typename pointer_traits<_Ptr>::template rebind<void> type;
-#else
- typedef _LIBCPP_NODEBUG_TYPE typename pointer_traits<_Ptr>::template rebind<void>::other type;
-#endif
-};
-
-template <class _Tp, class = void>
-struct __has_const_void_pointer : false_type {};
-
-template <class _Tp>
-struct __has_const_void_pointer<_Tp,
- typename __void_t<typename _Tp::const_void_pointer>::type> : true_type {};
-
-template <class _Ptr, class _Alloc, bool = __has_const_void_pointer<_Alloc>::value>
-struct __const_void_pointer
-{
- typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::const_void_pointer type;
-};
-
-template <class _Ptr, class _Alloc>
-struct __const_void_pointer<_Ptr, _Alloc, false>
-{
-#ifndef _LIBCPP_CXX03_LANG
- typedef _LIBCPP_NODEBUG_TYPE typename pointer_traits<_Ptr>::template rebind<const void> type;
-#else
- typedef _LIBCPP_NODEBUG_TYPE typename pointer_traits<_Ptr>::template rebind<const void>::other type;
-#endif
-};
-
-
template <bool _UsePointerTraits> struct __to_address_helper;
template <> struct __to_address_helper<true> {
template <class _Pointer>
- using __return_type = decltype(pointer_traits<_Pointer>::to_address(std::declval<const _Pointer&>()));
+ using __return_type = decltype(pointer_traits<_Pointer>::to_address(_VSTD::declval<const _Pointer&>()));
template <class _Pointer>
_LIBCPP_CONSTEXPR
@@ -1157,7 +761,7 @@ template <> struct __to_address_helper<false> {
template <class _Pointer>
_LIBCPP_CONSTEXPR
static __return_type<_Pointer>
- __do_it(const _Pointer &__p) _NOEXCEPT { return std::__to_address(__p.operator->()); }
+ __do_it(const _Pointer &__p) _NOEXCEPT { return _VSTD::__to_address(__p.operator->()); }
};
@@ -1172,7 +776,7 @@ to_address(_Tp* __p) _NOEXCEPT
}
template <class _Pointer>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY constexpr
auto
to_address(const _Pointer& __p) _NOEXCEPT
{
@@ -1180,765 +784,287 @@ to_address(const _Pointer& __p) _NOEXCEPT
}
#endif
-template <class _Tp, class = void>
-struct __has_size_type : false_type {};
-
-template <class _Tp>
-struct __has_size_type<_Tp,
- typename __void_t<typename _Tp::size_type>::type> : true_type {};
-
-template <class _Alloc, class _DiffType, bool = __has_size_type<_Alloc>::value>
-struct __size_type
-{
- typedef _LIBCPP_NODEBUG_TYPE typename make_unsigned<_DiffType>::type type;
-};
-
-template <class _Alloc, class _DiffType>
-struct __size_type<_Alloc, _DiffType, true>
-{
- typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::size_type type;
-};
-
-template <class _Tp, class = void>
-struct __has_propagate_on_container_copy_assignment : false_type {};
-
-template <class _Tp>
-struct __has_propagate_on_container_copy_assignment<_Tp,
- typename __void_t<typename _Tp::propagate_on_container_copy_assignment>::type>
- : true_type {};
-
-template <class _Alloc, bool = __has_propagate_on_container_copy_assignment<_Alloc>::value>
-struct __propagate_on_container_copy_assignment
-{
- typedef _LIBCPP_NODEBUG_TYPE false_type type;
-};
-
-template <class _Alloc>
-struct __propagate_on_container_copy_assignment<_Alloc, true>
-{
- typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::propagate_on_container_copy_assignment type;
-};
-
-template <class _Tp, class = void>
-struct __has_propagate_on_container_move_assignment : false_type {};
-
-template <class _Tp>
-struct __has_propagate_on_container_move_assignment<_Tp,
- typename __void_t<typename _Tp::propagate_on_container_move_assignment>::type>
- : true_type {};
-
-template <class _Alloc, bool = __has_propagate_on_container_move_assignment<_Alloc>::value>
-struct __propagate_on_container_move_assignment
-{
- typedef false_type type;
-};
-
-template <class _Alloc>
-struct __propagate_on_container_move_assignment<_Alloc, true>
-{
- typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::propagate_on_container_move_assignment type;
-};
-
-template <class _Tp, class = void>
-struct __has_propagate_on_container_swap : false_type {};
-
-template <class _Tp>
-struct __has_propagate_on_container_swap<_Tp,
- typename __void_t<typename _Tp::propagate_on_container_swap>::type>
- : true_type {};
-
-template <class _Alloc, bool = __has_propagate_on_container_swap<_Alloc>::value>
-struct __propagate_on_container_swap
-{
- typedef false_type type;
-};
-
-template <class _Alloc>
-struct __propagate_on_container_swap<_Alloc, true>
-{
- typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::propagate_on_container_swap type;
-};
-
-template <class _Tp, class = void>
-struct __has_is_always_equal : false_type {};
-
-template <class _Tp>
-struct __has_is_always_equal<_Tp,
- typename __void_t<typename _Tp::is_always_equal>::type>
- : true_type {};
-
-template <class _Alloc, bool = __has_is_always_equal<_Alloc>::value>
-struct __is_always_equal
-{
- typedef _LIBCPP_NODEBUG_TYPE typename _VSTD::is_empty<_Alloc>::type type;
-};
-
-template <class _Alloc>
-struct __is_always_equal<_Alloc, true>
-{
- typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::is_always_equal type;
-};
+template <class _Tp> class allocator;
-template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value>
-struct __has_rebind_other
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
+template <>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 allocator<void>
{
-private:
- struct __two {char __lx; char __lxx;};
- template <class _Xp> static __two __test(...);
- _LIBCPP_SUPPRESS_DEPRECATED_PUSH
- template <class _Xp> static char __test(typename _Xp::template rebind<_Up>::other* = 0);
- _LIBCPP_SUPPRESS_DEPRECATED_POP
public:
- static const bool value = sizeof(__test<_Tp>(0)) == 1;
-};
-
-template <class _Tp, class _Up>
-struct __has_rebind_other<_Tp, _Up, false>
-{
- static const bool value = false;
-};
-
-template <class _Tp, class _Up, bool = __has_rebind_other<_Tp, _Up>::value>
-struct __allocator_traits_rebind
-{
- _LIBCPP_SUPPRESS_DEPRECATED_PUSH
- typedef _LIBCPP_NODEBUG_TYPE typename _Tp::template rebind<_Up>::other type;
- _LIBCPP_SUPPRESS_DEPRECATED_POP
-};
-
-template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up>
-struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, true>
-{
- _LIBCPP_SUPPRESS_DEPRECATED_PUSH
- typedef _LIBCPP_NODEBUG_TYPE typename _Alloc<_Tp, _Args...>::template rebind<_Up>::other type;
- _LIBCPP_SUPPRESS_DEPRECATED_POP
-};
-
-template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up>
-struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, false>
-{
- typedef _LIBCPP_NODEBUG_TYPE _Alloc<_Up, _Args...> type;
-};
-
-#ifndef _LIBCPP_CXX03_LANG
-
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
-template <class _Alloc, class _SizeType, class _ConstVoidPtr>
-auto
-__has_allocate_hint_test(_Alloc&& __a, _SizeType&& __sz, _ConstVoidPtr&& __p)
- -> decltype((void)__a.allocate(__sz, __p), true_type());
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-
-template <class _Alloc, class _SizeType, class _ConstVoidPtr>
-auto
-__has_allocate_hint_test(const _Alloc& __a, _SizeType&& __sz, _ConstVoidPtr&& __p)
- -> false_type;
-
-template <class _Alloc, class _SizeType, class _ConstVoidPtr>
-struct __has_allocate_hint
- : decltype(_VSTD::__has_allocate_hint_test(declval<_Alloc>(),
- declval<_SizeType>(),
- declval<_ConstVoidPtr>()))
-{
-};
-
-#else // _LIBCPP_CXX03_LANG
-
-template <class _Alloc, class _SizeType, class _ConstVoidPtr>
-struct __has_allocate_hint
- : true_type
-{
-};
-
-#endif // _LIBCPP_CXX03_LANG
-
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
-template <class _Alloc, class ..._Args,
- class = decltype(_VSTD::declval<_Alloc>().construct(_VSTD::declval<_Args>()...))>
-static true_type __test_has_construct(int);
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-
-template <class _Alloc, class...>
-static false_type __test_has_construct(...);
-
-template <class _Alloc, class ..._Args>
-struct __has_construct : decltype(__test_has_construct<_Alloc, _Args...>(0)) {};
-
-#if !defined(_LIBCPP_CXX03_LANG)
-
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
-template <class _Alloc, class _Pointer>
-auto
-__has_destroy_test(_Alloc&& __a, _Pointer&& __p)
- -> decltype(__a.destroy(__p), true_type());
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-
-template <class _Alloc, class _Pointer>
-auto
-__has_destroy_test(const _Alloc& __a, _Pointer&& __p)
- -> false_type;
-
-template <class _Alloc, class _Pointer>
-struct __has_destroy
- : decltype(_VSTD::__has_destroy_test(declval<_Alloc>(),
- declval<_Pointer>()))
-{
-};
-
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
-template <class _Alloc>
-auto
-__has_max_size_test(_Alloc&& __a)
- -> decltype(__a.max_size(), true_type());
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-
-template <class _Alloc>
-auto
-__has_max_size_test(const volatile _Alloc& __a)
- -> false_type;
-
-template <class _Alloc>
-struct __has_max_size
- : decltype(_VSTD::__has_max_size_test(declval<_Alloc&>()))
-{
-};
-
-template <class _Alloc>
-auto
-__has_select_on_container_copy_construction_test(_Alloc&& __a)
- -> decltype(__a.select_on_container_copy_construction(), true_type());
-
-template <class _Alloc>
-auto
-__has_select_on_container_copy_construction_test(const volatile _Alloc& __a)
- -> false_type;
-
-template <class _Alloc>
-struct __has_select_on_container_copy_construction
- : decltype(_VSTD::__has_select_on_container_copy_construction_test(declval<_Alloc&>()))
-{
-};
-
-#else // _LIBCPP_CXX03_LANG
-
-template <class _Alloc, class _Pointer, class = void>
-struct __has_destroy : false_type {};
-
-template <class _Alloc, class _Pointer>
-struct __has_destroy<_Alloc, _Pointer, typename __void_t<
- decltype(_VSTD::declval<_Alloc>().destroy(_VSTD::declval<_Pointer>()))
->::type> : std::true_type {};
-
-template <class _Alloc>
-struct __has_max_size
- : true_type
-{
-};
+ typedef void* pointer;
+ typedef const void* const_pointer;
+ typedef void value_type;
-template <class _Alloc>
-struct __has_select_on_container_copy_construction
- : false_type
-{
+ template <class _Up> struct rebind {typedef allocator<_Up> other;};
};
-#endif // _LIBCPP_CXX03_LANG
-
-template <class _Alloc, class _Ptr, bool = __has_difference_type<_Alloc>::value>
-struct __alloc_traits_difference_type
+template <>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 allocator<const void>
{
- typedef _LIBCPP_NODEBUG_TYPE typename pointer_traits<_Ptr>::difference_type type;
-};
+public:
+ typedef const void* pointer;
+ typedef const void* const_pointer;
+ typedef const void value_type;
-template <class _Alloc, class _Ptr>
-struct __alloc_traits_difference_type<_Alloc, _Ptr, true>
-{
- typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::difference_type type;
+ template <class _Up> struct rebind {typedef allocator<_Up> other;};
};
+#endif
-template <class _Tp>
-struct __is_default_allocator : false_type {};
+// allocator
template <class _Tp>
-struct __is_default_allocator<_VSTD::allocator<_Tp> > : true_type {};
-
-
-
-template <class _Alloc,
- bool = __has_construct<_Alloc, typename _Alloc::value_type*, typename _Alloc::value_type&&>::value && !__is_default_allocator<_Alloc>::value
- >
-struct __is_cpp17_move_insertable;
-template <class _Alloc>
-struct __is_cpp17_move_insertable<_Alloc, true> : std::true_type {};
-template <class _Alloc>
-struct __is_cpp17_move_insertable<_Alloc, false> : std::is_move_constructible<typename _Alloc::value_type> {};
-
-template <class _Alloc,
- bool = __has_construct<_Alloc, typename _Alloc::value_type*, const typename _Alloc::value_type&>::value && !__is_default_allocator<_Alloc>::value
- >
-struct __is_cpp17_copy_insertable;
-template <class _Alloc>
-struct __is_cpp17_copy_insertable<_Alloc, true> : __is_cpp17_move_insertable<_Alloc> {};
-template <class _Alloc>
-struct __is_cpp17_copy_insertable<_Alloc, false> : integral_constant<bool,
- std::is_copy_constructible<typename _Alloc::value_type>::value &&
- __is_cpp17_move_insertable<_Alloc>::value>
- {};
-
-
-
-template <class _Alloc>
-struct _LIBCPP_TEMPLATE_VIS allocator_traits
+class _LIBCPP_TEMPLATE_VIS allocator
{
- typedef _Alloc allocator_type;
- typedef typename allocator_type::value_type value_type;
-
- typedef typename __pointer_type<value_type, allocator_type>::type pointer;
- typedef typename __const_pointer<value_type, pointer, allocator_type>::type const_pointer;
- typedef typename __void_pointer<pointer, allocator_type>::type void_pointer;
- typedef typename __const_void_pointer<pointer, allocator_type>::type const_void_pointer;
-
- typedef typename __alloc_traits_difference_type<allocator_type, pointer>::type difference_type;
- typedef typename __size_type<allocator_type, difference_type>::type size_type;
-
- typedef typename __propagate_on_container_copy_assignment<allocator_type>::type
- propagate_on_container_copy_assignment;
- typedef typename __propagate_on_container_move_assignment<allocator_type>::type
- propagate_on_container_move_assignment;
- typedef typename __propagate_on_container_swap<allocator_type>::type
- propagate_on_container_swap;
- typedef typename __is_always_equal<allocator_type>::type
- is_always_equal;
-
-#ifndef _LIBCPP_CXX03_LANG
- template <class _Tp> using rebind_alloc =
- typename __allocator_traits_rebind<allocator_type, _Tp>::type;
- template <class _Tp> using rebind_traits = allocator_traits<rebind_alloc<_Tp> >;
-#else // _LIBCPP_CXX03_LANG
- template <class _Tp> struct rebind_alloc
- {typedef typename __allocator_traits_rebind<allocator_type, _Tp>::type other;};
- template <class _Tp> struct rebind_traits
- {typedef allocator_traits<typename rebind_alloc<_Tp>::other> other;};
-#endif // _LIBCPP_CXX03_LANG
-
- _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
- static pointer allocate(allocator_type& __a, size_type __n)
- {return __a.allocate(__n);}
- _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
- static pointer allocate(allocator_type& __a, size_type __n, const_void_pointer __hint)
- {return __allocate(__a, __n, __hint,
- __has_allocate_hint<allocator_type, size_type, const_void_pointer>());}
-
- _LIBCPP_INLINE_VISIBILITY
- static void deallocate(allocator_type& __a, pointer __p, size_type __n) _NOEXCEPT
- {__a.deallocate(__p, __n);}
-
- template <class _Tp, class... _Args>
- _LIBCPP_INLINE_VISIBILITY
- static void construct(allocator_type& __a, _Tp* __p, _Args&&... __args)
- {__construct(__has_construct<allocator_type, _Tp*, _Args...>(),
- __a, __p, _VSTD::forward<_Args>(__args)...);}
-
- template <class _Tp>
- _LIBCPP_INLINE_VISIBILITY
- static void destroy(allocator_type& __a, _Tp* __p)
- {__destroy(__has_destroy<allocator_type, _Tp*>(), __a, __p);}
-
- _LIBCPP_INLINE_VISIBILITY
- static size_type max_size(const allocator_type& __a) _NOEXCEPT
- {return __max_size(__has_max_size<const allocator_type>(), __a);}
-
- _LIBCPP_INLINE_VISIBILITY
- static allocator_type
- select_on_container_copy_construction(const allocator_type& __a)
- {return __select_on_container_copy_construction(
- __has_select_on_container_copy_construction<const allocator_type>(),
- __a);}
-
- template <class _Ptr>
- _LIBCPP_INLINE_VISIBILITY
- static
- void
- __construct_forward_with_exception_guarantees(allocator_type& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __begin2)
- {
- static_assert(__is_cpp17_move_insertable<allocator_type>::value,
- "The specified type does not meet the requirements of Cpp17MoveInsertible");
- for (; __begin1 != __end1; ++__begin1, (void) ++__begin2)
- construct(__a, _VSTD::__to_address(__begin2),
-#ifdef _LIBCPP_NO_EXCEPTIONS
- _VSTD::move(*__begin1)
-#else
- _VSTD::move_if_noexcept(*__begin1)
-#endif
- );
- }
-
- template <class _Tp>
- _LIBCPP_INLINE_VISIBILITY
- static
- typename enable_if
- <
- (__is_default_allocator<allocator_type>::value
- || !__has_construct<allocator_type, _Tp*, _Tp>::value) &&
- is_trivially_move_constructible<_Tp>::value,
- void
- >::type
- __construct_forward_with_exception_guarantees(allocator_type&, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2)
- {
- ptrdiff_t _Np = __end1 - __begin1;
- if (_Np > 0)
- {
- _VSTD::memcpy(__begin2, __begin1, _Np * sizeof(_Tp));
- __begin2 += _Np;
- }
- }
-
- template <class _Iter, class _Ptr>
- _LIBCPP_INLINE_VISIBILITY
- static
- void
- __construct_range_forward(allocator_type& __a, _Iter __begin1, _Iter __end1, _Ptr& __begin2)
- {
- for (; __begin1 != __end1; ++__begin1, (void) ++__begin2)
- construct(__a, _VSTD::__to_address(__begin2), *__begin1);
- }
+public:
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef _Tp value_type;
+ typedef true_type propagate_on_container_move_assignment;
+ typedef true_type is_always_equal;
- template <class _SourceTp, class _DestTp,
- class _RawSourceTp = typename remove_const<_SourceTp>::type,
- class _RawDestTp = typename remove_const<_DestTp>::type>
- _LIBCPP_INLINE_VISIBILITY
- static
- typename enable_if
- <
- is_trivially_copy_constructible<_DestTp>::value &&
- is_same<_RawSourceTp, _RawDestTp>::value &&
- (__is_default_allocator<allocator_type>::value ||
- !__has_construct<allocator_type, _DestTp*, _SourceTp&>::value),
- void
- >::type
- __construct_range_forward(allocator_type&, _SourceTp* __begin1, _SourceTp* __end1, _DestTp*& __begin2)
- {
- ptrdiff_t _Np = __end1 - __begin1;
- if (_Np > 0)
- {
- _VSTD::memcpy(const_cast<_RawDestTp*>(__begin2), __begin1, _Np * sizeof(_DestTp));
- __begin2 += _Np;
- }
- }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ allocator() _NOEXCEPT { }
- template <class _Ptr>
- _LIBCPP_INLINE_VISIBILITY
- static
- void
- __construct_backward_with_exception_guarantees(allocator_type& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __end2)
- {
- static_assert(__is_cpp17_move_insertable<allocator_type>::value,
- "The specified type does not meet the requirements of Cpp17MoveInsertable");
- while (__end1 != __begin1)
- {
- construct(__a, _VSTD::__to_address(__end2 - 1),
-#ifdef _LIBCPP_NO_EXCEPTIONS
- _VSTD::move(*--__end1)
-#else
- _VSTD::move_if_noexcept(*--__end1)
-#endif
- );
- --__end2;
- }
- }
+ template <class _Up>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ allocator(const allocator<_Up>&) _NOEXCEPT { }
- template <class _Tp>
- _LIBCPP_INLINE_VISIBILITY
- static
- typename enable_if
- <
- (__is_default_allocator<allocator_type>::value
- || !__has_construct<allocator_type, _Tp*, _Tp>::value) &&
- is_trivially_move_constructible<_Tp>::value,
- void
- >::type
- __construct_backward_with_exception_guarantees(allocator_type&, _Tp* __begin1, _Tp* __end1, _Tp*& __end2)
- {
- ptrdiff_t _Np = __end1 - __begin1;
- __end2 -= _Np;
- if (_Np > 0)
- _VSTD::memcpy(__end2, __begin1, _Np * sizeof(_Tp));
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _Tp* allocate(size_t __n) {
+ if (__n > allocator_traits<allocator>::max_size(*this))
+ __throw_length_error("allocator<T>::allocate(size_t n)"
+ " 'n' exceeds maximum supported size");
+ if (__libcpp_is_constant_evaluated()) {
+ return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp)));
+ } else {
+ return static_cast<_Tp*>(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)));
}
+ }
-private:
-
- _LIBCPP_INLINE_VISIBILITY
- static pointer __allocate(allocator_type& __a, size_type __n,
- const_void_pointer __hint, true_type)
- {
- _LIBCPP_SUPPRESS_DEPRECATED_PUSH
- return __a.allocate(__n, __hint);
- _LIBCPP_SUPPRESS_DEPRECATED_POP
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ void deallocate(_Tp* __p, size_t __n) _NOEXCEPT {
+ if (__libcpp_is_constant_evaluated()) {
+ ::operator delete(__p);
+ } else {
+ _VSTD::__libcpp_deallocate((void*)__p, __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));
}
- _LIBCPP_INLINE_VISIBILITY
- static pointer __allocate(allocator_type& __a, size_type __n,
- const_void_pointer, false_type)
- {return __a.allocate(__n);}
+ }
- template <class _Tp, class... _Args>
- _LIBCPP_INLINE_VISIBILITY
- static void __construct(true_type, allocator_type& __a, _Tp* __p, _Args&&... __args)
- {
- _LIBCPP_SUPPRESS_DEPRECATED_PUSH
- __a.construct(__p, _VSTD::forward<_Args>(__args)...);
- _LIBCPP_SUPPRESS_DEPRECATED_POP
- }
+ // C++20 Removed members
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp* pointer;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* const_pointer;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp& reference;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& const_reference;
- template <class _Tp, class... _Args>
- _LIBCPP_INLINE_VISIBILITY
- static void __construct(false_type, allocator_type&, _Tp* __p, _Args&&... __args)
- {
- ::new ((void*)__p) _Tp(_VSTD::forward<_Args>(__args)...);
- }
+ template <class _Up>
+ struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {
+ typedef allocator<_Up> other;
+ };
- template <class _Tp>
- _LIBCPP_INLINE_VISIBILITY
- static void __destroy(true_type, allocator_type& __a, _Tp* __p)
- {
- _LIBCPP_SUPPRESS_DEPRECATED_PUSH
- __a.destroy(__p);
- _LIBCPP_SUPPRESS_DEPRECATED_POP
- }
- template <class _Tp>
- _LIBCPP_INLINE_VISIBILITY
- static void __destroy(false_type, allocator_type&, _Tp* __p)
- {
- __p->~_Tp();
- }
+ _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
+ pointer address(reference __x) const _NOEXCEPT {
+ return _VSTD::addressof(__x);
+ }
+ _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
+ const_pointer address(const_reference __x) const _NOEXCEPT {
+ return _VSTD::addressof(__x);
+ }
- _LIBCPP_INLINE_VISIBILITY
- static size_type __max_size(true_type, const allocator_type& __a) _NOEXCEPT
- {
- _LIBCPP_SUPPRESS_DEPRECATED_PUSH
- return __a.max_size();
- _LIBCPP_SUPPRESS_DEPRECATED_POP
- }
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_IN_CXX17
+ _Tp* allocate(size_t __n, const void*) {
+ return allocate(__n);
+ }
- _LIBCPP_INLINE_VISIBILITY
- static size_type __max_size(false_type, const allocator_type&) _NOEXCEPT
- {return numeric_limits<size_type>::max() / sizeof(value_type);}
+ _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT {
+ return size_type(~0) / sizeof(_Tp);
+ }
- _LIBCPP_INLINE_VISIBILITY
- static allocator_type
- __select_on_container_copy_construction(true_type, const allocator_type& __a)
- {return __a.select_on_container_copy_construction();}
- _LIBCPP_INLINE_VISIBILITY
- static allocator_type
- __select_on_container_copy_construction(false_type, const allocator_type& __a)
- {return __a;}
-};
+ template <class _Up, class... _Args>
+ _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
+ void construct(_Up* __p, _Args&&... __args) {
+ ::new ((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
+ }
-template <class _Traits, class _Tp>
-struct __rebind_alloc_helper
-{
-#ifndef _LIBCPP_CXX03_LANG
- typedef _LIBCPP_NODEBUG_TYPE typename _Traits::template rebind_alloc<_Tp> type;
-#else
- typedef typename _Traits::template rebind_alloc<_Tp>::other type;
+ _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
+ void destroy(pointer __p) {
+ __p->~_Tp();
+ }
#endif
};
-// allocator
-
template <class _Tp>
-class _LIBCPP_TEMPLATE_VIS allocator
+class _LIBCPP_TEMPLATE_VIS allocator<const _Tp>
{
public:
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t size_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef ptrdiff_t difference_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp* pointer;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* const_pointer;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp& reference;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& const_reference;
-
- template <class _Up> struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {typedef allocator<_Up> other;};
-#endif
-
- typedef _Tp value_type;
-
- typedef true_type propagate_on_container_move_assignment;
- typedef true_type is_always_equal;
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef const _Tp value_type;
+ typedef true_type propagate_on_container_move_assignment;
+ typedef true_type is_always_equal;
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- allocator() _NOEXCEPT {}
+ allocator() _NOEXCEPT { }
template <class _Up>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- allocator(const allocator<_Up>&) _NOEXCEPT {}
-
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
- _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
- pointer address(reference __x) const _NOEXCEPT
- {return _VSTD::addressof(__x);}
- _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
- const_pointer address(const_reference __x) const _NOEXCEPT
- {return _VSTD::addressof(__x);}
-#endif
+ allocator(const allocator<_Up>&) _NOEXCEPT { }
- _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _Tp* allocate(size_t __n)
- {
- // TODO(mpark): Replace with `allocator_traits<allocator>::max_size(*this)`.
- if (__n > (size_t(~0) / sizeof(_Tp)))
- __throw_length_error("allocator<T>::allocate(size_t n)"
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ const _Tp* allocate(size_t __n) {
+ if (__n > allocator_traits<allocator>::max_size(*this))
+ __throw_length_error("allocator<const T>::allocate(size_t n)"
" 'n' exceeds maximum supported size");
- return static_cast<_Tp*>(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)));
+ if (__libcpp_is_constant_evaluated()) {
+ return static_cast<const _Tp*>(::operator new(__n * sizeof(_Tp)));
+ } else {
+ return static_cast<const _Tp*>(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)));
}
+ }
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
- _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_IN_CXX17
- _Tp* allocate(size_t __n, const void*) { return allocate(__n); }
-#endif
-
- _LIBCPP_INLINE_VISIBILITY void deallocate(_Tp* __p, size_t __n) _NOEXCEPT
- {_VSTD::__libcpp_deallocate((void*)__p, __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));}
-
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
- _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT
- {return size_type(~0) / sizeof(_Tp);}
-
- template <class _Up, class... _Args>
- _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
- void
- construct(_Up* __p, _Args&&... __args)
- {
- ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ void deallocate(const _Tp* __p, size_t __n) {
+ if (__libcpp_is_constant_evaluated()) {
+ ::operator delete(const_cast<_Tp*>(__p));
+ } else {
+ _VSTD::__libcpp_deallocate((void*) const_cast<_Tp *>(__p), __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));
}
- _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();}
-#endif
-};
+ }
-template <class _Tp>
-class _LIBCPP_TEMPLATE_VIS allocator<const _Tp>
-{
-public:
+ // C++20 Removed members
#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t size_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef ptrdiff_t difference_type;
_LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* pointer;
_LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* const_pointer;
_LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& reference;
_LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& const_reference;
- template <class _Up> struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {typedef allocator<_Up> other;};
-#endif
-
- typedef const _Tp value_type;
-
- typedef true_type propagate_on_container_move_assignment;
- typedef true_type is_always_equal;
-
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- allocator() _NOEXCEPT {}
-
template <class _Up>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- allocator(const allocator<_Up>&) _NOEXCEPT {}
+ struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {
+ typedef allocator<_Up> other;
+ };
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
_LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
- const_pointer address(const_reference __x) const _NOEXCEPT
- {return _VSTD::addressof(__x);}
-#endif
-
- _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const _Tp* allocate(size_t __n)
- {
- // TODO(mpark): Replace with `allocator_traits<allocator>::max_size(*this)`.
- if (__n > (size_t(~0) / sizeof(_Tp)))
- __throw_length_error("allocator<const T>::allocate(size_t n)"
- " 'n' exceeds maximum supported size");
- return static_cast<const _Tp*>(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)));
+ const_pointer address(const_reference __x) const _NOEXCEPT {
+ return _VSTD::addressof(__x);
}
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_IN_CXX17
- const _Tp* allocate(size_t __n, const void*) { return allocate(__n); }
-#endif
-
- _LIBCPP_INLINE_VISIBILITY void deallocate(const _Tp* __p, size_t __n)
- {_VSTD::__libcpp_deallocate((void*) const_cast<_Tp *>(__p), __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));}
+ const _Tp* allocate(size_t __n, const void*) {
+ return allocate(__n);
+ }
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
- _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT
- {return size_type(~0) / sizeof(_Tp);}
+ _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT {
+ return size_type(~0) / sizeof(_Tp);
+ }
-#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
template <class _Up, class... _Args>
- _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
- void
- construct(_Up* __p, _Args&&... __args)
- {
- ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
- }
-#else // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
- _LIBCPP_INLINE_VISIBILITY
- void
- construct(pointer __p)
- {
- ::new((void*) const_cast<_Tp *>(__p)) _Tp();
- }
-# if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
+ _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
+ void construct(_Up* __p, _Args&&... __args) {
+ ::new ((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
+ }
- template <class _A0>
- _LIBCPP_INLINE_VISIBILITY
- void
- construct(pointer __p, _A0& __a0)
- {
- ::new((void*) const_cast<_Tp *>(__p)) _Tp(__a0);
- }
- template <class _A0>
- _LIBCPP_INLINE_VISIBILITY
- void
- construct(pointer __p, const _A0& __a0)
- {
- ::new((void*) const_cast<_Tp *>(__p)) _Tp(__a0);
- }
-# endif // defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
- template <class _A0, class _A1>
- _LIBCPP_INLINE_VISIBILITY
- void
- construct(pointer __p, _A0& __a0, _A1& __a1)
- {
- ::new((void*) const_cast<_Tp *>(__p)) _Tp(__a0, __a1);
- }
- template <class _A0, class _A1>
- _LIBCPP_INLINE_VISIBILITY
- void
- construct(pointer __p, const _A0& __a0, _A1& __a1)
- {
- ::new((void*) const_cast<_Tp *>(__p)) _Tp(__a0, __a1);
- }
- template <class _A0, class _A1>
- _LIBCPP_INLINE_VISIBILITY
- void
- construct(pointer __p, _A0& __a0, const _A1& __a1)
- {
- ::new((void*) const_cast<_Tp *>(__p)) _Tp(__a0, __a1);
- }
- template <class _A0, class _A1>
- _LIBCPP_INLINE_VISIBILITY
- void
- construct(pointer __p, const _A0& __a0, const _A1& __a1)
- {
- ::new((void*) const_cast<_Tp *>(__p)) _Tp(__a0, __a1);
- }
-#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
- _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();}
+ _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
+ void destroy(pointer __p) {
+ __p->~_Tp();
+ }
#endif
};
template <class _Tp, class _Up>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool operator==(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return true;}
template <class _Tp, class _Up>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool operator!=(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return false;}
+template <class _Alloc, class _Ptr>
+_LIBCPP_INLINE_VISIBILITY
+void __construct_forward_with_exception_guarantees(_Alloc& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __begin2) {
+ static_assert(__is_cpp17_move_insertable<_Alloc>::value,
+ "The specified type does not meet the requirements of Cpp17MoveInsertable");
+ typedef allocator_traits<_Alloc> _Traits;
+ for (; __begin1 != __end1; ++__begin1, (void)++__begin2) {
+ _Traits::construct(__a, _VSTD::__to_address(__begin2),
+#ifdef _LIBCPP_NO_EXCEPTIONS
+ _VSTD::move(*__begin1)
+#else
+ _VSTD::move_if_noexcept(*__begin1)
+#endif
+ );
+ }
+}
+
+template <class _Alloc, class _Tp, typename enable_if<
+ (__is_default_allocator<_Alloc>::value || !__has_construct<_Alloc, _Tp*, _Tp>::value) &&
+ is_trivially_move_constructible<_Tp>::value
+>::type>
+_LIBCPP_INLINE_VISIBILITY
+void __construct_forward_with_exception_guarantees(_Alloc&, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2) {
+ ptrdiff_t _Np = __end1 - __begin1;
+ if (_Np > 0) {
+ _VSTD::memcpy(__begin2, __begin1, _Np * sizeof(_Tp));
+ __begin2 += _Np;
+ }
+}
+
+template <class _Alloc, class _Iter, class _Ptr>
+_LIBCPP_INLINE_VISIBILITY
+void __construct_range_forward(_Alloc& __a, _Iter __begin1, _Iter __end1, _Ptr& __begin2) {
+ typedef allocator_traits<_Alloc> _Traits;
+ for (; __begin1 != __end1; ++__begin1, (void) ++__begin2) {
+ _Traits::construct(__a, _VSTD::__to_address(__begin2), *__begin1);
+ }
+}
+
+template <class _Alloc, class _Source, class _Dest,
+ class _RawSource = typename remove_const<_Source>::type,
+ class _RawDest = typename remove_const<_Dest>::type,
+ class =
+ typename enable_if<
+ is_trivially_copy_constructible<_Dest>::value &&
+ is_same<_RawSource, _RawDest>::value &&
+ (__is_default_allocator<_Alloc>::value || !__has_construct<_Alloc, _Dest*, _Source&>::value)
+ >::type>
+_LIBCPP_INLINE_VISIBILITY
+void __construct_range_forward(_Alloc&, _Source* __begin1, _Source* __end1, _Dest*& __begin2) {
+ ptrdiff_t _Np = __end1 - __begin1;
+ if (_Np > 0) {
+ _VSTD::memcpy(const_cast<_RawDest*>(__begin2), __begin1, _Np * sizeof(_Dest));
+ __begin2 += _Np;
+ }
+}
+
+template <class _Alloc, class _Ptr>
+_LIBCPP_INLINE_VISIBILITY
+void __construct_backward_with_exception_guarantees(_Alloc& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __end2) {
+ static_assert(__is_cpp17_move_insertable<_Alloc>::value,
+ "The specified type does not meet the requirements of Cpp17MoveInsertable");
+ typedef allocator_traits<_Alloc> _Traits;
+ while (__end1 != __begin1) {
+ _Traits::construct(__a, _VSTD::__to_address(__end2 - 1),
+#ifdef _LIBCPP_NO_EXCEPTIONS
+ _VSTD::move(*--__end1)
+#else
+ _VSTD::move_if_noexcept(*--__end1)
+#endif
+ );
+ --__end2;
+ }
+}
+
+template <class _Alloc, class _Tp, class = typename enable_if<
+ (__is_default_allocator<_Alloc>::value || !__has_construct<_Alloc, _Tp*, _Tp>::value) &&
+ is_trivially_move_constructible<_Tp>::value
+>::type>
+_LIBCPP_INLINE_VISIBILITY
+void __construct_backward_with_exception_guarantees(_Alloc&, _Tp* __begin1, _Tp* __end1, _Tp*& __end2) {
+ ptrdiff_t _Np = __end1 - __begin1;
+ __end2 -= _Np;
+ if (_Np > 0)
+ _VSTD::memcpy(__end2, __begin1, _Np * sizeof(_Tp));
+}
+
template <class _OutputIterator, class _Tp>
class _LIBCPP_TEMPLATE_VIS raw_storage_iterator
: public iterator<output_iterator_tag,
@@ -1953,10 +1079,10 @@ public:
_LIBCPP_INLINE_VISIBILITY explicit raw_storage_iterator(_OutputIterator __x) : __x_(__x) {}
_LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator*() {return *this;}
_LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator=(const _Tp& __element)
- {::new(_VSTD::addressof(*__x_)) _Tp(__element); return *this;}
+ {::new ((void*)_VSTD::addressof(*__x_)) _Tp(__element); return *this;}
#if _LIBCPP_STD_VER >= 14
_LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator=(_Tp&& __element)
- {::new(_VSTD::addressof(*__x_)) _Tp(_VSTD::move(__element)); return *this;}
+ {::new ((void*)_VSTD::addressof(*__x_)) _Tp(_VSTD::move(__element)); return *this;}
#endif
_LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator++() {++__x_; return *this;}
_LIBCPP_INLINE_VISIBILITY raw_storage_iterator operator++(int)
@@ -1982,8 +1108,8 @@ get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT
#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION)
if (__is_overaligned_for_new(_LIBCPP_ALIGNOF(_Tp)))
{
- std::align_val_t __al =
- std::align_val_t(std::alignment_of<_Tp>::value);
+ align_val_t __al =
+ align_val_t(alignment_of<_Tp>::value);
__r.first = static_cast<_Tp*>(::operator new(
__n * sizeof(_Tp), __al, nothrow));
} else {
@@ -2052,7 +1178,7 @@ public:
_LIBCPP_INLINE_VISIBILITY _Tp* release() _NOEXCEPT
{
_Tp* __t = __ptr_;
- __ptr_ = 0;
+ __ptr_ = nullptr;
return __t;
}
_LIBCPP_INLINE_VISIBILITY void reset(_Tp* __p = 0) _NOEXCEPT
@@ -2160,19 +1286,19 @@ struct __compressed_pair_elem<_Tp, _Idx, true> : private _Tp {
template <class _T1, class _T2>
class __compressed_pair : private __compressed_pair_elem<_T1, 0>,
private __compressed_pair_elem<_T2, 1> {
- typedef _LIBCPP_NODEBUG_TYPE __compressed_pair_elem<_T1, 0> _Base1;
- typedef _LIBCPP_NODEBUG_TYPE __compressed_pair_elem<_T2, 1> _Base2;
-
+public:
// NOTE: This static assert should never fire because __compressed_pair
// is *almost never* used in a scenario where it's possible for T1 == T2.
// (The exception is std::function where it is possible that the function
// object and the allocator have the same type).
static_assert((!is_same<_T1, _T2>::value),
- "__compressed_pair cannot be instantated when T1 and T2 are the same type; "
+ "__compressed_pair cannot be instantiated when T1 and T2 are the same type; "
"The current implementation is NOT ABI-compatible with the previous "
"implementation for this configuration");
-public:
+ typedef _LIBCPP_NODEBUG_TYPE __compressed_pair_elem<_T1, 0> _Base1;
+ typedef _LIBCPP_NODEBUG_TYPE __compressed_pair_elem<_T2, 1> _Base2;
+
template <bool _Dummy = true,
class = typename enable_if<
__dependent_type<is_default_constructible<_T1>, _Dummy>::value &&
@@ -2185,7 +1311,7 @@ public:
template <class _U1, class _U2>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
__compressed_pair(_U1&& __t1, _U2&& __t2)
- : _Base1(std::forward<_U1>(__t1)), _Base2(std::forward<_U2>(__t2)) {}
+ : _Base1(_VSTD::forward<_U1>(__t1)), _Base2(_VSTD::forward<_U2>(__t2)) {}
#ifndef _LIBCPP_CXX03_LANG
template <class... _Args1, class... _Args2>
@@ -2218,12 +1344,21 @@ public:
return static_cast<_Base2 const&>(*this).__get();
}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ static _Base1* __get_first_base(__compressed_pair* __pair) _NOEXCEPT {
+ return static_cast<_Base1*>(__pair);
+ }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ static _Base2* __get_second_base(__compressed_pair* __pair) _NOEXCEPT {
+ return static_cast<_Base2*>(__pair);
+ }
+
_LIBCPP_INLINE_VISIBILITY
void swap(__compressed_pair& __x)
_NOEXCEPT_(__is_nothrow_swappable<_T1>::value &&
__is_nothrow_swappable<_T2>::value)
{
- using std::swap;
+ using _VSTD::swap;
swap(first(), __x.first());
swap(second(), __x.second());
}
@@ -2316,12 +1451,18 @@ struct __unique_ptr_deleter_sfinae<_Deleter&> {
typedef false_type __enable_rval_overload;
};
+#if defined(_LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI)
+# define _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI __attribute__((trivial_abi))
+#else
+# define _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI
+#endif
+
template <class _Tp, class _Dp = default_delete<_Tp> >
-class _LIBCPP_TEMPLATE_VIS unique_ptr {
+class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr {
public:
typedef _Tp element_type;
typedef _Dp deleter_type;
- typedef _LIBCPP_NODEBUG_TYPE typename __pointer_type<_Tp, deleter_type>::type pointer;
+ typedef _LIBCPP_NODEBUG_TYPE typename __pointer<_Tp, deleter_type>::type pointer;
static_assert(!is_rvalue_reference<deleter_type>::value,
"the specified deleter type cannot be an rvalue reference");
@@ -2525,11 +1666,11 @@ public:
template <class _Tp, class _Dp>
-class _LIBCPP_TEMPLATE_VIS unique_ptr<_Tp[], _Dp> {
+class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr<_Tp[], _Dp> {
public:
typedef _Tp element_type;
typedef _Dp deleter_type;
- typedef typename __pointer_type<_Tp, deleter_type>::type pointer;
+ typedef typename __pointer<_Tp, deleter_type>::type pointer;
private:
__compressed_pair<pointer, deleter_type> __ptr_;
@@ -2987,7 +2128,7 @@ public:
: __size_(__s) {}
template <class _Tp>
- _LIBCPP_INLINE_VISIBILITY void __incr(_Tp*) _NOEXCEPT
+ _LIBCPP_INLINE_VISIBILITY void __incr() _NOEXCEPT
{__incr(integral_constant<bool, is_trivially_destructible<_Tp>::value>());}
template <class _Tp>
@@ -3029,7 +2170,7 @@ uninitialized_copy(_InputIterator __f, _InputIterator __l, _ForwardIterator __r)
{
#endif
for (; __f != __l; ++__f, (void) ++__r)
- ::new (static_cast<void*>(_VSTD::addressof(*__r))) value_type(*__f);
+ ::new ((void*)_VSTD::addressof(*__r)) value_type(*__f);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
@@ -3053,7 +2194,7 @@ uninitialized_copy_n(_InputIterator __f, _Size __n, _ForwardIterator __r)
{
#endif
for (; __n > 0; ++__f, (void) ++__r, (void) --__n)
- ::new (static_cast<void*>(_VSTD::addressof(*__r))) value_type(*__f);
+ ::new ((void*)_VSTD::addressof(*__r)) value_type(*__f);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
@@ -3077,7 +2218,7 @@ uninitialized_fill(_ForwardIterator __f, _ForwardIterator __l, const _Tp& __x)
{
#endif
for (; __f != __l; ++__f)
- ::new (static_cast<void*>(_VSTD::addressof(*__f))) value_type(__x);
+ ::new ((void*)_VSTD::addressof(*__f)) value_type(__x);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
@@ -3100,7 +2241,7 @@ uninitialized_fill_n(_ForwardIterator __f, _Size __n, const _Tp& __x)
{
#endif
for (; __n > 0; ++__f, (void) --__n)
- ::new (static_cast<void*>(_VSTD::addressof(*__f))) value_type(__x);
+ ::new ((void*)_VSTD::addressof(*__f)) value_type(__x);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
@@ -3115,22 +2256,15 @@ uninitialized_fill_n(_ForwardIterator __f, _Size __n, const _Tp& __x)
#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-void destroy_at(_Tp* __loc) {
- _LIBCPP_ASSERT(__loc, "null pointer given to destroy_at");
- __loc->~_Tp();
-}
-
template <class _ForwardIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void destroy(_ForwardIterator __first, _ForwardIterator __last) {
for (; __first != __last; ++__first)
_VSTD::destroy_at(_VSTD::addressof(*__first));
}
template <class _ForwardIterator, class _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_ForwardIterator destroy_n(_ForwardIterator __first, _Size __n) {
for (; __n > 0; (void)++__first, --__n)
_VSTD::destroy_at(_VSTD::addressof(*__first));
@@ -3146,7 +2280,7 @@ void uninitialized_default_construct(_ForwardIterator __first, _ForwardIterator
try {
#endif
for (; __idx != __last; ++__idx)
- ::new((void*)_VSTD::addressof(*__idx)) _Vt;
+ ::new ((void*)_VSTD::addressof(*__idx)) _Vt;
#ifndef _LIBCPP_NO_EXCEPTIONS
} catch (...) {
_VSTD::destroy(__first, __idx);
@@ -3164,7 +2298,7 @@ _ForwardIterator uninitialized_default_construct_n(_ForwardIterator __first, _Si
try {
#endif
for (; __n > 0; (void)++__idx, --__n)
- ::new((void*)_VSTD::addressof(*__idx)) _Vt;
+ ::new ((void*)_VSTD::addressof(*__idx)) _Vt;
return __idx;
#ifndef _LIBCPP_NO_EXCEPTIONS
} catch (...) {
@@ -3184,7 +2318,7 @@ void uninitialized_value_construct(_ForwardIterator __first, _ForwardIterator __
try {
#endif
for (; __idx != __last; ++__idx)
- ::new((void*)_VSTD::addressof(*__idx)) _Vt();
+ ::new ((void*)_VSTD::addressof(*__idx)) _Vt();
#ifndef _LIBCPP_NO_EXCEPTIONS
} catch (...) {
_VSTD::destroy(__first, __idx);
@@ -3202,7 +2336,7 @@ _ForwardIterator uninitialized_value_construct_n(_ForwardIterator __first, _Size
try {
#endif
for (; __n > 0; (void)++__idx, --__n)
- ::new((void*)_VSTD::addressof(*__idx)) _Vt();
+ ::new ((void*)_VSTD::addressof(*__idx)) _Vt();
return __idx;
#ifndef _LIBCPP_NO_EXCEPTIONS
} catch (...) {
@@ -3222,7 +2356,7 @@ _ForwardIt uninitialized_move(_InputIt __first, _InputIt __last, _ForwardIt __fi
try {
#endif
for (; __first != __last; (void)++__idx, ++__first)
- ::new((void*)_VSTD::addressof(*__idx)) _Vt(std::move(*__first));
+ ::new ((void*)_VSTD::addressof(*__idx)) _Vt(_VSTD::move(*__first));
return __idx;
#ifndef _LIBCPP_NO_EXCEPTIONS
} catch (...) {
@@ -3242,7 +2376,7 @@ uninitialized_move_n(_InputIt __first, _Size __n, _ForwardIt __first_res) {
try {
#endif
for (; __n > 0; ++__idx, (void)++__first, --__n)
- ::new((void*)_VSTD::addressof(*__idx)) _Vt(std::move(*__first));
+ ::new ((void*)_VSTD::addressof(*__idx)) _Vt(_VSTD::move(*__first));
return {__first, __idx};
#ifndef _LIBCPP_NO_EXCEPTIONS
} catch (...) {
@@ -3389,13 +2523,7 @@ public:
long use_count() const _NOEXCEPT {return __shared_count::use_count();}
__shared_weak_count* lock() _NOEXCEPT;
- // Define the function out only if we build static libc++ without RTTI.
- // Otherwise we may break clients who need to compile their projects with
- // -fno-rtti and yet link against a libc++.dylib compiled
- // without -fno-rtti.
-#if !defined(_LIBCPP_NO_RTTI) || !defined(_LIBCPP_BUILD_STATIC)
virtual const void* __get_deleter(const type_info&) const _NOEXCEPT;
-#endif
private:
virtual void __on_zero_shared_weak() _NOEXCEPT = 0;
};
@@ -3452,69 +2580,86 @@ __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT
}
template <class _Tp, class _Alloc>
-class __shared_ptr_emplace
- : public __shared_weak_count
+struct __shared_ptr_emplace
+ : __shared_weak_count
{
- __compressed_pair<_Alloc, _Tp> __data_;
-public:
-
- _LIBCPP_INLINE_VISIBILITY
- __shared_ptr_emplace(_Alloc __a)
- : __data_(_VSTD::move(__a), __value_init_tag()) {}
+ template<class ..._Args>
+ _LIBCPP_HIDE_FROM_ABI
+ explicit __shared_ptr_emplace(_Alloc __a, _Args&& ...__args)
+ : __storage_(_VSTD::move(__a))
+ {
+#if _LIBCPP_STD_VER > 17
+ using _TpAlloc = typename __allocator_traits_rebind<_Alloc, _Tp>::type;
+ _TpAlloc __tmp(*__get_alloc());
+ allocator_traits<_TpAlloc>::construct(__tmp, __get_elem(), _VSTD::forward<_Args>(__args)...);
+#else
+ ::new ((void*)__get_elem()) _Tp(_VSTD::forward<_Args>(__args)...);
+#endif
+ }
+ _LIBCPP_HIDE_FROM_ABI
+ _Alloc* __get_alloc() _NOEXCEPT { return __storage_.__get_alloc(); }
-#ifndef _LIBCPP_HAS_NO_VARIADICS
- template <class ..._Args>
- _LIBCPP_INLINE_VISIBILITY
- __shared_ptr_emplace(_Alloc __a, _Args&& ...__args)
- : __data_(piecewise_construct, _VSTD::forward_as_tuple(__a),
- _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)) {}
-#else // _LIBCPP_HAS_NO_VARIADICS
+ _LIBCPP_HIDE_FROM_ABI
+ _Tp* __get_elem() _NOEXCEPT { return __storage_.__get_elem(); }
- template <class _A0>
- _LIBCPP_INLINE_VISIBILITY
- __shared_ptr_emplace(_Alloc __a, _A0& __a0)
- : __data_(__a, _Tp(__a0)) {}
+private:
+ virtual void __on_zero_shared() _NOEXCEPT {
+#if _LIBCPP_STD_VER > 17
+ using _TpAlloc = typename __allocator_traits_rebind<_Alloc, _Tp>::type;
+ _TpAlloc __tmp(*__get_alloc());
+ allocator_traits<_TpAlloc>::destroy(__tmp, __get_elem());
+#else
+ __get_elem()->~_Tp();
+#endif
+ }
- template <class _A0, class _A1>
- _LIBCPP_INLINE_VISIBILITY
- __shared_ptr_emplace(_Alloc __a, _A0& __a0, _A1& __a1)
- : __data_(__a, _Tp(__a0, __a1)) {}
+ virtual void __on_zero_shared_weak() _NOEXCEPT {
+ using _ControlBlockAlloc = typename __allocator_traits_rebind<_Alloc, __shared_ptr_emplace>::type;
+ using _ControlBlockPointer = typename allocator_traits<_ControlBlockAlloc>::pointer;
+ _ControlBlockAlloc __tmp(*__get_alloc());
+ __storage_.~_Storage();
+ allocator_traits<_ControlBlockAlloc>::deallocate(__tmp,
+ pointer_traits<_ControlBlockPointer>::pointer_to(*this), 1);
+ }
- template <class _A0, class _A1, class _A2>
- _LIBCPP_INLINE_VISIBILITY
- __shared_ptr_emplace(_Alloc __a, _A0& __a0, _A1& __a1, _A2& __a2)
- : __data_(__a, _Tp(__a0, __a1, __a2)) {}
+ // This class implements the control block for non-array shared pointers created
+ // through `std::allocate_shared` and `std::make_shared`.
+ //
+ // In previous versions of the library, we used a compressed pair to store
+ // both the _Alloc and the _Tp. This implies using EBO, which is incompatible
+ // with Allocator construction for _Tp. To allow implementing P0674 in C++20,
+ // we now use a properly aligned char buffer while making sure that we maintain
+ // the same layout that we had when we used a compressed pair.
+ using _CompressedPair = __compressed_pair<_Alloc, _Tp>;
+ struct _ALIGNAS_TYPE(_CompressedPair) _Storage {
+ char __blob_[sizeof(_CompressedPair)];
-#endif // _LIBCPP_HAS_NO_VARIADICS
+ _LIBCPP_HIDE_FROM_ABI explicit _Storage(_Alloc&& __a) {
+ ::new ((void*)__get_alloc()) _Alloc(_VSTD::move(__a));
+ }
+ _LIBCPP_HIDE_FROM_ABI ~_Storage() {
+ __get_alloc()->~_Alloc();
+ }
+ _Alloc* __get_alloc() _NOEXCEPT {
+ _CompressedPair *__as_pair = reinterpret_cast<_CompressedPair*>(__blob_);
+ typename _CompressedPair::_Base1* __first = _CompressedPair::__get_first_base(__as_pair);
+ _Alloc *__alloc = reinterpret_cast<_Alloc*>(__first);
+ return __alloc;
+ }
+ _Tp* __get_elem() _NOEXCEPT {
+ _CompressedPair *__as_pair = reinterpret_cast<_CompressedPair*>(__blob_);
+ typename _CompressedPair::_Base2* __second = _CompressedPair::__get_second_base(__as_pair);
+ _Tp *__elem = reinterpret_cast<_Tp*>(__second);
+ return __elem;
+ }
+ };
-private:
- virtual void __on_zero_shared() _NOEXCEPT;
- virtual void __on_zero_shared_weak() _NOEXCEPT;
-public:
- _LIBCPP_INLINE_VISIBILITY
- _Tp* get() _NOEXCEPT {return _VSTD::addressof(__data_.second());}
+ static_assert(_LIBCPP_ALIGNOF(_Storage) == _LIBCPP_ALIGNOF(_CompressedPair), "");
+ static_assert(sizeof(_Storage) == sizeof(_CompressedPair), "");
+ _Storage __storage_;
};
-template <class _Tp, class _Alloc>
-void
-__shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared() _NOEXCEPT
-{
- __data_.second().~_Tp();
-}
-
-template <class _Tp, class _Alloc>
-void
-__shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT
-{
- typedef typename __allocator_traits_rebind<_Alloc, __shared_ptr_emplace>::type _Al;
- typedef allocator_traits<_Al> _ATraits;
- typedef pointer_traits<typename _ATraits::pointer> _PTraits;
- _Al __a(__data_.first());
- __data_.first().~_Alloc();
- __a.deallocate(_PTraits::pointer_to(*this), 1);
-}
-
struct __shared_ptr_dummy_rebind_allocator_type;
template <>
class _LIBCPP_TEMPLATE_VIS allocator<__shared_ptr_dummy_rebind_allocator_type>
@@ -3537,8 +2682,14 @@ struct __compatible_with
: is_convertible<_Tp*, _Up*> {};
#endif // _LIBCPP_STD_VER > 14
+#if defined(_LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI)
+# define _LIBCPP_SHARED_PTR_TRIVIAL_ABI __attribute__((trivial_abi))
+#else
+# define _LIBCPP_SHARED_PTR_TRIVIAL_ABI
+#endif
+
template<class _Tp>
-class _LIBCPP_TEMPLATE_VIS shared_ptr
+class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS shared_ptr
{
public:
#if _LIBCPP_STD_VER > 14
@@ -3577,25 +2728,17 @@ public:
shared_ptr(const shared_ptr<_Yp>& __r,
typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type = __nat())
_NOEXCEPT;
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
shared_ptr(shared_ptr&& __r) _NOEXCEPT;
template<class _Yp> _LIBCPP_INLINE_VISIBILITY shared_ptr(shared_ptr<_Yp>&& __r,
typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type = __nat())
_NOEXCEPT;
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
template<class _Yp> explicit shared_ptr(const weak_ptr<_Yp>& __r,
typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type= __nat());
#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template<class _Yp>
shared_ptr(auto_ptr<_Yp>&& __r,
typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat());
-#else
- template<class _Yp>
- shared_ptr(auto_ptr<_Yp> __r,
- typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat());
-#endif
#endif
template <class _Yp, class _Dp>
shared_ptr(unique_ptr<_Yp, _Dp>&&,
@@ -3628,7 +2771,6 @@ public:
>::type
_LIBCPP_INLINE_VISIBILITY
operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT;
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
shared_ptr& operator=(shared_ptr&& __r) _NOEXCEPT;
template<class _Yp>
@@ -3650,19 +2792,6 @@ public:
>::type&
operator=(auto_ptr<_Yp>&& __r);
#endif
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
- template<class _Yp>
- _LIBCPP_INLINE_VISIBILITY
- typename enable_if
- <
- !is_array<_Yp>::value &&
- is_convertible<_Yp*, element_type*>::value,
- shared_ptr&
- >::type
- operator=(auto_ptr<_Yp> __r);
-#endif
-#endif
template <class _Yp, class _Dp>
typename enable_if
<
@@ -3670,13 +2799,8 @@ public:
is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
shared_ptr&
>::type
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
operator=(unique_ptr<_Yp, _Dp>&& __r);
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
- _LIBCPP_INLINE_VISIBILITY
- operator=(unique_ptr<_Yp, _Dp> __r);
-#endif
_LIBCPP_INLINE_VISIBILITY
void swap(shared_ptr& __r) _NOEXCEPT;
@@ -3724,7 +2848,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
bool unique() const _NOEXCEPT {return use_count() == 1;}
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return get() != 0;}
+ _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return get() != nullptr;}
template <class _Up>
_LIBCPP_INLINE_VISIBILITY
bool owner_before(shared_ptr<_Up> const& __p) const _NOEXCEPT
@@ -3828,8 +2952,8 @@ template<class _Tp>
inline
_LIBCPP_CONSTEXPR
shared_ptr<_Tp>::shared_ptr() _NOEXCEPT
- : __ptr_(0),
- __cntrl_(0)
+ : __ptr_(nullptr),
+ __cntrl_(nullptr)
{
}
@@ -3837,8 +2961,8 @@ template<class _Tp>
inline
_LIBCPP_CONSTEXPR
shared_ptr<_Tp>::shared_ptr(nullptr_t) _NOEXCEPT
- : __ptr_(0),
- __cntrl_(0)
+ : __ptr_(nullptr),
+ __cntrl_(nullptr)
{
}
@@ -3883,7 +3007,7 @@ shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d,
template<class _Tp>
template<class _Dp>
shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d)
- : __ptr_(0)
+ : __ptr_(nullptr)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
try
@@ -3917,8 +3041,7 @@ shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a,
typedef __allocator_destructor<_A2> _D2;
_A2 __a2(__a);
unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
- ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
- _CntrlBlk(__p, __d, __a);
+ ::new ((void*)_VSTD::addressof(*__hold2.get())) _CntrlBlk(__p, __d, __a);
__cntrl_ = _VSTD::addressof(*__hold2.release());
__enable_weak_this(__p, __p);
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -3934,7 +3057,7 @@ shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a,
template<class _Tp>
template<class _Dp, class _Alloc>
shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a)
- : __ptr_(0)
+ : __ptr_(nullptr)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
try
@@ -3945,8 +3068,7 @@ shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a)
typedef __allocator_destructor<_A2> _D2;
_A2 __a2(__a);
unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
- ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
- _CntrlBlk(__p, __d, __a);
+ ::new ((void*)_VSTD::addressof(*__hold2.get())) _CntrlBlk(__p, __d, __a);
__cntrl_ = _VSTD::addressof(*__hold2.release());
#ifndef _LIBCPP_NO_EXCEPTIONS
}
@@ -3992,16 +3114,14 @@ shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r,
__cntrl_->__add_shared();
}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
template<class _Tp>
inline
shared_ptr<_Tp>::shared_ptr(shared_ptr&& __r) _NOEXCEPT
: __ptr_(__r.__ptr_),
__cntrl_(__r.__cntrl_)
{
- __r.__ptr_ = 0;
- __r.__cntrl_ = 0;
+ __r.__ptr_ = nullptr;
+ __r.__cntrl_ = nullptr;
}
template<class _Tp>
@@ -4013,20 +3133,14 @@ shared_ptr<_Tp>::shared_ptr(shared_ptr<_Yp>&& __r,
: __ptr_(__r.__ptr_),
__cntrl_(__r.__cntrl_)
{
- __r.__ptr_ = 0;
- __r.__cntrl_ = 0;
+ __r.__ptr_ = nullptr;
+ __r.__cntrl_ = nullptr;
}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
template<class _Tp>
template<class _Yp>
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp>&& __r,
-#else
-shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp> __r,
-#endif
typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type)
: __ptr_(__r.get())
{
@@ -4121,8 +3235,6 @@ shared_ptr<_Tp>::operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT
return *this;
}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
template<class _Tp>
inline
shared_ptr<_Tp>&
@@ -4179,43 +3291,6 @@ shared_ptr<_Tp>::operator=(unique_ptr<_Yp, _Dp>&& __r)
return *this;
}
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
-#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
-template<class _Tp>
-template<class _Yp>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
- !is_array<_Yp>::value &&
- is_convertible<_Yp*, typename shared_ptr<_Tp>::element_type*>::value,
- shared_ptr<_Tp>&
->::type
-shared_ptr<_Tp>::operator=(auto_ptr<_Yp> __r)
-{
- shared_ptr(__r).swap(*this);
- return *this;
-}
-#endif
-
-template<class _Tp>
-template <class _Yp, class _Dp>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
- !is_array<_Yp>::value &&
- is_convertible<typename unique_ptr<_Yp, _Dp>::pointer,
- typename shared_ptr<_Tp>::element_type*>::value,
- shared_ptr<_Tp>&
->::type
-shared_ptr<_Tp>::operator=(unique_ptr<_Yp, _Dp> __r)
-{
- shared_ptr(_VSTD::move(__r)).swap(*this);
- return *this;
-}
-
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
template<class _Tp>
inline
void
@@ -4272,50 +3347,26 @@ shared_ptr<_Tp>::reset(_Yp* __p, _Dp __d, _Alloc __a)
shared_ptr(__p, __d, __a).swap(*this);
}
-template<class _Tp, class ..._Args>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
- !is_array<_Tp>::value,
- shared_ptr<_Tp>
->::type
-make_shared(_Args&& ...__args)
+//
+// std::allocate_shared and std::make_shared
+//
+template<class _Tp, class _Alloc, class ..._Args, class = _EnableIf<!is_array<_Tp>::value> >
+_LIBCPP_HIDE_FROM_ABI
+shared_ptr<_Tp> allocate_shared(const _Alloc& __a, _Args&& ...__args)
{
- static_assert(is_constructible<_Tp, _Args...>::value, "Can't construct object in make_shared");
- typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk;
- typedef allocator<_CntrlBlk> _A2;
- typedef __allocator_destructor<_A2> _D2;
-
- _A2 __a2;
- unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
- ::new(__hold2.get()) _CntrlBlk(__a2, _VSTD::forward<_Args>(__args)...);
-
- _Tp *__ptr = __hold2.get()->get();
- return shared_ptr<_Tp>::__create_with_control_block(__ptr, __hold2.release());
+ using _ControlBlock = __shared_ptr_emplace<_Tp, _Alloc>;
+ using _ControlBlockAllocator = typename __allocator_traits_rebind<_Alloc, _ControlBlock>::type;
+ __allocation_guard<_ControlBlockAllocator> __guard(__a, 1);
+ ::new ((void*)_VSTD::addressof(*__guard.__get())) _ControlBlock(__a, _VSTD::forward<_Args>(__args)...);
+ auto __control_block = __guard.__release_ptr();
+ return shared_ptr<_Tp>::__create_with_control_block((*__control_block).__get_elem(), _VSTD::addressof(*__control_block));
}
-template<class _Tp, class _Alloc, class ..._Args>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
- !is_array<_Tp>::value,
- shared_ptr<_Tp>
->::type
-allocate_shared(const _Alloc& __a, _Args&& ...__args)
+template<class _Tp, class ..._Args, class = _EnableIf<!is_array<_Tp>::value> >
+_LIBCPP_HIDE_FROM_ABI
+shared_ptr<_Tp> make_shared(_Args&& ...__args)
{
- static_assert( is_constructible<_Tp, _Args...>::value, "Can't construct object in allocate_shared");
-
- typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
- typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2;
- typedef __allocator_destructor<_A2> _D2;
-
- _A2 __a2(__a);
- unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
- ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
- _CntrlBlk(__a, _VSTD::forward<_Args>(__args)...);
-
- typename shared_ptr<_Tp>::element_type *__p = __hold2.get()->get();
- return shared_ptr<_Tp>::__create_with_control_block(__p, _VSTD::addressof(*__hold2.release()));
+ return _VSTD::allocate_shared<_Tp>(allocator<_Tp>(), _VSTD::forward<_Args>(__args)...);
}
template<class _Tp, class _Up>
@@ -4526,7 +3577,7 @@ get_deleter(const shared_ptr<_Tp>& __p) _NOEXCEPT
#endif // _LIBCPP_NO_RTTI
template<class _Tp>
-class _LIBCPP_TEMPLATE_VIS weak_ptr
+class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS weak_ptr
{
public:
typedef _Tp element_type;
@@ -4546,13 +3597,11 @@ public:
typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0)
_NOEXCEPT;
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
weak_ptr(weak_ptr&& __r) _NOEXCEPT;
template<class _Yp> _LIBCPP_INLINE_VISIBILITY weak_ptr(weak_ptr<_Yp>&& __r,
typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0)
_NOEXCEPT;
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
~weak_ptr();
_LIBCPP_INLINE_VISIBILITY
@@ -4566,8 +3615,6 @@ public:
_LIBCPP_INLINE_VISIBILITY
operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT;
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
_LIBCPP_INLINE_VISIBILITY
weak_ptr& operator=(weak_ptr&& __r) _NOEXCEPT;
template<class _Yp>
@@ -4579,8 +3626,6 @@ public:
_LIBCPP_INLINE_VISIBILITY
operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT;
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
template<class _Yp>
typename enable_if
<
@@ -4600,7 +3645,7 @@ public:
{return __cntrl_ ? __cntrl_->use_count() : 0;}
_LIBCPP_INLINE_VISIBILITY
bool expired() const _NOEXCEPT
- {return __cntrl_ == 0 || __cntrl_->use_count() == 0;}
+ {return __cntrl_ == nullptr || __cntrl_->use_count() == 0;}
shared_ptr<_Tp> lock() const _NOEXCEPT;
template<class _Up>
_LIBCPP_INLINE_VISIBILITY
@@ -4624,8 +3669,8 @@ template<class _Tp>
inline
_LIBCPP_CONSTEXPR
weak_ptr<_Tp>::weak_ptr() _NOEXCEPT
- : __ptr_(0),
- __cntrl_(0)
+ : __ptr_(nullptr),
+ __cntrl_(nullptr)
{
}
@@ -4665,16 +3710,14 @@ weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp> const& __r,
__cntrl_->__add_weak();
}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
template<class _Tp>
inline
weak_ptr<_Tp>::weak_ptr(weak_ptr&& __r) _NOEXCEPT
: __ptr_(__r.__ptr_),
__cntrl_(__r.__cntrl_)
{
- __r.__ptr_ = 0;
- __r.__cntrl_ = 0;
+ __r.__ptr_ = nullptr;
+ __r.__cntrl_ = nullptr;
}
template<class _Tp>
@@ -4686,12 +3729,10 @@ weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp>&& __r,
: __ptr_(__r.__ptr_),
__cntrl_(__r.__cntrl_)
{
- __r.__ptr_ = 0;
- __r.__cntrl_ = 0;
+ __r.__ptr_ = nullptr;
+ __r.__cntrl_ = nullptr;
}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
template<class _Tp>
weak_ptr<_Tp>::~weak_ptr()
{
@@ -4722,8 +3763,6 @@ weak_ptr<_Tp>::operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT
return *this;
}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
template<class _Tp>
inline
weak_ptr<_Tp>&
@@ -4747,8 +3786,6 @@ weak_ptr<_Tp>::operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT
return *this;
}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
template<class _Tp>
template<class _Yp>
inline
@@ -4795,7 +3832,7 @@ shared_ptr<_Tp>::shared_ptr(const weak_ptr<_Yp>& __r,
: __ptr_(__r.__ptr_),
__cntrl_(__r.__cntrl_ ? __r.__cntrl_->lock() : __r.__cntrl_)
{
- if (__cntrl_ == 0)
+ if (__cntrl_ == nullptr)
__throw_bad_weak_ptr();
}
@@ -5130,35 +4167,35 @@ _LIBCPP_FUNC_VIS void* align(size_t __align, size_t __sz, void*& __ptr, size_t&
// --- Helper for container swap --
template <typename _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
-void __swap_allocator(_Alloc & __a1, _Alloc & __a2)
+_LIBCPP_INLINE_VISIBILITY
+void __swap_allocator(_Alloc & __a1, _Alloc & __a2, true_type)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT
#else
_NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value)
#endif
{
- __swap_allocator(__a1, __a2,
- integral_constant<bool, _VSTD::allocator_traits<_Alloc>::propagate_on_container_swap::value>());
+ using _VSTD::swap;
+ swap(__a1, __a2);
}
template <typename _Alloc>
-_LIBCPP_INLINE_VISIBILITY
-void __swap_allocator(_Alloc & __a1, _Alloc & __a2, true_type)
+inline _LIBCPP_INLINE_VISIBILITY
+void __swap_allocator(_Alloc &, _Alloc &, false_type) _NOEXCEPT {}
+
+template <typename _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+void __swap_allocator(_Alloc & __a1, _Alloc & __a2)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT
#else
_NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value)
#endif
{
- using _VSTD::swap;
- swap(__a1, __a2);
+ _VSTD::__swap_allocator(__a1, __a2,
+ integral_constant<bool, _VSTD::allocator_traits<_Alloc>::propagate_on_container_swap::value>());
}
-template <typename _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
-void __swap_allocator(_Alloc &, _Alloc &, false_type) _NOEXCEPT {}
-
template <typename _Alloc, typename _Traits=allocator_traits<_Alloc> >
struct __noexcept_move_assign_container : public integral_constant<bool,
_Traits::propagate_on_container_move_assignment::value
@@ -5170,7 +4207,6 @@ struct __noexcept_move_assign_container : public integral_constant<bool,
> {};
-#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class _Tp, class _Alloc>
struct __temp_value {
typedef allocator_traits<_Alloc> _Traits;
@@ -5190,7 +4226,6 @@ struct __temp_value {
~__temp_value() { _Traits::destroy(__a, __addr()); }
};
-#endif
template<typename _Alloc, typename = void, typename = void>
struct __is_allocator : false_type {};
@@ -5214,7 +4249,7 @@ struct __builtin_new_allocator {
: __size_(__size), __align_(__align) {}
void operator()(void* p) const _NOEXCEPT {
- std::__libcpp_deallocate(p, __size_, __align_);
+ _VSTD::__libcpp_deallocate(p, __size_, __align_);
}
private:
@@ -5225,13 +4260,13 @@ struct __builtin_new_allocator {
typedef unique_ptr<void, __builtin_new_deleter> __holder_t;
static __holder_t __allocate_bytes(size_t __s, size_t __align) {
- return __holder_t(std::__libcpp_allocate(__s, __align),
+ return __holder_t(_VSTD::__libcpp_allocate(__s, __align),
__builtin_new_deleter(__s, __align));
}
static void __deallocate_bytes(void* __p, size_t __s,
size_t __align) _NOEXCEPT {
- std::__libcpp_deallocate(__p, __s, __align);
+ _VSTD::__libcpp_deallocate(__p, __s, __align);
}
template <class _Tp>
diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap
index b8d2a6669aac..750cd3858887 100644
--- a/libcxx/include/module.modulemap
+++ b/libcxx/include/module.modulemap
@@ -522,6 +522,7 @@ module std [system] {
}
// FIXME: These should be private.
+ module __bits { header "__bits" export * }
module __bit_reference { header "__bit_reference" export * }
module __debug { header "__debug" export * }
module __errc { header "__errc" export * }
diff --git a/libcxx/include/mutex b/libcxx/include/mutex
index 62780bd07344..f098ccba4892 100644
--- a/libcxx/include/mutex
+++ b/libcxx/include/mutex
@@ -626,7 +626,7 @@ private:
_LIBCPP_INLINE_VISIBILITY
void __execute(__tuple_indices<_Indices...>)
{
- __invoke(_VSTD::get<0>(_VSTD::move(__f_)), _VSTD::get<_Indices>(_VSTD::move(__f_))...);
+ _VSTD::__invoke(_VSTD::get<0>(_VSTD::move(__f_)), _VSTD::get<_Indices>(_VSTD::move(__f_))...);
}
};
diff --git a/libcxx/include/new b/libcxx/include/new
index 40d351e9b770..0562cef45868 100644
--- a/libcxx/include/new
+++ b/libcxx/include/new
@@ -49,11 +49,11 @@ new_handler get_new_handler() noexcept;
template <class T> constexpr T* launder(T* p) noexcept; // C++17
} // std
-void* operator new(std::size_t size); // replaceable, nodiscard in C++2a
-void* operator new(std::size_t size, std::align_val_t alignment); // replaceable, C++17, nodiscard in C++2a
-void* operator new(std::size_t size, const std::nothrow_t&) noexcept; // replaceable, nodiscard in C++2a
+void* operator new(std::size_t size); // replaceable, nodiscard in C++20
+void* operator new(std::size_t size, std::align_val_t alignment); // replaceable, C++17, nodiscard in C++20
+void* operator new(std::size_t size, const std::nothrow_t&) noexcept; // replaceable, nodiscard in C++20
void* operator new(std::size_t size, std::align_val_t alignment,
- const std::nothrow_t&) noexcept; // replaceable, C++17, nodiscard in C++2a
+ const std::nothrow_t&) noexcept; // replaceable, C++17, nodiscard in C++20
void operator delete(void* ptr) noexcept; // replaceable
void operator delete(void* ptr, std::size_t size) noexcept; // replaceable, C++14
void operator delete(void* ptr, std::align_val_t alignment) noexcept; // replaceable, C++17
@@ -63,12 +63,12 @@ void operator delete(void* ptr, const std::nothrow_t&) noexcept; // repla
void operator delete(void* ptr, std:align_val_t alignment,
const std::nothrow_t&) noexcept; // replaceable, C++17
-void* operator new[](std::size_t size); // replaceable, nodiscard in C++2a
+void* operator new[](std::size_t size); // replaceable, nodiscard in C++20
void* operator new[](std::size_t size,
- std::align_val_t alignment) noexcept; // replaceable, C++17, nodiscard in C++2a
-void* operator new[](std::size_t size, const std::nothrow_t&) noexcept; // replaceable, nodiscard in C++2a
+ std::align_val_t alignment) noexcept; // replaceable, C++17, nodiscard in C++20
+void* operator new[](std::size_t size, const std::nothrow_t&) noexcept; // replaceable, nodiscard in C++20
void* operator new[](std::size_t size, std::align_val_t alignment,
- const std::nothrow_t&) noexcept; // replaceable, C++17, nodiscard in C++2a
+ const std::nothrow_t&) noexcept; // replaceable, C++17, nodiscard in C++20
void operator delete[](void* ptr) noexcept; // replaceable
void operator delete[](void* ptr, std::size_t size) noexcept; // replaceable, C++14
void operator delete[](void* ptr,
@@ -79,21 +79,20 @@ void operator delete[](void* ptr, const std::nothrow_t&) noexcept; // repla
void operator delete[](void* ptr, std::align_val_t alignment,
const std::nothrow_t&) noexcept; // replaceable, C++17
-void* operator new (std::size_t size, void* ptr) noexcept; // nodiscard in C++2a
-void* operator new[](std::size_t size, void* ptr) noexcept; // nodiscard in C++2a
+void* operator new (std::size_t size, void* ptr) noexcept; // nodiscard in C++20
+void* operator new[](std::size_t size, void* ptr) noexcept; // nodiscard in C++20
void operator delete (void* ptr, void*) noexcept;
void operator delete[](void* ptr, void*) noexcept;
*/
#include <__config>
+#include <__availability>
+#include <cstddef>
+#include <cstdlib>
#include <exception>
#include <type_traits>
-#include <cstddef>
#include <version>
-#ifdef _LIBCPP_NO_EXCEPTIONS
-#include <cstdlib>
-#endif
#if defined(_LIBCPP_ABI_VCRUNTIME)
#include <new.h>
@@ -117,11 +116,6 @@ void operator delete[](void* ptr, void*) noexcept;
# define _LIBCPP_HAS_NO_SIZED_DEALLOCATION
#endif
-#if !__has_builtin(__builtin_operator_new) || \
- __has_builtin(__builtin_operator_new) < 201802L
-#define _LIBCPP_HAS_NO_BUILTIN_OVERLOADED_OPERATOR_NEW_DELETE
-#endif
-
namespace std // purposefully not using versioning namespace
{
@@ -234,31 +228,54 @@ _LIBCPP_CONSTEXPR inline _LIBCPP_INLINE_VISIBILITY bool __is_overaligned_for_new
#endif
}
-inline _LIBCPP_INLINE_VISIBILITY void *__libcpp_allocate(size_t __size, size_t __align) {
+template <class ..._Args>
+_LIBCPP_INLINE_VISIBILITY
+void* __libcpp_operator_new(_Args ...__args) {
+#if __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete)
+ return __builtin_operator_new(__args...);
+#else
+ return ::operator new(__args...);
+#endif
+}
+
+template <class ..._Args>
+_LIBCPP_INLINE_VISIBILITY
+void __libcpp_operator_delete(_Args ...__args) {
+#if __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete)
+ __builtin_operator_delete(__args...);
+#else
+ ::operator delete(__args...);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void *__libcpp_allocate(size_t __size, size_t __align) {
#ifndef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
if (__is_overaligned_for_new(__align)) {
const align_val_t __align_val = static_cast<align_val_t>(__align);
-# ifdef _LIBCPP_HAS_NO_BUILTIN_OVERLOADED_OPERATOR_NEW_DELETE
- return ::operator new(__size, __align_val);
-# else
- return __builtin_operator_new(__size, __align_val);
-# endif
+ return __libcpp_operator_new(__size, __align_val);
}
-#else
- ((void)__align);
#endif
-#ifdef _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE
- return ::operator new(__size);
+
+ (void)__align;
+ return __libcpp_operator_new(__size);
+}
+
+template <class ..._Args>
+_LIBCPP_INLINE_VISIBILITY
+void __do_deallocate_handle_size(void *__ptr, size_t __size, _Args ...__args) {
+#ifdef _LIBCPP_HAS_NO_SIZED_DEALLOCATION
+ (void)__size;
+ return __libcpp_operator_delete(__ptr, __args...);
#else
- return __builtin_operator_new(__size);
+ return __libcpp_operator_delete(__ptr, __size, __args...);
#endif
}
-struct _DeallocateCaller {
- static inline _LIBCPP_INLINE_VISIBILITY
- void __do_deallocate_handle_size_align(void *__ptr, size_t __size, size_t __align) {
+inline _LIBCPP_INLINE_VISIBILITY
+void __libcpp_deallocate(void* __ptr, size_t __size, size_t __align) {
#if defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION)
- ((void)__align);
+ (void)__align;
return __do_deallocate_handle_size(__ptr, __size);
#else
if (__is_overaligned_for_new(__align)) {
@@ -268,81 +285,51 @@ struct _DeallocateCaller {
return __do_deallocate_handle_size(__ptr, __size);
}
#endif
- }
+}
- static inline _LIBCPP_INLINE_VISIBILITY
- void __do_deallocate_handle_align(void *__ptr, size_t __align) {
+inline _LIBCPP_INLINE_VISIBILITY void __libcpp_deallocate_unsized(void* __ptr, size_t __align) {
#if defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION)
- ((void)__align);
- return __do_call(__ptr);
+ (void)__align;
+ return __libcpp_operator_delete(__ptr);
#else
if (__is_overaligned_for_new(__align)) {
const align_val_t __align_val = static_cast<align_val_t>(__align);
- return __do_call(__ptr, __align_val);
+ return __libcpp_operator_delete(__ptr, __align_val);
} else {
- return __do_call(__ptr);
+ return __libcpp_operator_delete(__ptr);
}
#endif
- }
-
- private:
- static inline void __do_deallocate_handle_size(void *__ptr, size_t __size) {
-#ifdef _LIBCPP_HAS_NO_SIZED_DEALLOCATION
- ((void)__size);
- return __do_call(__ptr);
-#else
- return __do_call(__ptr, __size);
-#endif
- }
-
-#ifndef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
- static inline void __do_deallocate_handle_size(void *__ptr, size_t __size, align_val_t __align) {
-#ifdef _LIBCPP_HAS_NO_SIZED_DEALLOCATION
- ((void)__size);
- return __do_call(__ptr, __align);
-#else
- return __do_call(__ptr, __size, __align);
-#endif
- }
-#endif
-
-private:
- template <class _A1, class _A2>
- static inline void __do_call(void *__ptr, _A1 __a1, _A2 __a2) {
-#if defined(_LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE) || \
- defined(_LIBCPP_HAS_NO_BUILTIN_OVERLOADED_OPERATOR_NEW_DELETE)
- return ::operator delete(__ptr, __a1, __a2);
-#else
- return __builtin_operator_delete(__ptr, __a1, __a2);
-#endif
- }
+}
- template <class _A1>
- static inline void __do_call(void *__ptr, _A1 __a1) {
-#if defined(_LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE) || \
- defined(_LIBCPP_HAS_NO_BUILTIN_OVERLOADED_OPERATOR_NEW_DELETE)
- return ::operator delete(__ptr, __a1);
+#if !defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION)
+// Low-level helpers to call the aligned allocation and deallocation functions
+// on the target platform. This is used to implement libc++'s own memory
+// allocation routines -- if you need to allocate memory inside the library,
+// chances are that you want to use `__libcpp_allocate` instead.
+//
+// Returns the allocated memory, or `nullptr` on failure.
+inline _LIBCPP_INLINE_VISIBILITY
+void* __libcpp_aligned_alloc(std::size_t __alignment, std::size_t __size) {
+#if defined(_LIBCPP_MSVCRT_LIKE)
+ return ::_aligned_malloc(__size, __alignment);
#else
- return __builtin_operator_delete(__ptr, __a1);
+ void* __result = nullptr;
+ ::posix_memalign(&__result, __alignment, __size);
+ // If posix_memalign fails, __result is unmodified so we still return `nullptr`.
+ return __result;
#endif
- }
+}
- static inline void __do_call(void *__ptr) {
-#ifdef _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE
- return ::operator delete(__ptr);
+inline _LIBCPP_INLINE_VISIBILITY
+void __libcpp_aligned_free(void* __ptr) {
+#if defined(_LIBCPP_MSVCRT_LIKE)
+ ::_aligned_free(__ptr);
#else
- return __builtin_operator_delete(__ptr);
+ ::free(__ptr);
#endif
- }
-};
-
-inline _LIBCPP_INLINE_VISIBILITY void __libcpp_deallocate(void* __ptr, size_t __size, size_t __align) {
- _DeallocateCaller::__do_deallocate_handle_size_align(__ptr, __size, __align);
}
+#endif // !_LIBCPP_HAS_NO_ALIGNED_ALLOCATION
-inline _LIBCPP_INLINE_VISIBILITY void __libcpp_deallocate_unsized(void* __ptr, size_t __align) {
- _DeallocateCaller::__do_deallocate_handle_align(__ptr, __align);
-}
template <class _Tp>
_LIBCPP_NODISCARD_AFTER_CXX17 inline
diff --git a/libcxx/include/numbers b/libcxx/include/numbers
index e7d981be4aa4..38dad9955487 100644
--- a/libcxx/include/numbers
+++ b/libcxx/include/numbers
@@ -100,7 +100,7 @@ template <class T> inline constexpr T egamma_v = __illformed<T>{};
template <class T> inline constexpr T phi_v = __illformed<T>{};
template <class T>
-concept __floating_point = std::is_floating_point_v<T>;
+concept __floating_point = is_floating_point_v<T>;
template <__floating_point T> inline constexpr T e_v<T> = 2.718281828459045235360287471352662;
template <__floating_point T> inline constexpr T log2e_v<T> = 1.442695040888963407359924681001892;
diff --git a/libcxx/include/numeric b/libcxx/include/numeric
index 5ceadc17755e..4f202bb84f70 100644
--- a/libcxx/include/numeric
+++ b/libcxx/include/numeric
@@ -17,115 +17,116 @@ namespace std
{
template <class InputIterator, class T>
- T
+ constexpr T // constexpr since C++20
accumulate(InputIterator first, InputIterator last, T init);
template <class InputIterator, class T, class BinaryOperation>
- T
+ constexpr T // constexpr since C++20
accumulate(InputIterator first, InputIterator last, T init, BinaryOperation binary_op);
template<class InputIterator>
- typename iterator_traits<InputIterator>::value_type
+ constexpr typename iterator_traits<InputIterator>::value_type // constexpr since C++20
reduce(InputIterator first, InputIterator last); // C++17
template<class InputIterator, class T>
- T
+ constexpr T // constexpr since C++20
reduce(InputIterator first, InputIterator last, T init); // C++17
template<class InputIterator, class T, class BinaryOperation>
- T
+ constexpr T // constexpr since C++20
reduce(InputIterator first, InputIterator last, T init, BinaryOperation binary_op); // C++17
template <class InputIterator1, class InputIterator2, class T>
- T
+ constexpr T // constexpr since C++20
inner_product(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, T init);
template <class InputIterator1, class InputIterator2, class T, class BinaryOperation1, class BinaryOperation2>
- T
+ constexpr T // constexpr since C++20
inner_product(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
T init, BinaryOperation1 binary_op1, BinaryOperation2 binary_op2);
template<class InputIterator1, class InputIterator2, class T>
- T
+ constexpr T // constexpr since C++20
transform_reduce(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, T init); // C++17
template<class InputIterator1, class InputIterator2, class T, class BinaryOperation1, class BinaryOperation2>
- T
+ constexpr T // constexpr since C++20
transform_reduce(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, T init,
BinaryOperation1 binary_op1, BinaryOperation2 binary_op2); // C++17
template<class InputIterator, class T, class BinaryOperation, class UnaryOperation>
- T
+ constexpr T // constexpr since C++20
transform_reduce(InputIterator first, InputIterator last, T init,
BinaryOperation binary_op, UnaryOperation unary_op); // C++17
template <class InputIterator, class OutputIterator>
- OutputIterator
+ constexpr OutputIterator // constexpr since C++20
partial_sum(InputIterator first, InputIterator last, OutputIterator result);
template <class InputIterator, class OutputIterator, class BinaryOperation>
- OutputIterator
+ constexpr OutputIterator // constexpr since C++20
partial_sum(InputIterator first, InputIterator last, OutputIterator result, BinaryOperation binary_op);
template<class InputIterator, class OutputIterator, class T>
- OutputIterator
+ constexpr OutputIterator // constexpr since C++20
exclusive_scan(InputIterator first, InputIterator last,
OutputIterator result, T init); // C++17
template<class InputIterator, class OutputIterator, class T, class BinaryOperation>
- OutputIterator
+ constexpr OutputIterator // constexpr since C++20
exclusive_scan(InputIterator first, InputIterator last,
OutputIterator result, T init, BinaryOperation binary_op); // C++17
template<class InputIterator, class OutputIterator>
- OutputIterator
+ constexpr OutputIterator // constexpr since C++20
inclusive_scan(InputIterator first, InputIterator last, OutputIterator result); // C++17
template<class InputIterator, class OutputIterator, class BinaryOperation>
- OutputIterator
+ constexpr OutputIterator // constexpr since C++20
inclusive_scan(InputIterator first, InputIterator last,
OutputIterator result, BinaryOperation binary_op); // C++17
template<class InputIterator, class OutputIterator, class BinaryOperation, class T>
- OutputIterator
+ constexpr OutputIterator // constexpr since C++20
inclusive_scan(InputIterator first, InputIterator last,
OutputIterator result, BinaryOperation binary_op, T init); // C++17
template<class InputIterator, class OutputIterator, class T,
class BinaryOperation, class UnaryOperation>
- OutputIterator
+ constexpr OutputIterator // constexpr since C++20
transform_exclusive_scan(InputIterator first, InputIterator last,
OutputIterator result, T init,
BinaryOperation binary_op, UnaryOperation unary_op); // C++17
template<class InputIterator, class OutputIterator,
class BinaryOperation, class UnaryOperation>
- OutputIterator
+ constexpr OutputIterator // constexpr since C++20
transform_inclusive_scan(InputIterator first, InputIterator last,
OutputIterator result,
BinaryOperation binary_op, UnaryOperation unary_op); // C++17
template<class InputIterator, class OutputIterator,
class BinaryOperation, class UnaryOperation, class T>
- OutputIterator
+ constexpr OutputIterator // constexpr since C++20
transform_inclusive_scan(InputIterator first, InputIterator last,
OutputIterator result,
BinaryOperation binary_op, UnaryOperation unary_op,
T init); // C++17
template <class InputIterator, class OutputIterator>
- OutputIterator
+ constexpr OutputIterator // constexpr since C++20
adjacent_difference(InputIterator first, InputIterator last, OutputIterator result);
template <class InputIterator, class OutputIterator, class BinaryOperation>
- OutputIterator
+ constexpr OutputIterator // constexpr since C++20
adjacent_difference(InputIterator first, InputIterator last, OutputIterator result, BinaryOperation binary_op);
template <class ForwardIterator, class T>
- void iota(ForwardIterator first, ForwardIterator last, T value);
+ constexpr void // constexpr since C++20
+ iota(ForwardIterator first, ForwardIterator last, T value);
template <class M, class N>
constexpr common_type_t<M,N> gcd(M m, N n); // C++17
@@ -133,9 +134,11 @@ template <class M, class N>
template <class M, class N>
constexpr common_type_t<M,N> lcm(M m, N n); // C++17
-integer midpoint(integer a, integer b); // C++20
-pointer midpoint(pointer a, pointer b); // C++20
-floating_point midpoint(floating_point a, floating_point b); // C++20
+template<class T>
+ constexpr T midpoint(T a, T b) noexcept; // C++20
+
+template<class T>
+ constexpr T* midpoint(T* a, T* b); // C++20
} // std
@@ -158,28 +161,36 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_Tp
accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
{
for (; __first != __last; ++__first)
+#if _LIBCPP_STD_VER > 17
+ __init = _VSTD::move(__init) + *__first;
+#else
__init = __init + *__first;
+#endif
return __init;
}
template <class _InputIterator, class _Tp, class _BinaryOperation>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_Tp
accumulate(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOperation __binary_op)
{
for (; __first != __last; ++__first)
+#if _LIBCPP_STD_VER > 17
+ __init = __binary_op(_VSTD::move(__init), *__first);
+#else
__init = __binary_op(__init, *__first);
+#endif
return __init;
}
#if _LIBCPP_STD_VER > 14
template <class _InputIterator, class _Tp, class _BinaryOp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_Tp
reduce(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOp __b)
{
@@ -189,7 +200,7 @@ reduce(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOp __b)
}
template <class _InputIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_Tp
reduce(_InputIterator __first, _InputIterator __last, _Tp __init)
{
@@ -197,7 +208,7 @@ reduce(_InputIterator __first, _InputIterator __last, _Tp __init)
}
template <class _InputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
typename iterator_traits<_InputIterator>::value_type
reduce(_InputIterator __first, _InputIterator __last)
{
@@ -207,29 +218,37 @@ reduce(_InputIterator __first, _InputIterator __last)
#endif
template <class _InputIterator1, class _InputIterator2, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_Tp
inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _Tp __init)
{
for (; __first1 != __last1; ++__first1, (void) ++__first2)
+#if _LIBCPP_STD_VER > 17
+ __init = _VSTD::move(__init) + *__first1 * *__first2;
+#else
__init = __init + *__first1 * *__first2;
+#endif
return __init;
}
template <class _InputIterator1, class _InputIterator2, class _Tp, class _BinaryOperation1, class _BinaryOperation2>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_Tp
inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2,
_Tp __init, _BinaryOperation1 __binary_op1, _BinaryOperation2 __binary_op2)
{
for (; __first1 != __last1; ++__first1, (void) ++__first2)
+#if _LIBCPP_STD_VER > 17
+ __init = __binary_op1(_VSTD::move(__init), __binary_op2(*__first1, *__first2));
+#else
__init = __binary_op1(__init, __binary_op2(*__first1, *__first2));
+#endif
return __init;
}
#if _LIBCPP_STD_VER > 14
template <class _InputIterator, class _Tp, class _BinaryOp, class _UnaryOp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_Tp
transform_reduce(_InputIterator __first, _InputIterator __last,
_Tp __init, _BinaryOp __b, _UnaryOp __u)
@@ -241,7 +260,7 @@ transform_reduce(_InputIterator __first, _InputIterator __last,
template <class _InputIterator1, class _InputIterator2,
class _Tp, class _BinaryOp1, class _BinaryOp2>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_Tp
transform_reduce(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _Tp __init, _BinaryOp1 __b1, _BinaryOp2 __b2)
@@ -252,7 +271,7 @@ transform_reduce(_InputIterator1 __first1, _InputIterator1 __last1,
}
template <class _InputIterator1, class _InputIterator2, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_Tp
transform_reduce(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _Tp __init)
@@ -263,7 +282,7 @@ transform_reduce(_InputIterator1 __first1, _InputIterator1 __last1,
#endif
template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
{
@@ -273,7 +292,11 @@ partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __res
*__result = __t;
for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result)
{
+#if _LIBCPP_STD_VER > 17
+ __t = _VSTD::move(__t) + *__first;
+#else
__t = __t + *__first;
+#endif
*__result = __t;
}
}
@@ -281,7 +304,7 @@ partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __res
}
template <class _InputIterator, class _OutputIterator, class _BinaryOperation>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
_BinaryOperation __binary_op)
@@ -292,7 +315,11 @@ partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __res
*__result = __t;
for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result)
{
+#if _LIBCPP_STD_VER > 17
+ __t = __binary_op(_VSTD::move(__t), *__first);
+#else
__t = __binary_op(__t, *__first);
+#endif
*__result = __t;
}
}
@@ -301,27 +328,30 @@ partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __res
#if _LIBCPP_STD_VER > 14
template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
exclusive_scan(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _Tp __init, _BinaryOp __b)
{
if (__first != __last)
{
- _Tp __saved = __init;
- do
+ _Tp __tmp(__b(__init, *__first));
+ while (true)
{
- __init = __b(__init, *__first);
- *__result = __saved;
- __saved = __init;
+ *__result = _VSTD::move(__init);
++__result;
- } while (++__first != __last);
+ ++__first;
+ if (__first == __last)
+ break;
+ __init = _VSTD::move(__tmp);
+ __tmp = __b(__init, *__first);
+ }
}
return __result;
}
template <class _InputIterator, class _OutputIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
exclusive_scan(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _Tp __init)
@@ -330,40 +360,43 @@ exclusive_scan(_InputIterator __first, _InputIterator __last,
}
template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _BinaryOp __b, _Tp __init)
{
for (; __first != __last; ++__first, (void) ++__result) {
__init = __b(__init, *__first);
*__result = __init;
- }
+ }
return __result;
}
template <class _InputIterator, class _OutputIterator, class _BinaryOp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _BinaryOp __b)
{
if (__first != __last) {
- typename std::iterator_traits<_InputIterator>::value_type __init = *__first;
+ typename iterator_traits<_InputIterator>::value_type __init = *__first;
*__result++ = __init;
if (++__first != __last)
return _VSTD::inclusive_scan(__first, __last, __result, __b, __init);
- }
+ }
return __result;
}
template <class _InputIterator, class _OutputIterator>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last,
_OutputIterator __result)
{
- return _VSTD::inclusive_scan(__first, __last, __result, std::plus<>());
+ return _VSTD::inclusive_scan(__first, __last, __result, _VSTD::plus<>());
}
template <class _InputIterator, class _OutputIterator, class _Tp,
class _BinaryOp, class _UnaryOp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
transform_exclusive_scan(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _Tp __init,
@@ -384,7 +417,9 @@ transform_exclusive_scan(_InputIterator __first, _InputIterator __last,
}
template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp, class _UnaryOp>
-_OutputIterator transform_inclusive_scan(_InputIterator __first, _InputIterator __last,
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+transform_inclusive_scan(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _BinaryOp __b, _UnaryOp __u, _Tp __init)
{
for (; __first != __last; ++__first, (void) ++__result) {
@@ -396,61 +431,71 @@ _OutputIterator transform_inclusive_scan(_InputIterator __first, _InputIterator
}
template <class _InputIterator, class _OutputIterator, class _BinaryOp, class _UnaryOp>
-_OutputIterator transform_inclusive_scan(_InputIterator __first, _InputIterator __last,
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+transform_inclusive_scan(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _BinaryOp __b, _UnaryOp __u)
{
if (__first != __last) {
- typename std::iterator_traits<_InputIterator>::value_type __init = __u(*__first);
+ typename iterator_traits<_InputIterator>::value_type __init = __u(*__first);
*__result++ = __init;
if (++__first != __last)
return _VSTD::transform_inclusive_scan(__first, __last, __result, __b, __u, __init);
- }
+ }
return __result;
}
#endif
template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
{
if (__first != __last)
{
- typename iterator_traits<_InputIterator>::value_type __t1(*__first);
- *__result = __t1;
+ typename iterator_traits<_InputIterator>::value_type __acc(*__first);
+ *__result = __acc;
for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result)
{
- typename iterator_traits<_InputIterator>::value_type __t2(*__first);
- *__result = __t2 - __t1;
- __t1 = _VSTD::move(__t2);
+ typename iterator_traits<_InputIterator>::value_type __val(*__first);
+#if _LIBCPP_STD_VER > 17
+ *__result = __val - _VSTD::move(__acc);
+#else
+ *__result = __val - __acc;
+#endif
+ __acc = _VSTD::move(__val);
}
}
return __result;
}
template <class _InputIterator, class _OutputIterator, class _BinaryOperation>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
_BinaryOperation __binary_op)
{
if (__first != __last)
{
- typename iterator_traits<_InputIterator>::value_type __t1(*__first);
- *__result = __t1;
+ typename iterator_traits<_InputIterator>::value_type __acc(*__first);
+ *__result = __acc;
for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result)
{
- typename iterator_traits<_InputIterator>::value_type __t2(*__first);
- *__result = __binary_op(__t2, __t1);
- __t1 = _VSTD::move(__t2);
+ typename iterator_traits<_InputIterator>::value_type __val(*__first);
+#if _LIBCPP_STD_VER > 17
+ *__result = __binary_op(__val, _VSTD::move(__acc));
+#else
+ *__result = __binary_op(__val, __acc);
+#endif
+ __acc = _VSTD::move(__val);
}
}
return __result;
}
template <class _ForwardIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void
iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value_)
{
@@ -467,9 +512,9 @@ struct __ct_abs<_Result, _Source, true> {
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
_Result operator()(_Source __t) const noexcept
{
- if (__t >= 0) return __t;
- if (__t == numeric_limits<_Source>::min()) return -static_cast<_Result>(__t);
- return -__t;
+ if (__t >= 0) return __t;
+ if (__t == numeric_limits<_Source>::min()) return -static_cast<_Result>(__t);
+ return -__t;
}
};
@@ -531,8 +576,8 @@ enable_if_t<is_integral_v<_Tp> && !is_same_v<bool, _Tp> && !is_null_pointer_v<_T
midpoint(_Tp __a, _Tp __b) noexcept
_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
{
- using _Up = std::make_unsigned_t<_Tp>;
- constexpr _Up __bitshift = std::numeric_limits<_Up>::digits - 1;
+ using _Up = make_unsigned_t<_Tp>;
+ constexpr _Up __bitshift = numeric_limits<_Up>::digits - 1;
_Up __diff = _Up(__b) - _Up(__a);
_Up __sign_bit = __b < __a;
diff --git a/libcxx/include/optional b/libcxx/include/optional
index a147d69da00f..97a0bbe66ca9 100644
--- a/libcxx/include/optional
+++ b/libcxx/include/optional
@@ -147,6 +147,7 @@ template<class T>
*/
#include <__config>
+#include <__availability>
#include <__debug>
#include <__functional_base>
#include <functional>
@@ -320,7 +321,7 @@ struct __optional_storage_base : __optional_destruct_base<_Tp>
void __construct(_Args&&... __args)
{
_LIBCPP_ASSERT(!has_value(), "__construct called for engaged __optional_storage");
- ::new((void*)_VSTD::addressof(this->__val_)) value_type(_VSTD::forward<_Args>(__args)...);
+ ::new ((void*)_VSTD::addressof(this->__val_)) value_type(_VSTD::forward<_Args>(__args)...);
this->__engaged_ = true;
}
@@ -656,7 +657,7 @@ private:
}
template <class _Up, class _QUp = _QualUp>
static constexpr bool __enable_assign() {
- // Construction and assignability of _Qup to _Tp has already been
+ // Construction and assignability of _QUp to _Tp has already been
// checked.
return !__check_constructible_from_opt<_Up>::value &&
!__check_assignable_from_opt<_Up>::value;
diff --git a/libcxx/include/ostream b/libcxx/include/ostream
index 697732d54e6d..f5eb8a894607 100644
--- a/libcxx/include/ostream
+++ b/libcxx/include/ostream
@@ -126,9 +126,8 @@ template <class charT, class traits>
basic_ostream<charT,traits>& flush(basic_ostream<charT,traits>& os);
// rvalue stream insertion
-template <class charT, class traits, class T>
- basic_ostream<charT, traits>&
- operator<<(basic_ostream<charT, traits>&& os, const T& x);
+template <class Stream, class T>
+ Stream&& operator<<(Stream&& os, const T& x);
} // std
@@ -1028,15 +1027,20 @@ flush(basic_ostream<_CharT, _Traits>& __os)
#ifndef _LIBCPP_CXX03_LANG
+template <class _Stream, class _Tp, class = void>
+struct __is_ostreamable : false_type { };
+
template <class _Stream, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
- !is_lvalue_reference<_Stream>::value &&
- is_base_of<ios_base, _Stream>::value,
- _Stream&&
->::type
-operator<<(_Stream&& __os, const _Tp& __x)
+struct __is_ostreamable<_Stream, _Tp, decltype(
+ _VSTD::declval<_Stream>() << _VSTD::declval<_Tp>(), void()
+)> : true_type { };
+
+template <class _Stream, class _Tp, class = typename enable_if<
+ _And<is_base_of<ios_base, _Stream>,
+ __is_ostreamable<_Stream&, const _Tp&>>::value
+>::type>
+_LIBCPP_INLINE_VISIBILITY
+_Stream&& operator<<(_Stream&& __os, const _Tp& __x)
{
__os << __x;
return _VSTD::move(__os);
@@ -1097,10 +1101,8 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x)
use_facet<ctype<_CharT> >(__os.getloc()).widen('1'));
}
-#ifndef _LIBCPP_DO_NOT_ASSUME_STREAMS_EXPLICIT_INSTANTIATION_IN_DYLIB
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<char>)
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<wchar_t>)
-#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/queue b/libcxx/include/queue
index 33c25e0dfc13..a2048c1e22cc 100644
--- a/libcxx/include/queue
+++ b/libcxx/include/queue
@@ -112,18 +112,11 @@ protected:
Compare comp;
public:
- priority_queue() = default;
- ~priority_queue() = default;
-
- priority_queue(const priority_queue& q) = default;
- priority_queue(priority_queue&& q) = default;
-
- priority_queue& operator=(const priority_queue& q) = default;
- priority_queue& operator=(priority_queue&& q) = default;
-
- explicit priority_queue(const Compare& comp);
- priority_queue(const Compare& comp, const container_type& c);
- explicit priority_queue(const Compare& comp, container_type&& c);
+ priority_queue() : priority_queue(Compare()) {} // C++20
+ explicit priority_queue(const Compare& x) : priority_queue(x, Container()) {}
+ priority_queue(const Compare& x, const Container&);
+ explicit priority_queue(const Compare& x = Compare(), Container&&= Container()); // before C++20
+ priority_queue(const Compare& x, Container&&); // C++20
template <class InputIterator>
priority_queue(InputIterator first, InputIterator last,
const Compare& comp = Compare());
@@ -474,7 +467,7 @@ public:
priority_queue(const value_compare& __comp, const container_type& __c);
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
- explicit priority_queue(const value_compare& __comp, container_type&& __c);
+ priority_queue(const value_compare& __comp, container_type&& __c);
#endif
template <class _InputIter>
_LIBCPP_INLINE_VISIBILITY
diff --git a/libcxx/include/random b/libcxx/include/random
index ce3d135e064a..6e0d2ecb47c0 100644
--- a/libcxx/include/random
+++ b/libcxx/include/random
@@ -36,7 +36,9 @@ public:
static constexpr result_type default_seed = 1u;
// constructors and seeding functions
- explicit linear_congruential_engine(result_type s = default_seed);
+ explicit linear_congruential_engine(result_type s = default_seed); // before C++20
+ linear_congruential_engine() : linear_congruential_engine(default_seed) {} // C++20
+ explicit linear_congruential_engine(result_type s); // C++20
template<class Sseq> explicit linear_congruential_engine(Sseq& q);
void seed(result_type s = default_seed);
template<class Sseq> void seed(Sseq& q);
@@ -96,7 +98,9 @@ public:
static constexpr result_type default_seed = 5489u;
// constructors and seeding functions
- explicit mersenne_twister_engine(result_type value = default_seed);
+ explicit mersenne_twister_engine(result_type s = default_seed); // before C++20
+ mersenne_twister_engine() : mersenne_twister_engine(default_seed) {} // C++20
+ explicit mersenne_twister_engine(result_type s); // C++20
template<class Sseq> explicit mersenne_twister_engine(Sseq& q);
void seed(result_type value = default_seed);
template<class Sseq> void seed(Sseq& q);
@@ -154,7 +158,9 @@ public:
static constexpr result_type default_seed = 19780503u;
// constructors and seeding functions
- explicit subtract_with_carry_engine(result_type value = default_seed);
+ explicit subtract_with_carry_engine(result_type value = default_seed); // before C++20
+ subtract_with_carry_engine() : subtract_with_carry_engine(default_seed) {} // C++20
+ explicit subtract_with_carry_engine(result_type value); // C++20
template<class Sseq> explicit subtract_with_carry_engine(Sseq& q);
void seed(result_type value = default_seed);
template<class Sseq> void seed(Sseq& q);
@@ -385,7 +391,9 @@ public:
static constexpr result_type max() { return numeric_limits<result_type>::max(); }
// constructors
- explicit random_device(const string& token = "/dev/urandom");
+ explicit random_device(const string& token = implementation-defined); // before C++20
+ random_device() : random_device(implementation-defined) {} // C++20
+ explicit random_device(const string& token); // C++20
// generating functions
result_type operator()();
@@ -456,7 +464,10 @@ public:
// constructors and reset functions
explicit uniform_int_distribution(IntType a = 0,
- IntType b = numeric_limits<IntType>::max());
+ IntType b = numeric_limits<IntType>::max()); // before C++20
+ uniform_int_distribution() : uniform_int_distribution(0) {} // C++20
+ explicit uniform_int_distribution(IntType a,
+ IntType b = numeric_limits<IntType>::max()); // C++20
explicit uniform_int_distribution(const param_type& parm);
void reset();
@@ -515,7 +526,9 @@ public:
};
// constructors and reset functions
- explicit uniform_real_distribution(RealType a = 0.0, RealType b = 1.0);
+ explicit uniform_real_distribution(RealType a = 0.0, RealType b = 1.0); // before C++20
+ uniform_real_distribution() : uniform_real_distribution(0.0) {} // C++20
+ explicit uniform_real_distribution(RealType a, RealType b = 1.0); // C++20
explicit uniform_real_distribution(const param_type& parm);
void reset();
@@ -571,7 +584,9 @@ public:
};
// constructors and reset functions
- explicit bernoulli_distribution(double p = 0.5);
+ explicit bernoulli_distribution(double p = 0.5); // before C++20
+ bernoulli_distribution() : bernoulli_distribution(0.5) {} // C++20
+ explicit bernoulli_distribution(double p); // C++20
explicit bernoulli_distribution(const param_type& parm);
void reset();
@@ -628,7 +643,9 @@ public:
};
// constructors and reset functions
- explicit binomial_distribution(IntType t = 1, double p = 0.5);
+ explicit binomial_distribution(IntType t = 1, double p = 0.5); // before C++20
+ binomial_distribution() : binomial_distribution(1) {} // C++20
+ explicit binomial_distribution(IntType t, double p = 0.5); // C++20
explicit binomial_distribution(const param_type& parm);
void reset();
@@ -685,7 +702,9 @@ public:
};
// constructors and reset functions
- explicit geometric_distribution(double p = 0.5);
+ explicit geometric_distribution(double p = 0.5); // before C++20
+ geometric_distribution() : geometric_distribution(0.5) {} // C++20
+ explicit geometric_distribution(double p); // C++20
explicit geometric_distribution(const param_type& parm);
void reset();
@@ -742,7 +761,9 @@ public:
};
// constructor and reset functions
- explicit negative_binomial_distribution(result_type k = 1, double p = 0.5);
+ explicit negative_binomial_distribution(IntType k = 1, double p = 0.5); // before C++20
+ negative_binomial_distribution() : negative_binomial_distribution(1) {} // C++20
+ explicit negative_binomial_distribution(IntType k, double p = 0.5); // C++20
explicit negative_binomial_distribution(const param_type& parm);
void reset();
@@ -799,7 +820,9 @@ public:
};
// constructors and reset functions
- explicit poisson_distribution(double mean = 1.0);
+ explicit poisson_distribution(double mean = 1.0); // before C++20
+ poisson_distribution() : poisson_distribution(1.0) {} // C++20
+ explicit poisson_distribution(double mean); // C++20
explicit poisson_distribution(const param_type& parm);
void reset();
@@ -855,7 +878,9 @@ public:
};
// constructors and reset functions
- explicit exponential_distribution(result_type lambda = 1.0);
+ explicit exponential_distribution(RealType lambda = 1.0); // before C++20
+ exponential_distribution() : exponential_distribution(1.0) {} // C++20
+ explicit exponential_distribution(RealType lambda); // C++20
explicit exponential_distribution(const param_type& parm);
void reset();
@@ -912,7 +937,9 @@ public:
};
// constructors and reset functions
- explicit gamma_distribution(result_type alpha = 1, result_type beta = 1);
+ explicit gamma_distribution(RealType alpha = 0.0, RealType beta = 1.0); // before C++20
+ gamma_distribution() : gamma_distribution(0.0) {} // C++20
+ explicit gamma_distribution(RealType alpha, RealType beta = 1.0); // C++20
explicit gamma_distribution(const param_type& parm);
void reset();
@@ -970,7 +997,9 @@ public:
};
// constructor and reset functions
- explicit weibull_distribution(result_type a = 1, result_type b = 1);
+ explicit weibull_distribution(RealType a = 1.0, RealType b = 1.0); // before C++20
+ weibull_distribution() : weibull_distribution(1.0) {} // C++20
+ explicit weibull_distribution(RealType a, RealType b = 1.0); // C++20
explicit weibull_distribution(const param_type& parm);
void reset();
@@ -1028,7 +1057,9 @@ public:
};
// constructor and reset functions
- explicit extreme_value_distribution(result_type a = 0, result_type b = 1);
+ explicit extreme_value_distribution(RealType a = 0.0, RealType b = 1.0); // before C++20
+ extreme_value_distribution() : extreme_value_distribution(0.0) {} // C++20
+ explicit extreme_value_distribution(RealType a, RealType b = 1.0); // C++20
explicit extreme_value_distribution(const param_type& parm);
void reset();
@@ -1086,7 +1117,9 @@ public:
};
// constructors and reset functions
- explicit normal_distribution(result_type mean = 0, result_type stddev = 1);
+ explicit normal_distribution(RealType mean = 0.0, RealType stddev = 1.0); // before C++20
+ normal_distribution() : normal_distribution(0.0) {} // C++20
+ explicit normal_distribution(RealType mean, RealType stddev = 1.0); // C++20
explicit normal_distribution(const param_type& parm);
void reset();
@@ -1144,7 +1177,9 @@ public:
};
// constructor and reset functions
- explicit lognormal_distribution(result_type m = 0, result_type s = 1);
+ explicit lognormal_distribution(RealType mean = 0.0, RealType stddev = 1.0); // before C++20
+ lognormal_distribution() : lognormal_distribution(0.0) {} // C++20
+ explicit lognormal_distribution(RealType mean, RealType stddev = 1.0); // C++20
explicit lognormal_distribution(const param_type& parm);
void reset();
@@ -1201,7 +1236,9 @@ public:
};
// constructor and reset functions
- explicit chi_squared_distribution(result_type n = 1);
+ explicit chi_squared_distribution(RealType n = 1.0); // before C++20
+ chi_squared_distribution() : chi_squared_distribution(1.0) {} // C++20
+ explicit chi_squared_distribution(RealType n); // C++20
explicit chi_squared_distribution(const param_type& parm);
void reset();
@@ -1258,7 +1295,9 @@ public:
};
// constructor and reset functions
- explicit cauchy_distribution(result_type a = 0, result_type b = 1);
+ explicit cauchy_distribution(RealType a = 0.0, RealType b = 1.0); // before C++20
+ cauchy_distribution() : cauchy_distribution(0.0) {} // C++20
+ explicit cauchy_distribution(RealType a, RealType b = 1.0); // C++20
explicit cauchy_distribution(const param_type& parm);
void reset();
@@ -1316,7 +1355,9 @@ public:
};
// constructor and reset functions
- explicit fisher_f_distribution(result_type m = 1, result_type n = 1);
+ explicit fisher_f_distribution(RealType m = 1.0, RealType n = 1.0); // before C++20
+ fisher_f_distribution() : fisher_f_distribution(1.0) {} // C++20
+ explicit fisher_f_distribution(RealType m, RealType n = 1.0); // C++20
explicit fisher_f_distribution(const param_type& parm);
void reset();
@@ -1373,7 +1414,9 @@ public:
};
// constructor and reset functions
- explicit student_t_distribution(result_type n = 1);
+ explicit student_t_distribution(RealType n = 1.0); // before C++20
+ student_t_distribution() : student_t_distribution(1.0) {} // C++20
+ explicit student_t_distribution(RealType n); // C++20
explicit student_t_distribution(const param_type& parm);
void reset();
@@ -1642,8 +1685,7 @@ class piecewise_linear_distribution
#include <numeric>
#include <vector>
#include <string>
-#include <istream>
-#include <ostream>
+#include <iosfwd>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -1669,7 +1711,23 @@ struct __is_seed_sequence
template <unsigned long long __a, unsigned long long __c,
unsigned long long __m, unsigned long long _Mp,
- bool _MightOverflow = (__a != 0 && __m != 0 && __m-1 > (_Mp-__c)/__a)>
+ bool _MightOverflow = (__a != 0 && __m != 0 && __m-1 > (_Mp-__c)/__a),
+ bool _OverflowOK = ((__m|__m-1) > __m), // m = 2^n
+ bool _SchrageOK = (__a != 0 && __m != 0 && __m % __a <= __m / __a)> // r <= q
+struct __lce_alg_picker
+{
+ static_assert(__a != 0 || __m != 0 || !_MightOverflow || _OverflowOK || _SchrageOK,
+ "The current values of a, c, and m cannot generate a number "
+ "within bounds of linear_congruential_engine.");
+
+ static _LIBCPP_CONSTEXPR const bool __use_schrage = _MightOverflow &&
+ !_OverflowOK &&
+ _SchrageOK;
+};
+
+template <unsigned long long __a, unsigned long long __c,
+ unsigned long long __m, unsigned long long _Mp,
+ bool _UseSchrage = __lce_alg_picker<__a, __c, __m, _Mp>::__use_schrage>
struct __lce_ta;
// 64
@@ -1843,6 +1901,7 @@ private:
static_assert(__m == 0 || __a < __m, "linear_congruential_engine invalid parameters");
static_assert(__m == 0 || __c < __m, "linear_congruential_engine invalid parameters");
+ static_assert(_VSTD::is_unsigned<_UIntType>::value, "_UIntType must be unsigned type");
public:
static _LIBCPP_CONSTEXPR const result_type _Min = __c == 0u ? 1u: 0u;
static _LIBCPP_CONSTEXPR const result_type _Max = __m - 1u;
@@ -1859,9 +1918,17 @@ public:
static _LIBCPP_CONSTEXPR const result_type default_seed = 1u;
// constructors and seeding functions
+#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
- explicit linear_congruential_engine(result_type __s = default_seed)
- {seed(__s);}
+ linear_congruential_engine() : linear_congruential_engine(default_seed) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit linear_congruential_engine(result_type __s) { seed(__s); }
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ explicit linear_congruential_engine(result_type __s = default_seed) {
+ seed(__s);
+ }
+#endif
template<class _Sseq>
_LIBCPP_INLINE_VISIBILITY
explicit linear_congruential_engine(_Sseq& __q,
@@ -1982,7 +2049,8 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
const linear_congruential_engine<_UIntType, __a, __c, __m>& __x)
{
__save_flags<_CharT, _Traits> __lx(__os);
- __os.flags(ios_base::dec | ios_base::left);
+ typedef basic_ostream<_CharT, _Traits> _Ostream;
+ __os.flags(_Ostream::dec | _Ostream::left);
__os.fill(__os.widen(' '));
return __os << __x.__x_;
}
@@ -1994,7 +2062,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
linear_congruential_engine<_UIntType, __a, __c, __m>& __x)
{
__save_flags<_CharT, _Traits> __lx(__is);
- __is.flags(ios_base::dec | ios_base::skipws);
+ typedef basic_istream<_CharT, _Traits> _Istream;
+ __is.flags(_Istream::dec | _Istream::skipws);
_UIntType __t;
__is >> __t;
if (!__is.fail())
@@ -2106,9 +2175,17 @@ public:
static _LIBCPP_CONSTEXPR const result_type default_seed = 5489u;
// constructors and seeding functions
+#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
- explicit mersenne_twister_engine(result_type __sd = default_seed)
- {seed(__sd);}
+ mersenne_twister_engine() : mersenne_twister_engine(default_seed) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit mersenne_twister_engine(result_type __sd) { seed(__sd); }
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ explicit mersenne_twister_engine(result_type __sd = default_seed) {
+ seed(__sd);
+ }
+#endif
template<class _Sseq>
_LIBCPP_INLINE_VISIBILITY
explicit mersenne_twister_engine(_Sseq& __q,
@@ -2453,7 +2530,8 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
_Bp, _Tp, _Cp, _Lp, _Fp>& __x)
{
__save_flags<_CharT, _Traits> __lx(__os);
- __os.flags(ios_base::dec | ios_base::left);
+ typedef basic_ostream<_CharT, _Traits> _Ostream;
+ __os.flags(_Ostream::dec | _Ostream::left);
_CharT __sp = __os.widen(' ');
__os.fill(__sp);
__os << __x.__x_[__x.__i_];
@@ -2474,7 +2552,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
_Bp, _Tp, _Cp, _Lp, _Fp>& __x)
{
__save_flags<_CharT, _Traits> __lx(__is);
- __is.flags(ios_base::dec | ios_base::skipws);
+ typedef basic_istream<_CharT, _Traits> _Istream;
+ __is.flags(_Istream::dec | _Istream::skipws);
_UInt __t[_Np];
for (size_t __i = 0; __i < _Np; ++__i)
__is >> __t[__i];
@@ -2562,9 +2641,17 @@ public:
static _LIBCPP_CONSTEXPR const result_type default_seed = 19780503u;
// constructors and seeding functions
+#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
- explicit subtract_with_carry_engine(result_type __sd = default_seed)
- {seed(__sd);}
+ subtract_with_carry_engine() : subtract_with_carry_engine(default_seed) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit subtract_with_carry_engine(result_type __sd) { seed(__sd); }
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ explicit subtract_with_carry_engine(result_type __sd = default_seed) {
+ seed(__sd);
+ }
+#endif
template<class _Sseq>
_LIBCPP_INLINE_VISIBILITY
explicit subtract_with_carry_engine(_Sseq& __q,
@@ -2773,7 +2860,8 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x)
{
__save_flags<_CharT, _Traits> __lx(__os);
- __os.flags(ios_base::dec | ios_base::left);
+ typedef basic_ostream<_CharT, _Traits> _Ostream;
+ __os.flags(_Ostream::dec | _Ostream::left);
_CharT __sp = __os.widen(' ');
__os.fill(__sp);
__os << __x.__x_[__x.__i_];
@@ -2792,7 +2880,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x)
{
__save_flags<_CharT, _Traits> __lx(__is);
- __is.flags(ios_base::dec | ios_base::skipws);
+ typedef basic_istream<_CharT, _Traits> _Istream;
+ __is.flags(_Istream::dec | _Istream::skipws);
_UInt __t[_Rp+1];
for (size_t __i = 0; __i < _Rp+1; ++__i)
__is >> __t[__i];
@@ -2955,7 +3044,8 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
const discard_block_engine<_Eng, _Pp, _Rp>& __x)
{
__save_flags<_CharT, _Traits> __lx(__os);
- __os.flags(ios_base::dec | ios_base::left);
+ typedef basic_ostream<_CharT, _Traits> _Ostream;
+ __os.flags(_Ostream::dec | _Ostream::left);
_CharT __sp = __os.widen(' ');
__os.fill(__sp);
return __os << __x.__e_ << __sp << __x.__n_;
@@ -2968,7 +3058,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
discard_block_engine<_Eng, _Pp, _Rp>& __x)
{
__save_flags<_CharT, _Traits> __lx(__is);
- __is.flags(ios_base::dec | ios_base::skipws);
+ typedef basic_istream<_CharT, _Traits> _Istream;
+ __is.flags(_Istream::dec | _Istream::skipws);
_Eng __e;
int __n;
__is >> __e >> __n;
@@ -3440,7 +3531,8 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
const shuffle_order_engine<_Eng, _Kp>& __x)
{
__save_flags<_CharT, _Traits> __lx(__os);
- __os.flags(ios_base::dec | ios_base::left);
+ typedef basic_ostream<_CharT, _Traits> _Ostream;
+ __os.flags(_Ostream::dec | _Ostream::left);
_CharT __sp = __os.widen(' ');
__os.fill(__sp);
__os << __x.__e_ << __sp << __x._V_[0];
@@ -3457,7 +3549,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
{
typedef typename shuffle_order_engine<_Eng, _Kp>::result_type result_type;
__save_flags<_CharT, _Traits> __lx(__is);
- __is.flags(ios_base::dec | ios_base::skipws);
+ typedef basic_istream<_CharT, _Traits> _Istream;
+ __is.flags(_Istream::dec | _Istream::skipws);
_Eng __e;
result_type _Vp[_Kp+1];
__is >> __e;
@@ -3477,6 +3570,8 @@ typedef shuffle_order_engine<minstd_rand0, 256> knuth_b;
// random_device
+#if !defined(_LIBCPP_HAS_NO_RANDOM_DEVICE)
+
class _LIBCPP_TYPE_VIS random_device
{
#ifdef _LIBCPP_USING_DEV_RANDOM
@@ -3496,7 +3591,12 @@ public:
static _LIBCPP_CONSTEXPR result_type max() { return _Max;}
// constructors
+#ifndef _LIBCPP_CXX03_LANG
+ random_device() : random_device("/dev/urandom") {}
+ explicit random_device(const string& __token);
+#else
explicit random_device(const string& __token = "/dev/urandom");
+#endif
~random_device();
// generating functions
@@ -3511,6 +3611,8 @@ private:
random_device& operator=(const random_device&); // = delete;
};
+#endif // !_LIBCPP_HAS_NO_RANDOM_DEVICE
+
// seed_seq
class _LIBCPP_TEMPLATE_VIS seed_seq
@@ -3663,7 +3765,8 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
const uniform_int_distribution<_IT>& __x)
{
__save_flags<_CharT, _Traits> __lx(__os);
- __os.flags(ios_base::dec | ios_base::left);
+ typedef basic_ostream<_CharT, _Traits> _Ostream;
+ __os.flags(_Ostream::dec | _Ostream::left);
_CharT __sp = __os.widen(' ');
__os.fill(__sp);
return __os << __x.a() << __sp << __x.b();
@@ -3678,7 +3781,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
typedef typename _Eng::result_type result_type;
typedef typename _Eng::param_type param_type;
__save_flags<_CharT, _Traits> __lx(__is);
- __is.flags(ios_base::dec | ios_base::skipws);
+ typedef basic_istream<_CharT, _Traits> _Istream;
+ __is.flags(_Istream::dec | _Istream::skipws);
result_type __a;
result_type __b;
__is >> __a >> __b;
@@ -3726,9 +3830,16 @@ private:
public:
// constructors and reset functions
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ uniform_real_distribution() : uniform_real_distribution(0) {}
+ explicit uniform_real_distribution(result_type __a, result_type __b = 1)
+ : __p_(param_type(__a, __b)) {}
+#else
_LIBCPP_INLINE_VISIBILITY
explicit uniform_real_distribution(result_type __a = 0, result_type __b = 1)
: __p_(param_type(__a, __b)) {}
+#endif
_LIBCPP_INLINE_VISIBILITY
explicit uniform_real_distribution(const param_type& __p) : __p_(__p) {}
_LIBCPP_INLINE_VISIBILITY
@@ -3784,8 +3895,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
const uniform_real_distribution<_RT>& __x)
{
__save_flags<_CharT, _Traits> __lx(__os);
- __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
- ios_base::scientific);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
_CharT __sp = __os.widen(' ');
__os.fill(__sp);
return __os << __x.a() << __sp << __x.b();
@@ -3800,7 +3912,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
typedef typename _Eng::result_type result_type;
typedef typename _Eng::param_type param_type;
__save_flags<_CharT, _Traits> __lx(__is);
- __is.flags(ios_base::dec | ios_base::skipws);
+ typedef basic_istream<_CharT, _Traits> _Istream;
+ __is.flags(_Istream::dec | _Istream::skipws);
result_type __a;
result_type __b;
__is >> __a >> __b;
@@ -3842,9 +3955,15 @@ private:
public:
// constructors and reset functions
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ bernoulli_distribution() : bernoulli_distribution(0.5) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit bernoulli_distribution(double __p) : __p_(param_type(__p)) {}
+#else
_LIBCPP_INLINE_VISIBILITY
- explicit bernoulli_distribution(double __p = 0.5)
- : __p_(param_type(__p)) {}
+ explicit bernoulli_distribution(double __p = 0.5) : __p_(param_type(__p)) {}
+#endif
_LIBCPP_INLINE_VISIBILITY
explicit bernoulli_distribution(const param_type& __p) : __p_(__p) {}
_LIBCPP_INLINE_VISIBILITY
@@ -3895,8 +4014,9 @@ basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, const bernoulli_distribution& __x)
{
__save_flags<_CharT, _Traits> __lx(__os);
- __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
- ios_base::scientific);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
_CharT __sp = __os.widen(' ');
__os.fill(__sp);
return __os << __x.p();
@@ -3909,7 +4029,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bernoulli_distribution& __x)
typedef bernoulli_distribution _Eng;
typedef typename _Eng::param_type param_type;
__save_flags<_CharT, _Traits> __lx(__is);
- __is.flags(ios_base::dec | ios_base::skipws);
+ typedef basic_istream<_CharT, _Traits> _Istream;
+ __is.flags(_Istream::dec | _Istream::skipws);
double __p;
__is >> __p;
if (!__is.fail())
@@ -3958,9 +4079,17 @@ private:
public:
// constructors and reset functions
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ binomial_distribution() : binomial_distribution(1) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit binomial_distribution(result_type __t, double __p = 0.5)
+ : __p_(param_type(__t, __p)) {}
+#else
_LIBCPP_INLINE_VISIBILITY
explicit binomial_distribution(result_type __t = 1, double __p = 0.5)
: __p_(param_type(__t, __p)) {}
+#endif
_LIBCPP_INLINE_VISIBILITY
explicit binomial_distribution(const param_type& __p) : __p_(__p) {}
_LIBCPP_INLINE_VISIBILITY
@@ -3999,12 +4128,12 @@ public:
{return !(__x == __y);}
};
-#ifndef _LIBCPP_MSVCRT
+#ifndef _LIBCPP_MSVCRT_LIKE
extern "C" double lgamma_r(double, int *);
#endif
inline _LIBCPP_INLINE_VISIBILITY double __libcpp_lgamma(double __d) {
-#if defined(_LIBCPP_MSVCRT)
+#if defined(_LIBCPP_MSVCRT_LIKE)
return lgamma(__d);
#else
int __sign;
@@ -4079,8 +4208,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
const binomial_distribution<_IntType>& __x)
{
__save_flags<_CharT, _Traits> __lx(__os);
- __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
- ios_base::scientific);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
_CharT __sp = __os.widen(' ');
__os.fill(__sp);
return __os << __x.t() << __sp << __x.p();
@@ -4095,7 +4225,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
typedef typename _Eng::result_type result_type;
typedef typename _Eng::param_type param_type;
__save_flags<_CharT, _Traits> __lx(__is);
- __is.flags(ios_base::dec | ios_base::skipws);
+ typedef basic_istream<_CharT, _Traits> _Istream;
+ __is.flags(_Istream::dec | _Istream::skipws);
result_type __t;
double __p;
__is >> __t >> __p;
@@ -4138,9 +4269,17 @@ private:
public:
// constructors and reset functions
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ exponential_distribution() : exponential_distribution(1) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit exponential_distribution(result_type __lambda)
+ : __p_(param_type(__lambda)) {}
+#else
_LIBCPP_INLINE_VISIBILITY
explicit exponential_distribution(result_type __lambda = 1)
: __p_(param_type(__lambda)) {}
+#endif
_LIBCPP_INLINE_VISIBILITY
explicit exponential_distribution(const param_type& __p) : __p_(__p) {}
_LIBCPP_INLINE_VISIBILITY
@@ -4197,8 +4336,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
const exponential_distribution<_RealType>& __x)
{
__save_flags<_CharT, _Traits> __lx(__os);
- __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
- ios_base::scientific);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
return __os << __x.lambda();
}
@@ -4211,7 +4351,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
typedef typename _Eng::result_type result_type;
typedef typename _Eng::param_type param_type;
__save_flags<_CharT, _Traits> __lx(__is);
- __is.flags(ios_base::dec | ios_base::skipws);
+ typedef basic_istream<_CharT, _Traits> _Istream;
+ __is.flags(_Istream::dec | _Istream::skipws);
result_type __lambda;
__is >> __lambda;
if (!__is.fail())
@@ -4259,9 +4400,18 @@ private:
public:
// constructors and reset functions
+#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
- explicit normal_distribution(result_type __mean = 0, result_type __stddev = 1)
+ normal_distribution() : normal_distribution(0) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit normal_distribution(result_type __mean, result_type __stddev = 1)
: __p_(param_type(__mean, __stddev)), _V_hot_(false) {}
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ explicit normal_distribution(result_type __mean = 0,
+ result_type __stddev = 1)
+ : __p_(param_type(__mean, __stddev)), _V_hot_(false) {}
+#endif
_LIBCPP_INLINE_VISIBILITY
explicit normal_distribution(const param_type& __p)
: __p_(__p), _V_hot_(false) {}
@@ -4351,8 +4501,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
const normal_distribution<_RT>& __x)
{
__save_flags<_CharT, _Traits> __lx(__os);
- __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
- ios_base::scientific);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
_CharT __sp = __os.widen(' ');
__os.fill(__sp);
__os << __x.mean() << __sp << __x.stddev() << __sp << __x._V_hot_;
@@ -4370,7 +4521,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
typedef typename _Eng::result_type result_type;
typedef typename _Eng::param_type param_type;
__save_flags<_CharT, _Traits> __lx(__is);
- __is.flags(ios_base::dec | ios_base::skipws);
+ typedef basic_istream<_CharT, _Traits> _Istream;
+ __is.flags(_Istream::dec | _Istream::skipws);
result_type __mean;
result_type __stddev;
result_type _Vp = 0;
@@ -4437,9 +4589,18 @@ private:
public:
// constructor and reset functions
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ lognormal_distribution() : lognormal_distribution(0) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit lognormal_distribution(result_type __m, result_type __s = 1)
+ : __p_(param_type(__m, __s)) {}
+#else
_LIBCPP_INLINE_VISIBILITY
- explicit lognormal_distribution(result_type __m = 0, result_type __s = 1)
+ explicit lognormal_distribution(result_type __m = 0,
+ result_type __s = 1)
: __p_(param_type(__m, __s)) {}
+#endif
_LIBCPP_INLINE_VISIBILITY
explicit lognormal_distribution(const param_type& __p)
: __p_(__p) {}
@@ -4557,8 +4718,17 @@ private:
public:
// constructors and reset functions
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ poisson_distribution() : poisson_distribution(1.0) {}
_LIBCPP_INLINE_VISIBILITY
- explicit poisson_distribution(double __mean = 1.0) : __p_(__mean) {}
+ explicit poisson_distribution(double __mean)
+ : __p_(__mean) {}
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ explicit poisson_distribution(double __mean = 1.0)
+ : __p_(__mean) {}
+#endif
_LIBCPP_INLINE_VISIBILITY
explicit poisson_distribution(const param_type& __p) : __p_(__p) {}
_LIBCPP_INLINE_VISIBILITY
@@ -4618,7 +4788,7 @@ poisson_distribution<_IntType>::param_type::param_type(double __mean)
{
__s_ = _VSTD::sqrt(__mean_);
__d_ = 6 * __mean_ * __mean_;
- __l_ = std::trunc(__mean_ - 1.1484);
+ __l_ = _VSTD::trunc(__mean_ - 1.1484);
__omega_ = .3989423 / __s_;
double __b1_ = .4166667E-1 / __mean_;
double __b2_ = .3 * __b1_ * __b1_;
@@ -4650,13 +4820,13 @@ poisson_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr
double __u;
if (__g > 0)
{
- __tx = std::trunc(__g);
+ __tx = _VSTD::trunc(__g);
if (__tx >= __pr.__l_)
- return std::__clamp_to_integral<result_type>(__tx);
+ return _VSTD::__clamp_to_integral<result_type>(__tx);
__difmuk = __pr.__mean_ - __tx;
__u = __urd(__urng);
if (__pr.__d_ * __u >= __difmuk * __difmuk * __difmuk)
- return std::__clamp_to_integral<result_type>(__tx);
+ return _VSTD::__clamp_to_integral<result_type>(__tx);
}
exponential_distribution<double> __edist;
for (bool __using_exp_dist = false; true; __using_exp_dist = true)
@@ -4672,7 +4842,7 @@ poisson_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr
__u += __u - 1;
__t = 1.8 + (__u < 0 ? -__e : __e);
} while (__t <= -.6744);
- __tx = std::trunc(__pr.__mean_ + __pr.__s_ * __t);
+ __tx = _VSTD::trunc(__pr.__mean_ + __pr.__s_ * __t);
__difmuk = __pr.__mean_ - __tx;
__using_exp_dist = true;
}
@@ -4716,7 +4886,7 @@ poisson_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr
}
}
}
- return std::__clamp_to_integral<result_type>(__tx);
+ return _VSTD::__clamp_to_integral<result_type>(__tx);
}
template <class _CharT, class _Traits, class _IntType>
@@ -4725,8 +4895,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
const poisson_distribution<_IntType>& __x)
{
__save_flags<_CharT, _Traits> __lx(__os);
- __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
- ios_base::scientific);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
return __os << __x.mean();
}
@@ -4738,7 +4909,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
typedef poisson_distribution<_IntType> _Eng;
typedef typename _Eng::param_type param_type;
__save_flags<_CharT, _Traits> __lx(__is);
- __is.flags(ios_base::dec | ios_base::skipws);
+ typedef basic_istream<_CharT, _Traits> _Istream;
+ __is.flags(_Istream::dec | _Istream::skipws);
double __mean;
__is >> __mean;
if (!__is.fail())
@@ -4784,9 +4956,17 @@ private:
public:
// constructor and reset functions
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ weibull_distribution() : weibull_distribution(1) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit weibull_distribution(result_type __a, result_type __b = 1)
+ : __p_(param_type(__a, __b)) {}
+#else
_LIBCPP_INLINE_VISIBILITY
explicit weibull_distribution(result_type __a = 1, result_type __b = 1)
: __p_(param_type(__a, __b)) {}
+#endif
_LIBCPP_INLINE_VISIBILITY
explicit weibull_distribution(const param_type& __p)
: __p_(__p) {}
@@ -4836,8 +5016,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
const weibull_distribution<_RT>& __x)
{
__save_flags<_CharT, _Traits> __lx(__os);
- __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
- ios_base::scientific);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
_CharT __sp = __os.widen(' ');
__os.fill(__sp);
__os << __x.a() << __sp << __x.b();
@@ -4853,7 +5034,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
typedef typename _Eng::result_type result_type;
typedef typename _Eng::param_type param_type;
__save_flags<_CharT, _Traits> __lx(__is);
- __is.flags(ios_base::dec | ios_base::skipws);
+ typedef basic_istream<_CharT, _Traits> _Istream;
+ __is.flags(_Istream::dec | _Istream::skipws);
result_type __a;
result_type __b;
__is >> __a >> __b;
@@ -4898,9 +5080,18 @@ private:
public:
// constructor and reset functions
+#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
- explicit extreme_value_distribution(result_type __a = 0, result_type __b = 1)
+ extreme_value_distribution() : extreme_value_distribution(0) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit extreme_value_distribution(result_type __a, result_type __b = 1)
: __p_(param_type(__a, __b)) {}
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ explicit extreme_value_distribution(result_type __a = 0,
+ result_type __b = 1)
+ : __p_(param_type(__a, __b)) {}
+#endif
_LIBCPP_INLINE_VISIBILITY
explicit extreme_value_distribution(const param_type& __p)
: __p_(__p) {}
@@ -4955,8 +5146,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
const extreme_value_distribution<_RT>& __x)
{
__save_flags<_CharT, _Traits> __lx(__os);
- __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
- ios_base::scientific);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
_CharT __sp = __os.widen(' ');
__os.fill(__sp);
__os << __x.a() << __sp << __x.b();
@@ -4972,7 +5164,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
typedef typename _Eng::result_type result_type;
typedef typename _Eng::param_type param_type;
__save_flags<_CharT, _Traits> __lx(__is);
- __is.flags(ios_base::dec | ios_base::skipws);
+ typedef basic_istream<_CharT, _Traits> _Istream;
+ __is.flags(_Istream::dec | _Istream::skipws);
result_type __a;
result_type __b;
__is >> __a >> __b;
@@ -5019,9 +5212,18 @@ private:
public:
// constructors and reset functions
+#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
- explicit gamma_distribution(result_type __alpha = 1, result_type __beta = 1)
+ gamma_distribution() : gamma_distribution(1) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit gamma_distribution(result_type __alpha, result_type __beta = 1)
: __p_(param_type(__alpha, __beta)) {}
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ explicit gamma_distribution(result_type __alpha = 1,
+ result_type __beta = 1)
+ : __p_(param_type(__alpha, __beta)) {}
+#endif
_LIBCPP_INLINE_VISIBILITY
explicit gamma_distribution(const param_type& __p)
: __p_(__p) {}
@@ -5127,8 +5329,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
const gamma_distribution<_RT>& __x)
{
__save_flags<_CharT, _Traits> __lx(__os);
- __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
- ios_base::scientific);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
_CharT __sp = __os.widen(' ');
__os.fill(__sp);
__os << __x.alpha() << __sp << __x.beta();
@@ -5144,7 +5347,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
typedef typename _Eng::result_type result_type;
typedef typename _Eng::param_type param_type;
__save_flags<_CharT, _Traits> __lx(__is);
- __is.flags(ios_base::dec | ios_base::skipws);
+ typedef basic_istream<_CharT, _Traits> _Istream;
+ __is.flags(_Istream::dec | _Istream::skipws);
result_type __alpha;
result_type __beta;
__is >> __alpha >> __beta;
@@ -5191,9 +5395,18 @@ private:
public:
// constructor and reset functions
+#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
- explicit negative_binomial_distribution(result_type __k = 1, double __p = 0.5)
+ negative_binomial_distribution() : negative_binomial_distribution(1) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit negative_binomial_distribution(result_type __k, double __p = 0.5)
: __p_(__k, __p) {}
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ explicit negative_binomial_distribution(result_type __k = 1,
+ double __p = 0.5)
+ : __p_(__k, __p) {}
+#endif
_LIBCPP_INLINE_VISIBILITY
explicit negative_binomial_distribution(const param_type& __p) : __p_(__p) {}
_LIBCPP_INLINE_VISIBILITY
@@ -5263,8 +5476,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
const negative_binomial_distribution<_IntType>& __x)
{
__save_flags<_CharT, _Traits> __lx(__os);
- __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
- ios_base::scientific);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
_CharT __sp = __os.widen(' ');
__os.fill(__sp);
return __os << __x.k() << __sp << __x.p();
@@ -5279,7 +5493,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
typedef typename _Eng::result_type result_type;
typedef typename _Eng::param_type param_type;
__save_flags<_CharT, _Traits> __lx(__is);
- __is.flags(ios_base::dec | ios_base::skipws);
+ typedef basic_istream<_CharT, _Traits> _Istream;
+ __is.flags(_Istream::dec | _Istream::skipws);
result_type __k;
double __p;
__is >> __k >> __p;
@@ -5322,8 +5537,17 @@ private:
public:
// constructors and reset functions
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ geometric_distribution() : geometric_distribution(0.5) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit geometric_distribution(double __p)
+ : __p_(__p) {}
+#else
_LIBCPP_INLINE_VISIBILITY
- explicit geometric_distribution(double __p = 0.5) : __p_(__p) {}
+ explicit geometric_distribution(double __p = 0.5)
+ : __p_(__p) {}
+#endif
_LIBCPP_INLINE_VISIBILITY
explicit geometric_distribution(const param_type& __p) : __p_(__p) {}
_LIBCPP_INLINE_VISIBILITY
@@ -5369,8 +5593,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
const geometric_distribution<_IntType>& __x)
{
__save_flags<_CharT, _Traits> __lx(__os);
- __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
- ios_base::scientific);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
return __os << __x.p();
}
@@ -5382,7 +5607,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
typedef geometric_distribution<_IntType> _Eng;
typedef typename _Eng::param_type param_type;
__save_flags<_CharT, _Traits> __lx(__is);
- __is.flags(ios_base::dec | ios_base::skipws);
+ typedef basic_istream<_CharT, _Traits> _Istream;
+ __is.flags(_Istream::dec | _Istream::skipws);
double __p;
__is >> __p;
if (!__is.fail())
@@ -5424,9 +5650,17 @@ private:
public:
// constructor and reset functions
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ chi_squared_distribution() : chi_squared_distribution(1) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit chi_squared_distribution(result_type __n)
+ : __p_(param_type(__n)) {}
+#else
_LIBCPP_INLINE_VISIBILITY
explicit chi_squared_distribution(result_type __n = 1)
: __p_(param_type(__n)) {}
+#endif
_LIBCPP_INLINE_VISIBILITY
explicit chi_squared_distribution(const param_type& __p)
: __p_(__p) {}
@@ -5473,8 +5707,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
const chi_squared_distribution<_RT>& __x)
{
__save_flags<_CharT, _Traits> __lx(__os);
- __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
- ios_base::scientific);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
__os << __x.n();
return __os;
}
@@ -5488,7 +5723,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
typedef typename _Eng::result_type result_type;
typedef typename _Eng::param_type param_type;
__save_flags<_CharT, _Traits> __lx(__is);
- __is.flags(ios_base::dec | ios_base::skipws);
+ typedef basic_istream<_CharT, _Traits> _Istream;
+ __is.flags(_Istream::dec | _Istream::skipws);
result_type __n;
__is >> __n;
if (!__is.fail())
@@ -5534,9 +5770,17 @@ private:
public:
// constructor and reset functions
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ cauchy_distribution() : cauchy_distribution(0) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit cauchy_distribution(result_type __a, result_type __b = 1)
+ : __p_(param_type(__a, __b)) {}
+#else
_LIBCPP_INLINE_VISIBILITY
explicit cauchy_distribution(result_type __a = 0, result_type __b = 1)
: __p_(param_type(__a, __b)) {}
+#endif
_LIBCPP_INLINE_VISIBILITY
explicit cauchy_distribution(const param_type& __p)
: __p_(__p) {}
@@ -5593,8 +5837,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
const cauchy_distribution<_RT>& __x)
{
__save_flags<_CharT, _Traits> __lx(__os);
- __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
- ios_base::scientific);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
_CharT __sp = __os.widen(' ');
__os.fill(__sp);
__os << __x.a() << __sp << __x.b();
@@ -5610,7 +5855,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
typedef typename _Eng::result_type result_type;
typedef typename _Eng::param_type param_type;
__save_flags<_CharT, _Traits> __lx(__is);
- __is.flags(ios_base::dec | ios_base::skipws);
+ typedef basic_istream<_CharT, _Traits> _Istream;
+ __is.flags(_Istream::dec | _Istream::skipws);
result_type __a;
result_type __b;
__is >> __a >> __b;
@@ -5657,9 +5903,17 @@ private:
public:
// constructor and reset functions
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ fisher_f_distribution() : fisher_f_distribution(1) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit fisher_f_distribution(result_type __m, result_type __n = 1)
+ : __p_(param_type(__m, __n)) {}
+#else
_LIBCPP_INLINE_VISIBILITY
explicit fisher_f_distribution(result_type __m = 1, result_type __n = 1)
: __p_(param_type(__m, __n)) {}
+#endif
_LIBCPP_INLINE_VISIBILITY
explicit fisher_f_distribution(const param_type& __p)
: __p_(__p) {}
@@ -5715,8 +5969,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
const fisher_f_distribution<_RT>& __x)
{
__save_flags<_CharT, _Traits> __lx(__os);
- __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
- ios_base::scientific);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
_CharT __sp = __os.widen(' ');
__os.fill(__sp);
__os << __x.m() << __sp << __x.n();
@@ -5732,7 +5987,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
typedef typename _Eng::result_type result_type;
typedef typename _Eng::param_type param_type;
__save_flags<_CharT, _Traits> __lx(__is);
- __is.flags(ios_base::dec | ios_base::skipws);
+ typedef basic_istream<_CharT, _Traits> _Istream;
+ __is.flags(_Istream::dec | _Istream::skipws);
result_type __m;
result_type __n;
__is >> __m >> __n;
@@ -5776,9 +6032,17 @@ private:
public:
// constructor and reset functions
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ student_t_distribution() : student_t_distribution(1) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit student_t_distribution(result_type __n)
+ : __p_(param_type(__n)) {}
+#else
_LIBCPP_INLINE_VISIBILITY
explicit student_t_distribution(result_type __n = 1)
: __p_(param_type(__n)) {}
+#endif
_LIBCPP_INLINE_VISIBILITY
explicit student_t_distribution(const param_type& __p)
: __p_(__p) {}
@@ -5831,8 +6095,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
const student_t_distribution<_RT>& __x)
{
__save_flags<_CharT, _Traits> __lx(__os);
- __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
- ios_base::scientific);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
__os << __x.n();
return __os;
}
@@ -5846,7 +6111,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
typedef typename _Eng::result_type result_type;
typedef typename _Eng::param_type param_type;
__save_flags<_CharT, _Traits> __lx(__is);
- __is.flags(ios_base::dec | ios_base::skipws);
+ typedef basic_istream<_CharT, _Traits> _Istream;
+ __is.flags(_Istream::dec | _Istream::skipws);
result_type __n;
__is >> __n;
if (!__is.fail())
@@ -6054,8 +6320,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
const discrete_distribution<_IT>& __x)
{
__save_flags<_CharT, _Traits> __lx(__os);
- __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
- ios_base::scientific);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
_CharT __sp = __os.widen(' ');
__os.fill(__sp);
size_t __n = __x.__p_.__p_.size();
@@ -6071,7 +6338,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
discrete_distribution<_IT>& __x)
{
__save_flags<_CharT, _Traits> __lx(__is);
- __is.flags(ios_base::dec | ios_base::skipws);
+ typedef basic_istream<_CharT, _Traits> _Istream;
+ __is.flags(_Istream::dec | _Istream::skipws);
size_t __n;
__is >> __n;
vector<double> __p(__n);
@@ -6356,8 +6624,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
const piecewise_constant_distribution<_RT>& __x)
{
__save_flags<_CharT, _Traits> __lx(__os);
- __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
- ios_base::scientific);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
_CharT __sp = __os.widen(' ');
__os.fill(__sp);
size_t __n = __x.__p_.__b_.size();
@@ -6383,7 +6652,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
typedef piecewise_constant_distribution<_RT> _Eng;
typedef typename _Eng::result_type result_type;
__save_flags<_CharT, _Traits> __lx(__is);
- __is.flags(ios_base::dec | ios_base::skipws);
+ typedef basic_istream<_CharT, _Traits> _Istream;
+ __is.flags(_Istream::dec | _Istream::skipws);
size_t __n;
__is >> __n;
vector<result_type> __b(__n);
@@ -6696,8 +6966,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
const piecewise_linear_distribution<_RT>& __x)
{
__save_flags<_CharT, _Traits> __lx(__os);
- __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
- ios_base::scientific);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
_CharT __sp = __os.widen(' ');
__os.fill(__sp);
size_t __n = __x.__p_.__b_.size();
@@ -6723,7 +6994,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
typedef piecewise_linear_distribution<_RT> _Eng;
typedef typename _Eng::result_type result_type;
__save_flags<_CharT, _Traits> __lx(__is);
- __is.flags(ios_base::dec | ios_base::skipws);
+ typedef basic_istream<_CharT, _Traits> _Istream;
+ __is.flags(_Istream::dec | _Istream::skipws);
size_t __n;
__is >> __n;
vector<result_type> __b(__n);
diff --git a/libcxx/include/regex b/libcxx/include/regex
index f42f1ecd16a4..d78e4888a619 100644
--- a/libcxx/include/regex
+++ b/libcxx/include/regex
@@ -32,7 +32,8 @@ enum syntax_option_type
extended = unspecified,
awk = unspecified,
grep = unspecified,
- egrep = unspecified
+ egrep = unspecified,
+ multiline = unspecified
};
constexpr syntax_option_type operator~(syntax_option_type f);
@@ -142,6 +143,7 @@ public:
static constexpr regex_constants::syntax_option_type awk = regex_constants::awk;
static constexpr regex_constants::syntax_option_type grep = regex_constants::grep;
static constexpr regex_constants::syntax_option_type egrep = regex_constants::egrep;
+ static constexpr regex_constants::syntax_option_type multiline = regex_constants::multiline;
// construct/copy/destroy:
basic_regex();
@@ -453,7 +455,9 @@ public:
typedef basic_string<char_type> string_type;
// construct/copy/destroy:
- explicit match_results(const Allocator& a = Allocator());
+ explicit match_results(const Allocator& a = Allocator()); // before C++20
+ match_results() : match_results(Allocator()) {} // C++20
+ explicit match_results(const Allocator& a); // C++20
match_results(const match_results& m);
match_results(match_results&& m) noexcept;
match_results& operator=(const match_results& m);
@@ -802,7 +806,9 @@ enum syntax_option_type
extended = 1 << 5,
awk = 1 << 6,
grep = 1 << 7,
- egrep = 1 << 8
+ egrep = 1 << 8,
+ // 1 << 9 may be used by ECMAScript
+ multiline = 1 << 10
};
inline _LIBCPP_CONSTEXPR
@@ -1982,24 +1988,33 @@ __word_boundary<_CharT, _Traits>::__exec(__state& __s) const
// __l_anchor
template <class _CharT>
-class __l_anchor
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+bool __is_eol(_CharT c)
+{
+ return c == '\r' || c == '\n';
+}
+
+template <class _CharT>
+class __l_anchor_multiline
: public __owns_one_state<_CharT>
{
typedef __owns_one_state<_CharT> base;
+ bool __multiline;
+
public:
typedef _VSTD::__state<_CharT> __state;
_LIBCPP_INLINE_VISIBILITY
- __l_anchor(__node<_CharT>* __s)
- : base(__s) {}
+ __l_anchor_multiline(bool __multiline, __node<_CharT>* __s)
+ : base(__s), __multiline(__multiline) {}
virtual void __exec(__state&) const;
};
template <class _CharT>
void
-__l_anchor<_CharT>::__exec(__state& __s) const
+__l_anchor_multiline<_CharT>::__exec(__state& __s) const
{
if (__s.__at_first_ && __s.__current_ == __s.__first_ &&
!(__s.__flags_ & regex_constants::match_not_bol))
@@ -2007,6 +2022,13 @@ __l_anchor<_CharT>::__exec(__state& __s) const
__s.__do_ = __state::__accept_but_not_consume;
__s.__node_ = this->first();
}
+ else if (__multiline &&
+ !__s.__at_first_ &&
+ __is_eol(*_VSTD::prev(__s.__current_)))
+ {
+ __s.__do_ = __state::__accept_but_not_consume;
+ __s.__node_ = this->first();
+ }
else
{
__s.__do_ = __state::__reject;
@@ -2017,24 +2039,26 @@ __l_anchor<_CharT>::__exec(__state& __s) const
// __r_anchor
template <class _CharT>
-class __r_anchor
+class __r_anchor_multiline
: public __owns_one_state<_CharT>
{
typedef __owns_one_state<_CharT> base;
+ bool __multiline;
+
public:
typedef _VSTD::__state<_CharT> __state;
_LIBCPP_INLINE_VISIBILITY
- __r_anchor(__node<_CharT>* __s)
- : base(__s) {}
+ __r_anchor_multiline(bool __multiline, __node<_CharT>* __s)
+ : base(__s), __multiline(__multiline) {}
virtual void __exec(__state&) const;
};
template <class _CharT>
void
-__r_anchor<_CharT>::__exec(__state& __s) const
+__r_anchor_multiline<_CharT>::__exec(__state& __s) const
{
if (__s.__current_ == __s.__last_ &&
!(__s.__flags_ & regex_constants::match_not_eol))
@@ -2042,6 +2066,11 @@ __r_anchor<_CharT>::__exec(__state& __s) const
__s.__do_ = __state::__accept_but_not_consume;
__s.__node_ = this->first();
}
+ else if (__multiline && __is_eol(*__s.__current_))
+ {
+ __s.__do_ = __state::__accept_but_not_consume;
+ __s.__node_ = this->first();
+ }
else
{
__s.__do_ = __state::__reject;
@@ -2448,7 +2477,7 @@ __bracket_expression<_CharT, _Traits>::__exec(__state& __s) const
{
const bool __in_neg_mask = __traits_.isctype(__ch, __neg_mask_);
const bool __in_neg_chars =
- std::find(__neg_chars_.begin(), __neg_chars_.end(), __ch) !=
+ _VSTD::find(__neg_chars_.begin(), __neg_chars_.end(), __ch) !=
__neg_chars_.end();
if (!(__in_neg_mask || __in_neg_chars))
{
@@ -2507,7 +2536,17 @@ __exit:
template <class _CharT, class _Traits> class __lookahead;
template <class _CharT, class _Traits = regex_traits<_CharT> >
-class _LIBCPP_TEMPLATE_VIS basic_regex
+ class _LIBCPP_TEMPLATE_VIS basic_regex;
+
+typedef basic_regex<char> regex;
+typedef basic_regex<wchar_t> wregex;
+
+template <class _CharT, class _Traits>
+class
+ _LIBCPP_TEMPLATE_VIS
+ _LIBCPP_PREFERRED_NAME(regex)
+ _LIBCPP_PREFERRED_NAME(wregex)
+ basic_regex
{
public:
// types:
@@ -2541,17 +2580,18 @@ public:
static const regex_constants::syntax_option_type awk = regex_constants::awk;
static const regex_constants::syntax_option_type grep = regex_constants::grep;
static const regex_constants::syntax_option_type egrep = regex_constants::egrep;
+ static const regex_constants::syntax_option_type multiline = regex_constants::multiline;
// construct/copy/destroy:
_LIBCPP_INLINE_VISIBILITY
basic_regex()
: __flags_(regex_constants::ECMAScript), __marked_count_(0), __loop_count_(0), __open_count_(0),
- __end_(0)
+ __end_(nullptr)
{}
_LIBCPP_INLINE_VISIBILITY
explicit basic_regex(const value_type* __p, flag_type __f = regex_constants::ECMAScript)
: __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
- __end_(0)
+ __end_(nullptr)
{
__init(__p, __p + __traits_.length(__p));
}
@@ -2559,7 +2599,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
basic_regex(const value_type* __p, size_t __len, flag_type __f = regex_constants::ECMAScript)
: __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
- __end_(0)
+ __end_(nullptr)
{
__init(__p, __p + __len);
}
@@ -2571,7 +2611,7 @@ public:
explicit basic_regex(const basic_string<value_type, _ST, _SA>& __p,
flag_type __f = regex_constants::ECMAScript)
: __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
- __end_(0)
+ __end_(nullptr)
{
__init(__p.begin(), __p.end());
}
@@ -2581,7 +2621,7 @@ public:
basic_regex(_ForwardIterator __first, _ForwardIterator __last,
flag_type __f = regex_constants::ECMAScript)
: __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
- __end_(0)
+ __end_(nullptr)
{
__init(__first, __last);
}
@@ -2590,7 +2630,7 @@ public:
basic_regex(initializer_list<value_type> __il,
flag_type __f = regex_constants::ECMAScript)
: __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
- __end_(0)
+ __end_(nullptr)
{
__init(__il.begin(), __il.end());
}
@@ -2707,6 +2747,12 @@ private:
_LIBCPP_INLINE_VISIBILITY
unsigned __loop_count() const {return __loop_count_;}
+ _LIBCPP_INLINE_VISIBILITY
+ bool __use_multiline() const
+ {
+ return __get_grammar(__flags_) == ECMAScript && (__flags_ & multiline);
+ }
+
template <class _ForwardIterator>
void
__init(_ForwardIterator __first, _ForwardIterator __last);
@@ -4119,7 +4165,7 @@ basic_regex<_CharT, _Traits>::__parse_DUP_COUNT(_ForwardIterator __first,
__first != __last && ( __val = __traits_.value(*__first, 10)) != -1;
++__first)
{
- if (__c >= std::numeric_limits<int>::max() / 10)
+ if (__c >= numeric_limits<int>::max() / 10)
__throw_regex_error<regex_constants::error_badbrace>();
__c *= 10;
__c += __val;
@@ -4383,7 +4429,7 @@ basic_regex<_CharT, _Traits>::__parse_decimal_escape(_ForwardIterator __first,
for (++__first;
__first != __last && '0' <= *__first && *__first <= '9'; ++__first)
{
- if (__v >= std::numeric_limits<unsigned>::max() / 10)
+ if (__v >= numeric_limits<unsigned>::max() / 10)
__throw_regex_error<regex_constants::error_backref>();
__v = 10 * __v + *__first - '0';
}
@@ -4746,7 +4792,7 @@ template <class _CharT, class _Traits>
void
basic_regex<_CharT, _Traits>::__push_l_anchor()
{
- __end_->first() = new __l_anchor<_CharT>(__end_->first());
+ __end_->first() = new __l_anchor_multiline<_CharT>(__use_multiline(), __end_->first());
__end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
}
@@ -4754,7 +4800,7 @@ template <class _CharT, class _Traits>
void
basic_regex<_CharT, _Traits>::__push_r_anchor()
{
- __end_->first() = new __r_anchor<_CharT>(__end_->first());
+ __end_->first() = new __r_anchor_multiline<_CharT>(__use_multiline(), __end_->first());
__end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
}
@@ -4845,13 +4891,21 @@ basic_regex<_CharT, _Traits>::__push_lookahead(const basic_regex& __exp,
__end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
}
-typedef basic_regex<char> regex;
-typedef basic_regex<wchar_t> wregex;
-
// sub_match
+typedef sub_match<const char*> csub_match;
+typedef sub_match<const wchar_t*> wcsub_match;
+typedef sub_match<string::const_iterator> ssub_match;
+typedef sub_match<wstring::const_iterator> wssub_match;
+
template <class _BidirectionalIterator>
-class _LIBCPP_TEMPLATE_VIS sub_match
+class
+ _LIBCPP_TEMPLATE_VIS
+ _LIBCPP_PREFERRED_NAME(csub_match)
+ _LIBCPP_PREFERRED_NAME(wcsub_match)
+ _LIBCPP_PREFERRED_NAME(ssub_match)
+ _LIBCPP_PREFERRED_NAME(wssub_match)
+ sub_match
: public pair<_BidirectionalIterator, _BidirectionalIterator>
{
public:
@@ -4886,11 +4940,6 @@ public:
{return str().compare(__s);}
};
-typedef sub_match<const char*> csub_match;
-typedef sub_match<const wchar_t*> wcsub_match;
-typedef sub_match<string::const_iterator> ssub_match;
-typedef sub_match<wstring::const_iterator> wssub_match;
-
template <class _BiIter>
inline _LIBCPP_INLINE_VISIBILITY
bool
@@ -5273,8 +5322,19 @@ operator<<(basic_ostream<_CharT, _ST>& __os, const sub_match<_BiIter>& __m)
return __os << __m.str();
}
+typedef match_results<const char*> cmatch;
+typedef match_results<const wchar_t*> wcmatch;
+typedef match_results<string::const_iterator> smatch;
+typedef match_results<wstring::const_iterator> wsmatch;
+
template <class _BidirectionalIterator, class _Allocator>
-class _LIBCPP_TEMPLATE_VIS match_results
+class
+ _LIBCPP_TEMPLATE_VIS
+ _LIBCPP_PREFERRED_NAME(cmatch)
+ _LIBCPP_PREFERRED_NAME(wcmatch)
+ _LIBCPP_PREFERRED_NAME(smatch)
+ _LIBCPP_PREFERRED_NAME(wsmatch)
+ match_results
{
public:
typedef _Allocator allocator_type;
@@ -5299,7 +5359,13 @@ public:
typedef basic_string<char_type> string_type;
// construct/copy/destroy:
+#ifndef _LIBCPP_CXX03_LANG
+ match_results() : match_results(allocator_type()) {}
+ explicit match_results(const allocator_type& __a);
+#else
explicit match_results(const allocator_type& __a = allocator_type());
+#endif
+
// match_results(const match_results&) = default;
// match_results& operator=(const match_results&) = default;
// match_results(match_results&& __m) = default;
@@ -5556,7 +5622,7 @@ match_results<_BidirectionalIterator, _Allocator>::format(_OutputIter __output_i
'0' <= __fmt_first[1] && __fmt_first[1] <= '9')
{
++__fmt_first;
- if (__idx >= std::numeric_limits<size_t>::max() / 10)
+ if (__idx >= numeric_limits<size_t>::max() / 10)
__throw_regex_error<regex_constants::error_escape>();
__idx = 10 * __idx + *__fmt_first - '0';
}
@@ -5594,11 +5660,6 @@ match_results<_BidirectionalIterator, _Allocator>::swap(match_results& __m)
swap(__ready_, __m.__ready_);
}
-typedef match_results<const char*> cmatch;
-typedef match_results<const wchar_t*> wcmatch;
-typedef match_results<string::const_iterator> smatch;
-typedef match_results<wstring::const_iterator> wsmatch;
-
template <class _BidirectionalIterator, class _Allocator>
bool
operator==(const match_results<_BidirectionalIterator, _Allocator>& __x,
@@ -6182,7 +6243,21 @@ regex_match(const basic_string<_CharT, _ST, _SA>& __s,
template <class _BidirectionalIterator,
class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type,
class _Traits = regex_traits<_CharT> >
-class _LIBCPP_TEMPLATE_VIS regex_iterator
+ class _LIBCPP_TEMPLATE_VIS regex_iterator;
+
+typedef regex_iterator<const char*> cregex_iterator;
+typedef regex_iterator<const wchar_t*> wcregex_iterator;
+typedef regex_iterator<string::const_iterator> sregex_iterator;
+typedef regex_iterator<wstring::const_iterator> wsregex_iterator;
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+class
+ _LIBCPP_TEMPLATE_VIS
+ _LIBCPP_PREFERRED_NAME(cregex_iterator)
+ _LIBCPP_PREFERRED_NAME(wcregex_iterator)
+ _LIBCPP_PREFERRED_NAME(sregex_iterator)
+ _LIBCPP_PREFERRED_NAME(wsregex_iterator)
+ regex_iterator
{
public:
typedef basic_regex<_CharT, _Traits> regex_type;
@@ -6291,17 +6366,26 @@ regex_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++()
return *this;
}
-typedef regex_iterator<const char*> cregex_iterator;
-typedef regex_iterator<const wchar_t*> wcregex_iterator;
-typedef regex_iterator<string::const_iterator> sregex_iterator;
-typedef regex_iterator<wstring::const_iterator> wsregex_iterator;
-
// regex_token_iterator
template <class _BidirectionalIterator,
class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type,
class _Traits = regex_traits<_CharT> >
-class _LIBCPP_TEMPLATE_VIS regex_token_iterator
+ class _LIBCPP_TEMPLATE_VIS regex_token_iterator;
+
+typedef regex_token_iterator<const char*> cregex_token_iterator;
+typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator;
+typedef regex_token_iterator<string::const_iterator> sregex_token_iterator;
+typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+class
+ _LIBCPP_TEMPLATE_VIS
+ _LIBCPP_PREFERRED_NAME(cregex_token_iterator)
+ _LIBCPP_PREFERRED_NAME(wcregex_token_iterator)
+ _LIBCPP_PREFERRED_NAME(sregex_token_iterator)
+ _LIBCPP_PREFERRED_NAME(wsregex_token_iterator)
+ regex_token_iterator
{
public:
typedef basic_regex<_CharT, _Traits> regex_type;
@@ -6367,7 +6451,7 @@ public:
regex_constants::match_flag_type __m =
regex_constants::match_default);
#if _LIBCPP_STD_VER > 11
- template <std::size_t _Np>
+ template <size_t _Np>
regex_token_iterator(_BidirectionalIterator __a,
_BidirectionalIterator __b,
const regex_type&& __re,
@@ -6579,11 +6663,6 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++()
return *this;
}
-typedef regex_token_iterator<const char*> cregex_token_iterator;
-typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator;
-typedef regex_token_iterator<string::const_iterator> sregex_token_iterator;
-typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
-
// regex_replace
template <class _OutputIterator, class _BidirectionalIterator,
diff --git a/libcxx/include/semaphore b/libcxx/include/semaphore
index 447bc2f385d1..0e0434f7fbd5 100644
--- a/libcxx/include/semaphore
+++ b/libcxx/include/semaphore
@@ -46,9 +46,9 @@ using binary_semaphore = counting_semaphore<1>;
*/
#include <__config>
+#include <__availability>
#include <__threading_support>
#include <atomic>
-#include <cassert>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -58,6 +58,9 @@ using binary_semaphore = counting_semaphore<1>;
# error <semaphore> is not supported on this single threaded system
#endif
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
#if _LIBCPP_STD_VER >= 14
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -68,7 +71,7 @@ __atomic_semaphore_base is the general-case implementation, to be used for
user-requested least-max values that exceed the OS implementation support
(incl. when the OS has no support of its own) and for binary semaphores.
-It is a typical Dijsktra semaphore algorithm over atomics, wait and notify
+It is a typical Dijkstra semaphore algorithm over atomics, wait and notify
functions. It avoids contention against users' own use of those facilities.
*/
@@ -232,4 +235,6 @@ _LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_STD_VER >= 14
+_LIBCPP_POP_MACROS
+
#endif //_LIBCPP_SEMAPHORE
diff --git a/libcxx/include/shared_mutex b/libcxx/include/shared_mutex
index fcafd8c0f44f..5448d8a80715 100644
--- a/libcxx/include/shared_mutex
+++ b/libcxx/include/shared_mutex
@@ -123,6 +123,7 @@ template <class Mutex>
*/
#include <__config>
+#include <__availability>
#include <version>
_LIBCPP_PUSH_MACROS
diff --git a/libcxx/include/span b/libcxx/include/span
index b307c98aee20..4f63d0ac4e1f 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -132,11 +132,14 @@ template<class Container>
#pragma GCC system_header
#endif
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
_LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 17
-inline constexpr size_t dynamic_extent = (numeric_limits<size_t>::max)();
+inline constexpr size_t dynamic_extent = numeric_limits<size_t>::max();
template <typename _Tp, size_t _Extent = dynamic_extent> class span;
@@ -546,4 +549,6 @@ template<class _Container>
_LIBCPP_END_NAMESPACE_STD
+_LIBCPP_POP_MACROS
+
#endif // _LIBCPP_SPAN
diff --git a/libcxx/include/sstream b/libcxx/include/sstream
index 14c91971c2f1..7ce85be6ac32 100644
--- a/libcxx/include/sstream
+++ b/libcxx/include/sstream
@@ -25,8 +25,10 @@ public:
typedef typename traits_type::off_type off_type;
typedef Allocator allocator_type;
- // 27.8.1.1 Constructors:
- explicit basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out);
+ // 27.8.1.1 [stringbuf.cons], constructors:
+ explicit basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out); // before C++20
+ basic_stringbuf() : basic_stringbuf(ios_base::in | ios_base::out) {} // C++20
+ explicit basic_stringbuf(ios_base::openmode which); // C++20
explicit basic_stringbuf(const basic_string<char_type, traits_type, allocator_type>& str,
ios_base::openmode which = ios_base::in | ios_base::out);
basic_stringbuf(basic_stringbuf&& rhs);
@@ -71,7 +73,10 @@ public:
typedef Allocator allocator_type;
// 27.8.2.1 Constructors:
- explicit basic_istringstream(ios_base::openmode which = ios_base::in);
+ explicit basic_istringstream(ios_base::openmode which = ios_base::in); // before C++20
+ basic_istringstream() : basic_istringstream(ios_base::in) {} // C++20
+ explicit basic_istringstream(ios_base::openmode which); // C++20
+
explicit basic_istringstream(const basic_string<char_type, traits_type,allocator_type>& str,
ios_base::openmode which = ios_base::in);
basic_istringstream(basic_istringstream&& rhs);
@@ -107,7 +112,10 @@ public:
typedef Allocator allocator_type;
// 27.8.3.1 Constructors/destructor:
- explicit basic_ostringstream(ios_base::openmode which = ios_base::out);
+ explicit basic_ostringstream(ios_base::openmode which = ios_base::out); // before C++20
+ basic_ostringstream() : basic_ostringstream(ios_base::out) {} // C++20
+ explicit basic_ostringstream(ios_base::openmode which); // C++20
+
explicit basic_ostringstream(const basic_string<char_type, traits_type, allocator_type>& str,
ios_base::openmode which = ios_base::out);
basic_ostringstream(basic_ostringstream&& rhs);
@@ -143,7 +151,10 @@ public:
typedef Allocator allocator_type;
// constructors/destructor
- explicit basic_stringstream(ios_base::openmode which = ios_base::out|ios_base::in);
+ explicit basic_stringstream(ios_base::openmode which = ios_base::out | ios_base::in); // before C++20
+ basic_stringstream() : basic_stringstream(ios_base::out | ios_base::in) {} // C++20
+ explicit basic_stringstream(ios_base::openmode which); // C++20
+
explicit basic_stringstream(const basic_string<char_type, traits_type, allocator_type>& str,
ios_base::openmode which = ios_base::out|ios_base::in);
basic_stringstream(basic_stringstream&& rhs);
@@ -207,18 +218,33 @@ private:
ios_base::openmode __mode_;
public:
- // 27.8.1.1 Constructors:
- inline _LIBCPP_INLINE_VISIBILITY
- explicit basic_stringbuf(ios_base::openmode __wch = ios_base::in | ios_base::out);
- inline _LIBCPP_INLINE_VISIBILITY
- explicit basic_stringbuf(const string_type& __s,
- ios_base::openmode __wch = ios_base::in | ios_base::out);
+ // 30.8.2.1 [stringbuf.cons], constructors
#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ basic_stringbuf() : basic_stringbuf(ios_base::in | ios_base::out) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit basic_stringbuf(ios_base::openmode __wch)
+ : __hm_(nullptr), __mode_(__wch) {}
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ explicit basic_stringbuf(ios_base::openmode __wch = ios_base::in |
+ ios_base::out)
+ : __hm_(nullptr), __mode_(__wch) {}
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit basic_stringbuf(const string_type& __s,
+ ios_base::openmode __wch = ios_base::in | ios_base::out)
+ : __str_(__s.get_allocator()), __hm_(nullptr), __mode_(__wch)
+ {
+ str(__s);
+ }
+
basic_stringbuf(basic_stringbuf&& __rhs);
// 27.8.1.2 Assign and swap:
basic_stringbuf& operator=(basic_stringbuf&& __rhs);
-#endif
void swap(basic_stringbuf& __rhs);
// 27.8.1.3 Get and set:
@@ -232,31 +258,14 @@ protected:
virtual int_type overflow (int_type __c = traits_type::eof());
virtual pos_type seekoff(off_type __off, ios_base::seekdir __way,
ios_base::openmode __wch = ios_base::in | ios_base::out);
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY
virtual pos_type seekpos(pos_type __sp,
- ios_base::openmode __wch = ios_base::in | ios_base::out);
+ ios_base::openmode __wch = ios_base::in | ios_base::out) {
+ return seekoff(__sp, ios_base::beg, __wch);
+ }
};
template <class _CharT, class _Traits, class _Allocator>
-basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(ios_base::openmode __wch)
- : __hm_(0),
- __mode_(__wch)
-{
-}
-
-template <class _CharT, class _Traits, class _Allocator>
-basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(const string_type& __s,
- ios_base::openmode __wch)
- : __str_(__s.get_allocator()),
- __hm_(0),
- __mode_(__wch)
-{
- str(__s);
-}
-
-#ifndef _LIBCPP_CXX03_LANG
-
-template <class _CharT, class _Traits, class _Allocator>
basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(basic_stringbuf&& __rhs)
: __mode_(__rhs.__mode_)
{
@@ -345,8 +354,6 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::operator=(basic_stringbuf&& __rhs)
return *this;
}
-#endif // _LIBCPP_CXX03_LANG
-
template <class _CharT, class _Traits, class _Allocator>
void
basic_stringbuf<_CharT, _Traits, _Allocator>::swap(basic_stringbuf& __rhs)
@@ -453,7 +460,7 @@ void
basic_stringbuf<_CharT, _Traits, _Allocator>::str(const string_type& __s)
{
__str_ = __s;
- __hm_ = 0;
+ __hm_ = nullptr;
if (__mode_ & ios_base::in)
{
__hm_ = const_cast<char_type*>(__str_.data()) + __str_.size();
@@ -600,9 +607,9 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::seekoff(off_type __off,
return pos_type(-1);
if (__noff != 0)
{
- if ((__wch & ios_base::in) && this->gptr() == 0)
+ if ((__wch & ios_base::in) && this->gptr() == nullptr)
return pos_type(-1);
- if ((__wch & ios_base::out) && this->pptr() == 0)
+ if ((__wch & ios_base::out) && this->pptr() == nullptr)
return pos_type(-1);
}
if (__wch & ios_base::in)
@@ -615,14 +622,6 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::seekoff(off_type __off,
return pos_type(__noff);
}
-template <class _CharT, class _Traits, class _Allocator>
-typename basic_stringbuf<_CharT, _Traits, _Allocator>::pos_type
-basic_stringbuf<_CharT, _Traits, _Allocator>::seekpos(pos_type __sp,
- ios_base::openmode __wch)
-{
- return seekoff(__sp, ios_base::beg, __wch);
-}
-
// basic_istringstream
template <class _CharT, class _Traits, class _Allocator>
@@ -643,73 +642,61 @@ private:
basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
public:
- // 27.8.2.1 Constructors:
- inline _LIBCPP_INLINE_VISIBILITY
- explicit basic_istringstream(ios_base::openmode __wch = ios_base::in);
- inline _LIBCPP_INLINE_VISIBILITY
- explicit basic_istringstream(const string_type& __s,
- ios_base::openmode __wch = ios_base::in);
+ // 30.8.3.1 [istringstream.cons], constructors
#ifndef _LIBCPP_CXX03_LANG
- inline _LIBCPP_INLINE_VISIBILITY
- basic_istringstream(basic_istringstream&& __rhs);
-
- // 27.8.2.2 Assign and swap:
- basic_istringstream& operator=(basic_istringstream&& __rhs);
-#endif // _LIBCPP_CXX03_LANG
- inline _LIBCPP_INLINE_VISIBILITY
- void swap(basic_istringstream& __rhs);
-
- // 27.8.2.3 Members:
- inline _LIBCPP_INLINE_VISIBILITY
- basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
- inline _LIBCPP_INLINE_VISIBILITY
- string_type str() const;
- inline _LIBCPP_INLINE_VISIBILITY
- void str(const string_type& __s);
-};
-
-template <class _CharT, class _Traits, class _Allocator>
-basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(ios_base::openmode __wch)
- : basic_istream<_CharT, _Traits>(&__sb_),
- __sb_(__wch | ios_base::in)
-{
-}
-
-template <class _CharT, class _Traits, class _Allocator>
-basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(const string_type& __s,
- ios_base::openmode __wch)
- : basic_istream<_CharT, _Traits>(&__sb_),
- __sb_(__s, __wch | ios_base::in)
-{
-}
+ _LIBCPP_INLINE_VISIBILITY
+ basic_istringstream() : basic_istringstream(ios_base::in) {}
-#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ explicit basic_istringstream(ios_base::openmode __wch)
+ : basic_istream<_CharT, _Traits>(&__sb_), __sb_(__wch | ios_base::in) {}
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ explicit basic_istringstream(ios_base::openmode __wch = ios_base::in)
+ : basic_istream<_CharT, _Traits>(&__sb_), __sb_(__wch | ios_base::in) {}
+#endif
-template <class _CharT, class _Traits, class _Allocator>
-basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(basic_istringstream&& __rhs)
- : basic_istream<_CharT, _Traits>(_VSTD::move(__rhs)),
- __sb_(_VSTD::move(__rhs.__sb_))
-{
- basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
-}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit basic_istringstream(const string_type& __s,
+ ios_base::openmode __wch = ios_base::in)
+ : basic_istream<_CharT, _Traits>(&__sb_)
+ , __sb_(__s, __wch | ios_base::in)
+ { }
-template <class _CharT, class _Traits, class _Allocator>
-basic_istringstream<_CharT, _Traits, _Allocator>&
-basic_istringstream<_CharT, _Traits, _Allocator>::operator=(basic_istringstream&& __rhs)
-{
- basic_istream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
- __sb_ = _VSTD::move(__rhs.__sb_);
- return *this;
-}
+ _LIBCPP_INLINE_VISIBILITY
+ basic_istringstream(basic_istringstream&& __rhs)
+ : basic_istream<_CharT, _Traits>(_VSTD::move(__rhs))
+ , __sb_(_VSTD::move(__rhs.__sb_))
+ {
+ basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
+ }
-#endif // _LIBCPP_CXX03_LANG
+ // 27.8.2.2 Assign and swap:
+ basic_istringstream& operator=(basic_istringstream&& __rhs) {
+ basic_istream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
+ __sb_ = _VSTD::move(__rhs.__sb_);
+ return *this;
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(basic_istringstream& __rhs) {
+ basic_istream<char_type, traits_type>::swap(__rhs);
+ __sb_.swap(__rhs.__sb_);
+ }
-template <class _CharT, class _Traits, class _Allocator>
-void basic_istringstream<_CharT, _Traits, _Allocator>::swap(basic_istringstream& __rhs)
-{
- basic_istream<char_type, traits_type>::swap(__rhs);
- __sb_.swap(__rhs.__sb_);
-}
+ // 27.8.2.3 Members:
+ _LIBCPP_INLINE_VISIBILITY
+ basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const {
+ return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ string_type str() const {
+ return __sb_.str();
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ void str(const string_type& __s) {
+ __sb_.str(__s);
+ }
+};
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
@@ -720,26 +707,6 @@ swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x,
__x.swap(__y);
}
-template <class _CharT, class _Traits, class _Allocator>
-basic_stringbuf<_CharT, _Traits, _Allocator>*
-basic_istringstream<_CharT, _Traits, _Allocator>::rdbuf() const
-{
- return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
-}
-
-template <class _CharT, class _Traits, class _Allocator>
-basic_string<_CharT, _Traits, _Allocator>
-basic_istringstream<_CharT, _Traits, _Allocator>::str() const
-{
- return __sb_.str();
-}
-
-template <class _CharT, class _Traits, class _Allocator>
-void basic_istringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s)
-{
- __sb_.str(__s);
-}
-
// basic_ostringstream
template <class _CharT, class _Traits, class _Allocator>
@@ -760,74 +727,64 @@ private:
basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
public:
- // 27.8.2.1 Constructors:
- inline _LIBCPP_INLINE_VISIBILITY
- explicit basic_ostringstream(ios_base::openmode __wch = ios_base::out);
- inline _LIBCPP_INLINE_VISIBILITY
- explicit basic_ostringstream(const string_type& __s,
- ios_base::openmode __wch = ios_base::out);
+ // 30.8.4.1 [ostringstream.cons], constructors
#ifndef _LIBCPP_CXX03_LANG
- inline _LIBCPP_INLINE_VISIBILITY
- basic_ostringstream(basic_ostringstream&& __rhs);
-
- // 27.8.2.2 Assign and swap:
- basic_ostringstream& operator=(basic_ostringstream&& __rhs);
-#endif // _LIBCPP_CXX03_LANG
- inline _LIBCPP_INLINE_VISIBILITY
- void swap(basic_ostringstream& __rhs);
-
- // 27.8.2.3 Members:
- inline _LIBCPP_INLINE_VISIBILITY
- basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
- inline _LIBCPP_INLINE_VISIBILITY
- string_type str() const;
- inline _LIBCPP_INLINE_VISIBILITY
- void str(const string_type& __s);
-};
+ _LIBCPP_INLINE_VISIBILITY
+ basic_ostringstream() : basic_ostringstream(ios_base::out) {}
-template <class _CharT, class _Traits, class _Allocator>
-basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(ios_base::openmode __wch)
- : basic_ostream<_CharT, _Traits>(&__sb_),
- __sb_(__wch | ios_base::out)
-{
-}
-
-template <class _CharT, class _Traits, class _Allocator>
-basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(const string_type& __s,
- ios_base::openmode __wch)
- : basic_ostream<_CharT, _Traits>(&__sb_),
- __sb_(__s, __wch | ios_base::out)
-{
-}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit basic_ostringstream(ios_base::openmode __wch)
+ : basic_ostream<_CharT, _Traits>(&__sb_),
+ __sb_(__wch | ios_base::out) {}
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ explicit basic_ostringstream(ios_base::openmode __wch = ios_base::out)
+ : basic_ostream<_CharT, _Traits>(&__sb_),
+ __sb_(__wch | ios_base::out) {}
+#endif
-#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ explicit basic_ostringstream(const string_type& __s,
+ ios_base::openmode __wch = ios_base::out)
+ : basic_ostream<_CharT, _Traits>(&__sb_)
+ , __sb_(__s, __wch | ios_base::out)
+ { }
-template <class _CharT, class _Traits, class _Allocator>
-basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(basic_ostringstream&& __rhs)
- : basic_ostream<_CharT, _Traits>(_VSTD::move(__rhs)),
- __sb_(_VSTD::move(__rhs.__sb_))
-{
- basic_ostream<_CharT, _Traits>::set_rdbuf(&__sb_);
-}
+ _LIBCPP_INLINE_VISIBILITY
+ basic_ostringstream(basic_ostringstream&& __rhs)
+ : basic_ostream<_CharT, _Traits>(_VSTD::move(__rhs))
+ , __sb_(_VSTD::move(__rhs.__sb_))
+ {
+ basic_ostream<_CharT, _Traits>::set_rdbuf(&__sb_);
+ }
-template <class _CharT, class _Traits, class _Allocator>
-basic_ostringstream<_CharT, _Traits, _Allocator>&
-basic_ostringstream<_CharT, _Traits, _Allocator>::operator=(basic_ostringstream&& __rhs)
-{
- basic_ostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
- __sb_ = _VSTD::move(__rhs.__sb_);
- return *this;
-}
+ // 27.8.2.2 Assign and swap:
+ basic_ostringstream& operator=(basic_ostringstream&& __rhs) {
+ basic_ostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
+ __sb_ = _VSTD::move(__rhs.__sb_);
+ return *this;
+ }
-#endif // _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(basic_ostringstream& __rhs) {
+ basic_ostream<char_type, traits_type>::swap(__rhs);
+ __sb_.swap(__rhs.__sb_);
+ }
-template <class _CharT, class _Traits, class _Allocator>
-void
-basic_ostringstream<_CharT, _Traits, _Allocator>::swap(basic_ostringstream& __rhs)
-{
- basic_ostream<char_type, traits_type>::swap(__rhs);
- __sb_.swap(__rhs.__sb_);
-}
+ // 27.8.2.3 Members:
+ _LIBCPP_INLINE_VISIBILITY
+ basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const {
+ return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ string_type str() const {
+ return __sb_.str();
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ void str(const string_type& __s) {
+ __sb_.str(__s);
+ }
+};
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
@@ -838,27 +795,6 @@ swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x,
__x.swap(__y);
}
-template <class _CharT, class _Traits, class _Allocator>
-basic_stringbuf<_CharT, _Traits, _Allocator>*
-basic_ostringstream<_CharT, _Traits, _Allocator>::rdbuf() const
-{
- return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
-}
-
-template <class _CharT, class _Traits, class _Allocator>
-basic_string<_CharT, _Traits, _Allocator>
-basic_ostringstream<_CharT, _Traits, _Allocator>::str() const
-{
- return __sb_.str();
-}
-
-template <class _CharT, class _Traits, class _Allocator>
-void
-basic_ostringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s)
-{
- __sb_.str(__s);
-}
-
// basic_stringstream
template <class _CharT, class _Traits, class _Allocator>
@@ -879,74 +815,62 @@ private:
basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
public:
- // 27.8.2.1 Constructors:
- inline _LIBCPP_INLINE_VISIBILITY
- explicit basic_stringstream(ios_base::openmode __wch = ios_base::in | ios_base::out);
- inline _LIBCPP_INLINE_VISIBILITY
- explicit basic_stringstream(const string_type& __s,
- ios_base::openmode __wch = ios_base::in | ios_base::out);
+ // 30.8.5.1 [stringstream.cons], constructors
#ifndef _LIBCPP_CXX03_LANG
- inline _LIBCPP_INLINE_VISIBILITY
- basic_stringstream(basic_stringstream&& __rhs);
-
- // 27.8.2.2 Assign and swap:
- basic_stringstream& operator=(basic_stringstream&& __rhs);
-#endif // _LIBCPP_CXX03_LANG
- inline _LIBCPP_INLINE_VISIBILITY
- void swap(basic_stringstream& __rhs);
-
- // 27.8.2.3 Members:
- inline _LIBCPP_INLINE_VISIBILITY
- basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
- inline _LIBCPP_INLINE_VISIBILITY
- string_type str() const;
- inline _LIBCPP_INLINE_VISIBILITY
- void str(const string_type& __s);
-};
-
-template <class _CharT, class _Traits, class _Allocator>
-basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(ios_base::openmode __wch)
- : basic_iostream<_CharT, _Traits>(&__sb_),
- __sb_(__wch)
-{
-}
+ _LIBCPP_INLINE_VISIBILITY
+ basic_stringstream() : basic_stringstream(ios_base::in | ios_base::out) {}
-template <class _CharT, class _Traits, class _Allocator>
-basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(const string_type& __s,
- ios_base::openmode __wch)
- : basic_iostream<_CharT, _Traits>(&__sb_),
- __sb_(__s, __wch)
-{
-}
-
-#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ explicit basic_stringstream(ios_base::openmode __wch)
+ : basic_iostream<_CharT, _Traits>(&__sb_), __sb_(__wch) {}
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ explicit basic_stringstream(ios_base::openmode __wch = ios_base::in |
+ ios_base::out)
+ : basic_iostream<_CharT, _Traits>(&__sb_), __sb_(__wch) {}
+#endif
-template <class _CharT, class _Traits, class _Allocator>
-basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(basic_stringstream&& __rhs)
- : basic_iostream<_CharT, _Traits>(_VSTD::move(__rhs)),
- __sb_(_VSTD::move(__rhs.__sb_))
-{
- basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
-}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit basic_stringstream(const string_type& __s,
+ ios_base::openmode __wch = ios_base::in | ios_base::out)
+ : basic_iostream<_CharT, _Traits>(&__sb_)
+ , __sb_(__s, __wch)
+ { }
-template <class _CharT, class _Traits, class _Allocator>
-basic_stringstream<_CharT, _Traits, _Allocator>&
-basic_stringstream<_CharT, _Traits, _Allocator>::operator=(basic_stringstream&& __rhs)
-{
- basic_iostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
- __sb_ = _VSTD::move(__rhs.__sb_);
- return *this;
-}
+ _LIBCPP_INLINE_VISIBILITY
+ basic_stringstream(basic_stringstream&& __rhs)
+ : basic_iostream<_CharT, _Traits>(_VSTD::move(__rhs))
+ , __sb_(_VSTD::move(__rhs.__sb_))
+ {
+ basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
+ }
-#endif // _LIBCPP_CXX03_LANG
+ // 27.8.2.2 Assign and swap:
+ basic_stringstream& operator=(basic_stringstream&& __rhs) {
+ basic_iostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
+ __sb_ = _VSTD::move(__rhs.__sb_);
+ return *this;
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(basic_stringstream& __rhs) {
+ basic_iostream<char_type, traits_type>::swap(__rhs);
+ __sb_.swap(__rhs.__sb_);
+ }
-template <class _CharT, class _Traits, class _Allocator>
-void
-basic_stringstream<_CharT, _Traits, _Allocator>::swap(basic_stringstream& __rhs)
-{
- basic_iostream<char_type, traits_type>::swap(__rhs);
- __sb_.swap(__rhs.__sb_);
-}
+ // 27.8.2.3 Members:
+ _LIBCPP_INLINE_VISIBILITY
+ basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const {
+ return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ string_type str() const {
+ return __sb_.str();
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ void str(const string_type& __s) {
+ __sb_.str(__s);
+ }
+};
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
@@ -957,26 +881,12 @@ swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x,
__x.swap(__y);
}
-template <class _CharT, class _Traits, class _Allocator>
-basic_stringbuf<_CharT, _Traits, _Allocator>*
-basic_stringstream<_CharT, _Traits, _Allocator>::rdbuf() const
-{
- return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
-}
-
-template <class _CharT, class _Traits, class _Allocator>
-basic_string<_CharT, _Traits, _Allocator>
-basic_stringstream<_CharT, _Traits, _Allocator>::str() const
-{
- return __sb_.str();
-}
-
-template <class _CharT, class _Traits, class _Allocator>
-void
-basic_stringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s)
-{
- __sb_.str(__s);
-}
+#if defined(_LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1)
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringbuf<char>)
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringstream<char>)
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostringstream<char>)
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istringstream<char>)
+#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/stdexcept b/libcxx/include/stdexcept
index 7a7f36794099..7b5de7ea367c 100644
--- a/libcxx/include/stdexcept
+++ b/libcxx/include/stdexcept
@@ -42,11 +42,9 @@ public:
*/
#include <__config>
+#include <cstdlib>
#include <exception>
#include <iosfwd> // for string forward decl
-#ifdef _LIBCPP_NO_EXCEPTIONS
-#include <cstdlib>
-#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
diff --git a/libcxx/include/streambuf b/libcxx/include/streambuf
index 48c07d5e1f42..0dfa31449b90 100644
--- a/libcxx/include/streambuf
+++ b/libcxx/include/streambuf
@@ -308,12 +308,12 @@ basic_streambuf<_CharT, _Traits>::~basic_streambuf()
template <class _CharT, class _Traits>
basic_streambuf<_CharT, _Traits>::basic_streambuf()
- : __binp_(0),
- __ninp_(0),
- __einp_(0),
- __bout_(0),
- __nout_(0),
- __eout_(0)
+ : __binp_(nullptr),
+ __ninp_(nullptr),
+ __einp_(nullptr),
+ __bout_(nullptr),
+ __nout_(nullptr),
+ __eout_(nullptr)
{
}
@@ -485,13 +485,11 @@ basic_streambuf<_CharT, _Traits>::overflow(int_type)
return traits_type::eof();
}
-#ifndef _LIBCPP_DO_NOT_ASSUME_STREAMS_EXPLICIT_INSTANTIATION_IN_DYLIB
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<char>)
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<wchar_t>)
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<char>)
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<wchar_t>)
-#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/string b/libcxx/include/string
index 2f846eda06c5..687795c79bb9 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -153,7 +153,8 @@ public:
void resize(size_type n, value_type c);
void resize(size_type n);
- void reserve(size_type res_arg = 0);
+ void reserve(size_type res_arg);
+ void reserve(); // deprecated in C++20
void shrink_to_fit();
void clear() noexcept;
bool empty() const noexcept;
@@ -316,12 +317,16 @@ public:
int compare(size_type pos1, size_type n1, const value_type* s) const;
int compare(size_type pos1, size_type n1, const value_type* s, size_type n2) const;
- bool starts_with(basic_string_view<charT, traits> sv) const noexcept; // C++2a
- bool starts_with(charT c) const noexcept; // C++2a
- bool starts_with(const charT* s) const; // C++2a
- bool ends_with(basic_string_view<charT, traits> sv) const noexcept; // C++2a
- bool ends_with(charT c) const noexcept; // C++2a
- bool ends_with(const charT* s) const; // C++2a
+ bool starts_with(basic_string_view<charT, traits> sv) const noexcept; // C++20
+ bool starts_with(charT c) const noexcept; // C++20
+ bool starts_with(const charT* s) const; // C++20
+ bool ends_with(basic_string_view<charT, traits> sv) const noexcept; // C++20
+ bool ends_with(charT c) const noexcept; // C++20
+ bool ends_with(const charT* s) const; // C++20
+
+ constexpr bool contains(basic_string_view<charT, traits> sv) const noexcept; // C++2b
+ constexpr bool contains(charT c) const noexcept; // C++2b
+ constexpr bool contains(const charT* s) const; // C++2b
bool __invariants() const;
};
@@ -448,15 +453,15 @@ typedef basic_string<wchar_t> wstring;
typedef basic_string<char16_t> u16string;
typedef basic_string<char32_t> u32string;
-int stoi (const string& str, size_t* idx = 0, int base = 10);
-long stol (const string& str, size_t* idx = 0, int base = 10);
-unsigned long stoul (const string& str, size_t* idx = 0, int base = 10);
-long long stoll (const string& str, size_t* idx = 0, int base = 10);
-unsigned long long stoull(const string& str, size_t* idx = 0, int base = 10);
+int stoi (const string& str, size_t* idx = nullptr, int base = 10);
+long stol (const string& str, size_t* idx = nullptr, int base = 10);
+unsigned long stoul (const string& str, size_t* idx = nullptr, int base = 10);
+long long stoll (const string& str, size_t* idx = nullptr, int base = 10);
+unsigned long long stoull(const string& str, size_t* idx = nullptr, int base = 10);
-float stof (const string& str, size_t* idx = 0);
-double stod (const string& str, size_t* idx = 0);
-long double stold(const string& str, size_t* idx = 0);
+float stof (const string& str, size_t* idx = nullptr);
+double stod (const string& str, size_t* idx = nullptr);
+long double stold(const string& str, size_t* idx = nullptr);
string to_string(int val);
string to_string(unsigned val);
@@ -468,15 +473,15 @@ string to_string(float val);
string to_string(double val);
string to_string(long double val);
-int stoi (const wstring& str, size_t* idx = 0, int base = 10);
-long stol (const wstring& str, size_t* idx = 0, int base = 10);
-unsigned long stoul (const wstring& str, size_t* idx = 0, int base = 10);
-long long stoll (const wstring& str, size_t* idx = 0, int base = 10);
-unsigned long long stoull(const wstring& str, size_t* idx = 0, int base = 10);
+int stoi (const wstring& str, size_t* idx = nullptr, int base = 10);
+long stol (const wstring& str, size_t* idx = nullptr, int base = 10);
+unsigned long stoul (const wstring& str, size_t* idx = nullptr, int base = 10);
+long long stoll (const wstring& str, size_t* idx = nullptr, int base = 10);
+unsigned long long stoull(const wstring& str, size_t* idx = nullptr, int base = 10);
-float stof (const wstring& str, size_t* idx = 0);
-double stod (const wstring& str, size_t* idx = 0);
-long double stold(const wstring& str, size_t* idx = 0);
+float stof (const wstring& str, size_t* idx = nullptr);
+double stod (const wstring& str, size_t* idx = nullptr);
+long double stold(const wstring& str, size_t* idx = nullptr);
wstring to_wstring(int val);
wstring to_wstring(unsigned val);
@@ -665,8 +670,26 @@ struct __padding<_CharT, 1>
#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+typedef basic_string<char8_t> u8string;
+#endif
+
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+typedef basic_string<char16_t> u16string;
+typedef basic_string<char32_t> u32string;
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+
template<class _CharT, class _Traits, class _Allocator>
-class _LIBCPP_TEMPLATE_VIS basic_string
+class
+ _LIBCPP_TEMPLATE_VIS
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+ _LIBCPP_PREFERRED_NAME(u8string)
+#endif
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ _LIBCPP_PREFERRED_NAME(u16string)
+ _LIBCPP_PREFERRED_NAME(u32string)
+#endif
+ basic_string
: private __basic_string_common<true>
{
public:
@@ -816,7 +839,7 @@ public:
basic_string(const _CharT* __s) : __r_(__default_init_tag(), __default_init_tag()) {
_LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected nullptr");
__init(__s, traits_type::length(__s));
-# if _LIBCPP_DEBUG_LEVEL >= 2
+# if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
# endif
}
@@ -890,7 +913,7 @@ public:
_LIBCPP_INLINE_VISIBILITY basic_string& operator=(const value_type* __s) {return assign(__s);}
basic_string& operator=(value_type __c);
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY
iterator begin() _NOEXCEPT
{return iterator(this, __get_pointer());}
@@ -916,7 +939,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
const_iterator end() const _NOEXCEPT
{return const_iterator(__get_pointer() + size());}
-#endif // _LIBCPP_DEBUG_LEVEL >= 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY
reverse_iterator rbegin() _NOEXCEPT
{return reverse_iterator(end());}
@@ -954,13 +977,13 @@ public:
void resize(size_type __n, value_type __c);
_LIBCPP_INLINE_VISIBILITY void resize(size_type __n) {resize(__n, value_type());}
- void reserve(size_type __res_arg);
+ void reserve(size_type __requested_capacity);
_LIBCPP_INLINE_VISIBILITY void __resize_default_init(size_type __n);
+ _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_INLINE_VISIBILITY
+ void reserve() _NOEXCEPT {shrink_to_fit();}
_LIBCPP_INLINE_VISIBILITY
- void reserve() _NOEXCEPT {reserve(0);}
- _LIBCPP_INLINE_VISIBILITY
- void shrink_to_fit() _NOEXCEPT {reserve();}
+ void shrink_to_fit() _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
void clear() _NOEXCEPT;
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
@@ -1414,22 +1437,38 @@ public:
{ return ends_with(__self_view(__s)); }
#endif
+#if _LIBCPP_STD_VER > 20
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool contains(__self_view __sv) const noexcept
+ { return __self_view(data(), size()).contains(__sv); }
+
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool contains(value_type __c) const noexcept
+ { return __self_view(data(), size()).contains(__c); }
+
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool contains(const value_type* __s) const
+ { return __self_view(data(), size()).contains(__s); }
+#endif
+
_LIBCPP_INLINE_VISIBILITY bool __invariants() const;
_LIBCPP_INLINE_VISIBILITY void __clear_and_shrink() _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY void __shrink_or_extend(size_type __target_capacity);
+
_LIBCPP_INLINE_VISIBILITY
bool __is_long() const _NOEXCEPT
{return bool(__r_.first().__s.__size_ & __short_mask);}
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
bool __dereferenceable(const const_iterator* __i) const;
bool __decrementable(const const_iterator* __i) const;
bool __addable(const const_iterator* __i, ptrdiff_t __n) const;
bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;
-#endif // _LIBCPP_DEBUG_LEVEL >= 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
private:
_LIBCPP_INLINE_VISIBILITY
@@ -1726,21 +1765,21 @@ inline
void
basic_string<_CharT, _Traits, _Allocator>::__invalidate_all_iterators()
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__invalidate_all(this);
-#endif // _LIBCPP_DEBUG_LEVEL >= 2
+#endif
}
template <class _CharT, class _Traits, class _Allocator>
inline
void
basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__pos
#endif
)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__c_node* __c = __get_db()->__find_c_and_lock(this);
if (__c)
{
@@ -1753,12 +1792,12 @@ basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type
{
(*__p)->__c_ = nullptr;
if (--__c->end_ != __p)
- memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
+ _VSTD::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
}
}
__get_db()->unlock();
}
-#endif // _LIBCPP_DEBUG_LEVEL >= 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
}
template <class _CharT, class _Traits, class _Allocator>
@@ -1767,7 +1806,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string()
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
: __r_(__default_init_tag(), __default_init_tag())
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
__zero();
@@ -1783,7 +1822,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __
#endif
: __r_(__default_init_tag(), __a)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
__zero();
@@ -1845,7 +1884,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const
{
_LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*, allocator) detected nullptr");
__init(__s, traits_type::length(__s));
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
}
@@ -1857,7 +1896,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_
{
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n) detected nullptr");
__init(__s, __n);
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
}
@@ -1869,7 +1908,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_
{
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr");
__init(__s, __n);
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
}
@@ -1884,7 +1923,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st
__init_copy_ctor_external(_VSTD::__to_address(__str.__get_long_pointer()),
__str.__get_long_size());
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
}
@@ -1899,7 +1938,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(
else
__init_copy_ctor_external(_VSTD::__to_address(__str.__get_long_pointer()),
__str.__get_long_size());
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
}
@@ -1936,7 +1975,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str)
: __r_(_VSTD::move(__str.__r_))
{
__str.__zero();
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
if (__is_long())
__get_db()->swap(this, &__str);
@@ -1955,7 +1994,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, co
__r_.first().__r = __str.__r_.first().__r;
__str.__zero();
}
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
if (__is_long())
__get_db()->swap(this, &__str);
@@ -1994,7 +2033,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __
: __r_(__default_init_tag(), __default_init_tag())
{
__init(__n, __c);
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
}
@@ -2005,7 +2044,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __
: __r_(__default_init_tag(), __a)
{
__init(__n, __c);
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
}
@@ -2020,7 +2059,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st
if (__pos > __str_sz)
this->__throw_out_of_range();
__init(__str.data() + __pos, _VSTD::min(__n, __str_sz - __pos));
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
}
@@ -2035,7 +2074,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st
if (__pos > __str_sz)
this->__throw_out_of_range();
__init(__str.data() + __pos, __str_sz - __pos);
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
}
@@ -2049,7 +2088,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(
__self_view __sv0 = __t;
__self_view __sv = __sv0.substr(__pos, __n);
__init(__sv.data(), __sv.size());
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
}
@@ -2061,7 +2100,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t)
{
__self_view __sv = __t;
__init(__sv.data(), __sv.size());
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
}
@@ -2073,7 +2112,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t, const _
{
__self_view __sv = __t;
__init(__sv.data(), __sv.size());
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
}
@@ -2141,7 +2180,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first,
: __r_(__default_init_tag(), __default_init_tag())
{
__init(__first, __last);
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
}
@@ -2154,7 +2193,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first,
: __r_(__default_init_tag(), __a)
{
__init(__first, __last);
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
}
@@ -2168,7 +2207,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(
: __r_(__default_init_tag(), __default_init_tag())
{
__init(__il.begin(), __il.end());
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
}
@@ -2181,7 +2220,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(
: __r_(__default_init_tag(), __a)
{
__init(__il.begin(), __il.end());
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
}
@@ -2191,7 +2230,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(
template <class _CharT, class _Traits, class _Allocator>
basic_string<_CharT, _Traits, _Allocator>::~basic_string()
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__erase_c(this);
#endif
if (__is_long())
@@ -2768,7 +2807,7 @@ _EnableIf
>
basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIterator __first, _InputIterator __last)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this,
"string::insert(iterator, range) called with an iterator not"
" referring to this string");
@@ -2787,7 +2826,7 @@ _EnableIf
>
basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this,
"string::insert(iterator, range) called with an iterator not"
" referring to this string");
@@ -2903,7 +2942,7 @@ inline
typename basic_string<_CharT, _Traits, _Allocator>::iterator
basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, size_type __n, value_type __c)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this,
"string::insert(iterator, n, value) called with an iterator not"
" referring to this string");
@@ -3137,7 +3176,7 @@ inline
typename basic_string<_CharT, _Traits, _Allocator>::iterator
basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this,
"string::erase(iterator) called with an iterator not"
" referring to this string");
@@ -3155,7 +3194,7 @@ inline
typename basic_string<_CharT, _Traits, _Allocator>::iterator
basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_iterator __last)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this,
"string::erase(iterator, iterator) called with an iterator not"
" referring to this string");
@@ -3262,65 +3301,88 @@ basic_string<_CharT, _Traits, _Allocator>::max_size() const _NOEXCEPT
template <class _CharT, class _Traits, class _Allocator>
void
-basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __res_arg)
+basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacity)
{
- if (__res_arg > max_size())
+ if (__requested_capacity > max_size())
this->__throw_length_error();
+
+#if _LIBCPP_STD_VER > 17
+ // Reserve never shrinks as of C++20.
+ if (__requested_capacity <= capacity()) return;
+#endif
+
+ size_type __target_capacity = _VSTD::max(__requested_capacity, size());
+ __target_capacity = __recommend(__target_capacity);
+ if (__target_capacity == capacity()) return;
+
+ __shrink_or_extend(__target_capacity);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+void
+basic_string<_CharT, _Traits, _Allocator>::shrink_to_fit() _NOEXCEPT
+{
+ size_type __target_capacity = __recommend(size());
+ if (__target_capacity == capacity()) return;
+
+ __shrink_or_extend(__target_capacity);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+void
+basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target_capacity)
+{
size_type __cap = capacity();
size_type __sz = size();
- __res_arg = _VSTD::max(__res_arg, __sz);
- __res_arg = __recommend(__res_arg);
- if (__res_arg != __cap)
+
+ pointer __new_data, __p;
+ bool __was_long, __now_long;
+ if (__target_capacity == __min_cap - 1)
{
- pointer __new_data, __p;
- bool __was_long, __now_long;
- if (__res_arg == __min_cap - 1)
- {
- __was_long = true;
- __now_long = false;
- __new_data = __get_short_pointer();
- __p = __get_long_pointer();
- }
+ __was_long = true;
+ __now_long = false;
+ __new_data = __get_short_pointer();
+ __p = __get_long_pointer();
+ }
+ else
+ {
+ if (__target_capacity > __cap)
+ __new_data = __alloc_traits::allocate(__alloc(), __target_capacity+1);
else
{
- if (__res_arg > __cap)
- __new_data = __alloc_traits::allocate(__alloc(), __res_arg+1);
- else
+ #ifndef _LIBCPP_NO_EXCEPTIONS
+ try
{
- #ifndef _LIBCPP_NO_EXCEPTIONS
- try
- {
- #endif // _LIBCPP_NO_EXCEPTIONS
- __new_data = __alloc_traits::allocate(__alloc(), __res_arg+1);
- #ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
- return;
- }
- #else // _LIBCPP_NO_EXCEPTIONS
- if (__new_data == nullptr)
- return;
- #endif // _LIBCPP_NO_EXCEPTIONS
+ #endif // _LIBCPP_NO_EXCEPTIONS
+ __new_data = __alloc_traits::allocate(__alloc(), __target_capacity+1);
+ #ifndef _LIBCPP_NO_EXCEPTIONS
}
- __now_long = true;
- __was_long = __is_long();
- __p = __get_pointer();
- }
- traits_type::copy(_VSTD::__to_address(__new_data),
- _VSTD::__to_address(__p), size()+1);
- if (__was_long)
- __alloc_traits::deallocate(__alloc(), __p, __cap+1);
- if (__now_long)
- {
- __set_long_cap(__res_arg+1);
- __set_long_size(__sz);
- __set_long_pointer(__new_data);
+ catch (...)
+ {
+ return;
+ }
+ #else // _LIBCPP_NO_EXCEPTIONS
+ if (__new_data == nullptr)
+ return;
+ #endif // _LIBCPP_NO_EXCEPTIONS
}
- else
- __set_short_size(__sz);
- __invalidate_all_iterators();
+ __now_long = true;
+ __was_long = __is_long();
+ __p = __get_pointer();
}
+ traits_type::copy(_VSTD::__to_address(__new_data),
+ _VSTD::__to_address(__p), size()+1);
+ if (__was_long)
+ __alloc_traits::deallocate(__alloc(), __p, __cap+1);
+ if (__now_long)
+ {
+ __set_long_cap(__target_capacity+1);
+ __set_long_size(__sz);
+ __set_long_pointer(__new_data);
+ }
+ else
+ __set_short_size(__sz);
+ __invalidate_all_iterators();
}
template <class _CharT, class _Traits, class _Allocator>
@@ -3426,7 +3488,7 @@ basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str)
__is_nothrow_swappable<allocator_type>::value)
#endif
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
if (!__is_long())
__get_db()->__invalidate_all(this);
if (!__str.__is_long())
@@ -3438,7 +3500,7 @@ basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str)
__alloc_traits::is_always_equal::value ||
__alloc() == __str.__alloc(), "swapping non-equal allocators");
_VSTD::swap(__r_.first(), __str.__r_.first());
- __swap_allocator(__alloc(), __str.__alloc());
+ _VSTD::__swap_allocator(__alloc(), __str.__alloc());
}
// find
@@ -3939,9 +4001,9 @@ basic_string<_CharT, _Traits, _Allocator>::__invariants() const
return false;
if (capacity() < __min_cap - 1)
return false;
- if (data() == 0)
+ if (data() == nullptr)
return false;
- if (data()[size()] != value_type(0))
+ if (data()[size()] != value_type())
return false;
return true;
}
@@ -3959,6 +4021,7 @@ basic_string<_CharT, _Traits, _Allocator>::__clear_and_shrink() _NOEXCEPT
__alloc_traits::deallocate(__alloc(), __get_long_pointer(), capacity() + 1);
__set_long_cap(0);
__set_short_size(0);
+ traits_type::assign(*__get_short_pointer(), value_type());
}
}
@@ -4300,24 +4363,15 @@ swap(basic_string<_CharT, _Traits, _Allocator>& __lhs,
__lhs.swap(__rhs);
}
-#ifndef _LIBCPP_NO_HAS_CHAR8_T
-typedef basic_string<char8_t> u8string;
-#endif
-
-#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
-typedef basic_string<char16_t> u16string;
-typedef basic_string<char32_t> u32string;
-#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
-
-_LIBCPP_FUNC_VIS int stoi (const string& __str, size_t* __idx = 0, int __base = 10);
-_LIBCPP_FUNC_VIS long stol (const string& __str, size_t* __idx = 0, int __base = 10);
-_LIBCPP_FUNC_VIS unsigned long stoul (const string& __str, size_t* __idx = 0, int __base = 10);
-_LIBCPP_FUNC_VIS long long stoll (const string& __str, size_t* __idx = 0, int __base = 10);
-_LIBCPP_FUNC_VIS unsigned long long stoull(const string& __str, size_t* __idx = 0, int __base = 10);
+_LIBCPP_FUNC_VIS int stoi (const string& __str, size_t* __idx = nullptr, int __base = 10);
+_LIBCPP_FUNC_VIS long stol (const string& __str, size_t* __idx = nullptr, int __base = 10);
+_LIBCPP_FUNC_VIS unsigned long stoul (const string& __str, size_t* __idx = nullptr, int __base = 10);
+_LIBCPP_FUNC_VIS long long stoll (const string& __str, size_t* __idx = nullptr, int __base = 10);
+_LIBCPP_FUNC_VIS unsigned long long stoull(const string& __str, size_t* __idx = nullptr, int __base = 10);
-_LIBCPP_FUNC_VIS float stof (const string& __str, size_t* __idx = 0);
-_LIBCPP_FUNC_VIS double stod (const string& __str, size_t* __idx = 0);
-_LIBCPP_FUNC_VIS long double stold(const string& __str, size_t* __idx = 0);
+_LIBCPP_FUNC_VIS float stof (const string& __str, size_t* __idx = nullptr);
+_LIBCPP_FUNC_VIS double stod (const string& __str, size_t* __idx = nullptr);
+_LIBCPP_FUNC_VIS long double stold(const string& __str, size_t* __idx = nullptr);
_LIBCPP_FUNC_VIS string to_string(int __val);
_LIBCPP_FUNC_VIS string to_string(unsigned __val);
@@ -4329,15 +4383,15 @@ _LIBCPP_FUNC_VIS string to_string(float __val);
_LIBCPP_FUNC_VIS string to_string(double __val);
_LIBCPP_FUNC_VIS string to_string(long double __val);
-_LIBCPP_FUNC_VIS int stoi (const wstring& __str, size_t* __idx = 0, int __base = 10);
-_LIBCPP_FUNC_VIS long stol (const wstring& __str, size_t* __idx = 0, int __base = 10);
-_LIBCPP_FUNC_VIS unsigned long stoul (const wstring& __str, size_t* __idx = 0, int __base = 10);
-_LIBCPP_FUNC_VIS long long stoll (const wstring& __str, size_t* __idx = 0, int __base = 10);
-_LIBCPP_FUNC_VIS unsigned long long stoull(const wstring& __str, size_t* __idx = 0, int __base = 10);
+_LIBCPP_FUNC_VIS int stoi (const wstring& __str, size_t* __idx = nullptr, int __base = 10);
+_LIBCPP_FUNC_VIS long stol (const wstring& __str, size_t* __idx = nullptr, int __base = 10);
+_LIBCPP_FUNC_VIS unsigned long stoul (const wstring& __str, size_t* __idx = nullptr, int __base = 10);
+_LIBCPP_FUNC_VIS long long stoll (const wstring& __str, size_t* __idx = nullptr, int __base = 10);
+_LIBCPP_FUNC_VIS unsigned long long stoull(const wstring& __str, size_t* __idx = nullptr, int __base = 10);
-_LIBCPP_FUNC_VIS float stof (const wstring& __str, size_t* __idx = 0);
-_LIBCPP_FUNC_VIS double stod (const wstring& __str, size_t* __idx = 0);
-_LIBCPP_FUNC_VIS long double stold(const wstring& __str, size_t* __idx = 0);
+_LIBCPP_FUNC_VIS float stof (const wstring& __str, size_t* __idx = nullptr);
+_LIBCPP_FUNC_VIS double stod (const wstring& __str, size_t* __idx = nullptr);
+_LIBCPP_FUNC_VIS long double stold(const wstring& __str, size_t* __idx = nullptr);
_LIBCPP_FUNC_VIS wstring to_wstring(int __val);
_LIBCPP_FUNC_VIS wstring to_wstring(unsigned __val);
@@ -4425,7 +4479,7 @@ inline _LIBCPP_INLINE_VISIBILITY
}
#endif
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
template<class _CharT, class _Traits, class _Allocator>
bool
@@ -4459,7 +4513,7 @@ basic_string<_CharT, _Traits, _Allocator>::__subscriptable(const const_iterator*
return this->data() <= __p && __p < this->data() + this->size();
}
-#endif // _LIBCPP_DEBUG_LEVEL >= 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
#if _LIBCPP_STD_VER > 11
// Literal suffixes for basic_string [basic.string.literals]
diff --git a/libcxx/include/string_view b/libcxx/include/string_view
index 8a684a8f966c..bc0245cf2b5e 100644
--- a/libcxx/include/string_view
+++ b/libcxx/include/string_view
@@ -142,12 +142,16 @@ namespace std {
constexpr size_type find_last_not_of(const charT* s, size_type pos, size_type n) const;
constexpr size_type find_last_not_of(const charT* s, size_type pos = npos) const;
- constexpr bool starts_with(basic_string_view s) const noexcept; // C++2a
- constexpr bool starts_with(charT c) const noexcept; // C++2a
- constexpr bool starts_with(const charT* s) const; // C++2a
- constexpr bool ends_with(basic_string_view s) const noexcept; // C++2a
- constexpr bool ends_with(charT c) const noexcept; // C++2a
- constexpr bool ends_with(const charT* s) const; // C++2a
+ constexpr bool starts_with(basic_string_view s) const noexcept; // C++20
+ constexpr bool starts_with(charT c) const noexcept; // C++20
+ constexpr bool starts_with(const charT* s) const; // C++20
+ constexpr bool ends_with(basic_string_view s) const noexcept; // C++20
+ constexpr bool ends_with(charT c) const noexcept; // C++20
+ constexpr bool ends_with(const charT* s) const; // C++20
+
+ constexpr bool contains(basic_string_view s) const noexcept; // C++2b
+ constexpr bool contains(charT c) const noexcept; // C++2b
+ constexpr bool contains(const charT* s) const; // C++2b
private:
const_pointer data_; // exposition only
@@ -192,7 +196,26 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
template<class _CharT, class _Traits = char_traits<_CharT> >
-class _LIBCPP_TEMPLATE_VIS basic_string_view {
+ class _LIBCPP_TEMPLATE_VIS basic_string_view;
+
+typedef basic_string_view<char> string_view;
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+typedef basic_string_view<char8_t> u8string_view;
+#endif
+typedef basic_string_view<char16_t> u16string_view;
+typedef basic_string_view<char32_t> u32string_view;
+typedef basic_string_view<wchar_t> wstring_view;
+
+template<class _CharT, class _Traits>
+class
+ _LIBCPP_PREFERRED_NAME(string_view)
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+ _LIBCPP_PREFERRED_NAME(u8string_view)
+#endif
+ _LIBCPP_PREFERRED_NAME(u16string_view)
+ _LIBCPP_PREFERRED_NAME(u32string_view)
+ _LIBCPP_PREFERRED_NAME(wstring_view)
+ basic_string_view {
public:
// types
typedef _Traits traits_type;
@@ -236,7 +259,7 @@ public:
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
basic_string_view(const _CharT* __s)
- : __data(__s), __size(std::__char_traits_length_checked<_Traits>(__s)) {}
+ : __data(__s), __size(_VSTD::__char_traits_length_checked<_Traits>(__s)) {}
// [string.view.iterators], iterators
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
@@ -278,7 +301,9 @@ public:
// [string.view.access], element access
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
- const_reference operator[](size_type __pos) const _NOEXCEPT { return __data[__pos]; }
+ const_reference operator[](size_type __pos) const _NOEXCEPT {
+ return _LIBCPP_ASSERT(__pos < size(), "string_view[] index out of bounds"), __data[__pos];
+ }
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
const_reference at(size_type __pos) const
@@ -601,6 +626,20 @@ public:
{ return ends_with(basic_string_view(__s)); }
#endif
+#if _LIBCPP_STD_VER > 20
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool contains(basic_string_view __sv) const noexcept
+ { return find(__sv) != npos; }
+
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool contains(value_type __c) const noexcept
+ { return find(__c) != npos; }
+
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool contains(const value_type* __s) const
+ { return find(__s) != npos; }
+#endif
+
private:
const value_type* __data;
size_type __size;
@@ -774,14 +813,6 @@ basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os,
basic_string_view<_CharT, _Traits> __str);
-typedef basic_string_view<char> string_view;
-#ifndef _LIBCPP_NO_HAS_CHAR8_T
-typedef basic_string_view<char8_t> u8string_view;
-#endif
-typedef basic_string_view<char16_t> u16string_view;
-typedef basic_string_view<char32_t> u32string_view;
-typedef basic_string_view<wchar_t> wstring_view;
-
// [string.view.hash]
template<class _CharT>
struct _LIBCPP_TEMPLATE_VIS hash<basic_string_view<_CharT, char_traits<_CharT> > >
diff --git a/libcxx/include/strstream b/libcxx/include/strstream
index 31999bbae14b..0062777cd437 100644
--- a/libcxx/include/strstream
+++ b/libcxx/include/strstream
@@ -17,14 +17,17 @@ class strstreambuf
: public basic_streambuf<char>
{
public:
- explicit strstreambuf(streamsize alsize_arg = 0);
+ explicit strstreambuf(streamsize alsize_arg = 0); // before C++20
+ strstreambuf() : strstreambuf(0) {} // C++20
+ explicit strstreambuf(streamsize alsize_arg); // C++20
+
strstreambuf(void* (*palloc_arg)(size_t), void (*pfree_arg)(void*));
- strstreambuf(char* gnext_arg, streamsize n, char* pbeg_arg = 0);
+ strstreambuf(char* gnext_arg, streamsize n, char* pbeg_arg = nullptr);
strstreambuf(const char* gnext_arg, streamsize n);
- strstreambuf(signed char* gnext_arg, streamsize n, signed char* pbeg_arg = 0);
+ strstreambuf(signed char* gnext_arg, streamsize n, signed char* pbeg_arg = nullptr);
strstreambuf(const signed char* gnext_arg, streamsize n);
- strstreambuf(unsigned char* gnext_arg, streamsize n, unsigned char* pbeg_arg = 0);
+ strstreambuf(unsigned char* gnext_arg, streamsize n, unsigned char* pbeg_arg = nullptr);
strstreambuf(const unsigned char* gnext_arg, streamsize n);
strstreambuf(strstreambuf&& rhs);
@@ -140,14 +143,19 @@ class _LIBCPP_TYPE_VIS strstreambuf
: public streambuf
{
public:
+#ifndef _LIBCPP_CXX03_LANG
+ strstreambuf() : strstreambuf(0) {}
+ explicit strstreambuf(streamsize __alsize);
+#else
explicit strstreambuf(streamsize __alsize = 0);
+#endif
strstreambuf(void* (*__palloc)(size_t), void (*__pfree)(void*));
- strstreambuf(char* __gnext, streamsize __n, char* __pbeg = 0);
+ strstreambuf(char* __gnext, streamsize __n, char* __pbeg = nullptr);
strstreambuf(const char* __gnext, streamsize __n);
- strstreambuf(signed char* __gnext, streamsize __n, signed char* __pbeg = 0);
+ strstreambuf(signed char* __gnext, streamsize __n, signed char* __pbeg = nullptr);
strstreambuf(const signed char* __gnext, streamsize __n);
- strstreambuf(unsigned char* __gnext, streamsize __n, unsigned char* __pbeg = 0);
+ strstreambuf(unsigned char* __gnext, streamsize __n, unsigned char* __pbeg = nullptr);
strstreambuf(const unsigned char* __gnext, streamsize __n);
#ifndef _LIBCPP_CXX03_LANG
@@ -290,7 +298,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
ostrstream(char* __s, int __n, ios_base::openmode __mode = ios_base::out)
: ostream(&__sb_),
- __sb_(__s, __n, __s + (__mode & ios::app ? strlen(__s) : 0))
+ __sb_(__s, __n, __s + (__mode & ios::app ? _VSTD::strlen(__s) : 0))
{}
#ifndef _LIBCPP_CXX03_LANG
@@ -350,7 +358,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
strstream(char* __s, int __n, ios_base::openmode __mode = ios_base::in | ios_base::out)
: iostream(&__sb_),
- __sb_(__s, __n, __s + (__mode & ios::app ? strlen(__s) : 0))
+ __sb_(__s, __n, __s + (__mode & ios::app ? _VSTD::strlen(__s) : 0))
{}
#ifndef _LIBCPP_CXX03_LANG
diff --git a/libcxx/include/system_error b/libcxx/include/system_error
index 74e889aa9ac7..b714e1d4263d 100644
--- a/libcxx/include/system_error
+++ b/libcxx/include/system_error
@@ -253,7 +253,7 @@ public:
template <class _Ep>
_LIBCPP_INLINE_VISIBILITY
error_condition(_Ep __e,
- typename enable_if<is_error_condition_enum<_Ep>::value>::type* = 0
+ typename enable_if<is_error_condition_enum<_Ep>::value>::type* = nullptr
) _NOEXCEPT
{*this = make_error_condition(__e);}
@@ -325,7 +325,7 @@ public:
template <class _Ep>
_LIBCPP_INLINE_VISIBILITY
error_code(_Ep __e,
- typename enable_if<is_error_code_enum<_Ep>::value>::type* = 0
+ typename enable_if<is_error_code_enum<_Ep>::value>::type* = nullptr
) _NOEXCEPT
{*this = make_error_code(__e);}
diff --git a/libcxx/include/thread b/libcxx/include/thread
index 6eff1800acdb..34e0c2a23916 100644
--- a/libcxx/include/thread
+++ b/libcxx/include/thread
@@ -277,18 +277,18 @@ inline _LIBCPP_INLINE_VISIBILITY
void
__thread_execute(tuple<_TSp, _Fp, _Args...>& __t, __tuple_indices<_Indices...>)
{
- __invoke(_VSTD::move(_VSTD::get<1>(__t)), _VSTD::move(_VSTD::get<_Indices>(__t))...);
+ _VSTD::__invoke(_VSTD::move(_VSTD::get<1>(__t)), _VSTD::move(_VSTD::get<_Indices>(__t))...);
}
template <class _Fp>
_LIBCPP_INLINE_VISIBILITY
void* __thread_proxy(void* __vp)
{
- // _Fp = std::tuple< unique_ptr<__thread_struct>, Functor, Args...>
- std::unique_ptr<_Fp> __p(static_cast<_Fp*>(__vp));
- __thread_local_data().set_pointer(_VSTD::get<0>(*__p).release());
+ // _Fp = tuple< unique_ptr<__thread_struct>, Functor, Args...>
+ unique_ptr<_Fp> __p(static_cast<_Fp*>(__vp));
+ __thread_local_data().set_pointer(_VSTD::get<0>(*__p.get()).release());
typedef typename __make_tuple_indices<tuple_size<_Fp>::value, 2>::type _Index;
- __thread_execute(*__p, _Index());
+ _VSTD::__thread_execute(*__p.get(), _Index());
return nullptr;
}
@@ -300,11 +300,11 @@ thread::thread(_Fp&& __f, _Args&&... __args)
typedef unique_ptr<__thread_struct> _TSPtr;
_TSPtr __tsp(new __thread_struct);
typedef tuple<_TSPtr, typename decay<_Fp>::type, typename decay<_Args>::type...> _Gp;
- _VSTD::unique_ptr<_Gp> __p(
- new _Gp(std::move(__tsp),
- __decay_copy(_VSTD::forward<_Fp>(__f)),
- __decay_copy(_VSTD::forward<_Args>(__args))...));
- int __ec = __libcpp_thread_create(&__t_, &__thread_proxy<_Gp>, __p.get());
+ unique_ptr<_Gp> __p(
+ new _Gp(_VSTD::move(__tsp),
+ _VSTD::__decay_copy(_VSTD::forward<_Fp>(__f)),
+ _VSTD::__decay_copy(_VSTD::forward<_Args>(__args))...));
+ int __ec = _VSTD::__libcpp_thread_create(&__t_, &__thread_proxy<_Gp>, __p.get());
if (__ec == 0)
__p.release();
else
@@ -326,7 +326,7 @@ struct __thread_invoke_pair {
template <class _Fp>
void* __thread_proxy_cxx03(void* __vp)
{
- std::unique_ptr<_Fp> __p(static_cast<_Fp*>(__vp));
+ unique_ptr<_Fp> __p(static_cast<_Fp*>(__vp));
__thread_local_data().set_pointer(__p->__tsp_.release());
(__p->__fn_)();
return nullptr;
@@ -337,9 +337,9 @@ thread::thread(_Fp __f)
{
typedef __thread_invoke_pair<_Fp> _InvokePair;
- typedef std::unique_ptr<_InvokePair> _PairPtr;
+ typedef unique_ptr<_InvokePair> _PairPtr;
_PairPtr __pp(new _InvokePair(__f));
- int __ec = __libcpp_thread_create(&__t_, &__thread_proxy_cxx03<_InvokePair>, __pp.get());
+ int __ec = _VSTD::__libcpp_thread_create(&__t_, &__thread_proxy_cxx03<_InvokePair>, __pp.get());
if (__ec == 0)
__pp.release();
else
@@ -360,25 +360,24 @@ template <class _Rep, class _Period>
void
sleep_for(const chrono::duration<_Rep, _Period>& __d)
{
- using namespace chrono;
- if (__d > duration<_Rep, _Period>::zero())
+ if (__d > chrono::duration<_Rep, _Period>::zero())
{
#if defined(_LIBCPP_COMPILER_GCC) && (__powerpc__ || __POWERPC__)
// GCC's long double const folding is incomplete for IBM128 long doubles.
- _LIBCPP_CONSTEXPR duration<long double> _Max = duration<long double>(ULLONG_MAX/1000000000ULL) ;
+ _LIBCPP_CONSTEXPR chrono::duration<long double> _Max = chrono::duration<long double>(ULLONG_MAX/1000000000ULL) ;
#else
- _LIBCPP_CONSTEXPR duration<long double> _Max = nanoseconds::max();
+ _LIBCPP_CONSTEXPR chrono::duration<long double> _Max = chrono::nanoseconds::max();
#endif
- nanoseconds __ns;
+ chrono::nanoseconds __ns;
if (__d < _Max)
{
- __ns = duration_cast<nanoseconds>(__d);
+ __ns = chrono::duration_cast<chrono::nanoseconds>(__d);
if (__ns < __d)
++__ns;
}
else
- __ns = nanoseconds::max();
- sleep_for(__ns);
+ __ns = chrono::nanoseconds::max();
+ this_thread::sleep_for(__ns);
}
}
@@ -386,7 +385,6 @@ template <class _Clock, class _Duration>
void
sleep_until(const chrono::time_point<_Clock, _Duration>& __t)
{
- using namespace chrono;
mutex __mut;
condition_variable __cv;
unique_lock<mutex> __lk(__mut);
@@ -399,8 +397,7 @@ inline _LIBCPP_INLINE_VISIBILITY
void
sleep_until(const chrono::time_point<chrono::steady_clock, _Duration>& __t)
{
- using namespace chrono;
- sleep_for(__t - steady_clock::now());
+ this_thread::sleep_for(__t - chrono::steady_clock::now());
}
inline _LIBCPP_INLINE_VISIBILITY
diff --git a/libcxx/include/tuple b/libcxx/include/tuple
index 1f80b70759c7..c3c7db5ff118 100644
--- a/libcxx/include/tuple
+++ b/libcxx/include/tuple
@@ -1393,7 +1393,7 @@ struct _LIBCPP_TEMPLATE_VIS uses_allocator<tuple<_Tp...>, _Alloc>
template <class _T1, class _T2>
template <class... _Args1, class... _Args2, size_t ..._I1, size_t ..._I2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
pair<_T1, _T2>::pair(piecewise_construct_t,
tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
__tuple_indices<_I1...>, __tuple_indices<_I2...>)
diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits
index be031037d676..59dfd1e9bae6 100644
--- a/libcxx/include/type_traits
+++ b/libcxx/include/type_traits
@@ -51,6 +51,7 @@ namespace std
template <class T> struct is_arithmetic;
template <class T> struct is_fundamental;
template <class T> struct is_member_pointer;
+ template <class T> struct is_scoped_enum; // C++2b
template <class T> struct is_scalar;
template <class T> struct is_object;
template <class T> struct is_compound;
@@ -284,6 +285,8 @@ namespace std
= is_compound<T>::value; // C++17
template <class T> inline constexpr bool is_member_pointer_v
= is_member_pointer<T>::value; // C++17
+ template <class T> inline constexpr bool is_scoped_enum_v
+ = is_scoped_enum<T>::value; // C++2b
// See C++14 20.10.4.3, type properties
template <class T> inline constexpr bool is_const_v
@@ -514,7 +517,7 @@ template <template <class...> class, class ...>
false_type __sfinae_test_impl(...);
template <template <class ...> class _Templ, class ..._Args>
-using _IsValidExpansion _LIBCPP_NODEBUG_TYPE = decltype(std::__sfinae_test_impl<_Templ, _Args...>(0));
+using _IsValidExpansion _LIBCPP_NODEBUG_TYPE = decltype(__sfinae_test_impl<_Templ, _Args...>(0));
template <class>
struct __void_t { typedef void type; };
@@ -595,75 +598,6 @@ using __is_primary_template = _IsValidExpansion<
__test_for_primary_template, _Tp
>;
-// addressof
-#ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
-
-template <class _Tp>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX14
-_LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
-_Tp*
-addressof(_Tp& __x) _NOEXCEPT
-{
- return __builtin_addressof(__x);
-}
-
-#else
-
-template <class _Tp>
-inline _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
-_Tp*
-addressof(_Tp& __x) _NOEXCEPT
-{
- return reinterpret_cast<_Tp *>(
- const_cast<char *>(&reinterpret_cast<const volatile char &>(__x)));
-}
-
-#endif // _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
-
-#if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF)
-// Objective-C++ Automatic Reference Counting uses qualified pointers
-// that require special addressof() signatures. When
-// _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler
-// itself is providing these definitions. Otherwise, we provide them.
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-__strong _Tp*
-addressof(__strong _Tp& __x) _NOEXCEPT
-{
- return &__x;
-}
-
-#ifdef _LIBCPP_HAS_OBJC_ARC_WEAK
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-__weak _Tp*
-addressof(__weak _Tp& __x) _NOEXCEPT
-{
- return &__x;
-}
-#endif
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-__autoreleasing _Tp*
-addressof(__autoreleasing _Tp& __x) _NOEXCEPT
-{
- return &__x;
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-__unsafe_unretained _Tp*
-addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT
-{
- return &__x;
-}
-#endif
-
-#if !defined(_LIBCPP_CXX03_LANG)
-template <class _Tp> _Tp* addressof(const _Tp&&) noexcept = delete;
-#endif
-
struct __two {char __lx[2];};
// helper class:
@@ -1731,6 +1665,21 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_base_of_v
= is_base_of<_Bp, _Dp>::value;
#endif
+// __is_core_convertible
+
+// [conv.general]/3 says "E is convertible to T" whenever "T t=E;" is well-formed.
+// We can't test for that, but we can test implicit convertibility by passing it
+// to a function. Notice that __is_core_convertible<void,void> is false,
+// and __is_core_convertible<immovable-type,immovable-type> is true in C++17 and later.
+
+template <class _Tp, class _Up, class = void>
+struct __is_core_convertible : public false_type {};
+
+template <class _Tp, class _Up>
+struct __is_core_convertible<_Tp, _Up, decltype(
+ static_cast<void(*)(_Up)>(0) ( static_cast<_Tp(*)()>(0)() )
+)> : public true_type {};
+
// is_convertible
#if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
@@ -1821,7 +1770,7 @@ template <typename _Tp>
static void __test_noexcept(_Tp) noexcept;
template<typename _Fm, typename _To>
-static bool_constant<noexcept(__test_noexcept<_To>(declval<_Fm>()))>
+static bool_constant<noexcept(_VSTD::__test_noexcept<_To>(declval<_Fm>()))>
__is_nothrow_convertible_test();
template <typename _Fm, typename _To>
@@ -2550,7 +2499,7 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_destructible_v = __is_destructible(
// if it's a function, return false
// if it's void, return false
// if it's an array of unknown bound, return false
-// Otherwise, return "std::declval<_Up&>().~_Up()" is well-formed
+// Otherwise, return "declval<_Up&>().~_Up()" is well-formed
// where _Up is remove_all_extents<_Tp>::type
template <class>
@@ -2876,167 +2825,13 @@ struct __member_pointer_class_type<_Ret _ClassType::*> {
typedef _ClassType type;
};
-// result_of
-
-template <class _Callable> class result_of;
-
-#ifdef _LIBCPP_HAS_NO_VARIADICS
-
-template <class _Fn, bool, bool>
-class __result_of
-{
-};
-
-template <class _Fn>
-class __result_of<_Fn(), true, false>
-{
-public:
- typedef decltype(declval<_Fn>()()) type;
-};
-
-template <class _Fn, class _A0>
-class __result_of<_Fn(_A0), true, false>
-{
-public:
- typedef decltype(declval<_Fn>()(declval<_A0>())) type;
-};
-
-template <class _Fn, class _A0, class _A1>
-class __result_of<_Fn(_A0, _A1), true, false>
-{
-public:
- typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type;
-};
-
-template <class _Fn, class _A0, class _A1, class _A2>
-class __result_of<_Fn(_A0, _A1, _A2), true, false>
-{
-public:
- typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type;
-};
-
-template <class _MP, class _Tp, bool _IsMemberFunctionPtr>
-struct __result_of_mp;
-
-// member function pointer
-
-template <class _MP, class _Tp>
-struct __result_of_mp<_MP, _Tp, true>
- : public __identity<typename __member_pointer_traits<_MP>::_ReturnType>
-{
-};
-
-// member data pointer
-
-template <class _MP, class _Tp, bool>
-struct __result_of_mdp;
-
-template <class _Rp, class _Class, class _Tp>
-struct __result_of_mdp<_Rp _Class::*, _Tp, false>
-{
- typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type;
-};
-
-template <class _Rp, class _Class, class _Tp>
-struct __result_of_mdp<_Rp _Class::*, _Tp, true>
-{
- typedef typename __apply_cv<_Tp, _Rp>::type& type;
-};
-
-template <class _Rp, class _Class, class _Tp>
-struct __result_of_mp<_Rp _Class::*, _Tp, false>
- : public __result_of_mdp<_Rp _Class::*, _Tp,
- is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
-{
-};
-
-
-
-template <class _Fn, class _Tp>
-class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer
- : public __result_of_mp<typename remove_reference<_Fn>::type,
- _Tp,
- is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
-{
-};
-
-template <class _Fn, class _Tp, class _A0>
-class __result_of<_Fn(_Tp, _A0), false, true> // _Fn must be member pointer
- : public __result_of_mp<typename remove_reference<_Fn>::type,
- _Tp,
- is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
-{
-};
-
-template <class _Fn, class _Tp, class _A0, class _A1>
-class __result_of<_Fn(_Tp, _A0, _A1), false, true> // _Fn must be member pointer
- : public __result_of_mp<typename remove_reference<_Fn>::type,
- _Tp,
- is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
-{
-};
-
-template <class _Fn, class _Tp, class _A0, class _A1, class _A2>
-class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true> // _Fn must be member pointer
- : public __result_of_mp<typename remove_reference<_Fn>::type,
- _Tp,
- is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
-{
-};
-
-// result_of
-
-template <class _Fn>
-class _LIBCPP_TEMPLATE_VIS result_of<_Fn()>
- : public __result_of<_Fn(),
- is_class<typename remove_reference<_Fn>::type>::value ||
- is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
- is_member_pointer<typename remove_reference<_Fn>::type>::value
- >
-{
-};
-
-template <class _Fn, class _A0>
-class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0)>
- : public __result_of<_Fn(_A0),
- is_class<typename remove_reference<_Fn>::type>::value ||
- is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
- is_member_pointer<typename remove_reference<_Fn>::type>::value
- >
-{
-};
-
-template <class _Fn, class _A0, class _A1>
-class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1)>
- : public __result_of<_Fn(_A0, _A1),
- is_class<typename remove_reference<_Fn>::type>::value ||
- is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
- is_member_pointer<typename remove_reference<_Fn>::type>::value
- >
-{
-};
-
-template <class _Fn, class _A0, class _A1, class _A2>
-class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1, _A2)>
- : public __result_of<_Fn(_A0, _A1, _A2),
- is_class<typename remove_reference<_Fn>::type>::value ||
- is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
- is_member_pointer<typename remove_reference<_Fn>::type>::value
- >
-{
-};
-
-#endif // _LIBCPP_HAS_NO_VARIADICS
-
// template <class T, class... Args> struct is_constructible;
-namespace __is_construct
-{
-struct __nat {};
-}
+#if defined(_LIBCPP_COMPILER_GCC) && _GNUC_VER_NEW >= 10000
+# define _LIBCPP_GCC_SUPPORTS_IS_CONSTRUCTIBLE
+#endif
-#if !defined(_LIBCPP_CXX03_LANG) && (!__has_feature(is_constructible) || \
- defined(_LIBCPP_TESTING_FALLBACK_IS_CONSTRUCTIBLE))
+#if !defined(_LIBCPP_CXX03_LANG) && !__has_feature(is_constructible) && !defined(_LIBCPP_GCC_SUPPORTS_IS_CONSTRUCTIBLE)
template <class _Tp, class... _Args>
struct __libcpp_is_constructible;
@@ -3151,7 +2946,7 @@ struct __libcpp_is_constructible<_Tp&&, _A0>
#endif
-#if __has_feature(is_constructible)
+#if __has_feature(is_constructible) || defined(_LIBCPP_GCC_SUPPORTS_IS_CONSTRUCTIBLE)
template <class _Tp, class ..._Args>
struct _LIBCPP_TEMPLATE_VIS is_constructible
: public integral_constant<bool, __is_constructible(_Tp, _Args...)>
@@ -3442,7 +3237,7 @@ void __implicit_conversion_to(_Tp) noexcept { }
template <class _Tp, class _Arg>
struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg>
- : public integral_constant<bool, noexcept(__implicit_conversion_to<_Tp>(declval<_Arg>()))>
+ : public integral_constant<bool, noexcept(_VSTD::__implicit_conversion_to<_Tp>(declval<_Arg>()))>
{
};
@@ -3807,7 +3602,7 @@ auto __invoke_constexpr(__any, _Args&& ...__args) -> __nat;
template <class _Fp, class _A0, class ..._Args,
class = __enable_if_bullet1<_Fp, _A0>>
inline _LIBCPP_INLINE_VISIBILITY
-auto
+_LIBCPP_CONSTEXPR_AFTER_CXX17 auto
__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
_LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
@@ -3821,7 +3616,7 @@ _LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__a
template <class _Fp, class _A0, class ..._Args,
class = __enable_if_bullet2<_Fp, _A0>>
inline _LIBCPP_INLINE_VISIBILITY
-auto
+_LIBCPP_CONSTEXPR_AFTER_CXX17 auto
__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
_LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
@@ -3835,7 +3630,7 @@ _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
template <class _Fp, class _A0, class ..._Args,
class = __enable_if_bullet3<_Fp, _A0>>
inline _LIBCPP_INLINE_VISIBILITY
-auto
+_LIBCPP_CONSTEXPR_AFTER_CXX17 auto
__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
_LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
@@ -3851,7 +3646,7 @@ _LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(
template <class _Fp, class _A0,
class = __enable_if_bullet4<_Fp, _A0>>
inline _LIBCPP_INLINE_VISIBILITY
-auto
+_LIBCPP_CONSTEXPR_AFTER_CXX17 auto
__invoke(_Fp&& __f, _A0&& __a0)
_LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
@@ -3865,7 +3660,7 @@ _LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
template <class _Fp, class _A0,
class = __enable_if_bullet5<_Fp, _A0>>
inline _LIBCPP_INLINE_VISIBILITY
-auto
+_LIBCPP_CONSTEXPR_AFTER_CXX17 auto
__invoke(_Fp&& __f, _A0&& __a0)
_LIBCPP_INVOKE_RETURN(__a0.get().*__f)
@@ -3879,7 +3674,7 @@ _LIBCPP_INVOKE_RETURN(__a0.get().*__f)
template <class _Fp, class _A0,
class = __enable_if_bullet6<_Fp, _A0>>
inline _LIBCPP_INLINE_VISIBILITY
-auto
+_LIBCPP_CONSTEXPR_AFTER_CXX17 auto
__invoke(_Fp&& __f, _A0&& __a0)
_LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
@@ -3894,7 +3689,7 @@ _LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
template <class _Fp, class ..._Args>
inline _LIBCPP_INLINE_VISIBILITY
-auto
+_LIBCPP_CONSTEXPR_AFTER_CXX17 auto
__invoke(_Fp&& __f, _Args&& ...__args)
_LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
@@ -3982,14 +3777,97 @@ struct __invoke_of
{
};
+#endif // _LIBCPP_CXX03_LANG
+
// result_of
+template <class _Callable> class result_of;
+
+#ifndef _LIBCPP_CXX03_LANG
+
template <class _Fp, class ..._Args>
class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)>
: public __invoke_of<_Fp, _Args...>
{
};
+#else // C++03
+
+template <class _Fn, bool, bool>
+class __result_of
+{
+};
+
+template <class _Fn, class ..._Args>
+class __result_of<_Fn(_Args...), true, false>
+{
+public:
+ typedef decltype(declval<_Fn>()(declval<_Args>()...)) type;
+};
+
+template <class _MP, class _Tp, bool _IsMemberFunctionPtr>
+struct __result_of_mp;
+
+// member function pointer
+
+template <class _MP, class _Tp>
+struct __result_of_mp<_MP, _Tp, true>
+ : public __identity<typename __member_pointer_traits<_MP>::_ReturnType>
+{
+};
+
+// member data pointer
+
+template <class _MP, class _Tp, bool>
+struct __result_of_mdp;
+
+template <class _Rp, class _Class, class _Tp>
+struct __result_of_mdp<_Rp _Class::*, _Tp, false>
+{
+ typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type;
+};
+
+template <class _Rp, class _Class, class _Tp>
+struct __result_of_mdp<_Rp _Class::*, _Tp, true>
+{
+ typedef typename __apply_cv<_Tp, _Rp>::type& type;
+};
+
+template <class _Rp, class _Class, class _Tp>
+struct __result_of_mp<_Rp _Class::*, _Tp, false>
+ : public __result_of_mdp<_Rp _Class::*, _Tp,
+ is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
+{
+};
+
+template <class _Fn, class _Tp>
+class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer
+ : public __result_of_mp<typename remove_reference<_Fn>::type,
+ _Tp,
+ is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
+{
+};
+
+template <class _Fn, class _Tp, class ..._Args>
+class __result_of<_Fn(_Tp, _Args...), false, true> // _Fn must be member pointer
+ : public __result_of_mp<typename remove_reference<_Fn>::type,
+ _Tp,
+ is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
+{
+};
+
+template <class _Fn, class ..._Args>
+class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_Args...)>
+ : public __result_of<_Fn(_Args...),
+ is_class<typename remove_reference<_Fn>::type>::value ||
+ is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
+ is_member_pointer<typename remove_reference<_Fn>::type>::value
+ >
+{
+};
+
+#endif // C++03
+
#if _LIBCPP_STD_VER > 11
template <class _Tp> using result_of_t = typename result_of<_Tp>::type;
#endif
@@ -4045,8 +3923,6 @@ _LIBCPP_INLINE_VAR constexpr bool is_nothrow_invocable_r_v
#endif // _LIBCPP_STD_VER > 14
-#endif // !defined(_LIBCPP_CXX03_LANG)
-
template <class _Tp> struct __is_swappable;
template <class _Tp> struct __is_nothrow_swappable;
@@ -4319,6 +4195,25 @@ struct __has_operator_addressof
#endif // _LIBCPP_CXX03_LANG
+// is_scoped_enum [meta.unary.prop]
+
+#if _LIBCPP_STD_VER > 20
+template <class _Tp, bool = is_enum_v<_Tp> >
+struct __is_scoped_enum_helper : false_type {};
+
+template <class _Tp>
+struct __is_scoped_enum_helper<_Tp, true>
+ : public bool_constant<!is_convertible_v<_Tp, underlying_type_t<_Tp> > > {};
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_scoped_enum
+ : public __is_scoped_enum_helper<_Tp> {};
+
+template <class _Tp>
+_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_scoped_enum_v =
+ is_scoped_enum<_Tp>::value;
+#endif
+
#if _LIBCPP_STD_VER > 14
template <class... _Args>
@@ -4341,7 +4236,6 @@ _LIBCPP_INLINE_VAR constexpr bool negation_v
#endif // _LIBCPP_STD_VER > 14
// These traits are used in __tree and __hash_table
-#ifndef _LIBCPP_CXX03_LANG
struct __extract_key_fail_tag {};
struct __extract_key_self_tag {};
struct __extract_key_first_tag {};
@@ -4353,7 +4247,7 @@ struct __can_extract_key
__extract_key_fail_tag>::type {};
template <class _Pair, class _Key, class _First, class _Second>
-struct __can_extract_key<_Pair, _Key, pair<_First, _Second>>
+struct __can_extract_key<_Pair, _Key, pair<_First, _Second> >
: conditional<_IsSame<typename remove_const<_First>::type, _Key>::value,
__extract_key_first_tag, __extract_key_fail_tag>::type {};
@@ -4371,8 +4265,6 @@ template <class _ValTy, class _Key, class _RawValTy>
struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy>
: false_type {};
-#endif
-
#ifndef _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED
#if _LIBCPP_STD_VER > 17
_LIBCPP_INLINE_VISIBILITY
diff --git a/libcxx/include/typeinfo b/libcxx/include/typeinfo
index 7e76da538796..048e57614aff 100644
--- a/libcxx/include/typeinfo
+++ b/libcxx/include/typeinfo
@@ -57,6 +57,7 @@ public:
*/
#include <__config>
+#include <__availability>
#include <exception>
#include <cstddef>
#include <cstdint>
@@ -141,7 +142,7 @@ public:
// comparison is equal.
// -------------------------------------------------------------------------- //
// NonUniqueARMRTTIBit
-// (selected on ARM64 regardless of _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION)
+// (_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION = 3)
// -------------------------------------------------------------------------- //
// This implementation of type_info does not assume always a unique copy of
// the RTTI for a given type inside a program. It packs the pointer to the
@@ -160,6 +161,24 @@ public:
// the pointer when it constructs the type_info, depending on whether it can
// guarantee uniqueness for that specific type_info.
+// This value can be overriden in the __config_site. When it's not overriden,
+// we pick a default implementation based on the platform here.
+#ifndef _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION
+
+ // Windows binaries can't merge typeinfos, so use the NonUnique implementation.
+# ifdef _LIBCPP_OBJECT_FORMAT_COFF
+# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 2
+
+ // On arm64 on Apple platforms, use the special NonUniqueARMRTTIBit implementation.
+# elif defined(__APPLE__) && defined(__LP64__) && !defined(__x86_64__)
+# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 3
+
+ // On all other platforms, assume the Itanium C++ ABI and use the Unique implementation.
+# else
+# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 1
+# endif
+#endif
+
struct __type_info_implementations {
struct __string_impl_base {
typedef const char* __type_name_t;
@@ -243,7 +262,7 @@ struct __type_info_implementations {
private:
// The unique bit is the top bit. It is expected that __type_name_t is 64 bits when
// this implementation is actually used.
- typedef std::integral_constant<__type_name_t,
+ typedef integral_constant<__type_name_t,
(1ULL << ((__CHAR_BIT__ * sizeof(__type_name_t)) - 1))> __non_unique_rtti_bit;
_LIBCPP_INLINE_VISIBILITY
@@ -257,12 +276,12 @@ struct __type_info_implementations {
};
typedef
-#if defined(__APPLE__) && defined(__LP64__) && !defined(__x86_64__)
- __non_unique_arm_rtti_bit_impl
-#elif _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 1
+#if _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 1
__unique_impl
#elif _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 2
__non_unique_impl
+#elif _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 3
+ __non_unique_arm_rtti_bit_impl
#else
# error invalid configuration for _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION
#endif
diff --git a/libcxx/include/unordered_map b/libcxx/include/unordered_map
index 6156cfddd7bd..d595302e633b 100644
--- a/libcxx/include/unordered_map
+++ b/libcxx/include/unordered_map
@@ -173,10 +173,22 @@ public:
iterator find(const key_type& k);
const_iterator find(const key_type& k) const;
+ template<typename K>
+ iterator find(const K& x); // C++20
+ template<typename K>
+ const_iterator find(const K& x) const; // C++20
size_type count(const key_type& k) const;
+ template<typename K>
+ size_type count(const K& k) const; // C++20
bool contains(const key_type& k) const; // C++20
+ template<typename K>
+ bool contains(const K& k) const; // C++20
pair<iterator, iterator> equal_range(const key_type& k);
pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+ template<typename K>
+ pair<iterator, iterator> equal_range(const K& k); // C++20
+ template<typename K>
+ pair<const_iterator, const_iterator> equal_range(const K& k) const; // C++20
mapped_type& operator[](const key_type& k);
mapped_type& operator[](key_type&& k);
@@ -355,10 +367,22 @@ public:
iterator find(const key_type& k);
const_iterator find(const key_type& k) const;
+ template<typename K>
+ iterator find(const K& x); // C++20
+ template<typename K>
+ const_iterator find(const K& x) const; // C++20
size_type count(const key_type& k) const;
+ template<typename K>
+ size_type count(const K& k) const; // C++20
bool contains(const key_type& k) const; // C++20
+ template<typename K>
+ bool contains(const K& k) const; // C++20
pair<iterator, iterator> equal_range(const key_type& k);
pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+ template<typename K>
+ pair<iterator, iterator> equal_range(const K& k); // C++20
+ template<typename K>
+ pair<const_iterator, const_iterator> equal_range(const K& k) const; // C++20
size_type bucket_count() const noexcept;
size_type max_bucket_count() const noexcept;
@@ -423,7 +447,7 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Key, class _Cp, class _Hash,
+template <class _Key, class _Cp, class _Hash, class _Pred,
bool = is_empty<_Hash>::value && !__libcpp_is_final<_Hash>::value>
class __unordered_map_hasher
: private _Hash
@@ -445,6 +469,12 @@ public:
_LIBCPP_INLINE_VISIBILITY
size_t operator()(const _Key& __x) const
{return static_cast<const _Hash&>(*this)(__x);}
+#if _LIBCPP_STD_VER > 17
+ template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(const _K2& __x) const
+ {return static_cast<const _Hash&>(*this)(__x);}
+#endif
void swap(__unordered_map_hasher&__y)
_NOEXCEPT_(__is_nothrow_swappable<_Hash>::value)
{
@@ -453,8 +483,8 @@ public:
}
};
-template <class _Key, class _Cp, class _Hash>
-class __unordered_map_hasher<_Key, _Cp, _Hash, false>
+template <class _Key, class _Cp, class _Hash, class _Pred>
+class __unordered_map_hasher<_Key, _Cp, _Hash, _Pred, false>
{
_Hash __hash_;
public:
@@ -474,6 +504,12 @@ public:
_LIBCPP_INLINE_VISIBILITY
size_t operator()(const _Key& __x) const
{return __hash_(__x);}
+#if _LIBCPP_STD_VER > 17
+ template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(const _K2& __x) const
+ {return __hash_(__x);}
+#endif
void swap(__unordered_map_hasher&__y)
_NOEXCEPT_(__is_nothrow_swappable<_Hash>::value)
{
@@ -482,17 +518,17 @@ public:
}
};
-template <class _Key, class _Cp, class _Hash, bool __b>
+template <class _Key, class _Cp, class _Hash, class _Pred, bool __b>
inline _LIBCPP_INLINE_VISIBILITY
void
-swap(__unordered_map_hasher<_Key, _Cp, _Hash, __b>& __x,
- __unordered_map_hasher<_Key, _Cp, _Hash, __b>& __y)
+swap(__unordered_map_hasher<_Key, _Cp, _Hash, _Pred, __b>& __x,
+ __unordered_map_hasher<_Key, _Cp, _Hash, _Pred, __b>& __y)
_NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
{
__x.swap(__y);
}
-template <class _Key, class _Cp, class _Pred,
+template <class _Key, class _Cp, class _Pred, class _Hash,
bool = is_empty<_Pred>::value && !__libcpp_is_final<_Pred>::value>
class __unordered_map_equal
: private _Pred
@@ -517,6 +553,24 @@ public:
_LIBCPP_INLINE_VISIBILITY
bool operator()(const _Key& __x, const _Cp& __y) const
{return static_cast<const _Pred&>(*this)(__x, __y.__get_value().first);}
+#if _LIBCPP_STD_VER > 17
+ template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _Cp& __x, const _K2& __y) const
+ {return static_cast<const _Pred&>(*this)(__x.__get_value().first, __y);}
+ template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _K2& __x, const _Cp& __y) const
+ {return static_cast<const _Pred&>(*this)(__x, __y.__get_value().first);}
+ template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _Key& __x, const _K2& __y) const
+ {return static_cast<const _Pred&>(*this)(__x, __y);}
+ template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _K2& __x, const _Key& __y) const
+ {return static_cast<const _Pred&>(*this)(__x, __y);}
+#endif
void swap(__unordered_map_equal&__y)
_NOEXCEPT_(__is_nothrow_swappable<_Pred>::value)
{
@@ -525,8 +579,8 @@ public:
}
};
-template <class _Key, class _Cp, class _Pred>
-class __unordered_map_equal<_Key, _Cp, _Pred, false>
+template <class _Key, class _Cp, class _Pred, class _Hash>
+class __unordered_map_equal<_Key, _Cp, _Pred, _Hash, false>
{
_Pred __pred_;
public:
@@ -549,6 +603,24 @@ public:
_LIBCPP_INLINE_VISIBILITY
bool operator()(const _Key& __x, const _Cp& __y) const
{return __pred_(__x, __y.__get_value().first);}
+#if _LIBCPP_STD_VER > 17
+ template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _Cp& __x, const _K2& __y) const
+ {return __pred_(__x.__get_value().first, __y);}
+ template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _K2& __x, const _Cp& __y) const
+ {return __pred_(__x, __y.__get_value().first);}
+ template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _Key& __x, const _K2& __y) const
+ {return __pred_(__x, __y);}
+ template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _K2& __x, const _Key& __y) const
+ {return __pred_(__x, __y);}
+#endif
void swap(__unordered_map_equal&__y)
_NOEXCEPT_(__is_nothrow_swappable<_Pred>::value)
{
@@ -557,11 +629,11 @@ public:
}
};
-template <class _Key, class _Cp, class _Pred, bool __b>
+template <class _Key, class _Cp, class _Pred, class _Hash, bool __b>
inline _LIBCPP_INLINE_VISIBILITY
void
-swap(__unordered_map_equal<_Key, _Cp, _Pred, __b>& __x,
- __unordered_map_equal<_Key, _Cp, _Pred, __b>& __y)
+swap(__unordered_map_equal<_Key, _Cp, _Pred, _Hash, __b>& __x,
+ __unordered_map_equal<_Key, _Cp, _Pred, _Hash, __b>& __y)
_NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
{
__x.swap(__y);
@@ -858,11 +930,11 @@ public:
"Invalid allocator::value_type");
private:
- typedef __hash_value_type<key_type, mapped_type> __value_type;
- typedef __unordered_map_hasher<key_type, __value_type, hasher> __hasher;
- typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal;
+ typedef __hash_value_type<key_type, mapped_type> __value_type;
+ typedef __unordered_map_hasher<key_type, __value_type, hasher, key_equal> __hasher;
+ typedef __unordered_map_equal<key_type, __value_type, key_equal, hasher> __key_equal;
typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
- __value_type>::type __allocator_type;
+ __value_type>::type __allocator_type;
typedef __hash_table<__value_type, __hasher,
__key_equal, __allocator_type> __table;
@@ -906,7 +978,7 @@ public:
unordered_map()
_NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
}
@@ -1025,7 +1097,7 @@ public:
{return __table_.__insert_unique(__x);}
iterator insert(const_iterator __p, const value_type& __x) {
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
"unordered_map::insert(const_iterator, const value_type&) called with an iterator not"
" referring to this unordered_map");
@@ -1049,7 +1121,7 @@ public:
{return __table_.__insert_unique(_VSTD::move(__x));}
iterator insert(const_iterator __p, value_type&& __x) {
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
"unordered_map::insert(const_iterator, const value_type&) called with an iterator not"
" referring to this unordered_map");
@@ -1070,7 +1142,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
iterator insert(const_iterator __p, _Pp&& __x)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
"unordered_map::insert(const_iterator, value_type&&) called with an iterator not"
" referring to this unordered_map");
@@ -1089,7 +1161,7 @@ public:
template <class... _Args>
_LIBCPP_INLINE_VISIBILITY
iterator emplace_hint(const_iterator __p, _Args&&... __args) {
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
"unordered_map::emplace_hint(const_iterator, args...) called with an iterator not"
" referring to this unordered_map");
@@ -1106,7 +1178,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args)
{
- return __table_.__emplace_unique_key_args(__k, _VSTD::piecewise_construct,
+ return __table_.__emplace_unique_key_args(__k, piecewise_construct,
_VSTD::forward_as_tuple(__k),
_VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
}
@@ -1115,7 +1187,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
pair<iterator, bool> try_emplace(key_type&& __k, _Args&&... __args)
{
- return __table_.__emplace_unique_key_args(__k, _VSTD::piecewise_construct,
+ return __table_.__emplace_unique_key_args(__k, piecewise_construct,
_VSTD::forward_as_tuple(_VSTD::move(__k)),
_VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
}
@@ -1124,7 +1196,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__h) == this,
"unordered_map::try_emplace(const_iterator, key, args...) called with an iterator not"
" referring to this unordered_map");
@@ -1138,7 +1210,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__h) == this,
"unordered_map::try_emplace(const_iterator, key, args...) called with an iterator not"
" referring to this unordered_map");
@@ -1280,11 +1352,34 @@ public:
iterator find(const key_type& __k) {return __table_.find(__k);}
_LIBCPP_INLINE_VISIBILITY
const_iterator find(const key_type& __k) const {return __table_.find(__k);}
+
+ #if _LIBCPP_STD_VER > 17
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, iterator>
+ find(const _K2& __k) {return __table_.find(__k);}
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, const_iterator>
+ find(const _K2& __k) const {return __table_.find(__k);}
+ #endif // _LIBCPP_STD_VER > 17
+
_LIBCPP_INLINE_VISIBILITY
size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
#if _LIBCPP_STD_VER > 17
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, size_type>
+ count(const _K2& __k) const {return __table_.__count_unique(__k);}
+ #endif // _LIBCPP_STD_VER > 17
+ #if _LIBCPP_STD_VER > 17
_LIBCPP_INLINE_VISIBILITY
bool contains(const key_type& __k) const {return find(__k) != end();}
+
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, bool>
+ contains(const _K2& __k) const {return find(__k) != end();}
#endif // _LIBCPP_STD_VER > 17
_LIBCPP_INLINE_VISIBILITY
pair<iterator, iterator> equal_range(const key_type& __k)
@@ -1292,6 +1387,16 @@ public:
_LIBCPP_INLINE_VISIBILITY
pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
{return __table_.__equal_range_unique(__k);}
+ #if _LIBCPP_STD_VER > 17
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<iterator, iterator>>
+ equal_range(const _K2& __k) {return __table_.__equal_range_unique(__k);}
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<const_iterator, const_iterator>>
+ equal_range(const _K2& __k) const {return __table_.__equal_range_unique(__k);}
+ #endif // _LIBCPP_STD_VER > 17
mapped_type& operator[](const key_type& __k);
#ifndef _LIBCPP_CXX03_LANG
@@ -1336,7 +1441,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
void reserve(size_type __n) {__table_.reserve(__n);}
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
bool __dereferenceable(const const_iterator* __i) const
{return __table_.__dereferenceable(&__i->__i_);}
@@ -1347,7 +1452,7 @@ public:
bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
{return __table_.__addable(&__i->__i_, __n);}
-#endif // _LIBCPP_DEBUG_LEVEL >= 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
private:
@@ -1428,7 +1533,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
size_type __n, const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
__table_.rehash(__n);
@@ -1440,7 +1545,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
const allocator_type& __a)
: __table_(__hf, __eql, typename __table::allocator_type(__a))
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
__table_.rehash(__n);
@@ -1452,7 +1557,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
const allocator_type& __a)
: __table_(typename __table::allocator_type(__a))
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
}
@@ -1462,7 +1567,7 @@ template <class _InputIterator>
unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
_InputIterator __first, _InputIterator __last)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
insert(__first, __last);
@@ -1475,7 +1580,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
__table_.rehash(__n);
@@ -1489,7 +1594,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
: __table_(__hf, __eql, typename __table::allocator_type(__a))
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
__table_.rehash(__n);
@@ -1501,7 +1606,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
const unordered_map& __u)
: __table_(__u.__table_)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
__table_.rehash(__u.bucket_count());
@@ -1513,7 +1618,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
const unordered_map& __u, const allocator_type& __a)
: __table_(__u.__table_, typename __table::allocator_type(__a))
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
__table_.rehash(__u.bucket_count());
@@ -1529,7 +1634,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
_NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
: __table_(_VSTD::move(__u.__table_))
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
__get_db()->swap(this, &__u);
#endif
@@ -1540,7 +1645,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
unordered_map&& __u, const allocator_type& __a)
: __table_(_VSTD::move(__u.__table_), typename __table::allocator_type(__a))
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
if (__a != __u.get_allocator())
@@ -1551,7 +1656,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
__u.__table_.remove((__i++).__i_)->__value_.__move());
}
}
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
else
__get_db()->swap(this, &__u);
#endif
@@ -1561,7 +1666,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
initializer_list<value_type> __il)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
insert(__il.begin(), __il.end());
@@ -1573,7 +1678,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
const key_equal& __eql)
: __table_(__hf, __eql)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
__table_.rehash(__n);
@@ -1586,7 +1691,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
const key_equal& __eql, const allocator_type& __a)
: __table_(__hf, __eql, typename __table::allocator_type(__a))
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
__table_.rehash(__n);
@@ -1633,8 +1738,8 @@ _Tp&
unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k)
{
return __table_.__emplace_unique_key_args(__k,
- std::piecewise_construct, std::forward_as_tuple(__k),
- std::forward_as_tuple()).first->__get_value().second;
+ piecewise_construct, _VSTD::forward_as_tuple(__k),
+ _VSTD::forward_as_tuple()).first->__get_value().second;
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
@@ -1642,8 +1747,8 @@ _Tp&
unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](key_type&& __k)
{
return __table_.__emplace_unique_key_args(__k,
- std::piecewise_construct, std::forward_as_tuple(std::move(__k)),
- std::forward_as_tuple()).first->__get_value().second;
+ piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__k)),
+ _VSTD::forward_as_tuple()).first->__get_value().second;
}
#else // _LIBCPP_CXX03_LANG
@@ -1657,7 +1762,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(const
__h.get_deleter().__first_constructed = true;
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.__get_value().second));
__h.get_deleter().__second_constructed = true;
- return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03
+ return __h;
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
@@ -1762,11 +1867,11 @@ public:
"Invalid allocator::value_type");
private:
- typedef __hash_value_type<key_type, mapped_type> __value_type;
- typedef __unordered_map_hasher<key_type, __value_type, hasher> __hasher;
- typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal;
+ typedef __hash_value_type<key_type, mapped_type> __value_type;
+ typedef __unordered_map_hasher<key_type, __value_type, hasher, key_equal> __hasher;
+ typedef __unordered_map_equal<key_type, __value_type, key_equal, hasher> __key_equal;
typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
- __value_type>::type __allocator_type;
+ __value_type>::type __allocator_type;
typedef __hash_table<__value_type, __hasher,
__key_equal, __allocator_type> __table;
@@ -1807,7 +1912,7 @@ public:
unordered_multimap()
_NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
}
@@ -2059,11 +2164,32 @@ public:
iterator find(const key_type& __k) {return __table_.find(__k);}
_LIBCPP_INLINE_VISIBILITY
const_iterator find(const key_type& __k) const {return __table_.find(__k);}
+ #if _LIBCPP_STD_VER > 17
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, iterator>
+ find(const _K2& __k) {return __table_.find(__k);}
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, const_iterator>
+ find(const _K2& __k) const {return __table_.find(__k);}
+ #endif // _LIBCPP_STD_VER > 17
_LIBCPP_INLINE_VISIBILITY
size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
#if _LIBCPP_STD_VER > 17
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, size_type>
+ count(const _K2& __k) const {return __table_.__count_multi(__k);}
+ #endif // _LIBCPP_STD_VER > 17
+ #if _LIBCPP_STD_VER > 17
_LIBCPP_INLINE_VISIBILITY
bool contains(const key_type& __k) const {return find(__k) != end();}
+
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, bool>
+ contains(const _K2& __k) const {return find(__k) != end();}
#endif // _LIBCPP_STD_VER > 17
_LIBCPP_INLINE_VISIBILITY
pair<iterator, iterator> equal_range(const key_type& __k)
@@ -2071,6 +2197,16 @@ public:
_LIBCPP_INLINE_VISIBILITY
pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
{return __table_.__equal_range_multi(__k);}
+ #if _LIBCPP_STD_VER > 17
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<iterator, iterator>>
+ equal_range(const _K2& __k) {return __table_.__equal_range_multi(__k);}
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<const_iterator, const_iterator>>
+ equal_range(const _K2& __k) const {return __table_.__equal_range_multi(__k);}
+ #endif // _LIBCPP_STD_VER > 17
_LIBCPP_INLINE_VISIBILITY
size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
@@ -2108,7 +2244,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
void reserve(size_type __n) {__table_.reserve(__n);}
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
bool __dereferenceable(const const_iterator* __i) const
{return __table_.__dereferenceable(&__i->__i_);}
@@ -2119,7 +2255,7 @@ public:
bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
{return __table_.__addable(&__i->__i_, __n);}
-#endif // _LIBCPP_DEBUG_LEVEL >= 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
};
@@ -2196,7 +2332,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
size_type __n, const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
__table_.rehash(__n);
@@ -2208,7 +2344,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
const allocator_type& __a)
: __table_(__hf, __eql, typename __table::allocator_type(__a))
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
__table_.rehash(__n);
@@ -2219,7 +2355,7 @@ template <class _InputIterator>
unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
_InputIterator __first, _InputIterator __last)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
insert(__first, __last);
@@ -2232,7 +2368,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
__table_.rehash(__n);
@@ -2246,7 +2382,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
: __table_(__hf, __eql, typename __table::allocator_type(__a))
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
__table_.rehash(__n);
@@ -2259,7 +2395,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
const allocator_type& __a)
: __table_(typename __table::allocator_type(__a))
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
}
@@ -2269,7 +2405,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
const unordered_multimap& __u)
: __table_(__u.__table_)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
__table_.rehash(__u.bucket_count());
@@ -2281,7 +2417,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
const unordered_multimap& __u, const allocator_type& __a)
: __table_(__u.__table_, typename __table::allocator_type(__a))
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
__table_.rehash(__u.bucket_count());
@@ -2297,7 +2433,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
_NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
: __table_(_VSTD::move(__u.__table_))
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
__get_db()->swap(this, &__u);
#endif
@@ -2308,7 +2444,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
unordered_multimap&& __u, const allocator_type& __a)
: __table_(_VSTD::move(__u.__table_), typename __table::allocator_type(__a))
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
if (__a != __u.get_allocator())
@@ -2320,7 +2456,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
__u.__table_.remove((__i++).__i_)->__value_.__move());
}
}
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
else
__get_db()->swap(this, &__u);
#endif
@@ -2330,7 +2466,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
initializer_list<value_type> __il)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
insert(__il.begin(), __il.end());
@@ -2342,7 +2478,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
const key_equal& __eql)
: __table_(__hf, __eql)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
__table_.rehash(__n);
@@ -2355,7 +2491,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
const key_equal& __eql, const allocator_type& __a)
: __table_(__hf, __eql, typename __table::allocator_type(__a))
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
__table_.rehash(__n);
diff --git a/libcxx/include/unordered_set b/libcxx/include/unordered_set
index 6c4ad938006f..80f460d7edaa 100644
--- a/libcxx/include/unordered_set
+++ b/libcxx/include/unordered_set
@@ -145,10 +145,22 @@ public:
iterator find(const key_type& k);
const_iterator find(const key_type& k) const;
+ template<typename K>
+ iterator find(const K& x); // C++20
+ template<typename K>
+ const_iterator find(const K& x) const; // C++20
size_type count(const key_type& k) const;
+ template<typename K>
+ size_type count(const K& k) const; // C++20
bool contains(const key_type& k) const; // C++20
+ template<typename K>
+ bool contains(const K& k) const; // C++20
pair<iterator, iterator> equal_range(const key_type& k);
pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+ template<typename K>
+ pair<iterator, iterator> equal_range(const K& k); // C++20
+ template<typename K>
+ pair<const_iterator, const_iterator> equal_range(const K& k) const; // C++20
size_type bucket_count() const noexcept;
size_type max_bucket_count() const noexcept;
@@ -310,10 +322,22 @@ public:
iterator find(const key_type& k);
const_iterator find(const key_type& k) const;
+ template<typename K>
+ iterator find(const K& x); // C++20
+ template<typename K>
+ const_iterator find(const K& x) const; // C++20
size_type count(const key_type& k) const;
+ template<typename K>
+ size_type count(const K& k) const; // C++20
bool contains(const key_type& k) const; // C++20
+ template<typename K>
+ bool contains(const K& k) const; // C++20
pair<iterator, iterator> equal_range(const key_type& k);
pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+ template<typename K>
+ pair<iterator, iterator> equal_range(const K& k); // C++20
+ template<typename K>
+ pair<const_iterator, const_iterator> equal_range(const K& k) const; // C++20
size_type bucket_count() const noexcept;
size_type max_bucket_count() const noexcept;
@@ -425,7 +449,7 @@ public:
unordered_set()
_NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
}
@@ -539,7 +563,7 @@ public:
{return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...);}
template <class... _Args>
_LIBCPP_INLINE_VISIBILITY
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
iterator emplace_hint(const_iterator __p, _Args&&... __args)
{
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
@@ -556,7 +580,7 @@ public:
pair<iterator, bool> insert(value_type&& __x)
{return __table_.__insert_unique(_VSTD::move(__x));}
_LIBCPP_INLINE_VISIBILITY
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
iterator insert(const_iterator __p, value_type&& __x)
{
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
@@ -577,7 +601,7 @@ public:
{return __table_.__insert_unique(__x);}
_LIBCPP_INLINE_VISIBILITY
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
iterator insert(const_iterator __p, const value_type& __x)
{
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
@@ -679,11 +703,32 @@ public:
iterator find(const key_type& __k) {return __table_.find(__k);}
_LIBCPP_INLINE_VISIBILITY
const_iterator find(const key_type& __k) const {return __table_.find(__k);}
+ #if _LIBCPP_STD_VER > 17
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, iterator>
+ find(const _K2& __k) {return __table_.find(__k);}
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, const_iterator>
+ find(const _K2& __k) const {return __table_.find(__k);}
+ #endif // _LIBCPP_STD_VER > 17
_LIBCPP_INLINE_VISIBILITY
size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
#if _LIBCPP_STD_VER > 17
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, size_type>
+ count(const _K2& __k) const {return __table_.__count_unique(__k);}
+ #endif // _LIBCPP_STD_VER > 17
+ #if _LIBCPP_STD_VER > 17
_LIBCPP_INLINE_VISIBILITY
bool contains(const key_type& __k) const {return find(__k) != end();}
+
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, bool>
+ contains(const _K2& __k) const {return find(__k) != end();}
#endif // _LIBCPP_STD_VER > 17
_LIBCPP_INLINE_VISIBILITY
pair<iterator, iterator> equal_range(const key_type& __k)
@@ -691,6 +736,16 @@ public:
_LIBCPP_INLINE_VISIBILITY
pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
{return __table_.__equal_range_unique(__k);}
+ #if _LIBCPP_STD_VER > 17
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<iterator, iterator>>
+ equal_range(const _K2& __k) {return __table_.__equal_range_unique(__k);}
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<const_iterator, const_iterator>>
+ equal_range(const _K2& __k) const {return __table_.__equal_range_unique(__k);}
+ #endif // _LIBCPP_STD_VER > 17
_LIBCPP_INLINE_VISIBILITY
size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
@@ -726,7 +781,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
void reserve(size_type __n) {__table_.reserve(__n);}
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
bool __dereferenceable(const const_iterator* __i) const
{return __table_.__dereferenceable(__i);}
@@ -737,7 +792,7 @@ public:
bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
{return __table_.__addable(__i, __n);}
-#endif // _LIBCPP_DEBUG_LEVEL >= 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
};
@@ -802,7 +857,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n,
const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
__table_.rehash(__n);
@@ -813,7 +868,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n,
const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
__table_.rehash(__n);
@@ -824,7 +879,7 @@ template <class _InputIterator>
unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
_InputIterator __first, _InputIterator __last)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
insert(__first, __last);
@@ -837,7 +892,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
__table_.rehash(__n);
@@ -851,7 +906,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
__table_.rehash(__n);
@@ -864,7 +919,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
const allocator_type& __a)
: __table_(__a)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
}
@@ -874,7 +929,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
const unordered_set& __u)
: __table_(__u.__table_)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
__table_.rehash(__u.bucket_count());
@@ -886,7 +941,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
const unordered_set& __u, const allocator_type& __a)
: __table_(__u.__table_, __a)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
__table_.rehash(__u.bucket_count());
@@ -902,7 +957,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
_NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
: __table_(_VSTD::move(__u.__table_))
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
__get_db()->swap(this, &__u);
#endif
@@ -913,7 +968,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
unordered_set&& __u, const allocator_type& __a)
: __table_(_VSTD::move(__u.__table_), __a)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
if (__a != __u.get_allocator())
@@ -922,7 +977,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
while (__u.size() != 0)
__table_.__insert_unique(_VSTD::move(__u.__table_.remove(__i++)->__value_));
}
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
else
__get_db()->swap(this, &__u);
#endif
@@ -932,7 +987,7 @@ template <class _Value, class _Hash, class _Pred, class _Alloc>
unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
initializer_list<value_type> __il)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
insert(__il.begin(), __il.end());
@@ -944,7 +999,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
const key_equal& __eql)
: __table_(__hf, __eql)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
__table_.rehash(__n);
@@ -957,7 +1012,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
const key_equal& __eql, const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
__table_.rehash(__n);
@@ -1091,7 +1146,7 @@ public:
unordered_multiset()
_NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
}
@@ -1314,11 +1369,32 @@ public:
iterator find(const key_type& __k) {return __table_.find(__k);}
_LIBCPP_INLINE_VISIBILITY
const_iterator find(const key_type& __k) const {return __table_.find(__k);}
+ #if _LIBCPP_STD_VER > 17
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, iterator>
+ find(const _K2& __k) {return __table_.find(__k);}
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, const_iterator>
+ find(const _K2& __k) const {return __table_.find(__k);}
+ #endif // _LIBCPP_STD_VER > 17
_LIBCPP_INLINE_VISIBILITY
size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
#if _LIBCPP_STD_VER > 17
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, size_type>
+ count(const _K2& __k) const {return __table_.__count_multi(__k);}
+ #endif // _LIBCPP_STD_VER > 17
+ #if _LIBCPP_STD_VER > 17
_LIBCPP_INLINE_VISIBILITY
bool contains(const key_type& __k) const {return find(__k) != end();}
+
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, bool>
+ contains(const _K2& __k) const {return find(__k) != end();}
#endif // _LIBCPP_STD_VER > 17
_LIBCPP_INLINE_VISIBILITY
pair<iterator, iterator> equal_range(const key_type& __k)
@@ -1326,6 +1402,16 @@ public:
_LIBCPP_INLINE_VISIBILITY
pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
{return __table_.__equal_range_multi(__k);}
+ #if _LIBCPP_STD_VER > 17
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<iterator, iterator>>
+ equal_range(const _K2& __k) {return __table_.__equal_range_multi(__k);}
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<const_iterator, const_iterator>>
+ equal_range(const _K2& __k) const {return __table_.__equal_range_multi(__k);}
+ #endif // _LIBCPP_STD_VER > 17
_LIBCPP_INLINE_VISIBILITY
size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
@@ -1361,7 +1447,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
void reserve(size_type __n) {__table_.reserve(__n);}
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
bool __dereferenceable(const const_iterator* __i) const
{return __table_.__dereferenceable(__i);}
@@ -1372,7 +1458,7 @@ public:
bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
{return __table_.__addable(__i, __n);}
-#endif // _LIBCPP_DEBUG_LEVEL >= 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
};
@@ -1435,7 +1521,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
size_type __n, const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
__table_.rehash(__n);
@@ -1447,7 +1533,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
__table_.rehash(__n);
@@ -1458,7 +1544,7 @@ template <class _InputIterator>
unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
_InputIterator __first, _InputIterator __last)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
insert(__first, __last);
@@ -1471,7 +1557,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
__table_.rehash(__n);
@@ -1485,7 +1571,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
__table_.rehash(__n);
@@ -1498,7 +1584,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
const allocator_type& __a)
: __table_(__a)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
}
@@ -1508,7 +1594,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
const unordered_multiset& __u)
: __table_(__u.__table_)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
__table_.rehash(__u.bucket_count());
@@ -1520,7 +1606,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
const unordered_multiset& __u, const allocator_type& __a)
: __table_(__u.__table_, __a)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
__table_.rehash(__u.bucket_count());
@@ -1536,7 +1622,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
_NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
: __table_(_VSTD::move(__u.__table_))
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
__get_db()->swap(this, &__u);
#endif
@@ -1547,7 +1633,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
unordered_multiset&& __u, const allocator_type& __a)
: __table_(_VSTD::move(__u.__table_), __a)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
if (__a != __u.get_allocator())
@@ -1556,7 +1642,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
while (__u.size() != 0)
__table_.__insert_multi(_VSTD::move(__u.__table_.remove(__i++)->__value_));
}
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
else
__get_db()->swap(this, &__u);
#endif
@@ -1566,7 +1652,7 @@ template <class _Value, class _Hash, class _Pred, class _Alloc>
unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
initializer_list<value_type> __il)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
insert(__il.begin(), __il.end());
@@ -1578,7 +1664,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
const key_equal& __eql)
: __table_(__hf, __eql)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
__table_.rehash(__n);
@@ -1591,7 +1677,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
const key_equal& __eql, const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
__table_.rehash(__n);
diff --git a/libcxx/include/utility b/libcxx/include/utility
index 7ac322bfe710..6f27af70646b 100644
--- a/libcxx/include/utility
+++ b/libcxx/include/utility
@@ -499,7 +499,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
second(_VSTD::get<1>(_VSTD::forward<_Tuple>(__p))) {}
template <class... _Args1, class... _Args2>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
pair(piecewise_construct_t __pc,
tuple<_Args1...> __first_args, tuple<_Args2...> __second_args)
_NOEXCEPT_((is_nothrow_constructible<first_type, _Args1...>::value &&
@@ -508,7 +508,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
typename __make_tuple_indices<sizeof...(_Args1)>::type(),
typename __make_tuple_indices<sizeof...(_Args2) >::type()) {}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
pair& operator=(typename conditional<
is_copy_assignable<first_type>::value &&
is_copy_assignable<second_type>::value,
@@ -521,7 +521,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
return *this;
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
pair& operator=(typename conditional<
is_move_assignable<first_type>::value &&
is_move_assignable<second_type>::value,
@@ -537,7 +537,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
template <class _Tuple, _EnableB<
_CheckTLC<_Tuple>::template __enable_assign<_Tuple>()
> = false>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
pair& operator=(_Tuple&& __p) {
first = _VSTD::get<0>(_VSTD::forward<_Tuple>(__p));
second = _VSTD::get<1>(_VSTD::forward<_Tuple>(__p));
@@ -545,7 +545,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
}
#endif
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void
swap(pair& __p) _NOEXCEPT_(__is_nothrow_swappable<first_type>::value &&
__is_nothrow_swappable<second_type>::value)
@@ -558,10 +558,10 @@ private:
#ifndef _LIBCPP_CXX03_LANG
template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
- _LIBCPP_INLINE_VISIBILITY
- pair(piecewise_construct_t,
- tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
- __tuple_indices<_I1...>, __tuple_indices<_I2...>);
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ pair(piecewise_construct_t,
+ tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
+ __tuple_indices<_I1...>, __tuple_indices<_I2...>);
#endif
};
@@ -619,7 +619,7 @@ operator<=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
}
template <class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
typename enable_if
<
__is_swappable<_T1>::value &&
@@ -970,7 +970,7 @@ _Size
__loadword(const void* __p)
{
_Size __r;
- std::memcpy(&__r, __p, sizeof(__r));
+ _VSTD::memcpy(&__r, __p, sizeof(__r));
return __r;
}
@@ -1189,7 +1189,7 @@ __murmur2_or_cityhash<_Size, 64>::operator()(const void* __key, _Size __len)
__v = __weak_hash_len_32_with_seeds(__s, __v.second * __k1, __x + __w.first);
__w = __weak_hash_len_32_with_seeds(__s + 32, __z + __w.second,
__y + __loadword<_Size>(__s + 16));
- std::swap(__z, __x);
+ _VSTD::swap(__z, __x);
__s += 64;
__len -= 64;
} while (__len != 0);
@@ -1364,6 +1364,16 @@ struct _LIBCPP_TEMPLATE_VIS hash<unsigned char>
size_t operator()(unsigned char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+template <>
+struct _LIBCPP_TEMPLATE_VIS hash<char8_t>
+ : public unary_function<char8_t, size_t>
+{
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(char8_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
+};
+#endif // !_LIBCPP_NO_HAS_CHAR8_T
+
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
template <>
@@ -1506,7 +1516,7 @@ struct _LIBCPP_TEMPLATE_VIS hash<long double>
// -0.0 and 0.0 should return same hash
if (__v == 0.0L)
return 0;
-#if defined(__i386__)
+#if defined(__i386__) || (defined(__x86_64__) && defined(__ILP32__))
// Zero out padding bits
union
{
@@ -1593,7 +1603,7 @@ using __check_hash_requirements _LIBCPP_NODEBUG_TYPE = integral_constant<bool,
__invokable_r<size_t, _Hash, _Key const&>::value
>;
-template <class _Key, class _Hash = std::hash<_Key> >
+template <class _Key, class _Hash = hash<_Key> >
using __has_enabled_hash _LIBCPP_NODEBUG_TYPE = integral_constant<bool,
__check_hash_requirements<_Key, _Hash>::value &&
is_default_constructible<_Hash>::value
diff --git a/libcxx/include/valarray b/libcxx/include/valarray
index c048a6d7e498..787d8aca2f8e 100644
--- a/libcxx/include/valarray
+++ b/libcxx/include/valarray
@@ -136,6 +136,7 @@ public:
void operator>>=(const valarray<value_type>& v) const;
void operator=(const value_type& x) const;
+ void operator=(const valarray<T>& val_arr) const;
slice_array() = delete;
};
@@ -802,7 +803,7 @@ private:
public:
// construct/destroy:
_LIBCPP_INLINE_VISIBILITY
- valarray() : __begin_(0), __end_(0) {}
+ valarray() : __begin_(nullptr), __end_(nullptr) {}
inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
explicit valarray(size_t __n);
_LIBCPP_INLINE_VISIBILITY
@@ -1264,6 +1265,9 @@ public:
_LIBCPP_INLINE_VISIBILITY
void operator=(const value_type& __x) const;
+ _LIBCPP_INLINE_VISIBILITY
+ void operator=(const valarray<value_type>& __va) const;
+
private:
_LIBCPP_INLINE_VISIBILITY
slice_array(const slice& __sl, const valarray<value_type>& __v)
@@ -1304,6 +1308,15 @@ slice_array<_Tp>::operator=(const _Expr& __v) const
}
template <class _Tp>
+inline void
+slice_array<_Tp>::operator=(const valarray<value_type>& __va) const
+{
+ value_type* __t = __vp_;
+ for (size_t __i = 0; __i < __va.size(); ++__i, __t += __stride_)
+ *__t = __va[__i];
+}
+
+template <class _Tp>
template <class _Expr>
inline
typename enable_if
@@ -2738,11 +2751,9 @@ __val_expr<_ValExpr>::operator valarray<__val_expr::result_type>() const
if (__n)
{
__r.__begin_ =
- __r.__end_ =
- static_cast<result_type*>(
- _VSTD::__libcpp_allocate(__n * sizeof(result_type), _LIBCPP_ALIGNOF(result_type)));
+ __r.__end_ = allocator<result_type>().allocate(__n);
for (size_t __i = 0; __i != __n; ++__r.__end_, ++__i)
- ::new (__r.__end_) result_type(__expr_[__i]);
+ ::new ((void*)__r.__end_) result_type(__expr_[__i]);
}
return __r;
}
@@ -2752,19 +2763,18 @@ __val_expr<_ValExpr>::operator valarray<__val_expr::result_type>() const
template <class _Tp>
inline
valarray<_Tp>::valarray(size_t __n)
- : __begin_(0),
- __end_(0)
+ : __begin_(nullptr),
+ __end_(nullptr)
{
if (__n)
{
- __begin_ = __end_ = static_cast<value_type*>(
- _VSTD::__libcpp_allocate(__n * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)));
+ __begin_ = __end_ = allocator<value_type>().allocate(__n);
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
for (size_t __n_left = __n; __n_left; --__n_left, ++__end_)
- ::new (__end_) value_type();
+ ::new ((void*)__end_) value_type();
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
@@ -2779,27 +2789,26 @@ valarray<_Tp>::valarray(size_t __n)
template <class _Tp>
inline
valarray<_Tp>::valarray(const value_type& __x, size_t __n)
- : __begin_(0),
- __end_(0)
+ : __begin_(nullptr),
+ __end_(nullptr)
{
resize(__n, __x);
}
template <class _Tp>
valarray<_Tp>::valarray(const value_type* __p, size_t __n)
- : __begin_(0),
- __end_(0)
+ : __begin_(nullptr),
+ __end_(nullptr)
{
if (__n)
{
- __begin_ = __end_ = static_cast<value_type*>(
- _VSTD::__libcpp_allocate(__n * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)));
+ __begin_ = __end_ = allocator<value_type>().allocate(__n);
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
for (size_t __n_left = __n; __n_left; ++__end_, ++__p, --__n_left)
- ::new (__end_) value_type(*__p);
+ ::new ((void*)__end_) value_type(*__p);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
@@ -2813,19 +2822,18 @@ valarray<_Tp>::valarray(const value_type* __p, size_t __n)
template <class _Tp>
valarray<_Tp>::valarray(const valarray& __v)
- : __begin_(0),
- __end_(0)
+ : __begin_(nullptr),
+ __end_(nullptr)
{
if (__v.size())
{
- __begin_ = __end_ = static_cast<value_type*>(
- _VSTD::__libcpp_allocate(__v.size() * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)));
+ __begin_ = __end_ = allocator<value_type>().allocate(__v.size());
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
for (value_type* __p = __v.__begin_; __p != __v.__end_; ++__end_, ++__p)
- ::new (__end_) value_type(*__p);
+ ::new ((void*)__end_) value_type(*__p);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
@@ -2850,21 +2858,20 @@ valarray<_Tp>::valarray(valarray&& __v) _NOEXCEPT
template <class _Tp>
valarray<_Tp>::valarray(initializer_list<value_type> __il)
- : __begin_(0),
- __end_(0)
+ : __begin_(nullptr),
+ __end_(nullptr)
{
const size_t __n = __il.size();
if (__n)
{
- __begin_ = __end_ = static_cast<value_type*>(
-_VSTD::__libcpp_allocate(__n * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)));
+ __begin_ = __end_ = allocator<value_type>().allocate(__n);
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
size_t __n_left = __n;
for (const value_type* __p = __il.begin(); __n_left; ++__end_, ++__p, --__n_left)
- ::new (__end_) value_type(*__p);
+ ::new ((void*)__end_) value_type(*__p);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
@@ -2880,21 +2887,20 @@ _VSTD::__libcpp_allocate(__n * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)))
template <class _Tp>
valarray<_Tp>::valarray(const slice_array<value_type>& __sa)
- : __begin_(0),
- __end_(0)
+ : __begin_(nullptr),
+ __end_(nullptr)
{
const size_t __n = __sa.__size_;
if (__n)
{
- __begin_ = __end_ = static_cast<value_type*>(
- _VSTD::__libcpp_allocate(__n * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)));
+ __begin_ = __end_ = allocator<value_type>().allocate(__n);
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
size_t __n_left = __n;
for (const value_type* __p = __sa.__vp_; __n_left; ++__end_, __p += __sa.__stride_, --__n_left)
- ::new (__end_) value_type(*__p);
+ ::new ((void*)__end_) value_type(*__p);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
@@ -2908,14 +2914,13 @@ valarray<_Tp>::valarray(const slice_array<value_type>& __sa)
template <class _Tp>
valarray<_Tp>::valarray(const gslice_array<value_type>& __ga)
- : __begin_(0),
- __end_(0)
+ : __begin_(nullptr),
+ __end_(nullptr)
{
const size_t __n = __ga.__1d_.size();
if (__n)
{
- __begin_ = __end_ = static_cast<value_type*>(
- _VSTD::__libcpp_allocate(__n * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)));
+ __begin_ = __end_ = allocator<value_type>().allocate(__n);
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
@@ -2924,7 +2929,7 @@ valarray<_Tp>::valarray(const gslice_array<value_type>& __ga)
const value_type* __s = __ga.__vp_;
for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_;
__i != __e; ++__i, ++__end_)
- ::new (__end_) value_type(__s[*__i]);
+ ::new ((void*)__end_) value_type(__s[*__i]);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
@@ -2938,14 +2943,13 @@ valarray<_Tp>::valarray(const gslice_array<value_type>& __ga)
template <class _Tp>
valarray<_Tp>::valarray(const mask_array<value_type>& __ma)
- : __begin_(0),
- __end_(0)
+ : __begin_(nullptr),
+ __end_(nullptr)
{
const size_t __n = __ma.__1d_.size();
if (__n)
{
- __begin_ = __end_ = static_cast<value_type*>(
- _VSTD::__libcpp_allocate(__n * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)));
+ __begin_ = __end_ = allocator<value_type>().allocate(__n);
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
@@ -2954,7 +2958,7 @@ valarray<_Tp>::valarray(const mask_array<value_type>& __ma)
const value_type* __s = __ma.__vp_;
for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_;
__i != __e; ++__i, ++__end_)
- ::new (__end_) value_type(__s[*__i]);
+ ::new ((void*)__end_) value_type(__s[*__i]);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
@@ -2968,14 +2972,13 @@ valarray<_Tp>::valarray(const mask_array<value_type>& __ma)
template <class _Tp>
valarray<_Tp>::valarray(const indirect_array<value_type>& __ia)
- : __begin_(0),
- __end_(0)
+ : __begin_(nullptr),
+ __end_(nullptr)
{
const size_t __n = __ia.__1d_.size();
if (__n)
{
- __begin_ = __end_ = static_cast<value_type*>(
- _VSTD::__libcpp_allocate(__n * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)));
+ __begin_ = __end_ = allocator<value_type>().allocate(__n);
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
@@ -2984,7 +2987,7 @@ valarray<_Tp>::valarray(const indirect_array<value_type>& __ia)
const value_type* __s = __ia.__vp_;
for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_;
__i != __e; ++__i, ++__end_)
- ::new (__end_) value_type(__s[*__i]);
+ ::new ((void*)__end_) value_type(__s[*__i]);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
@@ -3011,8 +3014,7 @@ valarray<_Tp>::__assign_range(const value_type* __f, const value_type* __l)
if (size() != __n)
{
__clear(size());
- __begin_ = static_cast<value_type*>(
- _VSTD::__libcpp_allocate(__n * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)));
+ __begin_ = allocator<value_type>().allocate(__n);
__end_ = __begin_ + __n;
_VSTD::uninitialized_copy(__f, __l, __begin_);
} else {
@@ -3265,12 +3267,9 @@ valarray<_Tp>::operator+() const
size_t __n = size();
if (__n)
{
- __r.__begin_ =
- __r.__end_ =
- static_cast<value_type*>(
- _VSTD::__libcpp_allocate(__n * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)));
+ __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
- ::new (__r.__end_) value_type(+*__p);
+ ::new ((void*)__r.__end_) value_type(+*__p);
}
return __r;
}
@@ -3283,12 +3282,9 @@ valarray<_Tp>::operator-() const
size_t __n = size();
if (__n)
{
- __r.__begin_ =
- __r.__end_ =
- static_cast<value_type*>(
- _VSTD::__libcpp_allocate(__n * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)));
+ __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
- ::new (__r.__end_) value_type(-*__p);
+ ::new ((void*)__r.__end_) value_type(-*__p);
}
return __r;
}
@@ -3301,12 +3297,9 @@ valarray<_Tp>::operator~() const
size_t __n = size();
if (__n)
{
- __r.__begin_ =
- __r.__end_ =
- static_cast<value_type*>(
- _VSTD::__libcpp_allocate(__n * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)));
+ __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
- ::new (__r.__end_) value_type(~*__p);
+ ::new ((void*)__r.__end_) value_type(~*__p);
}
return __r;
}
@@ -3319,11 +3312,9 @@ valarray<_Tp>::operator!() const
size_t __n = size();
if (__n)
{
- __r.__begin_ =
- __r.__end_ =
- static_cast<bool*>(_VSTD::__libcpp_allocate(__n * sizeof(bool), _LIBCPP_ALIGNOF(bool)));
+ __r.__begin_ = __r.__end_ = allocator<bool>().allocate(__n);
for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
- ::new (__r.__end_) bool(!*__p);
+ ::new ((void*)__r.__end_) bool(!*__p);
}
return __r;
}
@@ -3639,10 +3630,7 @@ valarray<_Tp>::shift(int __i) const
size_t __n = size();
if (__n)
{
- __r.__begin_ =
- __r.__end_ =
- static_cast<value_type*>(
- _VSTD::__libcpp_allocate(__n * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)));
+ __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
const value_type* __sb;
value_type* __tb;
value_type* __te;
@@ -3661,11 +3649,11 @@ valarray<_Tp>::shift(int __i) const
__te = __r.__begin_ + __n;
}
for (; __r.__end_ != __tb; ++__r.__end_)
- ::new (__r.__end_) value_type();
+ ::new ((void*)__r.__end_) value_type();
for (; __r.__end_ != __te; ++__r.__end_, ++__sb)
- ::new (__r.__end_) value_type(*__sb);
+ ::new ((void*)__r.__end_) value_type(*__sb);
for (__te = __r.__begin_ + __n; __r.__end_ != __te; ++__r.__end_)
- ::new (__r.__end_) value_type();
+ ::new ((void*)__r.__end_) value_type();
}
return __r;
}
@@ -3678,16 +3666,13 @@ valarray<_Tp>::cshift(int __i) const
size_t __n = size();
if (__n)
{
- __r.__begin_ =
- __r.__end_ =
- static_cast<value_type*>(
- _VSTD::__libcpp_allocate(__n * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)));
+ __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
__i %= static_cast<int>(__n);
const value_type* __m = __i >= 0 ? __begin_ + __i : __end_ + __i;
for (const value_type* __s = __m; __s != __end_; ++__r.__end_, ++__s)
- ::new (__r.__end_) value_type(*__s);
+ ::new ((void*)__r.__end_) value_type(*__s);
for (const value_type* __s = __begin_; __s != __m; ++__r.__end_, ++__s)
- ::new (__r.__end_) value_type(*__s);
+ ::new ((void*)__r.__end_) value_type(*__s);
}
return __r;
}
@@ -3700,12 +3685,9 @@ valarray<_Tp>::apply(value_type __f(value_type)) const
size_t __n = size();
if (__n)
{
- __r.__begin_ =
- __r.__end_ =
- static_cast<value_type*>(
- _VSTD::__libcpp_allocate(__n * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)));
+ __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
- ::new (__r.__end_) value_type(__f(*__p));
+ ::new ((void*)__r.__end_) value_type(__f(*__p));
}
return __r;
}
@@ -3718,12 +3700,9 @@ valarray<_Tp>::apply(value_type __f(const value_type&)) const
size_t __n = size();
if (__n)
{
- __r.__begin_ =
- __r.__end_ =
- static_cast<value_type*>(
- _VSTD::__libcpp_allocate(__n * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)));
+ __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
- ::new (__r.__end_) value_type(__f(*__p));
+ ::new ((void*)__r.__end_) value_type(__f(*__p));
}
return __r;
}
@@ -3736,7 +3715,7 @@ void valarray<_Tp>::__clear(size_t __capacity)
{
while (__end_ != __begin_)
(--__end_)->~value_type();
- _VSTD::__libcpp_deallocate(__begin_, __capacity * sizeof(value_type), _LIBCPP_ALIGNOF(value_type));
+ allocator<value_type>().deallocate(__begin_, __capacity);
__begin_ = __end_ = nullptr;
}
}
@@ -3748,14 +3727,13 @@ valarray<_Tp>::resize(size_t __n, value_type __x)
__clear(size());
if (__n)
{
- __begin_ = __end_ = static_cast<value_type*>(
- _VSTD::__libcpp_allocate(__n * sizeof(value_type), _LIBCPP_ALIGNOF(value_type)));
+ __begin_ = __end_ = allocator<value_type>().allocate(__n);
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
for (size_t __n_left = __n; __n_left; --__n_left, ++__end_)
- ::new (__end_) value_type(__x);
+ ::new ((void*)__end_) value_type(__x);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
diff --git a/libcxx/include/variant b/libcxx/include/variant
index 03557239a69e..770dd335bae2 100644
--- a/libcxx/include/variant
+++ b/libcxx/include/variant
@@ -169,6 +169,9 @@ namespace std {
template <class Visitor, class... Variants>
constexpr see below visit(Visitor&&, Variants&&...);
+ template <class R, class Visitor, class... Variants>
+ constexpr R visit(Visitor&&, Variants&&...); // since C++20
+
// 20.7.7, class monostate
struct monostate;
@@ -197,6 +200,7 @@ namespace std {
*/
#include <__config>
+#include <__availability>
#include <__tuple>
#include <array>
#include <exception>
@@ -227,7 +231,10 @@ public:
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 14
+// TODO: GCC 5 lies about its support for C++17 (it says it supports it but it
+// really doesn't). That breaks variant, which uses some C++17 features.
+// Remove this once we drop support for GCC 5.
+#if _LIBCPP_STD_VER > 14 && !(defined(_LIBCPP_COMPILER_GCC) && _GNUC_VER_NEW < 6000)
_LIBCPP_NORETURN
inline _LIBCPP_INLINE_VISIBILITY
@@ -290,9 +297,9 @@ struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, variant<_Types...>> {
_LIBCPP_INLINE_VAR constexpr size_t variant_npos = static_cast<size_t>(-1);
constexpr int __choose_index_type(unsigned int __num_elem) {
- if (__num_elem < std::numeric_limits<unsigned char>::max())
+ if (__num_elem < numeric_limits<unsigned char>::max())
return 0;
- if (__num_elem < std::numeric_limits<unsigned short>::max())
+ if (__num_elem < numeric_limits<unsigned short>::max())
return 1;
return 2;
}
@@ -482,12 +489,12 @@ private:
return __result{{_VSTD::forward<_Fs>(__fs)...}};
}
- template <std::size_t... _Is>
+ template <size_t... _Is>
struct __dispatcher {
template <class _Fp, class... _Vs>
inline _LIBCPP_INLINE_VISIBILITY
static constexpr decltype(auto) __dispatch(_Fp __f, _Vs... __vs) {
- return __invoke_constexpr(
+ return _VSTD::__invoke_constexpr(
static_cast<_Fp>(__f),
__access::__base::__get_alt<_Is>(static_cast<_Vs>(__vs))...);
}
@@ -579,6 +586,16 @@ struct __variant {
__make_value_visitor(_VSTD::forward<_Visitor>(__visitor)),
_VSTD::forward<_Vs>(__vs)...);
}
+#if _LIBCPP_STD_VER > 17
+ template <class _Rp, class _Visitor, class... _Vs>
+ inline _LIBCPP_INLINE_VISIBILITY
+ static constexpr _Rp __visit_value(_Visitor&& __visitor,
+ _Vs&&... __vs) {
+ return __visit_alt(
+ __make_value_visitor<_Rp>(_VSTD::forward<_Visitor>(__visitor)),
+ _VSTD::forward<_Vs>(__vs)...);
+ }
+#endif
private:
template <class _Visitor, class... _Values>
@@ -595,17 +612,48 @@ private:
__std_visit_exhaustive_visitor_check<
_Visitor,
decltype((_VSTD::forward<_Alts>(__alts).__value))...>();
- return __invoke_constexpr(_VSTD::forward<_Visitor>(__visitor),
+ return _VSTD::__invoke_constexpr(_VSTD::forward<_Visitor>(__visitor),
_VSTD::forward<_Alts>(__alts).__value...);
}
_Visitor&& __visitor;
};
+#if _LIBCPP_STD_VER > 17
+ template <class _Rp, class _Visitor>
+ struct __value_visitor_return_type {
+ template <class... _Alts>
+ inline _LIBCPP_INLINE_VISIBILITY
+ constexpr _Rp operator()(_Alts&&... __alts) const {
+ __std_visit_exhaustive_visitor_check<
+ _Visitor,
+ decltype((_VSTD::forward<_Alts>(__alts).__value))...>();
+ if constexpr (is_void_v<_Rp>) {
+ _VSTD::__invoke_constexpr(_VSTD::forward<_Visitor>(__visitor),
+ _VSTD::forward<_Alts>(__alts).__value...);
+ }
+ else {
+ return _VSTD::__invoke_constexpr(_VSTD::forward<_Visitor>(__visitor),
+ _VSTD::forward<_Alts>(__alts).__value...);
+ }
+ }
+
+ _Visitor&& __visitor;
+ };
+#endif
+
template <class _Visitor>
inline _LIBCPP_INLINE_VISIBILITY
static constexpr auto __make_value_visitor(_Visitor&& __visitor) {
return __value_visitor<_Visitor>{_VSTD::forward<_Visitor>(__visitor)};
}
+
+#if _LIBCPP_STD_VER > 17
+ template <class _Rp, class _Visitor>
+ inline _LIBCPP_INLINE_VISIBILITY
+ static constexpr auto __make_value_visitor(_Visitor&& __visitor) {
+ return __value_visitor_return_type<_Rp, _Visitor>{_VSTD::forward<_Visitor>(__visitor)};
+ }
+#endif
};
} // namespace __visitation
@@ -720,12 +768,12 @@ protected:
};
template <class _Traits, _Trait = _Traits::__destructible_trait>
-class _LIBCPP_TEMPLATE_VIS __destructor;
+class _LIBCPP_TEMPLATE_VIS __dtor;
#define _LIBCPP_VARIANT_DESTRUCTOR(destructible_trait, destructor, destroy) \
template <class... _Types> \
- class _LIBCPP_TEMPLATE_VIS __destructor<__traits<_Types...>, \
- destructible_trait> \
+ class _LIBCPP_TEMPLATE_VIS __dtor<__traits<_Types...>, \
+ destructible_trait> \
: public __base<destructible_trait, _Types...> { \
using __base_type = __base<destructible_trait, _Types...>; \
using __index_t = typename __base_type::__index_t; \
@@ -734,11 +782,11 @@ class _LIBCPP_TEMPLATE_VIS __destructor;
using __base_type::__base_type; \
using __base_type::operator=; \
\
- __destructor(const __destructor&) = default; \
- __destructor(__destructor&&) = default; \
+ __dtor(const __dtor&) = default; \
+ __dtor(__dtor&&) = default; \
destructor \
- __destructor& operator=(const __destructor&) = default; \
- __destructor& operator=(__destructor&&) = default; \
+ __dtor& operator=(const __dtor&) = default; \
+ __dtor& operator=(__dtor&&) = default; \
\
protected: \
inline _LIBCPP_INLINE_VISIBILITY \
@@ -747,12 +795,12 @@ class _LIBCPP_TEMPLATE_VIS __destructor;
_LIBCPP_VARIANT_DESTRUCTOR(
_Trait::_TriviallyAvailable,
- ~__destructor() = default;,
+ ~__dtor() = default;,
void __destroy() noexcept { this->__index = __variant_npos<__index_t>; });
_LIBCPP_VARIANT_DESTRUCTOR(
_Trait::_Available,
- ~__destructor() { __destroy(); },
+ ~__dtor() { __destroy(); },
void __destroy() noexcept {
if (!this->valueless_by_exception()) {
__visitation::__base::__visit_alt(
@@ -767,14 +815,14 @@ _LIBCPP_VARIANT_DESTRUCTOR(
_LIBCPP_VARIANT_DESTRUCTOR(
_Trait::_Unavailable,
- ~__destructor() = delete;,
+ ~__dtor() = delete;,
void __destroy() noexcept = delete;);
#undef _LIBCPP_VARIANT_DESTRUCTOR
template <class _Traits>
-class _LIBCPP_TEMPLATE_VIS __constructor : public __destructor<_Traits> {
- using __base_type = __destructor<_Traits>;
+class _LIBCPP_TEMPLATE_VIS __ctor : public __dtor<_Traits> {
+ using __base_type = __dtor<_Traits>;
public:
using __base_type::__base_type;
@@ -791,7 +839,7 @@ protected:
template <class _Rhs>
inline _LIBCPP_INLINE_VISIBILITY
- static void __generic_construct(__constructor& __lhs, _Rhs&& __rhs) {
+ static void __generic_construct(__ctor& __lhs, _Rhs&& __rhs) {
__lhs.__destroy();
if (!__rhs.valueless_by_exception()) {
__visitation::__base::__visit_alt_at(
@@ -813,10 +861,10 @@ class _LIBCPP_TEMPLATE_VIS __move_constructor;
#define _LIBCPP_VARIANT_MOVE_CONSTRUCTOR(move_constructible_trait, \
move_constructor) \
template <class... _Types> \
- class _LIBCPP_TEMPLATE_VIS __move_constructor<__traits<_Types...>, \
- move_constructible_trait> \
- : public __constructor<__traits<_Types...>> { \
- using __base_type = __constructor<__traits<_Types...>>; \
+ class _LIBCPP_TEMPLATE_VIS __move_constructor<__traits<_Types...>, \
+ move_constructible_trait> \
+ : public __ctor<__traits<_Types...>> { \
+ using __base_type = __ctor<__traits<_Types...>>; \
\
public: \
using __base_type::__base_type; \
@@ -1104,7 +1152,7 @@ struct __narrowing_check {
template <class _Dest>
static auto __test_impl(_Dest (&&)[1]) -> __identity<_Dest>;
template <class _Dest, class _Source>
- using _Apply _LIBCPP_NODEBUG_TYPE = decltype(__test_impl<_Dest>({std::declval<_Source>()}));
+ using _Apply _LIBCPP_NODEBUG_TYPE = decltype(__test_impl<_Dest>({_VSTD::declval<_Source>()}));
};
template <class _Dest, class _Source>
@@ -1510,7 +1558,7 @@ template <class _Operator>
struct __convert_to_bool {
template <class _T1, class _T2>
_LIBCPP_INLINE_VISIBILITY constexpr bool operator()(_T1 && __t1, _T2&& __t2) const {
- static_assert(std::is_convertible<decltype(_Operator{}(_VSTD::forward<_T1>(__t1), _VSTD::forward<_T2>(__t2))), bool>::value,
+ static_assert(is_convertible<decltype(_Operator{}(_VSTD::forward<_T1>(__t1), _VSTD::forward<_T2>(__t2))), bool>::value,
"the relational operator does not return a type which is implicitly convertible to bool");
return _Operator{}(_VSTD::forward<_T1>(__t1), _VSTD::forward<_T2>(__t2));
}
@@ -1587,21 +1635,38 @@ constexpr bool operator>=(const variant<_Types...>& __lhs,
__lhs.index(), __convert_to_bool<greater_equal<>>{}, __lhs, __rhs);
}
+template <class... _Vs>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
+constexpr void __throw_if_valueless(_Vs&&... __vs) {
+ const bool __valueless = (... || __vs.valueless_by_exception());
+ if (__valueless) {
+ __throw_bad_variant_access();
+ }
+}
+
template <class _Visitor, class... _Vs>
inline _LIBCPP_INLINE_VISIBILITY
_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
constexpr decltype(auto) visit(_Visitor&& __visitor, _Vs&&... __vs) {
using __variant_detail::__visitation::__variant;
- bool __results[] = {__vs.valueless_by_exception()...};
- for (bool __result : __results) {
- if (__result) {
- __throw_bad_variant_access();
- }
- }
+ _VSTD::__throw_if_valueless(_VSTD::forward<_Vs>(__vs)...);
return __variant::__visit_value(_VSTD::forward<_Visitor>(__visitor),
_VSTD::forward<_Vs>(__vs)...);
}
+#if _LIBCPP_STD_VER > 17
+template <class _Rp, class _Visitor, class... _Vs>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
+constexpr _Rp visit(_Visitor&& __visitor, _Vs&&... __vs) {
+ using __variant_detail::__visitation::__variant;
+ _VSTD::__throw_if_valueless(_VSTD::forward<_Vs>(__vs)...);
+ return __variant::__visit_value<_Rp>(_VSTD::forward<_Visitor>(__visitor),
+ _VSTD::forward<_Vs>(__vs)...);
+}
+#endif
+
struct _LIBCPP_TEMPLATE_VIS monostate {};
inline _LIBCPP_INLINE_VISIBILITY
diff --git a/libcxx/include/vector b/libcxx/include/vector
index 1007beeaafd0..8e2df79f9284 100644
--- a/libcxx/include/vector
+++ b/libcxx/include/vector
@@ -454,7 +454,7 @@ inline _LIBCPP_INLINE_VISIBILITY
__vector_base<_Tp, _Allocator>::__vector_base(allocator_type&& __a) _NOEXCEPT
: __begin_(nullptr),
__end_(nullptr),
- __end_cap_(nullptr, std::move(__a)) {}
+ __end_cap_(nullptr, _VSTD::move(__a)) {}
#endif
template <class _Tp, class _Allocator>
@@ -496,7 +496,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
}
@@ -508,7 +508,7 @@ public:
#endif
: __base(__a)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
}
@@ -551,7 +551,7 @@ public:
~vector()
{
__annotate_delete();
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__erase_c(this);
#endif
}
@@ -789,14 +789,14 @@ public:
bool __invariants() const;
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
bool __dereferenceable(const const_iterator* __i) const;
bool __decrementable(const const_iterator* __i) const;
bool __addable(const const_iterator* __i, ptrdiff_t __n) const;
bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;
-#endif // _LIBCPP_DEBUG_LEVEL >= 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
private:
_LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators();
@@ -931,7 +931,7 @@ private:
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
template<class _InputIterator,
- class _Alloc = typename std::allocator<typename iterator_traits<_InputIterator>::value_type>,
+ class _Alloc = allocator<typename iterator_traits<_InputIterator>::value_type>,
class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
>
vector(_InputIterator, _InputIterator)
@@ -951,8 +951,7 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a
{
__annotate_delete();
- __alloc_traits::__construct_backward_with_exception_guarantees(
- this->__alloc(), this->__begin_, this->__end_, __v.__begin_);
+ _VSTD::__construct_backward_with_exception_guarantees(this->__alloc(), this->__begin_, this->__end_, __v.__begin_);
_VSTD::swap(this->__begin_, __v.__begin_);
_VSTD::swap(this->__end_, __v.__end_);
_VSTD::swap(this->__end_cap(), __v.__end_cap());
@@ -967,10 +966,8 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a
{
__annotate_delete();
pointer __r = __v.__begin_;
- __alloc_traits::__construct_backward_with_exception_guarantees(
- this->__alloc(), this->__begin_, __p, __v.__begin_);
- __alloc_traits::__construct_forward_with_exception_guarantees(
- this->__alloc(), __p, this->__end_, __v.__end_);
+ _VSTD::__construct_backward_with_exception_guarantees(this->__alloc(), this->__begin_, __p, __v.__begin_);
+ _VSTD::__construct_forward_with_exception_guarantees(this->__alloc(), __p, this->__end_, __v.__end_);
_VSTD::swap(this->__begin_, __v.__begin_);
_VSTD::swap(this->__end_, __v.__end_);
_VSTD::swap(this->__end_cap(), __v.__end_cap());
@@ -1077,7 +1074,7 @@ typename enable_if
vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n)
{
_ConstructTransaction __tx(*this, __n);
- __alloc_traits::__construct_range_forward(this->__alloc(), __first, __last, __tx.__pos_);
+ _VSTD::__construct_range_forward(this->__alloc(), __first, __last, __tx.__pos_);
}
// Default constructs __n objects starting at __end_
@@ -1121,7 +1118,7 @@ vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x)
template <class _Tp, class _Allocator>
vector<_Tp, _Allocator>::vector(size_type __n)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
if (__n > 0)
@@ -1136,7 +1133,7 @@ template <class _Tp, class _Allocator>
vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a)
: __base(__a)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
if (__n > 0)
@@ -1150,7 +1147,7 @@ vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a)
template <class _Tp, class _Allocator>
vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
if (__n > 0)
@@ -1164,7 +1161,7 @@ template <class _Tp, class _Allocator>
vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x, const allocator_type& __a)
: __base(__a)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
if (__n > 0)
@@ -1184,7 +1181,7 @@ vector<_Tp, _Allocator>::vector(_InputIterator __first,
typename iterator_traits<_InputIterator>::reference>::value,
_InputIterator>::type __last)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
for (; __first != __last; ++__first)
@@ -1201,7 +1198,7 @@ vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, c
typename iterator_traits<_InputIterator>::reference>::value>::type*)
: __base(__a)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
for (; __first != __last; ++__first)
@@ -1217,7 +1214,7 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first,
typename iterator_traits<_ForwardIterator>::reference>::value,
_ForwardIterator>::type __last)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
@@ -1237,7 +1234,7 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __las
typename iterator_traits<_ForwardIterator>::reference>::value>::type*)
: __base(__a)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
@@ -1252,7 +1249,7 @@ template <class _Tp, class _Allocator>
vector<_Tp, _Allocator>::vector(const vector& __x)
: __base(__alloc_traits::select_on_container_copy_construction(__x.__alloc()))
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
size_type __n = __x.size();
@@ -1267,7 +1264,7 @@ template <class _Tp, class _Allocator>
vector<_Tp, _Allocator>::vector(const vector& __x, const allocator_type& __a)
: __base(__a)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
size_type __n = __x.size();
@@ -1290,7 +1287,7 @@ vector<_Tp, _Allocator>::vector(vector&& __x)
#endif
: __base(_VSTD::move(__x.__alloc()))
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
__get_db()->swap(this, &__x);
#endif
@@ -1305,7 +1302,7 @@ inline _LIBCPP_INLINE_VISIBILITY
vector<_Tp, _Allocator>::vector(vector&& __x, const allocator_type& __a)
: __base(__a)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
if (__a == __x.__alloc())
@@ -1314,7 +1311,7 @@ vector<_Tp, _Allocator>::vector(vector&& __x, const allocator_type& __a)
this->__end_ = __x.__end_;
this->__end_cap() = __x.__end_cap();
__x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr;
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->swap(this, &__x);
#endif
}
@@ -1329,7 +1326,7 @@ template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
if (__il.size() > 0)
@@ -1344,7 +1341,7 @@ inline _LIBCPP_INLINE_VISIBILITY
vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)
: __base(__a)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
#endif
if (__il.size() > 0)
@@ -1390,7 +1387,7 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)
this->__end_ = __c.__end_;
this->__end_cap() = __c.__end_cap();
__c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr;
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->swap(this, &__c);
#endif
}
@@ -1493,7 +1490,7 @@ inline _LIBCPP_INLINE_VISIBILITY
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::__make_iter(pointer __p) _NOEXCEPT
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
return iterator(this, __p);
#else
return iterator(__p);
@@ -1505,7 +1502,7 @@ inline _LIBCPP_INLINE_VISIBILITY
typename vector<_Tp, _Allocator>::const_iterator
vector<_Tp, _Allocator>::__make_iter(const_pointer __p) const _NOEXCEPT
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
return const_iterator(this, __p);
#else
return const_iterator(__p);
@@ -1709,7 +1706,7 @@ inline _LIBCPP_INLINE_VISIBILITY
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::erase(const_iterator __position)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,
"vector::erase(iterator) called with an iterator not"
" referring to this vector");
@@ -1728,7 +1725,7 @@ template <class _Tp, class _Allocator>
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this,
"vector::erase(iterator, iterator) called with an iterator not"
" referring to this vector");
@@ -1769,7 +1766,7 @@ template <class _Tp, class _Allocator>
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,
"vector::insert(iterator, x) called with an iterator not"
" referring to this vector");
@@ -1806,7 +1803,7 @@ template <class _Tp, class _Allocator>
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,
"vector::insert(iterator, x) called with an iterator not"
" referring to this vector");
@@ -1839,7 +1836,7 @@ template <class... _Args>
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,
"vector::emplace(iterator, x) called with an iterator not"
" referring to this vector");
@@ -1874,7 +1871,7 @@ template <class _Tp, class _Allocator>
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,
"vector::insert(iterator, n, x) called with an iterator not"
" referring to this vector");
@@ -1925,7 +1922,7 @@ typename enable_if
>::type
vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,
"vector::insert(iterator, range) called with an iterator not"
" referring to this vector");
@@ -1978,7 +1975,7 @@ typename enable_if
>::type
vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last)
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,
"vector::insert(iterator, range) called with an iterator not"
" referring to this vector");
@@ -2057,11 +2054,11 @@ vector<_Tp, _Allocator>::swap(vector& __x)
_VSTD::swap(this->__begin_, __x.__begin_);
_VSTD::swap(this->__end_, __x.__end_);
_VSTD::swap(this->__end_cap(), __x.__end_cap());
- __swap_allocator(this->__alloc(), __x.__alloc(),
+ _VSTD::__swap_allocator(this->__alloc(), __x.__alloc(),
integral_constant<bool,__alloc_traits::propagate_on_container_swap::value>());
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->swap(this, &__x);
-#endif // _LIBCPP_DEBUG_LEVEL >= 2
+#endif
}
template <class _Tp, class _Allocator>
@@ -2085,7 +2082,7 @@ vector<_Tp, _Allocator>::__invariants() const
return true;
}
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
template <class _Tp, class _Allocator>
bool
@@ -2117,16 +2114,16 @@ vector<_Tp, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __
return this->__begin_ <= __p && __p < this->__end_;
}
-#endif // _LIBCPP_DEBUG_LEVEL >= 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
vector<_Tp, _Allocator>::__invalidate_all_iterators()
{
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__invalidate_all(this);
-#endif // _LIBCPP_DEBUG_LEVEL >= 2
+#endif
}
@@ -2134,7 +2131,7 @@ template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
vector<_Tp, _Allocator>::__invalidate_iterators_past(pointer __new_last) {
-#if _LIBCPP_DEBUG_LEVEL >= 2
+#if _LIBCPP_DEBUG_LEVEL == 2
__c_node* __c = __get_db()->__find_c_and_lock(this);
for (__i_node** __p = __c->end_; __p != __c->beg_; ) {
--__p;
@@ -2142,7 +2139,7 @@ vector<_Tp, _Allocator>::__invalidate_iterators_past(pointer __new_last) {
if (__i->base() > __new_last) {
(*__p)->__c_ = nullptr;
if (--__c->end_ != __p)
- memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
+ _VSTD::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
}
}
__get_db()->unlock();
@@ -2883,7 +2880,7 @@ inline _LIBCPP_INLINE_VISIBILITY vector<bool, _Allocator>::vector(vector&& __v)
#endif
: __begin_(__v.__begin_),
__size_(__v.__size_),
- __cap_alloc_(std::move(__v.__cap_alloc_)) {
+ __cap_alloc_(_VSTD::move(__v.__cap_alloc_)) {
__v.__begin_ = nullptr;
__v.__size_ = 0;
__v.__cap() = 0;
@@ -3235,7 +3232,7 @@ vector<bool, _Allocator>::swap(vector& __x)
_VSTD::swap(this->__begin_, __x.__begin_);
_VSTD::swap(this->__size_, __x.__size_);
_VSTD::swap(this->__cap(), __x.__cap());
- __swap_allocator(this->__alloc(), __x.__alloc(),
+ _VSTD::__swap_allocator(this->__alloc(), __x.__alloc(),
integral_constant<bool, __alloc_traits::propagate_on_container_swap::value>());
}
diff --git a/libcxx/include/version b/libcxx/include/version
index acedd03073cc..813bc1ab9e6a 100644
--- a/libcxx/include/version
+++ b/libcxx/include/version
@@ -15,20 +15,30 @@
Macro name Value Headers
__cpp_lib_addressof_constexpr 201603L <memory>
-__cpp_lib_allocator_traits_is_always_equal 201411L <memory> <scoped_allocator> <string>
- <deque> <forward_list> <list>
- <vector> <map> <set>
- <unordered_map> <unordered_set>
+__cpp_lib_allocator_traits_is_always_equal 201411L <deque> <forward_list> <list>
+ <map> <memory> <scoped_allocator>
+ <set> <string> <unordered_map>
+ <unordered_set> <vector>
__cpp_lib_any 201606L <any>
__cpp_lib_apply 201603L <tuple>
-__cpp_lib_array_constexpr 201811L <iterator> <array>
+__cpp_lib_array_constexpr 201811L <array> <iterator>
201603L // C++17
__cpp_lib_as_const 201510L <utility>
+__cpp_lib_assume_aligned 201811L <memory>
+__cpp_lib_atomic_flag_test 201907L <atomic>
+__cpp_lib_atomic_float 201711L <atomic>
__cpp_lib_atomic_is_always_lock_free 201603L <atomic>
+__cpp_lib_atomic_lock_free_type_aliases 201907L <atomic>
__cpp_lib_atomic_ref 201806L <atomic>
-__cpp_lib_bind_front 201811L <functional>
+__cpp_lib_atomic_shared_ptr 201711L <atomic>
+__cpp_lib_atomic_value_initialization 201911L <atomic> <memory>
+__cpp_lib_atomic_wait 201907L <atomic>
+__cpp_lib_barrier 201907L <barrier>
+__cpp_lib_bind_front 201907L <functional>
__cpp_lib_bit_cast 201806L <bit>
+__cpp_lib_bitops 201907L <bit>
__cpp_lib_bool_constant 201505L <type_traits>
+__cpp_lib_bounded_array_traits 201902L <type_traits>
__cpp_lib_boyer_moore_searcher 201603L <functional>
__cpp_lib_byte 201603L <cstddef>
__cpp_lib_char8_t 201811L <atomic> <filesystem> <istream>
@@ -38,18 +48,29 @@ __cpp_lib_chrono 201611L <chrono>
__cpp_lib_chrono_udls 201304L <chrono>
__cpp_lib_clamp 201603L <algorithm>
__cpp_lib_complex_udls 201309L <complex>
-__cpp_lib_concepts 201806L <concepts>
-__cpp_lib_constexpr_misc 201811L <array> <functional> <iterator>
- <string_view> <tuple> <utility>
-__cpp_lib_constexpr_swap_algorithms 201806L <algorithm>
+__cpp_lib_concepts 202002L <concepts>
+__cpp_lib_constexpr_algorithms 201806L <algorithm>
+__cpp_lib_constexpr_complex 201711L <complex>
+__cpp_lib_constexpr_dynamic_alloc 201907L <memory>
+__cpp_lib_constexpr_functional 201907L <functional>
+__cpp_lib_constexpr_iterator 201811L <iterator>
+__cpp_lib_constexpr_memory 201811L <memory>
+__cpp_lib_constexpr_numeric 201911L <numeric>
+__cpp_lib_constexpr_string 201907L <string>
+__cpp_lib_constexpr_string_view 201811L <string_view>
+__cpp_lib_constexpr_tuple 201811L <tuple>
+__cpp_lib_constexpr_utility 201811L <utility>
+__cpp_lib_constexpr_vector 201907L <vector>
+__cpp_lib_coroutine 201902L <coroutine>
__cpp_lib_destroying_delete 201806L <new>
__cpp_lib_enable_shared_from_this 201603L <memory>
__cpp_lib_endian 201907L <bit>
-__cpp_lib_erase_if 202002L <string> <deque> <forward_list>
- <list> <vector> <map>
- <set> <unordered_map> <unordered_set>
+__cpp_lib_erase_if 202002L <deque> <forward_list> <list>
+ <map> <set> <string>
+ <unordered_map> <unordered_set> <vector>
__cpp_lib_exchange_function 201304L <utility>
-__cpp_lib_execution 201603L <execution>
+__cpp_lib_execution 201902L <execution>
+ 201603L // C++17
__cpp_lib_filesystem 201703L <filesystem>
__cpp_lib_gcd_lcm 201606L <numeric>
__cpp_lib_generic_associative_lookup 201304L <map> <set>
@@ -58,16 +79,24 @@ __cpp_lib_hardware_interference_size 201703L <new>
__cpp_lib_has_unique_object_representations 201606L <type_traits>
__cpp_lib_hypot 201603L <cmath>
__cpp_lib_incomplete_container_elements 201505L <forward_list> <list> <vector>
+__cpp_lib_int_pow2 202002L <bit>
+__cpp_lib_integer_comparison_functions 202002L <utility>
__cpp_lib_integer_sequence 201304L <utility>
__cpp_lib_integral_constant_callable 201304L <type_traits>
-__cpp_lib_interpolate 201902L <numeric>
+__cpp_lib_interpolate 201902L <cmath> <numeric>
__cpp_lib_invoke 201411L <functional>
__cpp_lib_is_aggregate 201703L <type_traits>
__cpp_lib_is_constant_evaluated 201811L <type_traits>
__cpp_lib_is_final 201402L <type_traits>
__cpp_lib_is_invocable 201703L <type_traits>
+__cpp_lib_is_layout_compatible 201907L <type_traits>
+__cpp_lib_is_nothrow_convertible 201806L <type_traits>
__cpp_lib_is_null_pointer 201309L <type_traits>
+__cpp_lib_is_pointer_interconvertible 201907L <type_traits>
+__cpp_lib_is_scoped_enum 202011L <type_traits>
__cpp_lib_is_swappable 201603L <type_traits>
+__cpp_lib_jthread 201911L <stop_token> <thread>
+__cpp_lib_latch 201907L <latch>
__cpp_lib_launder 201606L <new>
__cpp_lib_list_remove_return_type 201806L <forward_list> <list>
__cpp_lib_logical_traits 201510L <type_traits>
@@ -80,40 +109,55 @@ __cpp_lib_math_special_functions 201603L <cmath>
__cpp_lib_memory_resource 201603L <memory_resource>
__cpp_lib_node_extract 201606L <map> <set> <unordered_map>
<unordered_set>
-__cpp_lib_nonmember_container_access 201411L <iterator> <array> <deque>
- <forward_list> <list> <map>
+__cpp_lib_nonmember_container_access 201411L <array> <deque> <forward_list>
+ <iterator> <list> <map>
<regex> <set> <string>
<unordered_map> <unordered_set> <vector>
__cpp_lib_not_fn 201603L <functional>
__cpp_lib_null_iterators 201304L <iterator>
__cpp_lib_optional 201606L <optional>
__cpp_lib_parallel_algorithm 201603L <algorithm> <numeric>
+__cpp_lib_polymorphic_allocator 201902L <memory>
__cpp_lib_quoted_string_io 201304L <iomanip>
__cpp_lib_ranges 201811L <algorithm> <functional> <iterator>
<memory> <ranges>
__cpp_lib_raw_memory_algorithms 201606L <memory>
+__cpp_lib_remove_cvref 201711L <type_traits>
__cpp_lib_result_of_sfinae 201210L <functional> <type_traits>
__cpp_lib_robust_nonmodifying_seq_ops 201304L <algorithm>
__cpp_lib_sample 201603L <algorithm>
__cpp_lib_scoped_lock 201703L <mutex>
+__cpp_lib_semaphore 201907L <semaphore>
__cpp_lib_shared_mutex 201505L <shared_mutex>
__cpp_lib_shared_ptr_arrays 201611L <memory>
__cpp_lib_shared_ptr_weak_type 201606L <memory>
__cpp_lib_shared_timed_mutex 201402L <shared_mutex>
+__cpp_lib_shift 201806L <algorithm>
+__cpp_lib_smart_ptr_for_overwrite 202002L <memory>
+__cpp_lib_source_location 201907L <source_location>
__cpp_lib_span 202002L <span>
+__cpp_lib_ssize 201902L <iterator>
+__cpp_lib_stacktrace 202011L <stacktrace>
+__cpp_lib_starts_ends_with 201711L <string> <string_view>
+__cpp_lib_stdatomic_h 202011L <stdatomic.h>
+__cpp_lib_string_contains 202011L <string> <string_view>
__cpp_lib_string_udls 201304L <string>
-__cpp_lib_string_view 201606L <string> <string_view>
-__cpp_lib_three_way_comparison 201711L <compare>
+__cpp_lib_string_view 201803L <string> <string_view>
+ 201606L // C++17
+__cpp_lib_syncbuf 201803L <syncstream>
+__cpp_lib_three_way_comparison 201907L <compare>
+__cpp_lib_to_address 201711L <memory>
__cpp_lib_to_array 201907L <array>
__cpp_lib_to_chars 201611L <utility>
__cpp_lib_transformation_trait_aliases 201304L <type_traits>
-__cpp_lib_transparent_operators 201510L <functional>
+__cpp_lib_transparent_operators 201510L <functional> <memory>
201210L // C++14
__cpp_lib_tuple_element_t 201402L <tuple>
-__cpp_lib_tuples_by_type 201304L <utility> <tuple>
+__cpp_lib_tuples_by_type 201304L <tuple> <utility>
__cpp_lib_type_trait_variable_templates 201510L <type_traits>
__cpp_lib_uncaught_exceptions 201411L <exception>
__cpp_lib_unordered_map_try_emplace 201411L <unordered_map>
+__cpp_lib_unwrap_ref 201811L <functional>
__cpp_lib_variant 201606L <variant>
__cpp_lib_void_t 201411L <type_traits>
@@ -200,7 +244,7 @@ __cpp_lib_void_t 201411L <type_traits>
# if !defined(_LIBCPP_HAS_NO_THREADS)
# define __cpp_lib_shared_mutex 201505L
# endif
-// # define __cpp_lib_shared_ptr_arrays 201611L
+# define __cpp_lib_shared_ptr_arrays 201611L
# define __cpp_lib_shared_ptr_weak_type 201606L
# define __cpp_lib_string_view 201606L
// # define __cpp_lib_to_chars 201611L
@@ -216,35 +260,105 @@ __cpp_lib_void_t 201411L <type_traits>
#if _LIBCPP_STD_VER > 17
# undef __cpp_lib_array_constexpr
# define __cpp_lib_array_constexpr 201811L
+// # define __cpp_lib_assume_aligned 201811L
+# if !defined(_LIBCPP_HAS_NO_THREADS)
+# define __cpp_lib_atomic_flag_test 201907L
+# endif
+# if !defined(_LIBCPP_HAS_NO_THREADS)
+// # define __cpp_lib_atomic_float 201711L
+# endif
+# if !defined(_LIBCPP_HAS_NO_THREADS)
+# define __cpp_lib_atomic_lock_free_type_aliases 201907L
+# endif
# if !defined(_LIBCPP_HAS_NO_THREADS)
// # define __cpp_lib_atomic_ref 201806L
# endif
-// # define __cpp_lib_bind_front 201811L
+# if !defined(_LIBCPP_HAS_NO_THREADS)
+// # define __cpp_lib_atomic_shared_ptr 201711L
+# endif
+# if !defined(_LIBCPP_HAS_NO_THREADS)
+// # define __cpp_lib_atomic_value_initialization 201911L
+# endif
+# if !defined(_LIBCPP_HAS_NO_THREADS)
+# define __cpp_lib_atomic_wait 201907L
+# endif
+# if !defined(_LIBCPP_HAS_NO_THREADS)
+# define __cpp_lib_barrier 201907L
+# endif
+// # define __cpp_lib_bind_front 201907L
// # define __cpp_lib_bit_cast 201806L
+// # define __cpp_lib_bitops 201907L
+# define __cpp_lib_bounded_array_traits 201902L
# if !defined(_LIBCPP_NO_HAS_CHAR8_T)
# define __cpp_lib_char8_t 201811L
# endif
-// # define __cpp_lib_concepts 201806L
-// # define __cpp_lib_constexpr_misc 201811L
-// # define __cpp_lib_constexpr_swap_algorithms 201806L
+// # define __cpp_lib_concepts 202002L
+// # define __cpp_lib_constexpr_algorithms 201806L
+// # define __cpp_lib_constexpr_complex 201711L
+# define __cpp_lib_constexpr_dynamic_alloc 201907L
+# define __cpp_lib_constexpr_functional 201907L
+// # define __cpp_lib_constexpr_iterator 201811L
+// # define __cpp_lib_constexpr_memory 201811L
+# define __cpp_lib_constexpr_numeric 201911L
+// # define __cpp_lib_constexpr_string 201907L
+// # define __cpp_lib_constexpr_string_view 201811L
+// # define __cpp_lib_constexpr_tuple 201811L
+# define __cpp_lib_constexpr_utility 201811L
+// # define __cpp_lib_constexpr_vector 201907L
+// # define __cpp_lib_coroutine 201902L
# if _LIBCPP_STD_VER > 17 && defined(__cpp_impl_destroying_delete) && __cpp_impl_destroying_delete >= 201806L
# define __cpp_lib_destroying_delete 201806L
# endif
# define __cpp_lib_endian 201907L
# define __cpp_lib_erase_if 202002L
-// # define __cpp_lib_generic_unordered_lookup 201811L
+# undef __cpp_lib_execution
+// # define __cpp_lib_execution 201902L
+# define __cpp_lib_generic_unordered_lookup 201811L
+# define __cpp_lib_int_pow2 202002L
+// # define __cpp_lib_integer_comparison_functions 202002L
# define __cpp_lib_interpolate 201902L
# if !defined(_LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED)
# define __cpp_lib_is_constant_evaluated 201811L
# endif
+// # define __cpp_lib_is_layout_compatible 201907L
+# define __cpp_lib_is_nothrow_convertible 201806L
+// # define __cpp_lib_is_pointer_interconvertible 201907L
+# if !defined(_LIBCPP_HAS_NO_THREADS)
+// # define __cpp_lib_jthread 201911L
+# endif
+# if !defined(_LIBCPP_HAS_NO_THREADS)
+# define __cpp_lib_latch 201907L
+# endif
# define __cpp_lib_list_remove_return_type 201806L
# if defined(__cpp_concepts) && __cpp_concepts >= 201811L
# define __cpp_lib_math_constants 201907L
# endif
+// # define __cpp_lib_polymorphic_allocator 201902L
// # define __cpp_lib_ranges 201811L
+# define __cpp_lib_remove_cvref 201711L
+# if !defined(_LIBCPP_HAS_NO_THREADS)
+# define __cpp_lib_semaphore 201907L
+# endif
+# define __cpp_lib_shift 201806L
+// # define __cpp_lib_smart_ptr_for_overwrite 202002L
+// # define __cpp_lib_source_location 201907L
# define __cpp_lib_span 202002L
-// # define __cpp_lib_three_way_comparison 201711L
+# define __cpp_lib_ssize 201902L
+# define __cpp_lib_starts_ends_with 201711L
+# undef __cpp_lib_string_view
+# define __cpp_lib_string_view 201803L
+// # define __cpp_lib_syncbuf 201803L
+// # define __cpp_lib_three_way_comparison 201907L
+# define __cpp_lib_to_address 201711L
# define __cpp_lib_to_array 201907L
+# define __cpp_lib_unwrap_ref 201811L
+#endif
+
+#if _LIBCPP_STD_VER > 20
+# define __cpp_lib_is_scoped_enum 202011L
+// # define __cpp_lib_stacktrace 202011L
+// # define __cpp_lib_stdatomic_h 202011L
+# define __cpp_lib_string_contains 202011L
#endif
#endif // _LIBCPP_VERSIONH
diff --git a/libcxx/include/wctype.h b/libcxx/include/wctype.h
index bdcf37234cc3..2d4c36d9921d 100644
--- a/libcxx/include/wctype.h
+++ b/libcxx/include/wctype.h
@@ -50,7 +50,9 @@ wctrans_t wctrans(const char* property);
#pragma GCC system_header
#endif
-#include_next <wctype.h>
+#if __has_include_next(<wctype.h>)
+# include_next <wctype.h>
+#endif
#ifdef __cplusplus