aboutsummaryrefslogtreecommitdiff
path: root/libcxx
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2020-01-17 20:45:01 +0000
committerDimitry Andric <dim@FreeBSD.org>2020-01-17 20:45:01 +0000
commit706b4fc47bbc608932d3b491ae19a3b9cde9497b (patch)
tree4adf86a776049cbf7f69a1929c4babcbbef925eb /libcxx
parent7cc9cf2bf09f069cb2dd947ead05d0b54301fb71 (diff)
downloadsrc-706b4fc47bbc608932d3b491ae19a3b9cde9497b.tar.gz
src-706b4fc47bbc608932d3b491ae19a3b9cde9497b.zip
Vendor import of llvm-project master e26a78e70, the last commit beforevendor/llvm-project/llvmorg-10-init-17466-ge26a78e7085
the llvmorg-11-init tag, from which release/10.x was branched.
Notes
Notes: svn path=/vendor/llvm-project/master/; revision=356843 svn path=/vendor/llvm-project/llvmorg-10-init-17466-ge26a78e7085/; revision=356844; tag=vendor/llvm-project/llvmorg-10-init-17466-ge26a78e7085
Diffstat (limited to 'libcxx')
-rw-r--r--libcxx/CREDITS.TXT4
-rw-r--r--libcxx/include/__bit_reference26
-rw-r--r--libcxx/include/__config47
-rw-r--r--libcxx/include/__debug1
-rw-r--r--libcxx/include/__functional_038
-rw-r--r--libcxx/include/__hash_table26
-rw-r--r--libcxx/include/__mutex_base9
-rw-r--r--libcxx/include/__split_buffer40
-rw-r--r--libcxx/include/__string180
-rw-r--r--libcxx/include/__threading_support241
-rw-r--r--libcxx/include/__tree17
-rw-r--r--libcxx/include/algorithm82
-rw-r--r--libcxx/include/bit4
-rw-r--r--libcxx/include/chrono10
-rw-r--r--libcxx/include/cstdlib2
-rw-r--r--libcxx/include/ctime6
-rw-r--r--libcxx/include/deque88
-rw-r--r--libcxx/include/experimental/functional78
-rw-r--r--libcxx/include/experimental/iterator12
-rw-r--r--libcxx/include/experimental/propagate_const1
-rw-r--r--libcxx/include/experimental/type_traits6
-rw-r--r--libcxx/include/ext/hash_map9
-rw-r--r--libcxx/include/filesystem6
-rw-r--r--libcxx/include/forward_list24
-rw-r--r--libcxx/include/future16
-rw-r--r--libcxx/include/iterator98
-rw-r--r--libcxx/include/list20
-rw-r--r--libcxx/include/math.h4
-rw-r--r--libcxx/include/memory161
-rw-r--r--libcxx/include/mutex2
-rw-r--r--libcxx/include/numeric19
-rw-r--r--libcxx/include/queue2
-rw-r--r--libcxx/include/random47
-rw-r--r--libcxx/include/regex40
-rw-r--r--libcxx/include/span72
-rw-r--r--libcxx/include/string174
-rw-r--r--libcxx/include/thread1
-rw-r--r--libcxx/include/tuple24
-rw-r--r--libcxx/include/type_traits18
-rw-r--r--libcxx/include/valarray26
-rw-r--r--libcxx/include/vector136
-rw-r--r--libcxx/include/version2
-rw-r--r--libcxx/src/algorithm.cpp2
-rw-r--r--libcxx/src/chrono.cpp4
-rw-r--r--libcxx/src/condition_variable.cpp2
-rw-r--r--libcxx/src/debug.cpp2
-rw-r--r--libcxx/src/experimental/memory_resource.cpp2
-rw-r--r--libcxx/src/filesystem/operations.cpp4
-rw-r--r--libcxx/src/locale.cpp4
-rw-r--r--libcxx/src/memory.cpp2
-rw-r--r--libcxx/src/mutex.cpp2
-rw-r--r--libcxx/src/mutex_destructor.cpp1
-rw-r--r--libcxx/src/regex.cpp2
-rw-r--r--libcxx/src/shared_mutex.cpp2
-rw-r--r--libcxx/src/thread.cpp4
55 files changed, 1132 insertions, 690 deletions
diff --git a/libcxx/CREDITS.TXT b/libcxx/CREDITS.TXT
index 46a06c6eab08..f97b9d822772 100644
--- a/libcxx/CREDITS.TXT
+++ b/libcxx/CREDITS.TXT
@@ -64,6 +64,10 @@ N: Howard Hinnant
E: hhinnant@apple.com
D: Architect and primary author of libc++
+N: Sergej Jaskiewicz
+E: jaskiewiczs@icloud.com
+D: Minor improvements in the testing infrastructure
+
N: Hyeon-bin Jeong
E: tuhertz@gmail.com
D: Minor patches and bug fixes.
diff --git a/libcxx/include/__bit_reference b/libcxx/include/__bit_reference
index cce74fb50236..3d4da1cbb68a 100644
--- a/libcxx/include/__bit_reference
+++ b/libcxx/include/__bit_reference
@@ -47,6 +47,9 @@ class __bit_reference
friend class __bit_const_reference<_Cp>;
friend class __bit_iterator<_Cp, false>;
public:
+ _LIBCPP_INLINE_VISIBILITY
+ __bit_reference(const __bit_reference&) = default;
+
_LIBCPP_INLINE_VISIBILITY operator bool() const _NOEXCEPT
{return static_cast<bool>(*__seg_ & __mask_);}
_LIBCPP_INLINE_VISIBILITY bool operator ~() const _NOEXCEPT
@@ -133,6 +136,9 @@ class __bit_const_reference
friend class __bit_iterator<_Cp, true>;
public:
_LIBCPP_INLINE_VISIBILITY
+ __bit_const_reference(const __bit_const_reference&) = default;
+
+ _LIBCPP_INLINE_VISIBILITY
__bit_const_reference(const __bit_reference<_Cp>& __x) _NOEXCEPT
: __seg_(__x.__seg_), __mask_(__x.__mask_) {}
@@ -147,7 +153,7 @@ private:
__bit_const_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT
: __seg_(__s), __mask_(__m) {}
- __bit_const_reference& operator=(const __bit_const_reference& __x);
+ __bit_const_reference& operator=(const __bit_const_reference&) = delete;
};
// find
@@ -332,7 +338,7 @@ __fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
}
// do middle whole words
__storage_type __nw = __n / __bits_per_word;
- _VSTD::memset(_VSTD::__to_raw_pointer(__first.__seg_), 0, __nw * sizeof(__storage_type));
+ _VSTD::memset(_VSTD::__to_address(__first.__seg_), 0, __nw * sizeof(__storage_type));
__n -= __nw * __bits_per_word;
// do last partial word
if (__n > 0)
@@ -362,7 +368,7 @@ __fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
}
// do middle whole words
__storage_type __nw = __n / __bits_per_word;
- _VSTD::memset(_VSTD::__to_raw_pointer(__first.__seg_), -1, __nw * sizeof(__storage_type));
+ _VSTD::memset(_VSTD::__to_address(__first.__seg_), -1, __nw * sizeof(__storage_type));
__n -= __nw * __bits_per_word;
// do last partial word
if (__n > 0)
@@ -429,8 +435,8 @@ __copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsCon
// __first.__ctz_ == 0;
// do middle words
__storage_type __nw = __n / __bits_per_word;
- _VSTD::memmove(_VSTD::__to_raw_pointer(__result.__seg_),
- _VSTD::__to_raw_pointer(__first.__seg_),
+ _VSTD::memmove(_VSTD::__to_address(__result.__seg_),
+ _VSTD::__to_address(__first.__seg_),
__nw * sizeof(__storage_type));
__n -= __nw * __bits_per_word;
__result.__seg_ += __nw;
@@ -570,8 +576,8 @@ __copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_C
__storage_type __nw = __n / __bits_per_word;
__result.__seg_ -= __nw;
__last.__seg_ -= __nw;
- _VSTD::memmove(_VSTD::__to_raw_pointer(__result.__seg_),
- _VSTD::__to_raw_pointer(__last.__seg_),
+ _VSTD::memmove(_VSTD::__to_address(__result.__seg_),
+ _VSTD::__to_address(__last.__seg_),
__nw * sizeof(__storage_type));
__n -= __nw * __bits_per_word;
// do last word
@@ -1108,8 +1114,12 @@ public:
#endif
{}
+ // avoid re-declaring a copy constructor for the non-const version.
+ using __type_for_copy_to_const =
+ _If<_IsConst, __bit_iterator<_Cp, false>, struct __private_nat>;
+
_LIBCPP_INLINE_VISIBILITY
- __bit_iterator(const __bit_iterator<_Cp, false>& __it) _NOEXCEPT
+ __bit_iterator(const __type_for_copy_to_const& __it) _NOEXCEPT
: __seg_(__it.__seg_), __ctz_(__it.__ctz_) {}
_LIBCPP_INLINE_VISIBILITY reference operator*() const _NOEXCEPT
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 044cd0ceb007..ac4549802ef2 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -260,7 +260,6 @@
# else // _BYTE_ORDER == _LITTLE_ENDIAN
# define _LIBCPP_BIG_ENDIAN
# endif // _BYTE_ORDER == _LITTLE_ENDIAN
-# define _LIBCPP_HAS_QUICK_EXIT
#endif // __NetBSD__
#if defined(_WIN32)
@@ -340,9 +339,22 @@
#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
# if defined(__FreeBSD__)
+# define _LIBCPP_HAS_ALIGNED_ALLOC
# define _LIBCPP_HAS_QUICK_EXIT
# define _LIBCPP_HAS_C11_FEATURES
-# elif defined(__Fuchsia__) || defined(__wasi__)
+# elif defined(__BIONIC__)
+# define _LIBCPP_HAS_C11_FEATURES
+# if __ANDROID_API__ >= 21
+# define _LIBCPP_HAS_QUICK_EXIT
+# endif
+# if __ANDROID_API__ >= 28
+# define _LIBCPP_HAS_ALIGNED_ALLOC
+# endif
+# if __ANDROID_API__ >= 29
+# define _LIBCPP_HAS_TIMESPEC_GET
+# endif
+# elif defined(__Fuchsia__) || defined(__wasi__) || defined(__NetBSD__)
+# define _LIBCPP_HAS_ALIGNED_ALLOC
# define _LIBCPP_HAS_QUICK_EXIT
# define _LIBCPP_HAS_TIMESPEC_GET
# define _LIBCPP_HAS_C11_FEATURES
@@ -352,10 +364,12 @@
# define _LIBCPP_HAS_QUICK_EXIT
# 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
@@ -866,6 +880,10 @@ typedef unsigned int char32_t;
# endif
#endif
+#ifndef _LIBCPP_DEBUG_LEVEL
+# define _LIBCPP_DEBUG_LEVEL 0
+#endif
+
#ifdef _LIBCPP_DISABLE_EXTERN_TEMPLATE
#define _LIBCPP_EXTERN_TEMPLATE(...)
#define _LIBCPP_EXTERN_TEMPLATE2(...)
@@ -1002,6 +1020,14 @@ 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)
@@ -1085,7 +1111,6 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
!defined(_LIBCPP_HAS_THREAD_API_WIN32) && \
!defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
# if defined(__FreeBSD__) || \
- defined(__Fuchsia__) || \
defined(__wasi__) || \
defined(__NetBSD__) || \
defined(__linux__) || \
@@ -1095,6 +1120,8 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
defined(__sun__) || \
(defined(__MINGW32__) && __has_include(<pthread.h>))
# define _LIBCPP_HAS_THREAD_API_PTHREAD
+# elif defined(__Fuchsia__)
+# define _LIBCPP_HAS_THREAD_API_C11
# elif defined(_LIBCPP_WIN32API)
# define _LIBCPP_HAS_THREAD_API_WIN32
# else
@@ -1146,6 +1173,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
// TODO(EricWF): Enable this optimization on Bionic after speaking to their
// respective stakeholders.
#if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) \
+ || (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) \
|| defined(_LIBCPP_HAS_THREAD_API_WIN32)
# define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION
#endif
@@ -1158,7 +1186,8 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
//
// TODO(EricWF): This is potentially true for some pthread implementations
// as well.
-#if defined(_LIBCPP_HAS_THREAD_API_WIN32)
+#if (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || \
+ defined(_LIBCPP_HAS_THREAD_API_WIN32)
# define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION
#endif
@@ -1231,6 +1260,14 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
# endif
#endif
+#ifndef _LIBCPP_THREAD_SAFETY_ANNOTATION
+# ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
+# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x))
+# else
+# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x)
+# endif
+#endif // _LIBCPP_THREAD_SAFETY_ANNOTATION
+
#if __has_attribute(require_constant_initialization)
# define _LIBCPP_SAFE_STATIC __attribute__((__require_constant_initialization__))
#else
@@ -1266,7 +1303,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
# define _LIBCPP_FALLTHROUGH() [[fallthrough]]
#elif __has_cpp_attribute(clang::fallthrough)
# define _LIBCPP_FALLTHROUGH() [[clang::fallthrough]]
-#elif __has_attribute(fallthough) || _GNUC_VER >= 700
+#elif __has_attribute(fallthrough) || _GNUC_VER >= 700
# define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__))
#else
# define _LIBCPP_FALLTHROUGH() ((void)0)
diff --git a/libcxx/include/__debug b/libcxx/include/__debug
index 524c5ff02847..11367413fccc 100644
--- a/libcxx/include/__debug
+++ b/libcxx/include/__debug
@@ -276,4 +276,3 @@ _LIBCPP_FUNC_VIS const __libcpp_db* __get_const_db();
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_DEBUG_H
-
diff --git a/libcxx/include/__functional_03 b/libcxx/include/__functional_03
index a90cbb75b2ad..bf86428dea05 100644
--- a/libcxx/include/__functional_03
+++ b/libcxx/include/__functional_03
@@ -104,7 +104,7 @@ class __func<_Fp, _Alloc, _Rp()>
{
__compressed_pair<_Fp, _Alloc> __f_;
public:
- explicit __func(_Fp __f) : __f_(_VSTD::move(__f)) {}
+ explicit __func(_Fp __f) : __f_(_VSTD::move(__f), __default_init_tag()) {}
explicit __func(_Fp __f, _Alloc __a) : __f_(_VSTD::move(__f), _VSTD::move(__a)) {}
virtual __base<_Rp()>* __clone() const;
virtual void __clone(__base<_Rp()>*) const;
@@ -189,7 +189,7 @@ class __func<_Fp, _Alloc, _Rp(_A0)>
{
__compressed_pair<_Fp, _Alloc> __f_;
public:
- _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f)) {}
+ _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f), __default_init_tag()) {}
_LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f, _Alloc __a)
: __f_(_VSTD::move(__f), _VSTD::move(__a)) {}
virtual __base<_Rp(_A0)>* __clone() const;
@@ -275,7 +275,7 @@ class __func<_Fp, _Alloc, _Rp(_A0, _A1)>
{
__compressed_pair<_Fp, _Alloc> __f_;
public:
- _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f)) {}
+ _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f), __default_init_tag()) {}
_LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f, _Alloc __a)
: __f_(_VSTD::move(__f), _VSTD::move(__a)) {}
virtual __base<_Rp(_A0, _A1)>* __clone() const;
@@ -361,7 +361,7 @@ class __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>
{
__compressed_pair<_Fp, _Alloc> __f_;
public:
- _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f)) {}
+ _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f), __default_init_tag()) {}
_LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f, _Alloc __a)
: __f_(_VSTD::move(__f), _VSTD::move(__a)) {}
virtual __base<_Rp(_A0, _A1, _A2)>* __clone() const;
diff --git a/libcxx/include/__hash_table b/libcxx/include/__hash_table
index 0b953f58e99e..13ff096897b4 100644
--- a/libcxx/include/__hash_table
+++ b/libcxx/include/__hash_table
@@ -776,7 +776,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
__bucket_list_deallocator()
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
- : __data_(0) {}
+ : __data_(0, __default_init_tag()) {}
_LIBCPP_INLINE_VISIBILITY
__bucket_list_deallocator(const allocator_type& __a, size_type __size)
@@ -825,11 +825,13 @@ private:
allocator_type& __na_;
- __hash_node_destructor& operator=(const __hash_node_destructor&);
-
public:
bool __value_constructed;
+ __hash_node_destructor(__hash_node_destructor const&) = default;
+ __hash_node_destructor& operator=(const __hash_node_destructor&) = delete;
+
+
_LIBCPP_INLINE_VISIBILITY
explicit __hash_node_destructor(allocator_type& __na,
bool __constructed = false) _NOEXCEPT
@@ -1416,8 +1418,8 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table()
is_nothrow_default_constructible<__node_allocator>::value &&
is_nothrow_default_constructible<hasher>::value &&
is_nothrow_default_constructible<key_equal>::value)
- : __p2_(0),
- __p3_(1.0f)
+ : __p2_(0, __default_init_tag()),
+ __p3_(1.0f, __default_init_tag())
{
}
@@ -1437,7 +1439,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const hasher& __hf,
const key_equal& __eql,
const allocator_type& __a)
: __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)),
- __p1_(__second_tag(), __node_allocator(__a)),
+ __p1_(__default_init_tag(), __node_allocator(__a)),
__p2_(0, __hf),
__p3_(1.0f, __eql)
{
@@ -1446,9 +1448,9 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const hasher& __hf,
template <class _Tp, class _Hash, class _Equal, class _Alloc>
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const allocator_type& __a)
: __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)),
- __p1_(__second_tag(), __node_allocator(__a)),
- __p2_(0),
- __p3_(1.0f)
+ __p1_(__default_init_tag(), __node_allocator(__a)),
+ __p2_(0, __default_init_tag()),
+ __p3_(1.0f, __default_init_tag())
{
}
@@ -1458,7 +1460,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u)
__bucket_list_deleter(allocator_traits<__pointer_allocator>::
select_on_container_copy_construction(
__u.__bucket_list_.get_deleter().__alloc()), 0)),
- __p1_(__second_tag(), allocator_traits<__node_allocator>::
+ __p1_(__default_init_tag(), allocator_traits<__node_allocator>::
select_on_container_copy_construction(__u.__node_alloc())),
__p2_(0, __u.hash_function()),
__p3_(__u.__p3_)
@@ -1469,7 +1471,7 @@ template <class _Tp, class _Hash, class _Equal, class _Alloc>
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u,
const allocator_type& __a)
: __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)),
- __p1_(__second_tag(), __node_allocator(__a)),
+ __p1_(__default_init_tag(), __node_allocator(__a)),
__p2_(0, __u.hash_function()),
__p3_(__u.__p3_)
{
@@ -1503,7 +1505,7 @@ template <class _Tp, class _Hash, class _Equal, class _Alloc>
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u,
const allocator_type& __a)
: __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)),
- __p1_(__second_tag(), __node_allocator(__a)),
+ __p1_(__default_init_tag(), __node_allocator(__a)),
__p2_(0, _VSTD::move(__u.hash_function())),
__p3_(_VSTD::move(__u.__p3_))
{
diff --git a/libcxx/include/__mutex_base b/libcxx/include/__mutex_base
index ed75c82380a6..8b4b74802b19 100644
--- a/libcxx/include/__mutex_base
+++ b/libcxx/include/__mutex_base
@@ -29,15 +29,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#ifndef _LIBCPP_HAS_NO_THREADS
-#ifndef _LIBCPP_THREAD_SAFETY_ANNOTATION
-# ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
-# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x))
-# else
-# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x)
-# endif
-#endif // _LIBCPP_THREAD_SAFETY_ANNOTATION
-
-
class _LIBCPP_TYPE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("mutex")) mutex
{
__libcpp_mutex_t __m_ = _LIBCPP_MUTEX_INITIALIZER;
diff --git a/libcxx/include/__split_buffer b/libcxx/include/__split_buffer
index 095fe8928c6d..fce209f8287e 100644
--- a/libcxx/include/__split_buffer
+++ b/libcxx/include/__split_buffer
@@ -116,15 +116,15 @@ public:
template <class _InputIter>
typename enable_if
<
- __is_input_iterator<_InputIter>::value &&
- !__is_forward_iterator<_InputIter>::value,
+ __is_cpp17_input_iterator<_InputIter>::value &&
+ !__is_cpp17_forward_iterator<_InputIter>::value,
void
>::type
__construct_at_end(_InputIter __first, _InputIter __last);
template <class _ForwardIterator>
typename enable_if
<
- __is_forward_iterator<_ForwardIterator>::value,
+ __is_cpp17_forward_iterator<_ForwardIterator>::value,
void
>::type
__construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
@@ -212,7 +212,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n)
{
_ConstructTransaction __tx(&this->__end_, __n);
for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) {
- __alloc_traits::construct(this->__alloc(), _VSTD::__to_raw_pointer(__tx.__pos_));
+ __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__tx.__pos_));
}
}
@@ -229,7 +229,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_referen
_ConstructTransaction __tx(&this->__end_, __n);
for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) {
__alloc_traits::construct(this->__alloc(),
- _VSTD::__to_raw_pointer(__tx.__pos_), __x);
+ _VSTD::__to_address(__tx.__pos_), __x);
}
}
@@ -237,8 +237,8 @@ template <class _Tp, class _Allocator>
template <class _InputIter>
typename enable_if
<
- __is_input_iterator<_InputIter>::value &&
- !__is_forward_iterator<_InputIter>::value,
+ __is_cpp17_input_iterator<_InputIter>::value &&
+ !__is_cpp17_forward_iterator<_InputIter>::value,
void
>::type
__split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIter __last)
@@ -253,10 +253,10 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIt
__split_buffer __buf(__new_cap, 0, __a);
for (pointer __p = __begin_; __p != __end_; ++__p, ++__buf.__end_)
__alloc_traits::construct(__buf.__alloc(),
- _VSTD::__to_raw_pointer(__buf.__end_), _VSTD::move(*__p));
+ _VSTD::__to_address(__buf.__end_), _VSTD::move(*__p));
swap(__buf);
}
- __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), *__first);
+ __alloc_traits::construct(__a, _VSTD::__to_address(this->__end_), *__first);
++this->__end_;
}
}
@@ -265,7 +265,7 @@ template <class _Tp, class _Allocator>
template <class _ForwardIterator>
typename enable_if
<
- __is_forward_iterator<_ForwardIterator>::value,
+ __is_cpp17_forward_iterator<_ForwardIterator>::value,
void
>::type
__split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last)
@@ -273,7 +273,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _F
_ConstructTransaction __tx(&this->__end_, std::distance(__first, __last));
for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_, ++__first) {
__alloc_traits::construct(this->__alloc(),
- _VSTD::__to_raw_pointer(__tx.__pos_), *__first);
+ _VSTD::__to_address(__tx.__pos_), *__first);
}
}
@@ -283,7 +283,7 @@ void
__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type)
{
while (__begin_ != __new_begin)
- __alloc_traits::destroy(__alloc(), __to_raw_pointer(__begin_++));
+ __alloc_traits::destroy(__alloc(), __to_address(__begin_++));
}
template <class _Tp, class _Allocator>
@@ -300,7 +300,7 @@ void
__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT
{
while (__new_last != __end_)
- __alloc_traits::destroy(__alloc(), __to_raw_pointer(--__end_));
+ __alloc_traits::destroy(__alloc(), __to_address(--__end_));
}
template <class _Tp, class _Allocator>
@@ -324,7 +324,7 @@ template <class _Tp, class _Allocator>
inline
__split_buffer<_Tp, _Allocator>::__split_buffer()
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
- : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr)
+ : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __default_init_tag())
{
}
@@ -368,7 +368,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c)
template <class _Tp, class _Allocator>
__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __alloc_rr& __a)
- : __end_cap_(__second_tag(), __a)
+ : __end_cap_(nullptr, __a)
{
if (__a == __c.__alloc())
{
@@ -495,7 +495,7 @@ __split_buffer<_Tp, _Allocator>::push_front(const_reference __x)
_VSTD::swap(__end_cap(), __t.__end_cap());
}
}
- __alloc_traits::construct(__alloc(), _VSTD::__to_raw_pointer(__begin_-1), __x);
+ __alloc_traits::construct(__alloc(), _VSTD::__to_address(__begin_-1), __x);
--__begin_;
}
@@ -526,7 +526,7 @@ __split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)
_VSTD::swap(__end_cap(), __t.__end_cap());
}
}
- __alloc_traits::construct(__alloc(), _VSTD::__to_raw_pointer(__begin_-1),
+ __alloc_traits::construct(__alloc(), _VSTD::__to_address(__begin_-1),
_VSTD::move(__x));
--__begin_;
}
@@ -559,7 +559,7 @@ __split_buffer<_Tp, _Allocator>::push_back(const_reference __x)
_VSTD::swap(__end_cap(), __t.__end_cap());
}
}
- __alloc_traits::construct(__alloc(), _VSTD::__to_raw_pointer(__end_), __x);
+ __alloc_traits::construct(__alloc(), _VSTD::__to_address(__end_), __x);
++__end_;
}
@@ -590,7 +590,7 @@ __split_buffer<_Tp, _Allocator>::push_back(value_type&& __x)
_VSTD::swap(__end_cap(), __t.__end_cap());
}
}
- __alloc_traits::construct(__alloc(), _VSTD::__to_raw_pointer(__end_),
+ __alloc_traits::construct(__alloc(), _VSTD::__to_address(__end_),
_VSTD::move(__x));
++__end_;
}
@@ -621,7 +621,7 @@ __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args)
_VSTD::swap(__end_cap(), __t.__end_cap());
}
}
- __alloc_traits::construct(__alloc(), _VSTD::__to_raw_pointer(__end_),
+ __alloc_traits::construct(__alloc(), _VSTD::__to_address(__end_),
_VSTD::forward<_Args>(__args)...);
++__end_;
}
diff --git a/libcxx/include/__string b/libcxx/include/__string
index b4c8815f72d2..056b9b80ea50 100644
--- a/libcxx/include/__string
+++ b/libcxx/include/__string
@@ -31,11 +31,12 @@ struct char_traits
static constexpr int compare(const char_type* s1, const char_type* s2, size_t n);
static constexpr size_t length(const char_type* s);
- static constexpr const char_type*
+ static constexpr const char_type*
find(const char_type* s, size_t n, const char_type& a);
- static char_type* move(char_type* s1, const char_type* s2, size_t n);
- static char_type* copy(char_type* s1, const char_type* s2, size_t n);
- static char_type* assign(char_type* s, size_t n, char_type a);
+
+ static constexpr char_type* move(char_type* s1, const char_type* s2, size_t n); // constexpr in C++20
+ static constexpr char_type* copy(char_type* s1, const char_type* s2, size_t n); // constexpr in C++20
+ static constexpr char_type* assign(char_type* s, size_t n, char_type a); // constexpr in C++20
static constexpr int_type not_eof(int_type c) noexcept;
static constexpr char_type to_char_type(int_type c) noexcept;
@@ -93,11 +94,14 @@ struct _LIBCPP_TEMPLATE_VIS char_traits
size_t length(const char_type* __s);
_LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
const char_type* find(const char_type* __s, size_t __n, const char_type& __a);
- static char_type* move(char_type* __s1, const char_type* __s2, size_t __n);
+ static _LIBCPP_CONSTEXPR_AFTER_CXX17
+ char_type* move(char_type* __s1, const char_type* __s2, size_t __n);
_LIBCPP_INLINE_VISIBILITY
- static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n);
+ static _LIBCPP_CONSTEXPR_AFTER_CXX17
+ char_type* copy(char_type* __s1, const char_type* __s2, size_t __n);
_LIBCPP_INLINE_VISIBILITY
- static char_type* assign(char_type* __s, size_t __n, char_type __a);
+ static _LIBCPP_CONSTEXPR_AFTER_CXX17
+ char_type* assign(char_type* __s, size_t __n, char_type __a);
static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
{return eq_int_type(__c, eof()) ? ~eof() : __c;}
@@ -151,9 +155,10 @@ char_traits<_CharT>::find(const char_type* __s, size_t __n, const char_type& __a
}
template <class _CharT>
-_CharT*
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _CharT*
char_traits<_CharT>::move(char_type* __s1, const char_type* __s2, size_t __n)
{
+ if (__n == 0) return __s1;
char_type* __r = __s1;
if (__s1 < __s2)
{
@@ -171,7 +176,7 @@ char_traits<_CharT>::move(char_type* __s1, const char_type* __s2, size_t __n)
}
template <class _CharT>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
_CharT*
char_traits<_CharT>::copy(char_type* __s1, const char_type* __s2, size_t __n)
{
@@ -183,7 +188,7 @@ char_traits<_CharT>::copy(char_type* __s1, const char_type* __s2, size_t __n)
}
template <class _CharT>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
_CharT*
char_traits<_CharT>::assign(char_type* __s, size_t __n, char_type __a)
{
@@ -193,6 +198,37 @@ char_traits<_CharT>::assign(char_type* __s, size_t __n, char_type __a)
return __r;
}
+// constexpr versions of move/copy/assign.
+
+template <class _CharT>
+static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
+_CharT* __move_constexpr(_CharT* __s1, const _CharT* __s2, size_t __n) _NOEXCEPT
+{
+ if (__n == 0) return __s1;
+ if (__s1 < __s2) {
+ _VSTD::copy(__s2, __s2 + __n, __s1);
+ } else if (__s2 < __s1) {
+ _VSTD::copy_backward(__s2, __s2 + __n, __s1 + __n);
+ }
+ return __s1;
+}
+
+template <class _CharT>
+static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
+_CharT* __copy_constexpr(_CharT* __s1, const _CharT* __s2, size_t __n) _NOEXCEPT
+{
+ _VSTD::copy_n(__s2, __n, __s1);
+ return __s1;
+}
+
+template <class _CharT>
+static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
+_CharT* __assign_constexpr(_CharT* __s, size_t __n, _CharT __a) _NOEXCEPT
+{
+ _VSTD::fill_n(__s, __n, __a);
+ return __s;
+}
+
// char_traits<char>
template <>
@@ -217,15 +253,28 @@ 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 char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
- {return __n == 0 ? __s1 : (char_type*) memmove(__s1, __s2, __n);}
- static inline char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
+ static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
+ 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);
+ }
+ static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
+ 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 __n == 0 ? __s1 : (char_type*)memcpy(__s1, __s2, __n);
+ return __libcpp_is_constant_evaluated()
+ ? __copy_constexpr(__s1, __s2, __n)
+ : __n == 0 ? __s1 : (char_type*)memcpy(__s1, __s2, __n);
+ }
+ static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
+ 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);
}
- static inline char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
- {return __n == 0 ? __s : (char_type*)memset(__s, to_int_type(__a), __n);}
static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
{return eq_int_type(__c, eof()) ? ~eof() : __c;}
@@ -307,16 +356,28 @@ 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 char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
- {return __n == 0 ? __s1 : (char_type*)wmemmove(__s1, __s2, __n);}
- static inline char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
+ static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
+ 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);
+ }
+ static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
+ 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 __n == 0 ? __s1 : (char_type*)wmemcpy(__s1, __s2, __n);
+ return __libcpp_is_constant_evaluated()
+ ? __copy_constexpr(__s1, __s2, __n)
+ : __n == 0 ? __s1 : wmemcpy(__s1, __s2, __n);
+ }
+ static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
+ 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);
}
- static inline char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
- {return __n == 0 ? __s : (char_type*)wmemset(__s, __a, __n);}
-
static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
{return eq_int_type(__c, eof()) ? ~eof() : __c;}
static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
@@ -424,21 +485,34 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>
static constexpr
size_t length(const char_type* __s) _NOEXCEPT;
-
+
_LIBCPP_INLINE_VISIBILITY static constexpr
const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
-
- static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
- {return __n == 0 ? __s1 : (char_type*) memmove(__s1, __s2, __n);}
-
- static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
+
+ static _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
+ 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);
+ }
+
+ static _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
+ 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 __n == 0 ? __s1 : (char_type*)memcpy(__s1, __s2, __n);
- }
-
- static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
- {return __n == 0 ? __s : (char_type*)memset(__s, to_int_type(__a), __n);}
+ return __libcpp_is_constant_evaluated()
+ ? __copy_constexpr(__s1, __s2, __n)
+ : __n == 0 ? __s1 : (char_type*)memcpy(__s1, __s2, __n);
+ }
+
+ static _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
+ 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);
+ }
static inline constexpr int_type not_eof(int_type __c) noexcept
{return eq_int_type(__c, eof()) ? ~eof() : __c;}
@@ -521,11 +595,11 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char16_t>
size_t length(const char_type* __s) _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT;
static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
@@ -577,10 +651,11 @@ char_traits<char16_t>::find(const char_type* __s, size_t __n, const char_type& _
return 0;
}
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
char16_t*
char_traits<char16_t>::move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{
+ if (__n == 0) return __s1;
char_type* __r = __s1;
if (__s1 < __s2)
{
@@ -597,7 +672,7 @@ char_traits<char16_t>::move(char_type* __s1, const char_type* __s2, size_t __n)
return __r;
}
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
char16_t*
char_traits<char16_t>::copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{
@@ -608,7 +683,7 @@ char_traits<char16_t>::copy(char_type* __s1, const char_type* __s2, size_t __n)
return __r;
}
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
char16_t*
char_traits<char16_t>::assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
{
@@ -640,11 +715,11 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char32_t>
size_t length(const char_type* __s) _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT;
static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
@@ -696,10 +771,11 @@ char_traits<char32_t>::find(const char_type* __s, size_t __n, const char_type& _
return 0;
}
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
char32_t*
char_traits<char32_t>::move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{
+ if (__n == 0) return __s1;
char_type* __r = __s1;
if (__s1 < __s2)
{
@@ -716,7 +792,7 @@ char_traits<char32_t>::move(char_type* __s1, const char_type* __s2, size_t __n)
return __r;
}
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
char32_t*
char_traits<char32_t>::copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{
@@ -727,7 +803,7 @@ char_traits<char32_t>::copy(char_type* __s1, const char_type* __s2, size_t __n)
return __r;
}
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
char32_t*
char_traits<char32_t>::assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
{
@@ -744,7 +820,7 @@ char_traits<char32_t>::assign(char_type* __s, size_t __n, char_type __a) _NOEXCE
// __str_find
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
-__str_find(const _CharT *__p, _SizeT __sz,
+__str_find(const _CharT *__p, _SizeT __sz,
_CharT __c, _SizeT __pos) _NOEXCEPT
{
if (__pos >= __sz)
@@ -796,7 +872,7 @@ __search_substring(const _CharT *__first1, const _CharT *__last1,
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
-__str_find(const _CharT *__p, _SizeT __sz,
+__str_find(const _CharT *__p, _SizeT __sz,
const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
{
if (__pos > __sz)
@@ -818,7 +894,7 @@ __str_find(const _CharT *__p, _SizeT __sz,
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
-__str_rfind(const _CharT *__p, _SizeT __sz,
+__str_rfind(const _CharT *__p, _SizeT __sz,
_CharT __c, _SizeT __pos) _NOEXCEPT
{
if (__sz < 1)
@@ -837,7 +913,7 @@ __str_rfind(const _CharT *__p, _SizeT __sz,
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
-__str_rfind(const _CharT *__p, _SizeT __sz,
+__str_rfind(const _CharT *__p, _SizeT __sz,
const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
{
__pos = _VSTD::min(__pos, __sz);
@@ -846,7 +922,7 @@ __str_rfind(const _CharT *__p, _SizeT __sz,
else
__pos = __sz;
const _CharT* __r = _VSTD::__find_end(
- __p, __p + __pos, __s, __s + __n, _Traits::eq,
+ __p, __p + __pos, __s, __s + __n, _Traits::eq,
random_access_iterator_tag(), random_access_iterator_tag());
if (__n > 0 && __r == __p + __pos)
return __npos;
@@ -975,7 +1051,7 @@ struct __quoted_output_proxy
__quoted_output_proxy(_Iter __f, _Iter __l, _CharT __d, _CharT __e)
: __first(__f), __last(__l), __delim(__d), __escape(__e) {}
- // This would be a nice place for a string_ref
+ // This would be a nice place for a string_ref
};
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__threading_support b/libcxx/include/__threading_support
index 0d1f1e681f50..026429f6a8ec 100644
--- a/libcxx/include/__threading_support
+++ b/libcxx/include/__threading_support
@@ -26,6 +26,8 @@
#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
# include <pthread.h>
# include <sched.h>
+#elif defined(_LIBCPP_HAS_THREAD_API_C11)
+# include <threads.h>
#endif
#if defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
@@ -79,6 +81,35 @@ typedef pthread_t __libcpp_thread_t;
typedef pthread_key_t __libcpp_tls_key;
#define _LIBCPP_TLS_DESTRUCTOR_CC
+#elif defined(_LIBCPP_HAS_THREAD_API_C11)
+// Mutex
+typedef mtx_t __libcpp_mutex_t;
+// mtx_t is a struct so using {} for initialization is valid.
+#define _LIBCPP_MUTEX_INITIALIZER {}
+
+typedef mtx_t __libcpp_recursive_mutex_t;
+
+// Condition Variable
+typedef cnd_t __libcpp_condvar_t;
+// cnd_t is a struct so using {} for initialization is valid.
+#define _LIBCPP_CONDVAR_INITIALIZER {}
+
+// Execute once
+typedef once_flag __libcpp_exec_once_flag;
+#define _LIBCPP_EXEC_ONCE_INITIALIZER ONCE_FLAG_INIT
+
+// Thread id
+typedef thrd_t __libcpp_thread_id;
+
+// Thread
+#define _LIBCPP_NULL_THREAD 0U
+
+typedef thrd_t __libcpp_thread_t;
+
+// Thread Local Storage
+typedef tss_t __libcpp_tls_key;
+
+#define _LIBCPP_TLS_DESTRUCTOR_CC
#elif !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
// Mutex
typedef void* __libcpp_mutex_t;
@@ -212,8 +243,35 @@ int __libcpp_tls_set(__libcpp_tls_key __key, void *__p);
#endif // !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
#if (!defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
- defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL)) && \
- defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
+ defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL))
+
+namespace __thread_detail {
+
+inline __libcpp_timespec_t __convert_to_timespec(const chrono::nanoseconds& __ns)
+{
+ using namespace chrono;
+ seconds __s = duration_cast<seconds>(__ns);
+ __libcpp_timespec_t __ts;
+ typedef decltype(__ts.tv_sec) __ts_sec;
+ const __ts_sec __ts_sec_max = numeric_limits<__ts_sec>::max();
+
+ if (__s.count() < __ts_sec_max)
+ {
+ __ts.tv_sec = static_cast<__ts_sec>(__s.count());
+ __ts.tv_nsec = static_cast<decltype(__ts.tv_nsec)>((__ns - __s).count());
+ }
+ else
+ {
+ __ts.tv_sec = __ts_sec_max;
+ __ts.tv_nsec = 999999999; // (10^9 - 1)
+ }
+
+ return __ts;
+}
+
+}
+
+#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m)
{
@@ -363,23 +421,7 @@ void __libcpp_thread_yield()
void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns)
{
- using namespace chrono;
- seconds __s = duration_cast<seconds>(__ns);
- __libcpp_timespec_t __ts;
- typedef decltype(__ts.tv_sec) ts_sec;
- _LIBCPP_CONSTEXPR ts_sec __ts_sec_max = numeric_limits<ts_sec>::max();
-
- if (__s.count() < __ts_sec_max)
- {
- __ts.tv_sec = static_cast<ts_sec>(__s.count());
- __ts.tv_nsec = static_cast<decltype(__ts.tv_nsec)>((__ns - __s).count());
- }
- else
- {
- __ts.tv_sec = __ts_sec_max;
- __ts.tv_nsec = 999999999; // (10^9 - 1)
- }
-
+ __libcpp_timespec_t __ts = __thread_detail::__convert_to_timespec(__ns);
while (nanosleep(&__ts, &__ts) == -1 && errno == EINTR);
}
@@ -399,6 +441,165 @@ int __libcpp_tls_set(__libcpp_tls_key __key, void *__p)
return pthread_setspecific(__key, __p);
}
+#elif defined(_LIBCPP_HAS_THREAD_API_C11)
+
+int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m)
+{
+ return mtx_init(__m, mtx_recursive) == thrd_success ? 0 : EINVAL;
+}
+
+int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m)
+{
+ return mtx_lock(__m) == thrd_success ? 0 : EINVAL;
+}
+
+bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m)
+{
+ return mtx_trylock(__m) == thrd_success;
+}
+
+int __libcpp_recursive_mutex_unlock(__libcpp_mutex_t *__m)
+{
+ return mtx_unlock(__m) == thrd_success ? 0 : EINVAL;
+}
+
+int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m)
+{
+ mtx_destroy(__m);
+ return 0;
+}
+
+int __libcpp_mutex_lock(__libcpp_mutex_t *__m)
+{
+ return mtx_lock(__m) == thrd_success ? 0 : EINVAL;
+}
+
+bool __libcpp_mutex_trylock(__libcpp_mutex_t *__m)
+{
+ return mtx_trylock(__m) == thrd_success;
+}
+
+int __libcpp_mutex_unlock(__libcpp_mutex_t *__m)
+{
+ return mtx_unlock(__m) == thrd_success ? 0 : EINVAL;
+}
+
+int __libcpp_mutex_destroy(__libcpp_mutex_t *__m)
+{
+ mtx_destroy(__m);
+ return 0;
+}
+
+// Condition Variable
+int __libcpp_condvar_signal(__libcpp_condvar_t *__cv)
+{
+ return cnd_signal(__cv) == thrd_success ? 0 : EINVAL;
+}
+
+int __libcpp_condvar_broadcast(__libcpp_condvar_t *__cv)
+{
+ return cnd_broadcast(__cv) == thrd_success ? 0 : EINVAL;
+}
+
+int __libcpp_condvar_wait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m)
+{
+ return cnd_wait(__cv, __m) == thrd_success ? 0 : EINVAL;
+}
+
+int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
+ timespec *__ts)
+{
+ int __ec = cnd_timedwait(__cv, __m, __ts);
+ return __ec == thrd_timedout ? ETIMEDOUT : __ec;
+}
+
+int __libcpp_condvar_destroy(__libcpp_condvar_t *__cv)
+{
+ cnd_destroy(__cv);
+ return 0;
+}
+
+// Execute once
+int __libcpp_execute_once(__libcpp_exec_once_flag *flag,
+ void (*init_routine)(void)) {
+ ::call_once(flag, init_routine);
+ return 0;
+}
+
+// Thread id
+// 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 thrd_equal(t1, t2) != 0;
+}
+
+// Returns non-zero if t1 < t2, otherwise 0
+bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2)
+{
+ return t1 < t2;
+}
+
+// Thread
+bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) {
+ return *__t == 0;
+}
+
+int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
+ void *__arg)
+{
+ int __ec = thrd_create(__t, reinterpret_cast<thrd_start_t>(__func), __arg);
+ return __ec == thrd_nomem ? ENOMEM : __ec;
+}
+
+__libcpp_thread_id __libcpp_thread_get_current_id()
+{
+ return thrd_current();
+}
+
+__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t)
+{
+ return *__t;
+}
+
+int __libcpp_thread_join(__libcpp_thread_t *__t)
+{
+ return thrd_join(*__t, nullptr) == thrd_success ? 0 : EINVAL;
+}
+
+int __libcpp_thread_detach(__libcpp_thread_t *__t)
+{
+ return thrd_detach(*__t) == thrd_success ? 0 : EINVAL;
+}
+
+void __libcpp_thread_yield()
+{
+ thrd_yield();
+}
+
+void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns)
+{
+ __libcpp_timespec_t __ts = __thread_detail::__convert_to_timespec(__ns);
+ thrd_sleep(&__ts, nullptr);
+}
+
+// Thread local storage
+int __libcpp_tls_create(__libcpp_tls_key *__key, void (*__at_exit)(void *))
+{
+ return tss_create(__key, __at_exit) == thrd_success ? 0 : EINVAL;
+}
+
+void *__libcpp_tls_get(__libcpp_tls_key __key)
+{
+ return tss_get(__key);
+}
+
+int __libcpp_tls_set(__libcpp_tls_key __key, void *__p)
+{
+ return tss_set(__key, __p) == thrd_success ? 0 : EINVAL;
+}
+
+#endif
+
#endif // !_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL || _LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL
class _LIBCPP_TYPE_VIS thread;
@@ -453,7 +654,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
void __reset() { __id_ = 0; }
-
+
template<class _CharT, class _Traits>
friend
_LIBCPP_INLINE_VISIBILITY
diff --git a/libcxx/include/__tree b/libcxx/include/__tree
index 15b03ec857f6..cb7a1022e626 100644
--- a/libcxx/include/__tree
+++ b/libcxx/include/__tree
@@ -775,11 +775,14 @@ private:
typedef __tree_node_types<pointer> _NodeTypes;
allocator_type& __na_;
- __tree_node_destructor& operator=(const __tree_node_destructor&);
public:
bool __value_constructed;
+
+ __tree_node_destructor(const __tree_node_destructor &) = default;
+ __tree_node_destructor& operator=(const __tree_node_destructor&) = delete;
+
_LIBCPP_INLINE_VISIBILITY
explicit __tree_node_destructor(allocator_type& __na, bool __val = false) _NOEXCEPT
: __na_(__na),
@@ -1574,8 +1577,8 @@ __tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp)
template <class _Tp, class _Compare, class _Allocator>
__tree<_Tp, _Compare, _Allocator>::__tree(const allocator_type& __a)
: __begin_node_(__iter_pointer()),
- __pair1_(__second_tag(), __node_allocator(__a)),
- __pair3_(0)
+ __pair1_(__default_init_tag(), __node_allocator(__a)),
+ __pair3_(0, __default_init_tag())
{
__begin_node() = __end_node();
}
@@ -1584,7 +1587,7 @@ template <class _Tp, class _Compare, class _Allocator>
__tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp,
const allocator_type& __a)
: __begin_node_(__iter_pointer()),
- __pair1_(__second_tag(), __node_allocator(__a)),
+ __pair1_(__default_init_tag(), __node_allocator(__a)),
__pair3_(0, __comp)
{
__begin_node() = __end_node();
@@ -1656,7 +1659,7 @@ __tree<_Tp, _Compare, _Allocator>::__assign_unique(_ForwardIterator __first, _Fo
typedef typename _ITraits::value_type _ItValueType;
static_assert((is_same<_ItValueType, __container_value_type>::value),
"__assign_unique may only be called with the containers value type");
- static_assert(__is_forward_iterator<_ForwardIterator>::value,
+ static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
"__assign_unique requires a forward iterator");
if (size() != 0)
{
@@ -1697,7 +1700,7 @@ __tree<_Tp, _Compare, _Allocator>::__assign_multi(_InputIterator __first, _Input
template <class _Tp, class _Compare, class _Allocator>
__tree<_Tp, _Compare, _Allocator>::__tree(const __tree& __t)
: __begin_node_(__iter_pointer()),
- __pair1_(__second_tag(), __node_traits::select_on_container_copy_construction(__t.__node_alloc())),
+ __pair1_(__default_init_tag(), __node_traits::select_on_container_copy_construction(__t.__node_alloc())),
__pair3_(0, __t.value_comp())
{
__begin_node() = __end_node();
@@ -1727,7 +1730,7 @@ __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t)
template <class _Tp, class _Compare, class _Allocator>
__tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t, const allocator_type& __a)
- : __pair1_(__second_tag(), __node_allocator(__a)),
+ : __pair1_(__default_init_tag(), __node_allocator(__a)),
__pair3_(0, _VSTD::move(__t.value_comp()))
{
if (__a == __t.__alloc())
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 55ea5eb2cc02..83e49f19ab98 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -167,20 +167,20 @@ template <class ForwardIterator, class Size, class T, class BinaryPredicate>
Size count, const T& value, BinaryPredicate pred);
template <class InputIterator, class OutputIterator>
- OutputIterator
+ constexpr OutputIterator // constexpr in C++20
copy(InputIterator first, InputIterator last, OutputIterator result);
template<class InputIterator, class OutputIterator, class Predicate>
- OutputIterator
+ constexpr OutputIterator // constexpr in C++20
copy_if(InputIterator first, InputIterator last,
OutputIterator result, Predicate pred);
template<class InputIterator, class Size, class OutputIterator>
- OutputIterator
+ constexpr OutputIterator // constexpr in C++20
copy_n(InputIterator first, Size n, OutputIterator result);
template <class BidirectionalIterator1, class BidirectionalIterator2>
- BidirectionalIterator2
+ constexpr BidirectionalIterator2 // constexpr in C++20
copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
BidirectionalIterator2 result);
@@ -1631,7 +1631,7 @@ search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const
// copy
template <class _Iter>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_Iter
__unwrap_iter(_Iter __i)
{
@@ -1639,7 +1639,7 @@ __unwrap_iter(_Iter __i)
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
typename enable_if
<
is_trivially_copy_assignable<_Tp>::value,
@@ -1693,15 +1693,23 @@ __unwrap_iter(__wrap_iter<_Tp*> __i)
#endif // _LIBCPP_DEBUG_LEVEL < 2
template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
-__copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
+__copy_constexpr(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
{
for (; __first != __last; ++__first, (void) ++__result)
*__result = *__first;
return __result;
}
+template <class _InputIterator, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+__copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
+{
+ return __copy_constexpr(__first, __last, __result);
+}
+
template <class _Tp, class _Up>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
@@ -1719,25 +1727,39 @@ __copy(_Tp* __first, _Tp* __last, _Up* __result)
}
template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
_OutputIterator
copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
{
- return _VSTD::__copy(__unwrap_iter(__first), __unwrap_iter(__last), __unwrap_iter(__result));
+ if (__libcpp_is_constant_evaluated()) {
+ return _VSTD::__copy_constexpr(
+ __unwrap_iter(__first), __unwrap_iter(__last), __unwrap_iter(__result));
+ } else {
+ return _VSTD::__copy(
+ __unwrap_iter(__first), __unwrap_iter(__last), __unwrap_iter(__result));
+ }
}
// copy_backward
template <class _BidirectionalIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
-__copy_backward(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result)
+__copy_backward_constexpr(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result)
{
while (__first != __last)
*--__result = *--__last;
return __result;
}
+template <class _BidirectionalIterator, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+__copy_backward(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result)
+{
+ return __copy_backward_constexpr(__first, __last, __result);
+}
+
template <class _Tp, class _Up>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
@@ -1758,20 +1780,26 @@ __copy_backward(_Tp* __first, _Tp* __last, _Up* __result)
}
template <class _BidirectionalIterator1, class _BidirectionalIterator2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
_BidirectionalIterator2
copy_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last,
_BidirectionalIterator2 __result)
{
- return _VSTD::__copy_backward(__unwrap_iter(__first),
- __unwrap_iter(__last),
- __unwrap_iter(__result));
+ if (__libcpp_is_constant_evaluated()) {
+ return _VSTD::__copy_backward_constexpr(__unwrap_iter(__first),
+ __unwrap_iter(__last),
+ __unwrap_iter(__result));
+ } else {
+ return _VSTD::__copy_backward(__unwrap_iter(__first),
+ __unwrap_iter(__last),
+ __unwrap_iter(__result));
+ }
}
// copy_if
template<class _InputIterator, class _OutputIterator, class _Predicate>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
copy_if(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _Predicate __pred)
@@ -1790,11 +1818,11 @@ copy_if(_InputIterator __first, _InputIterator __last,
// copy_n
template<class _InputIterator, class _Size, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
typename enable_if
<
- __is_input_iterator<_InputIterator>::value &&
- !__is_random_access_iterator<_InputIterator>::value,
+ __is_cpp17_input_iterator<_InputIterator>::value &&
+ !__is_cpp17_random_access_iterator<_InputIterator>::value,
_OutputIterator
>::type
copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
@@ -1816,10 +1844,10 @@ copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
}
template<class _InputIterator, class _Size, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
typename enable_if
<
- __is_random_access_iterator<_InputIterator>::value,
+ __is_cpp17_random_access_iterator<_InputIterator>::value,
_OutputIterator
>::type
copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
@@ -2492,7 +2520,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_ForwardIterator
min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
{
- static_assert(__is_forward_iterator<_ForwardIterator>::value,
+ static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
"std::min_element requires a ForwardIterator");
if (__first != __last)
{
@@ -2564,7 +2592,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_ForwardIterator
max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
{
- static_assert(__is_forward_iterator<_ForwardIterator>::value,
+ static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
"std::max_element requires a ForwardIterator");
if (__first != __last)
{
@@ -2659,7 +2687,7 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX11
std::pair<_ForwardIterator, _ForwardIterator>
minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
{
- static_assert(__is_forward_iterator<_ForwardIterator>::value,
+ static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
"std::minmax_element requires a ForwardIterator");
std::pair<_ForwardIterator, _ForwardIterator> __result(__first, __first);
if (__first != __last)
@@ -3158,8 +3186,8 @@ _SampleIterator __sample(_PopulationIterator __first,
_PopCategory;
typedef typename iterator_traits<_PopulationIterator>::difference_type
_Difference;
- static_assert(__is_forward_iterator<_PopulationIterator>::value ||
- __is_random_access_iterator<_SampleIterator>::value,
+ static_assert(__is_cpp17_forward_iterator<_PopulationIterator>::value ||
+ __is_cpp17_random_access_iterator<_SampleIterator>::value,
"SampleIterator must meet the requirements of RandomAccessIterator");
typedef typename common_type<_Distance, _Difference>::type _CommonType;
_LIBCPP_ASSERT(__n >= 0, "N must be a positive number.");
diff --git a/libcxx/include/bit b/libcxx/include/bit
index 8800b22b7bcb..6dc85b5d01fb 100644
--- a/libcxx/include/bit
+++ b/libcxx/include/bit
@@ -42,7 +42,7 @@ namespace std {
template<class T>
constexpr int popcount(T x) noexcept; // C++20
- // 20.15.9, endian
+ // 20.15.9, endian
enum class endian {
little = see below, // C++20
big = see below, // C++20
@@ -350,7 +350,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
bool __ispow2(_Tp __t) _NOEXCEPT
{
static_assert(__bitop_unsigned_integer<_Tp>::value, "__ispow2 requires unsigned");
- return __t != 0 && (((__t & (__t - 1)) == 0));
+ return __t != 0 && (((__t & (__t - 1)) == 0));
}
diff --git a/libcxx/include/chrono b/libcxx/include/chrono
index 0e4cf9aef3ac..6e5de398b72f 100644
--- a/libcxx/include/chrono
+++ b/libcxx/include/chrono
@@ -1858,6 +1858,7 @@ public:
constexpr weekday_indexed operator[](unsigned __index) const noexcept;
constexpr weekday_last operator[](last_spec) const noexcept;
+ // TODO: Make private?
static constexpr unsigned char __weekday_from_days(int __days) noexcept;
};
@@ -2568,8 +2569,13 @@ public:
inline constexpr bool ok() const noexcept
{
if (!__y.ok() || !__m.ok() || !__wdi.ok()) return false;
- // TODO: make sure it's a valid date
- return true;
+ if (__wdi.index() <= 4) return true;
+ auto __nth_weekday_day =
+ __wdi.weekday() -
+ chrono::weekday{static_cast<sys_days>(__y / __m / 1)} +
+ days{(__wdi.index() - 1) * 7 + 1};
+ return static_cast<unsigned>(__nth_weekday_day.count()) <=
+ static_cast<unsigned>((__y / __m / last).day());
}
static constexpr year_month_weekday __from_days(days __d) noexcept;
diff --git a/libcxx/include/cstdlib b/libcxx/include/cstdlib
index 68b3ded3fd51..675a12d9e04b 100644
--- a/libcxx/include/cstdlib
+++ b/libcxx/include/cstdlib
@@ -154,7 +154,7 @@ using ::wcstombs;
using ::at_quick_exit;
using ::quick_exit;
#endif
-#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_C11_FEATURES)
+#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_ALIGNED_ALLOC)
using ::aligned_alloc;
#endif
diff --git a/libcxx/include/ctime b/libcxx/include/ctime
index cb8474f8f0b5..f9f2f1659d0e 100644
--- a/libcxx/include/ctime
+++ b/libcxx/include/ctime
@@ -18,7 +18,7 @@ Macros:
NULL
CLOCKS_PER_SEC
TIME_UTC // C++17
-
+
namespace std
{
@@ -29,7 +29,7 @@ Types:
time_t
tm
timespec // C++17
-
+
clock_t clock();
double difftime(time_t time1, time_t time0);
time_t mktime(tm* timeptr);
@@ -58,7 +58,7 @@ using ::clock_t;
using ::size_t;
using ::time_t;
using ::tm;
-#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_C11_FEATURES)
+#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_TIMESPEC_GET)
using ::timespec;
#endif
using ::clock;
diff --git a/libcxx/include/deque b/libcxx/include/deque
index cb7e4e532719..115b1b642701 100644
--- a/libcxx/include/deque
+++ b/libcxx/include/deque
@@ -190,7 +190,7 @@ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
copy(_RAIter __f,
_RAIter __l,
__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
- typename enable_if<__is_random_access_iterator<_RAIter>::value>::type* = 0);
+ typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type* = 0);
template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
class _OutputIterator>
@@ -212,7 +212,7 @@ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
copy_backward(_RAIter __f,
_RAIter __l,
__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
- typename enable_if<__is_random_access_iterator<_RAIter>::value>::type* = 0);
+ typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type* = 0);
template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
class _OutputIterator>
@@ -234,7 +234,7 @@ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
move(_RAIter __f,
_RAIter __l,
__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
- typename enable_if<__is_random_access_iterator<_RAIter>::value>::type* = 0);
+ typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type* = 0);
template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
class _OutputIterator>
@@ -256,7 +256,7 @@ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
move_backward(_RAIter __f,
_RAIter __l,
__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
- typename enable_if<__is_random_access_iterator<_RAIter>::value>::type* = 0);
+ typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type* = 0);
template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
class _OutputIterator>
@@ -450,7 +450,7 @@ private:
copy(_RAIter __f,
_RAIter __l,
__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
- typename enable_if<__is_random_access_iterator<_RAIter>::value>::type*);
+ typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type*);
template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
class _OutputIterator>
@@ -475,7 +475,7 @@ private:
copy_backward(_RAIter __f,
_RAIter __l,
__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
- typename enable_if<__is_random_access_iterator<_RAIter>::value>::type*);
+ typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type*);
template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
class _OutputIterator>
@@ -500,7 +500,7 @@ private:
move(_RAIter __f,
_RAIter __l,
__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
- typename enable_if<__is_random_access_iterator<_RAIter>::value>::type*);
+ typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type*);
template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
class _OutputIterator>
@@ -525,7 +525,7 @@ private:
move_backward(_RAIter __f,
_RAIter __l,
__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
- typename enable_if<__is_random_access_iterator<_RAIter>::value>::type*);
+ typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type*);
template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
class _OutputIterator>
@@ -558,7 +558,7 @@ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
copy(_RAIter __f,
_RAIter __l,
__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
- typename enable_if<__is_random_access_iterator<_RAIter>::value>::type*)
+ typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type*)
{
typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::difference_type difference_type;
typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::pointer pointer;
@@ -646,7 +646,7 @@ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
copy_backward(_RAIter __f,
_RAIter __l,
__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
- typename enable_if<__is_random_access_iterator<_RAIter>::value>::type*)
+ typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type*)
{
typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::difference_type difference_type;
typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::pointer pointer;
@@ -734,7 +734,7 @@ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
move(_RAIter __f,
_RAIter __l,
__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
- typename enable_if<__is_random_access_iterator<_RAIter>::value>::type*)
+ typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type*)
{
typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::difference_type difference_type;
typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::pointer pointer;
@@ -822,7 +822,7 @@ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
move_backward(_RAIter __f,
_RAIter __l,
__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
- typename enable_if<__is_random_access_iterator<_RAIter>::value>::type*)
+ typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type*)
{
typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::difference_type difference_type;
typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::pointer pointer;
@@ -1171,7 +1171,7 @@ template <class _Tp, class _Allocator>
inline
__deque_base<_Tp, _Allocator>::__deque_base()
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
- : __start_(0), __size_(0) {}
+ : __start_(0), __size_(0, __default_init_tag()) {}
template <class _Tp, class _Allocator>
inline
@@ -1308,10 +1308,10 @@ public:
deque(size_type __n, const value_type& __v, const allocator_type& __a);
template <class _InputIter>
deque(_InputIter __f, _InputIter __l,
- typename enable_if<__is_input_iterator<_InputIter>::value>::type* = 0);
+ typename enable_if<__is_cpp17_input_iterator<_InputIter>::value>::type* = 0);
template <class _InputIter>
deque(_InputIter __f, _InputIter __l, const allocator_type& __a,
- typename enable_if<__is_input_iterator<_InputIter>::value>::type* = 0);
+ typename enable_if<__is_cpp17_input_iterator<_InputIter>::value>::type* = 0);
deque(const deque& __c);
deque(const deque& __c, const allocator_type& __a);
@@ -1339,11 +1339,11 @@ public:
template <class _InputIter>
void assign(_InputIter __f, _InputIter __l,
- typename enable_if<__is_input_iterator<_InputIter>::value &&
- !__is_random_access_iterator<_InputIter>::value>::type* = 0);
+ typename enable_if<__is_cpp17_input_iterator<_InputIter>::value &&
+ !__is_cpp17_random_access_iterator<_InputIter>::value>::type* = 0);
template <class _RAIter>
void assign(_RAIter __f, _RAIter __l,
- typename enable_if<__is_random_access_iterator<_RAIter>::value>::type* = 0);
+ typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type* = 0);
void assign(size_type __n, const value_type& __v);
_LIBCPP_INLINE_VISIBILITY
@@ -1443,15 +1443,15 @@ public:
iterator insert(const_iterator __p, size_type __n, const value_type& __v);
template <class _InputIter>
iterator insert(const_iterator __p, _InputIter __f, _InputIter __l,
- typename enable_if<__is_input_iterator<_InputIter>::value
- &&!__is_forward_iterator<_InputIter>::value>::type* = 0);
+ typename enable_if<__is_cpp17_input_iterator<_InputIter>::value
+ &&!__is_cpp17_forward_iterator<_InputIter>::value>::type* = 0);
template <class _ForwardIterator>
iterator insert(const_iterator __p, _ForwardIterator __f, _ForwardIterator __l,
- typename enable_if<__is_forward_iterator<_ForwardIterator>::value
- &&!__is_bidirectional_iterator<_ForwardIterator>::value>::type* = 0);
+ typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value
+ &&!__is_cpp17_bidirectional_iterator<_ForwardIterator>::value>::type* = 0);
template <class _BiIter>
iterator insert(const_iterator __p, _BiIter __f, _BiIter __l,
- typename enable_if<__is_bidirectional_iterator<_BiIter>::value>::type* = 0);
+ typename enable_if<__is_cpp17_bidirectional_iterator<_BiIter>::value>::type* = 0);
void pop_front();
void pop_back();
@@ -1535,11 +1535,11 @@ public:
template <class _InpIter>
void __append(_InpIter __f, _InpIter __l,
- typename enable_if<__is_input_iterator<_InpIter>::value &&
- !__is_forward_iterator<_InpIter>::value>::type* = 0);
+ typename enable_if<__is_cpp17_input_iterator<_InpIter>::value &&
+ !__is_cpp17_forward_iterator<_InpIter>::value>::type* = 0);
template <class _ForIter>
void __append(_ForIter __f, _ForIter __l,
- typename enable_if<__is_forward_iterator<_ForIter>::value>::type* = 0);
+ typename enable_if<__is_cpp17_forward_iterator<_ForIter>::value>::type* = 0);
void __append(size_type __n);
void __append(size_type __n, const value_type& __v);
void __erase_to_end(const_iterator __f);
@@ -1634,7 +1634,7 @@ deque<_Tp, _Allocator>::deque(size_type __n, const value_type& __v, const alloca
template <class _Tp, class _Allocator>
template <class _InputIter>
deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l,
- typename enable_if<__is_input_iterator<_InputIter>::value>::type*)
+ typename enable_if<__is_cpp17_input_iterator<_InputIter>::value>::type*)
{
__append(__f, __l);
}
@@ -1642,7 +1642,7 @@ deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l,
template <class _Tp, class _Allocator>
template <class _InputIter>
deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l, const allocator_type& __a,
- typename enable_if<__is_input_iterator<_InputIter>::value>::type*)
+ typename enable_if<__is_cpp17_input_iterator<_InputIter>::value>::type*)
: __base(__a)
{
__append(__f, __l);
@@ -1750,8 +1750,8 @@ template <class _Tp, class _Allocator>
template <class _InputIter>
void
deque<_Tp, _Allocator>::assign(_InputIter __f, _InputIter __l,
- typename enable_if<__is_input_iterator<_InputIter>::value &&
- !__is_random_access_iterator<_InputIter>::value>::type*)
+ typename enable_if<__is_cpp17_input_iterator<_InputIter>::value &&
+ !__is_cpp17_random_access_iterator<_InputIter>::value>::type*)
{
iterator __i = __base::begin();
iterator __e = __base::end();
@@ -1767,7 +1767,7 @@ template <class _Tp, class _Allocator>
template <class _RAIter>
void
deque<_Tp, _Allocator>::assign(_RAIter __f, _RAIter __l,
- typename enable_if<__is_random_access_iterator<_RAIter>::value>::type*)
+ typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type*)
{
if (static_cast<size_type>(__l - __f) > __base::size())
{
@@ -2252,8 +2252,8 @@ template <class _Tp, class _Allocator>
template <class _InputIter>
typename deque<_Tp, _Allocator>::iterator
deque<_Tp, _Allocator>::insert(const_iterator __p, _InputIter __f, _InputIter __l,
- typename enable_if<__is_input_iterator<_InputIter>::value
- &&!__is_forward_iterator<_InputIter>::value>::type*)
+ typename enable_if<__is_cpp17_input_iterator<_InputIter>::value
+ &&!__is_cpp17_forward_iterator<_InputIter>::value>::type*)
{
__split_buffer<value_type, allocator_type&> __buf(__base::__alloc());
__buf.__construct_at_end(__f, __l);
@@ -2265,8 +2265,8 @@ template <class _Tp, class _Allocator>
template <class _ForwardIterator>
typename deque<_Tp, _Allocator>::iterator
deque<_Tp, _Allocator>::insert(const_iterator __p, _ForwardIterator __f, _ForwardIterator __l,
- typename enable_if<__is_forward_iterator<_ForwardIterator>::value
- &&!__is_bidirectional_iterator<_ForwardIterator>::value>::type*)
+ typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value
+ &&!__is_cpp17_bidirectional_iterator<_ForwardIterator>::value>::type*)
{
size_type __n = _VSTD::distance(__f, __l);
__split_buffer<value_type, allocator_type&> __buf(__n, 0, __base::__alloc());
@@ -2279,7 +2279,7 @@ template <class _Tp, class _Allocator>
template <class _BiIter>
typename deque<_Tp, _Allocator>::iterator
deque<_Tp, _Allocator>::insert(const_iterator __p, _BiIter __f, _BiIter __l,
- typename enable_if<__is_bidirectional_iterator<_BiIter>::value>::type*)
+ typename enable_if<__is_cpp17_bidirectional_iterator<_BiIter>::value>::type*)
{
size_type __n = _VSTD::distance(__f, __l);
size_type __pos = __p - __base::begin();
@@ -2348,8 +2348,8 @@ template <class _Tp, class _Allocator>
template <class _InpIter>
void
deque<_Tp, _Allocator>::__append(_InpIter __f, _InpIter __l,
- typename enable_if<__is_input_iterator<_InpIter>::value &&
- !__is_forward_iterator<_InpIter>::value>::type*)
+ typename enable_if<__is_cpp17_input_iterator<_InpIter>::value &&
+ !__is_cpp17_forward_iterator<_InpIter>::value>::type*)
{
for (; __f != __l; ++__f)
#ifdef _LIBCPP_CXX03_LANG
@@ -2363,7 +2363,7 @@ template <class _Tp, class _Allocator>
template <class _ForIter>
void
deque<_Tp, _Allocator>::__append(_ForIter __f, _ForIter __l,
- typename enable_if<__is_forward_iterator<_ForIter>::value>::type*)
+ typename enable_if<__is_cpp17_forward_iterator<_ForIter>::value>::type*)
{
size_type __n = _VSTD::distance(__f, __l);
allocator_type& __a = __base::__alloc();
@@ -2374,7 +2374,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_raw_pointer(__tx.__pos_), *__f);
+ __alloc_traits::construct(__a, std::__to_address(__tx.__pos_), *__f);
}
}
}
@@ -2391,7 +2391,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_raw_pointer(__tx.__pos_));
+ __alloc_traits::construct(__a, std::__to_address(__tx.__pos_));
}
}
}
@@ -2408,7 +2408,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_raw_pointer(__tx.__pos_), __v);
+ __alloc_traits::construct(__a, std::__to_address(__tx.__pos_), __v);
}
}
@@ -2706,7 +2706,7 @@ void
deque<_Tp, _Allocator>::pop_front()
{
allocator_type& __a = __base::__alloc();
- __alloc_traits::destroy(__a, __to_raw_pointer(*(__base::__map_.begin() +
+ __alloc_traits::destroy(__a, __to_address(*(__base::__map_.begin() +
__base::__start_ / __base::__block_size) +
__base::__start_ % __base::__block_size));
--__base::size();
@@ -2721,7 +2721,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_raw_pointer(*(__base::__map_.begin() +
+ __alloc_traits::destroy(__a, __to_address(*(__base::__map_.begin() +
__p / __base::__block_size) +
__p % __base::__block_size));
--__base::size();
diff --git a/libcxx/include/experimental/functional b/libcxx/include/experimental/functional
index 755eda641556..c7dda2254b39 100644
--- a/libcxx/include/experimental/functional
+++ b/libcxx/include/experimental/functional
@@ -112,7 +112,7 @@ template<class _ForwardIterator, class _BinaryPredicate = equal_to<>>
class _LIBCPP_TYPE_VIS default_searcher {
public:
_LIBCPP_INLINE_VISIBILITY
- default_searcher(_ForwardIterator __f, _ForwardIterator __l,
+ default_searcher(_ForwardIterator __f, _ForwardIterator __l,
_BinaryPredicate __p = _BinaryPredicate())
: __first_(__f), __last_(__l), __pred_(__p) {}
@@ -151,12 +151,12 @@ public: // TODO private:
const _Value __default_value_;
std::unordered_map<_Key, _Value, _Hash, _BinaryPredicate> __table;
-
+
public:
_LIBCPP_INLINE_VISIBILITY
_BMSkipTable(std::size_t __sz, _Value __default, _Hash __hf, _BinaryPredicate __pred)
: __default_value_(__default), __table(__sz, __hf, __pred) {}
-
+
_LIBCPP_INLINE_VISIBILITY
void insert(const key_type &__key, value_type __val)
{
@@ -170,7 +170,7 @@ public:
return __it == __table.end() ? __default_value_ : __it->second;
}
};
-
+
// Special case small numeric values; use an array
template<class _Key, typename _Value, class _Hash, class _BinaryPredicate>
@@ -189,7 +189,7 @@ public:
{
std::fill_n(__table.begin(), __table.size(), __default);
}
-
+
_LIBCPP_INLINE_VISIBILITY
void insert(key_type __key, value_type __val)
{
@@ -204,8 +204,8 @@ public:
};
-template <class _RandomAccessIterator1,
- class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>,
+template <class _RandomAccessIterator1,
+ class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>,
class _BinaryPredicate = equal_to<>>
class _LIBCPP_TYPE_VIS boyer_moore_searcher {
private:
@@ -217,9 +217,9 @@ private:
is_same<_Hash, hash<value_type>>::value &&
is_same<_BinaryPredicate, equal_to<>>::value
> skip_table_type;
-
+
public:
- boyer_moore_searcher(_RandomAccessIterator1 __f, _RandomAccessIterator1 __l,
+ boyer_moore_searcher(_RandomAccessIterator1 __f, _RandomAccessIterator1 __l,
_Hash __hf = _Hash(), _BinaryPredicate __pred = _BinaryPredicate())
: __first_(__f), __last_(__l), __pred_(__pred),
__pattern_length_(_VSTD::distance(__first_, __last_)),
@@ -232,13 +232,13 @@ public:
this->__build_suffix_table ( __first_, __last_, __pred_ );
}
-
+
template <typename _RandomAccessIterator2>
pair<_RandomAccessIterator2, _RandomAccessIterator2>
operator ()(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const
{
static_assert ( std::is_same<
- typename std::__uncvref<typename std::iterator_traits<_RandomAccessIterator1>::value_type>::type,
+ typename std::__uncvref<typename std::iterator_traits<_RandomAccessIterator1>::value_type>::type,
typename std::__uncvref<typename std::iterator_traits<_RandomAccessIterator2>::value_type>::type
>::value,
"Corpus and Pattern iterators must point to the same type" );
@@ -247,13 +247,13 @@ public:
if (__first_ == __last_) return make_pair(__f, __f); // empty pattern
// If the pattern is larger than the corpus, we can't find it!
- if ( __pattern_length_ > _VSTD::distance (__f, __l))
+ if ( __pattern_length_ > _VSTD::distance (__f, __l))
return make_pair(__l, __l);
- // Do the search
+ // Do the search
return this->__search(__f, __l);
}
-
+
public: // TODO private:
_RandomAccessIterator1 __first_;
_RandomAccessIterator1 __last_;
@@ -270,7 +270,7 @@ public: // TODO private:
const _RandomAccessIterator2 __last = __l - __pattern_length_;
const skip_table_type & __skip = *__skip_.get();
const vector<difference_type> & __suffix = *__suffix_.get();
-
+
while (__cur <= __last)
{
@@ -282,7 +282,7 @@ public: // TODO private:
if ( __j == 0 )
return make_pair(__cur, __cur + __pattern_length_);
}
-
+
// Since we didn't match, figure out how far to skip forward
difference_type __k = __skip[__cur [ __j - 1 ]];
difference_type __m = __j - __k - 1;
@@ -291,7 +291,7 @@ public: // TODO private:
else
__cur += __suffix[ __j ];
}
-
+
return make_pair(__l, __l); // We didn't find anything
}
@@ -300,21 +300,21 @@ public: // TODO private:
void __compute_bm_prefix ( _Iterator __f, _Iterator __l, _BinaryPredicate __pred, _Container &__prefix )
{
const std::size_t __count = _VSTD::distance(__f, __l);
-
+
__prefix[0] = 0;
std::size_t __k = 0;
for ( std::size_t __i = 1; __i < __count; ++__i )
{
while ( __k > 0 && !__pred ( __f[__k], __f[__i] ))
__k = __prefix [ __k - 1 ];
-
+
if ( __pred ( __f[__k], __f[__i] ))
__k++;
__prefix [ __i ] = __k;
}
}
- void __build_suffix_table(_RandomAccessIterator1 __f, _RandomAccessIterator1 __l,
+ void __build_suffix_table(_RandomAccessIterator1 __f, _RandomAccessIterator1 __l,
_BinaryPredicate __pred)
{
const std::size_t __count = _VSTD::distance(__f, __l);
@@ -322,19 +322,19 @@ public: // TODO private:
if (__count > 0)
{
_VSTD::vector<value_type> __scratch(__count);
-
+
__compute_bm_prefix(__f, __l, __pred, __scratch);
for ( std::size_t __i = 0; __i <= __count; __i++ )
__suffix[__i] = __count - __scratch[__count-1];
-
+
typedef _VSTD::reverse_iterator<_RandomAccessIterator1> _RevIter;
__compute_bm_prefix(_RevIter(__l), _RevIter(__f), __pred, __scratch);
-
+
for ( std::size_t __i = 0; __i < __count; __i++ )
{
const std::size_t __j = __count - __scratch[__i];
const difference_type __k = __i - __scratch[__i] + 1;
-
+
if (__suffix[__j] > __k)
__suffix[__j] = __k;
}
@@ -343,20 +343,20 @@ public: // TODO private:
};
-template<class _RandomAccessIterator,
- class _Hash = hash<typename iterator_traits<_RandomAccessIterator>::value_type>,
+template<class _RandomAccessIterator,
+ class _Hash = hash<typename iterator_traits<_RandomAccessIterator>::value_type>,
class _BinaryPredicate = equal_to<>>
_LIBCPP_INLINE_VISIBILITY
boyer_moore_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate>
-make_boyer_moore_searcher( _RandomAccessIterator __f, _RandomAccessIterator __l,
+make_boyer_moore_searcher( _RandomAccessIterator __f, _RandomAccessIterator __l,
_Hash __hf = _Hash(), _BinaryPredicate __p = _BinaryPredicate ())
{
return boyer_moore_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate>(__f, __l, __hf, __p);
}
// boyer-moore-horspool
-template <class _RandomAccessIterator1,
- class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>,
+template <class _RandomAccessIterator1,
+ class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>,
class _BinaryPredicate = equal_to<>>
class _LIBCPP_TYPE_VIS boyer_moore_horspool_searcher {
private:
@@ -370,7 +370,7 @@ private:
> skip_table_type;
public:
- boyer_moore_horspool_searcher(_RandomAccessIterator1 __f, _RandomAccessIterator1 __l,
+ boyer_moore_horspool_searcher(_RandomAccessIterator1 __f, _RandomAccessIterator1 __l,
_Hash __hf = _Hash(), _BinaryPredicate __pred = _BinaryPredicate())
: __first_(__f), __last_(__l), __pred_(__pred),
__pattern_length_(_VSTD::distance(__first_, __last_)),
@@ -384,13 +384,13 @@ public:
__skip_->insert(*__f, __pattern_length_ - 1 - __i);
}
}
-
+
template <typename _RandomAccessIterator2>
pair<_RandomAccessIterator2, _RandomAccessIterator2>
operator ()(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const
{
static_assert ( std::is_same<
- typename std::__uncvref<typename std::iterator_traits<_RandomAccessIterator1>::value_type>::type,
+ typename std::__uncvref<typename std::iterator_traits<_RandomAccessIterator1>::value_type>::type,
typename std::__uncvref<typename std::iterator_traits<_RandomAccessIterator2>::value_type>::type
>::value,
"Corpus and Pattern iterators must point to the same type" );
@@ -399,13 +399,13 @@ public:
if (__first_ == __last_) return make_pair(__f, __f); // empty pattern
// If the pattern is larger than the corpus, we can't find it!
- if ( __pattern_length_ > _VSTD::distance (__f, __l))
+ if ( __pattern_length_ > _VSTD::distance (__f, __l))
return make_pair(__l, __l);
- // Do the search
+ // Do the search
return this->__search(__f, __l);
}
-
+
private:
_RandomAccessIterator1 __first_;
_RandomAccessIterator1 __last_;
@@ -433,17 +433,17 @@ private:
}
__cur += __skip[__cur[__pattern_length_-1]];
}
-
+
return make_pair(__l, __l);
}
};
-template<class _RandomAccessIterator,
- class _Hash = hash<typename iterator_traits<_RandomAccessIterator>::value_type>,
+template<class _RandomAccessIterator,
+ class _Hash = hash<typename iterator_traits<_RandomAccessIterator>::value_type>,
class _BinaryPredicate = equal_to<>>
_LIBCPP_INLINE_VISIBILITY
boyer_moore_horspool_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate>
-make_boyer_moore_horspool_searcher( _RandomAccessIterator __f, _RandomAccessIterator __l,
+make_boyer_moore_horspool_searcher( _RandomAccessIterator __f, _RandomAccessIterator __l,
_Hash __hf = _Hash(), _BinaryPredicate __p = _BinaryPredicate ())
{
return boyer_moore_horspool_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate>(__f, __l, __hf, __p);
diff --git a/libcxx/include/experimental/iterator b/libcxx/include/experimental/iterator
index 6a6e51d820d1..10b0599138c6 100644
--- a/libcxx/include/experimental/iterator
+++ b/libcxx/include/experimental/iterator
@@ -26,19 +26,19 @@ namespace std {
typedef void difference_type;
typedef void pointer;
typedef void reference;
-
+
ostream_joiner(ostream_type& s, const DelimT& delimiter);
ostream_joiner(ostream_type& s, DelimT&& delimiter);
- template<typename T>
+ template<typename T>
ostream_joiner& operator=(const T& value);
ostream_joiner& operator*() noexcept;
ostream_joiner& operator++() noexcept;
ostream_joiner& operator++(int) noexcept;
private:
- ostream_type* out_stream; // exposition only
- DelimT delim; // exposition only
+ ostream_type* out_stream; // exposition only
+ DelimT delim; // exposition only
bool first_element; // exposition only
};
@@ -75,10 +75,10 @@ public:
ostream_joiner(ostream_type& __os, _Delim&& __d)
: __output_iter(_VSTD::addressof(__os)), __delim(_VSTD::move(__d)), __first(true) {}
-
+
ostream_joiner(ostream_type& __os, const _Delim& __d)
: __output_iter(_VSTD::addressof(__os)), __delim(__d), __first(true) {}
-
+
template<typename _Tp>
ostream_joiner& operator=(const _Tp& __v)
diff --git a/libcxx/include/experimental/propagate_const b/libcxx/include/experimental/propagate_const
index 092b013bb904..59f50c5e574d 100644
--- a/libcxx/include/experimental/propagate_const
+++ b/libcxx/include/experimental/propagate_const
@@ -575,4 +575,3 @@ _LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_STD_VER > 11
#endif // _LIBCPP_EXPERIMENTAL_PROPAGATE_CONST
-
diff --git a/libcxx/include/experimental/type_traits b/libcxx/include/experimental/type_traits
index 19466e9a5a5d..7ab097226b5d 100644
--- a/libcxx/include/experimental/type_traits
+++ b/libcxx/include/experimental/type_traits
@@ -60,7 +60,7 @@ inline namespace fundamentals_v1 {
using is_detected_convertible = is_convertible<detected_t<Op, Args...>, To>;
template <class To, template<class...> class Op, class... Args>
constexpr bool is_detected_convertible_v
- = is_detected_convertible<To, Op, Args...>::value;
+ = is_detected_convertible<To, Op, Args...>::value;
} // namespace fundamentals_v1
} // namespace experimental
@@ -122,7 +122,7 @@ struct _DETECTOR<_Default, void_t<_Op<_Args...>>, _Op, _Args...> {
using value_t = true_type;
using type = _Op<_Args...>;
};
-
+
template <template<class...> class _Op, class... _Args>
using is_detected = typename _DETECTOR<nonesuch, void, _Op, _Args...>::value_t;
@@ -144,7 +144,7 @@ template <class Expected, template<class...> class _Op, class... _Args>
template <class To, template<class...> class _Op, class... _Args>
using is_detected_convertible = is_convertible<detected_t<_Op, _Args...>, To>;
template <class To, template<class...> class _Op, class... _Args>
- _LIBCPP_CONSTEXPR bool is_detected_convertible_v = is_detected_convertible<To, _Op, _Args...>::value;
+ _LIBCPP_CONSTEXPR bool is_detected_convertible_v = is_detected_convertible<To, _Op, _Args...>::value;
_LIBCPP_END_NAMESPACE_LFTS
diff --git a/libcxx/include/ext/hash_map b/libcxx/include/ext/hash_map
index 20f778be9710..7478d7410064 100644
--- a/libcxx/include/ext/hash_map
+++ b/libcxx/include/ext/hash_map
@@ -318,12 +318,13 @@ private:
allocator_type& __na_;
- __hash_map_node_destructor& operator=(const __hash_map_node_destructor&);
-
public:
bool __first_constructed;
bool __second_constructed;
+ __hash_map_node_destructor(__hash_map_node_destructor const&) = default;
+ __hash_map_node_destructor& operator=(const __hash_map_node_destructor&) = delete;
+
_LIBCPP_INLINE_VISIBILITY
explicit __hash_map_node_destructor(allocator_type& __na)
: __na_(__na),
@@ -394,10 +395,10 @@ public:
return __t;
}
- friend _LIBCPP_INLINE_VISIBILITY
+ friend _LIBCPP_INLINE_VISIBILITY
bool operator==(const __hash_map_iterator& __x, const __hash_map_iterator& __y)
{return __x.__i_ == __y.__i_;}
- friend _LIBCPP_INLINE_VISIBILITY
+ friend _LIBCPP_INLINE_VISIBILITY
bool operator!=(const __hash_map_iterator& __x, const __hash_map_iterator& __y)
{return __x.__i_ != __y.__i_;}
diff --git a/libcxx/include/filesystem b/libcxx/include/filesystem
index 9020a12fea18..0f7a4d556988 100644
--- a/libcxx/include/filesystem
+++ b/libcxx/include/filesystem
@@ -625,7 +625,7 @@ struct __is_pathable_char_array<_Source, _ECharT*, _UPtr, true>
static _ECharT __first_or_null(const _ECharT* __b) { return *__b; }
};
-template <class _Iter, bool _IsIt = __is_input_iterator<_Iter>::value,
+template <class _Iter, bool _IsIt = __is_cpp17_input_iterator<_Iter>::value,
class = void>
struct __is_pathable_iter : false_type {};
@@ -708,14 +708,14 @@ template <>
struct _PathCVT<char> {
template <class _Iter>
- static typename enable_if<__is_exactly_input_iterator<_Iter>::value>::type
+ static typename enable_if<__is_exactly_cpp17_input_iterator<_Iter>::value>::type
__append_range(string& __dest, _Iter __b, _Iter __e) {
for (; __b != __e; ++__b)
__dest.push_back(*__b);
}
template <class _Iter>
- static typename enable_if<__is_forward_iterator<_Iter>::value>::type
+ static typename enable_if<__is_cpp17_forward_iterator<_Iter>::value>::type
__append_range(string& __dest, _Iter __b, _Iter __e) {
__dest.__append_forward_unsafe(__b, __e);
}
diff --git a/libcxx/include/forward_list b/libcxx/include/forward_list
index d59ddd4ef97a..3905745931fd 100644
--- a/libcxx/include/forward_list
+++ b/libcxx/include/forward_list
@@ -490,7 +490,7 @@ protected:
_LIBCPP_INLINE_VISIBILITY
__forward_list_base()
_NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)
- : __before_begin_(__begin_node()) {}
+ : __before_begin_(__begin_node(), __default_init_tag()) {}
_LIBCPP_INLINE_VISIBILITY
explicit __forward_list_base(const allocator_type& __a)
: __before_begin_(__begin_node(), __node_allocator(__a)) {}
@@ -670,13 +670,13 @@ public:
template <class _InputIterator>
forward_list(_InputIterator __f, _InputIterator __l,
typename enable_if<
- __is_input_iterator<_InputIterator>::value
+ __is_cpp17_input_iterator<_InputIterator>::value
>::type* = nullptr);
template <class _InputIterator>
forward_list(_InputIterator __f, _InputIterator __l,
const allocator_type& __a,
typename enable_if<
- __is_input_iterator<_InputIterator>::value
+ __is_cpp17_input_iterator<_InputIterator>::value
>::type* = nullptr);
forward_list(const forward_list& __x);
forward_list(const forward_list& __x, const allocator_type& __a);
@@ -711,7 +711,7 @@ public:
template <class _InputIterator>
typename enable_if
<
- __is_input_iterator<_InputIterator>::value,
+ __is_cpp17_input_iterator<_InputIterator>::value,
void
>::type
assign(_InputIterator __f, _InputIterator __l);
@@ -792,7 +792,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
typename enable_if
<
- __is_input_iterator<_InputIterator>::value,
+ __is_cpp17_input_iterator<_InputIterator>::value,
iterator
>::type
insert_after(const_iterator __p, _InputIterator __f, _InputIterator __l);
@@ -950,7 +950,7 @@ template <class _Tp, class _Alloc>
template <class _InputIterator>
forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l,
typename enable_if<
- __is_input_iterator<_InputIterator>::value
+ __is_cpp17_input_iterator<_InputIterator>::value
>::type*)
{
insert_after(cbefore_begin(), __f, __l);
@@ -961,7 +961,7 @@ template <class _InputIterator>
forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l,
const allocator_type& __a,
typename enable_if<
- __is_input_iterator<_InputIterator>::value
+ __is_cpp17_input_iterator<_InputIterator>::value
>::type*)
: base(__a)
{
@@ -1074,7 +1074,7 @@ template <class _Tp, class _Alloc>
template <class _InputIterator>
typename enable_if
<
- __is_input_iterator<_InputIterator>::value,
+ __is_cpp17_input_iterator<_InputIterator>::value,
void
>::type
forward_list<_Tp, _Alloc>::assign(_InputIterator __f, _InputIterator __l)
@@ -1270,7 +1270,7 @@ template <class _Tp, class _Alloc>
template <class _InputIterator>
typename enable_if
<
- __is_input_iterator<_InputIterator>::value,
+ __is_cpp17_input_iterator<_InputIterator>::value,
typename forward_list<_Tp, _Alloc>::iterator
>::type
forward_list<_Tp, _Alloc>::insert_after(const_iterator __p,
@@ -1525,7 +1525,7 @@ forward_list<_Tp, _Alloc>::remove(const value_type& __v)
else
++__i;
}
-
+
return (__remove_return_type) __count_removed;
}
@@ -1553,7 +1553,7 @@ forward_list<_Tp, _Alloc>::remove_if(_Predicate __pred)
else
++__i;
}
-
+
return (__remove_return_type) __count_removed;
}
@@ -1573,7 +1573,7 @@ forward_list<_Tp, _Alloc>::unique(_BinaryPredicate __binary_pred)
__deleted_nodes.splice_after(__deleted_nodes.before_begin(), *this, __i, __j);
__i = __j;
}
-
+
return (__remove_return_type) __count_removed;
}
diff --git a/libcxx/include/future b/libcxx/include/future
index 6da88c6e62b2..751d122a6000 100644
--- a/libcxx/include/future
+++ b/libcxx/include/future
@@ -611,7 +611,7 @@ __assoc_sub_state::wait_for(const chrono::duration<_Rep, _Period>& __rel_time) c
}
template <class _Rp>
-class _LIBCPP_AVAILABILITY_FUTURE __assoc_state
+class _LIBCPP_AVAILABILITY_FUTURE _LIBCPP_HIDDEN __assoc_state
: public __assoc_sub_state
{
typedef __assoc_sub_state base;
@@ -1060,7 +1060,7 @@ template <class _Rp> class _LIBCPP_TEMPLATE_VIS shared_future;
template <class _Rp> class _LIBCPP_TEMPLATE_VIS future;
template <class _Rp, class _Fp>
-future<_Rp>
+_LIBCPP_INLINE_VISIBILITY future<_Rp>
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
__make_deferred_assoc_state(_Fp&& __f);
#else
@@ -1068,7 +1068,7 @@ __make_deferred_assoc_state(_Fp __f);
#endif
template <class _Rp, class _Fp>
-future<_Rp>
+_LIBCPP_INLINE_VISIBILITY future<_Rp>
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
__make_async_assoc_state(_Fp&& __f);
#else
@@ -1767,9 +1767,9 @@ class _LIBCPP_AVAILABILITY_FUTURE __packaged_task_func<_Fp, _Alloc, _Rp(_ArgType
__compressed_pair<_Fp, _Alloc> __f_;
public:
_LIBCPP_INLINE_VISIBILITY
- explicit __packaged_task_func(const _Fp& __f) : __f_(__f) {}
+ explicit __packaged_task_func(const _Fp& __f) : __f_(__f, __default_init_tag()) {}
_LIBCPP_INLINE_VISIBILITY
- explicit __packaged_task_func(_Fp&& __f) : __f_(_VSTD::move(__f)) {}
+ explicit __packaged_task_func(_Fp&& __f) : __f_(_VSTD::move(__f), __default_init_tag()) {}
_LIBCPP_INLINE_VISIBILITY
__packaged_task_func(const _Fp& __f, const _Alloc& __a)
: __f_(__f, __a) {}
@@ -2266,7 +2266,7 @@ struct _LIBCPP_TEMPLATE_VIS uses_allocator<packaged_task<_Callable>, _Alloc>
: public true_type {};
template <class _Rp, class _Fp>
-future<_Rp>
+_LIBCPP_INLINE_VISIBILITY future<_Rp>
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
__make_deferred_assoc_state(_Fp&& __f)
#else
@@ -2279,7 +2279,7 @@ __make_deferred_assoc_state(_Fp __f)
}
template <class _Rp, class _Fp>
-future<_Rp>
+_LIBCPP_INLINE_VISIBILITY future<_Rp>
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
__make_async_assoc_state(_Fp&& __f)
#else
@@ -2293,7 +2293,7 @@ __make_async_assoc_state(_Fp __f)
}
template <class _Fp, class... _Args>
-class __async_func
+class _LIBCPP_HIDDEN __async_func
{
tuple<_Fp, _Args...> __f_;
diff --git a/libcxx/include/iterator b/libcxx/include/iterator
index 30801ea83dbd..57dd055b4ac9 100644
--- a/libcxx/include/iterator
+++ b/libcxx/include/iterator
@@ -434,12 +434,65 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept;
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
+template <class _Iter>
+struct _LIBCPP_TEMPLATE_VIS iterator_traits;
struct _LIBCPP_TEMPLATE_VIS input_iterator_tag {};
struct _LIBCPP_TEMPLATE_VIS output_iterator_tag {};
struct _LIBCPP_TEMPLATE_VIS forward_iterator_tag : public input_iterator_tag {};
struct _LIBCPP_TEMPLATE_VIS bidirectional_iterator_tag : public forward_iterator_tag {};
struct _LIBCPP_TEMPLATE_VIS random_access_iterator_tag : public bidirectional_iterator_tag {};
+#if _LIBCPP_STD_VER > 17
+// TODO(EricWF) contiguous_iterator_tag is provided as an extension prior to
+// C++20 to allow optimizations for users providing wrapped iterator types.
+struct _LIBCPP_TEMPLATE_VIS contiguous_iterator_tag: public random_access_iterator_tag { };
+#endif
+
+template <class _Iter>
+struct __iter_traits_cache {
+ using type = _If<
+ __is_primary_template<iterator_traits<_Iter> >::value,
+ _Iter,
+ iterator_traits<_Iter>
+ >;
+};
+template <class _Iter>
+using _ITER_TRAITS = typename __iter_traits_cache<_Iter>::type;
+
+struct __iter_concept_concept_test {
+ template <class _Iter>
+ using _Apply = typename _ITER_TRAITS<_Iter>::iterator_concept;
+};
+struct __iter_concept_category_test {
+ template <class _Iter>
+ using _Apply = typename _ITER_TRAITS<_Iter>::iterator_category;
+};
+struct __iter_concept_random_fallback {
+ template <class _Iter>
+ using _Apply = _EnableIf<
+ __is_primary_template<iterator_traits<_Iter> >::value,
+ random_access_iterator_tag
+ >;
+};
+
+template <class _Iter, class _Tester> struct __test_iter_concept
+ : _IsValidExpansion<_Tester::template _Apply, _Iter>,
+ _Tester
+{
+};
+
+template <class _Iter>
+struct __iter_concept_cache {
+ using type = _Or<
+ __test_iter_concept<_Iter, __iter_concept_concept_test>,
+ __test_iter_concept<_Iter, __iter_concept_category_test>,
+ __test_iter_concept<_Iter, __iter_concept_random_fallback>
+ >;
+};
+
+template <class _Iter>
+using _ITER_CONCEPT = typename __iter_concept_cache<_Iter>::type::template _Apply<_Iter>;
+
template <class _Tp>
struct __has_iterator_typedefs
@@ -500,7 +553,10 @@ struct __iterator_traits<_Iter, true>
template <class _Iter>
struct _LIBCPP_TEMPLATE_VIS iterator_traits
- : __iterator_traits<_Iter, __has_iterator_typedefs<_Iter>::value> {};
+ : __iterator_traits<_Iter, __has_iterator_typedefs<_Iter>::value> {
+
+ using __primary_template = iterator_traits;
+};
template<class _Tp>
struct _LIBCPP_TEMPLATE_VIS iterator_traits<_Tp*>
@@ -510,6 +566,9 @@ struct _LIBCPP_TEMPLATE_VIS iterator_traits<_Tp*>
typedef _Tp* pointer;
typedef _Tp& reference;
typedef random_access_iterator_tag iterator_category;
+#if _LIBCPP_STD_VER > 17
+ typedef contiguous_iterator_tag iterator_concept;
+#endif
};
template <class _Tp, class _Up, bool = __has_iterator_category<iterator_traits<_Tp> >::value>
@@ -521,19 +580,28 @@ template <class _Tp, class _Up>
struct __has_iterator_category_convertible_to<_Tp, _Up, false> : public false_type {};
template <class _Tp>
-struct __is_input_iterator : public __has_iterator_category_convertible_to<_Tp, input_iterator_tag> {};
+struct __is_cpp17_input_iterator : public __has_iterator_category_convertible_to<_Tp, input_iterator_tag> {};
template <class _Tp>
-struct __is_forward_iterator : public __has_iterator_category_convertible_to<_Tp, forward_iterator_tag> {};
+struct __is_cpp17_forward_iterator : public __has_iterator_category_convertible_to<_Tp, forward_iterator_tag> {};
template <class _Tp>
-struct __is_bidirectional_iterator : public __has_iterator_category_convertible_to<_Tp, bidirectional_iterator_tag> {};
+struct __is_cpp17_bidirectional_iterator : public __has_iterator_category_convertible_to<_Tp, bidirectional_iterator_tag> {};
template <class _Tp>
-struct __is_random_access_iterator : public __has_iterator_category_convertible_to<_Tp, random_access_iterator_tag> {};
+struct __is_cpp17_random_access_iterator : public __has_iterator_category_convertible_to<_Tp, random_access_iterator_tag> {};
+
+#if _LIBCPP_STD_VER > 17
+template <class _Tp>
+struct __is_cpp17_contiguous_iterator : public __has_iterator_category_convertible_to<_Tp, contiguous_iterator_tag> {};
+#else
+template <class _Tp>
+struct __is_cpp17_contiguous_iterator : public false_type {};
+#endif
+
template <class _Tp>
-struct __is_exactly_input_iterator
+struct __is_exactly_cpp17_input_iterator
: public integral_constant<bool,
__has_iterator_category_convertible_to<_Tp, input_iterator_tag>::value &&
!__has_iterator_category_convertible_to<_Tp, forward_iterator_tag>::value> {};
@@ -600,7 +668,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
void advance(_InputIter& __i,
typename iterator_traits<_InputIter>::difference_type __n)
{
- _LIBCPP_ASSERT(__n >= 0 || __is_bidirectional_iterator<_InputIter>::value,
+ _LIBCPP_ASSERT(__n >= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value,
"Attempt to advance(it, -n) on a non-bidi iterator");
__advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category());
}
@@ -636,13 +704,13 @@ template <class _InputIter>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
typename enable_if
<
- __is_input_iterator<_InputIter>::value,
+ __is_cpp17_input_iterator<_InputIter>::value,
_InputIter
>::type
next(_InputIter __x,
typename iterator_traits<_InputIter>::difference_type __n = 1)
{
- _LIBCPP_ASSERT(__n >= 0 || __is_bidirectional_iterator<_InputIter>::value,
+ _LIBCPP_ASSERT(__n >= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value,
"Attempt to next(it, -n) on a non-bidi iterator");
_VSTD::advance(__x, __n);
@@ -653,13 +721,13 @@ template <class _InputIter>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
typename enable_if
<
- __is_input_iterator<_InputIter>::value,
+ __is_cpp17_input_iterator<_InputIter>::value,
_InputIter
>::type
prev(_InputIter __x,
typename iterator_traits<_InputIter>::difference_type __n = 1)
{
- _LIBCPP_ASSERT(__n <= 0 || __is_bidirectional_iterator<_InputIter>::value,
+ _LIBCPP_ASSERT(__n <= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value,
"Attempt to prev(it, +n) on a non-bidi iterator");
_VSTD::advance(__x, -__n);
return __x;
@@ -1304,8 +1372,8 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
__wrap_iter<_Iter>
operator+(typename __wrap_iter<_Iter>::difference_type, __wrap_iter<_Iter>) _NOEXCEPT;
-template <class _Ip, class _Op> _Op _LIBCPP_INLINE_VISIBILITY copy(_Ip, _Ip, _Op);
-template <class _B1, class _B2> _B2 _LIBCPP_INLINE_VISIBILITY copy_backward(_B1, _B1, _B2);
+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);
@@ -1515,8 +1583,8 @@ private:
__wrap_iter<_Iter1>
operator+(typename __wrap_iter<_Iter1>::difference_type, __wrap_iter<_Iter1>) _NOEXCEPT;
- template <class _Ip, class _Op> friend _Op copy(_Ip, _Ip, _Op);
- template <class _B1, class _B2> friend _B2 copy_backward(_B1, _B1, _B2);
+ 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);
diff --git a/libcxx/include/list b/libcxx/include/list
index c92ef79282ed..ae318ead31da 100644
--- a/libcxx/include/list
+++ b/libcxx/include/list
@@ -715,7 +715,7 @@ template <class _Tp, class _Alloc>
inline
__list_imp<_Tp, _Alloc>::__list_imp()
_NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)
- : __size_alloc_(0)
+ : __size_alloc_(0, __default_init_tag())
{
}
@@ -887,10 +887,10 @@ public:
list(size_type __n, const value_type& __x, const allocator_type& __a);
template <class _InpIter>
list(_InpIter __f, _InpIter __l,
- typename enable_if<__is_input_iterator<_InpIter>::value>::type* = 0);
+ typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type* = 0);
template <class _InpIter>
list(_InpIter __f, _InpIter __l, const allocator_type& __a,
- typename enable_if<__is_input_iterator<_InpIter>::value>::type* = 0);
+ typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type* = 0);
list(const list& __c);
list(const list& __c, const allocator_type& __a);
@@ -922,7 +922,7 @@ public:
template <class _InpIter>
void assign(_InpIter __f, _InpIter __l,
- typename enable_if<__is_input_iterator<_InpIter>::value>::type* = 0);
+ typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type* = 0);
void assign(size_type __n, const value_type& __x);
_LIBCPP_INLINE_VISIBILITY
@@ -1039,7 +1039,7 @@ public:
iterator insert(const_iterator __p, size_type __n, const value_type& __x);
template <class _InpIter>
iterator insert(const_iterator __p, _InpIter __f, _InpIter __l,
- typename enable_if<__is_input_iterator<_InpIter>::value>::type* = 0);
+ typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type* = 0);
_LIBCPP_INLINE_VISIBILITY
void swap(list& __c)
@@ -1252,7 +1252,7 @@ list<_Tp, _Alloc>::list(size_type __n, const value_type& __x, const allocator_ty
template <class _Tp, class _Alloc>
template <class _InpIter>
list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l,
- typename enable_if<__is_input_iterator<_InpIter>::value>::type*)
+ typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type*)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
@@ -1264,7 +1264,7 @@ list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l,
template <class _Tp, class _Alloc>
template <class _InpIter>
list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l, const allocator_type& __a,
- typename enable_if<__is_input_iterator<_InpIter>::value>::type*)
+ typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type*)
: base(__a)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
@@ -1403,7 +1403,7 @@ template <class _Tp, class _Alloc>
template <class _InpIter>
void
list<_Tp, _Alloc>::assign(_InpIter __f, _InpIter __l,
- typename enable_if<__is_input_iterator<_InpIter>::value>::type*)
+ typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type*)
{
iterator __i = begin();
iterator __e = end();
@@ -1532,7 +1532,7 @@ template <class _Tp, class _Alloc>
template <class _InpIter>
typename list<_Tp, _Alloc>::iterator
list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l,
- typename enable_if<__is_input_iterator<_InpIter>::value>::type*)
+ typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type*)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
@@ -2211,7 +2211,7 @@ list<_Tp, _Alloc>::unique(_BinaryPred __binary_pred)
__i = __j;
}
}
-
+
return (__remove_return_type) __deleted_nodes.size();
}
diff --git a/libcxx/include/math.h b/libcxx/include/math.h
index 194df2077bb1..c9b4733e9c44 100644
--- a/libcxx/include/math.h
+++ b/libcxx/include/math.h
@@ -510,7 +510,11 @@ _LIBCPP_INLINE_VISIBILITY
bool
__libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
{
+#if __has_builtin(__builtin_isnan)
+ return __builtin_isnan(__lcpp_x);
+#else
return isnan(__lcpp_x);
+#endif
}
#undef isnan
diff --git a/libcxx/include/memory b/libcxx/include/memory
index 96bb8fb5ccbb..34c3e0c0d8d1 100644
--- a/libcxx/include/memory
+++ b/libcxx/include/memory
@@ -1098,40 +1098,51 @@ struct __const_void_pointer<_Ptr, _Alloc, false>
#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&>()));
+
+ template <class _Pointer>
+ _LIBCPP_CONSTEXPR
+ static __return_type<_Pointer>
+ __do_it(const _Pointer &__p) _NOEXCEPT { return pointer_traits<_Pointer>::to_address(__p); }
+};
+
+template <class _Pointer, bool _Dummy = true>
+using __choose_to_address = __to_address_helper<_IsValidExpansion<__to_address_helper<_Dummy>::template __return_type, _Pointer>::value>;
+
+
template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
_Tp*
-__to_raw_pointer(_Tp* __p) _NOEXCEPT
+__to_address(_Tp* __p) _NOEXCEPT
{
+ static_assert(!is_function<_Tp>::value, "_Tp is a function type");
return __p;
}
-#if _LIBCPP_STD_VER <= 17
template <class _Pointer>
-inline _LIBCPP_INLINE_VISIBILITY
-typename pointer_traits<_Pointer>::element_type*
-__to_raw_pointer(_Pointer __p) _NOEXCEPT
-{
- return _VSTD::__to_raw_pointer(__p.operator->());
-}
-#else
-template <class _Pointer>
-inline _LIBCPP_INLINE_VISIBILITY
-auto
-__to_raw_pointer(const _Pointer& __p) _NOEXCEPT
--> decltype(pointer_traits<_Pointer>::to_address(__p))
-{
- return pointer_traits<_Pointer>::to_address(__p);
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+typename __choose_to_address<_Pointer>::template __return_type<_Pointer>
+__to_address(const _Pointer& __p) _NOEXCEPT {
+ return __choose_to_address<_Pointer>::__do_it(__p);
}
-template <class _Pointer, class... _None>
-inline _LIBCPP_INLINE_VISIBILITY
-auto
-__to_raw_pointer(const _Pointer& __p, _None...) _NOEXCEPT
-{
- return _VSTD::__to_raw_pointer(__p.operator->());
-}
+template <> struct __to_address_helper<false> {
+ template <class _Pointer>
+ using __return_type = typename pointer_traits<_Pointer>::element_type*;
+
+ template <class _Pointer>
+ _LIBCPP_CONSTEXPR
+ static __return_type<_Pointer>
+ __do_it(const _Pointer &__p) _NOEXCEPT { return std::__to_address(__p.operator->()); }
+};
+
+#if _LIBCPP_STD_VER > 17
template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY constexpr
_Tp*
@@ -1146,7 +1157,7 @@ inline _LIBCPP_INLINE_VISIBILITY
auto
to_address(const _Pointer& __p) _NOEXCEPT
{
- return _VSTD::__to_raw_pointer(__p);
+ return _VSTD::__to_address(__p);
}
#endif
@@ -1638,7 +1649,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
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_raw_pointer(__begin2),
+ construct(__a, _VSTD::__to_address(__begin2),
#ifdef _LIBCPP_NO_EXCEPTIONS
_VSTD::move(*__begin1)
#else
@@ -1674,7 +1685,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
__construct_range_forward(allocator_type& __a, _Iter __begin1, _Iter __end1, _Ptr& __begin2)
{
for (; __begin1 != __end1; ++__begin1, (void) ++__begin2)
- construct(__a, _VSTD::__to_raw_pointer(__begin2), *__begin1);
+ construct(__a, _VSTD::__to_address(__begin2), *__begin1);
}
template <class _SourceTp, class _DestTp,
@@ -1710,7 +1721,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
"The specified type does not meet the requirements of Cpp17MoveInsertable");
while (__end1 != __begin1)
{
- construct(__a, _VSTD::__to_raw_pointer(__end2 - 1),
+ construct(__a, _VSTD::__to_address(__end2 - 1),
#ifdef _LIBCPP_NO_EXCEPTIONS
_VSTD::move(*--__end1)
#else
@@ -2167,6 +2178,10 @@ public:
};
#endif
+// Tag used to default initialize one or both of the pair's elements.
+struct __default_init_tag {};
+struct __value_init_tag {};
+
template <class _Tp, int _Idx,
bool _CanBeEmptyBase =
is_empty<_Tp>::value && !__libcpp_is_final<_Tp>::value>
@@ -2175,30 +2190,31 @@ struct __compressed_pair_elem {
typedef _Tp& reference;
typedef const _Tp& const_reference;
-#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY constexpr __compressed_pair_elem() : __value_() {}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ __compressed_pair_elem(__default_init_tag) {}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ __compressed_pair_elem(__value_init_tag) : __value_() {}
template <class _Up, class = typename enable_if<
!is_same<__compressed_pair_elem, typename decay<_Up>::type>::value
>::type>
_LIBCPP_INLINE_VISIBILITY
- constexpr explicit
+ _LIBCPP_CONSTEXPR explicit
__compressed_pair_elem(_Up&& __u)
: __value_(_VSTD::forward<_Up>(__u))
{
}
+
+#ifndef _LIBCPP_CXX03_LANG
template <class... _Args, size_t... _Indexes>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
__compressed_pair_elem(piecewise_construct_t, tuple<_Args...> __args,
__tuple_indices<_Indexes...>)
: __value_(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {}
-#else
- _LIBCPP_INLINE_VISIBILITY __compressed_pair_elem() : __value_() {}
- _LIBCPP_INLINE_VISIBILITY
- __compressed_pair_elem(_ParamT __p) : __value_(std::forward<_ParamT>(__p)) {}
#endif
+
_LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return __value_; }
_LIBCPP_INLINE_VISIBILITY
const_reference __get() const _NOEXCEPT { return __value_; }
@@ -2214,28 +2230,27 @@ struct __compressed_pair_elem<_Tp, _Idx, true> : private _Tp {
typedef const _Tp& const_reference;
typedef _Tp __value_type;
-#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY constexpr __compressed_pair_elem() = default;
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __compressed_pair_elem() = default;
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ __compressed_pair_elem(__default_init_tag) {}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ __compressed_pair_elem(__value_init_tag) : __value_type() {}
template <class _Up, class = typename enable_if<
!is_same<__compressed_pair_elem, typename decay<_Up>::type>::value
>::type>
_LIBCPP_INLINE_VISIBILITY
- constexpr explicit
+ _LIBCPP_CONSTEXPR explicit
__compressed_pair_elem(_Up&& __u)
: __value_type(_VSTD::forward<_Up>(__u))
{}
+#ifndef _LIBCPP_CXX03_LANG
template <class... _Args, size_t... _Indexes>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
__compressed_pair_elem(piecewise_construct_t, tuple<_Args...> __args,
__tuple_indices<_Indexes...>)
: __value_type(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {}
-#else
- _LIBCPP_INLINE_VISIBILITY __compressed_pair_elem() : __value_type() {}
- _LIBCPP_INLINE_VISIBILITY
- __compressed_pair_elem(_ParamT __p)
- : __value_type(std::forward<_ParamT>(__p)) {}
#endif
_LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return *this; }
@@ -2243,9 +2258,6 @@ struct __compressed_pair_elem<_Tp, _Idx, true> : private _Tp {
const_reference __get() const _NOEXCEPT { return *this; }
};
-// Tag used to construct the second element of the compressed pair.
-struct __second_tag {};
-
template <class _T1, class _T2>
class __compressed_pair : private __compressed_pair_elem<_T1, 0>,
private __compressed_pair_elem<_T2, 1> {
@@ -2262,33 +2274,21 @@ class __compressed_pair : private __compressed_pair_elem<_T1, 0>,
"implementation for this configuration");
public:
-#ifndef _LIBCPP_CXX03_LANG
- template <bool _Dummy = true,
+ template <bool _Dummy = true,
class = typename enable_if<
__dependent_type<is_default_constructible<_T1>, _Dummy>::value &&
__dependent_type<is_default_constructible<_T2>, _Dummy>::value
>::type
>
_LIBCPP_INLINE_VISIBILITY
- constexpr __compressed_pair() {}
-
- template <class _Tp, typename enable_if<!is_same<typename decay<_Tp>::type,
- __compressed_pair>::value,
- bool>::type = true>
- _LIBCPP_INLINE_VISIBILITY constexpr explicit
- __compressed_pair(_Tp&& __t)
- : _Base1(std::forward<_Tp>(__t)), _Base2() {}
-
- template <class _Tp>
- _LIBCPP_INLINE_VISIBILITY constexpr
- __compressed_pair(__second_tag, _Tp&& __t)
- : _Base1(), _Base2(std::forward<_Tp>(__t)) {}
+ _LIBCPP_CONSTEXPR __compressed_pair() : _Base1(__value_init_tag()), _Base2(__value_init_tag()) {}
template <class _U1, class _U2>
- _LIBCPP_INLINE_VISIBILITY constexpr
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
__compressed_pair(_U1&& __t1, _U2&& __t2)
: _Base1(std::forward<_U1>(__t1)), _Base2(std::forward<_U2>(__t2)) {}
+#ifndef _LIBCPP_CXX03_LANG
template <class... _Args1, class... _Args2>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
__compressed_pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args,
@@ -2297,21 +2297,6 @@ public:
typename __make_tuple_indices<sizeof...(_Args1)>::type()),
_Base2(__pc, _VSTD::move(__second_args),
typename __make_tuple_indices<sizeof...(_Args2)>::type()) {}
-
-#else
- _LIBCPP_INLINE_VISIBILITY
- __compressed_pair() {}
-
- _LIBCPP_INLINE_VISIBILITY explicit
- __compressed_pair(_T1 __t1) : _Base1(_VSTD::forward<_T1>(__t1)) {}
-
- _LIBCPP_INLINE_VISIBILITY
- __compressed_pair(__second_tag, _T2 __t2)
- : _Base1(), _Base2(_VSTD::forward<_T2>(__t2)) {}
-
- _LIBCPP_INLINE_VISIBILITY
- __compressed_pair(_T1 __t1, _T2 __t2)
- : _Base1(_VSTD::forward<_T1>(__t1)), _Base2(_VSTD::forward<_T2>(__t2)) {}
#endif
_LIBCPP_INLINE_VISIBILITY
@@ -2492,17 +2477,17 @@ public:
template <bool _Dummy = true,
class = _EnableIfDeleterDefaultConstructible<_Dummy> >
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(pointer()) {}
+ _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(pointer(), __default_init_tag()) {}
template <bool _Dummy = true,
class = _EnableIfDeleterDefaultConstructible<_Dummy> >
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(pointer()) {}
+ _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(pointer(), __default_init_tag()) {}
template <bool _Dummy = true,
class = _EnableIfDeleterDefaultConstructible<_Dummy> >
_LIBCPP_INLINE_VISIBILITY
- explicit unique_ptr(pointer __p) _NOEXCEPT : __ptr_(__p) {}
+ explicit unique_ptr(pointer __p) _NOEXCEPT : __ptr_(__p, __default_init_tag()) {}
template <bool _Dummy = true,
class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > >
@@ -2544,7 +2529,7 @@ public:
typename enable_if<is_convertible<_Up*, _Tp*>::value &&
is_same<_Dp, default_delete<_Tp> >::value,
__nat>::type = __nat()) _NOEXCEPT
- : __ptr_(__p.release()) {}
+ : __ptr_(__p.release(), __default_init_tag()) {}
#endif
_LIBCPP_INLINE_VISIBILITY
@@ -2715,19 +2700,19 @@ public:
template <bool _Dummy = true,
class = _EnableIfDeleterDefaultConstructible<_Dummy> >
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(pointer()) {}
+ _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(pointer(), __default_init_tag()) {}
template <bool _Dummy = true,
class = _EnableIfDeleterDefaultConstructible<_Dummy> >
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(pointer()) {}
+ _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(pointer(), __default_init_tag()) {}
template <class _Pp, bool _Dummy = true,
class = _EnableIfDeleterDefaultConstructible<_Dummy>,
class = _EnableIfPointerConvertible<_Pp> >
_LIBCPP_INLINE_VISIBILITY
explicit unique_ptr(_Pp __p) _NOEXCEPT
- : __ptr_(__p) {}
+ : __ptr_(__p, __default_init_tag()) {}
template <class _Pp, bool _Dummy = true,
class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> >,
@@ -3571,24 +3556,20 @@ class __shared_ptr_emplace
{
__compressed_pair<_Alloc, _Tp> __data_;
public:
-#ifndef _LIBCPP_HAS_NO_VARIADICS
_LIBCPP_INLINE_VISIBILITY
__shared_ptr_emplace(_Alloc __a)
- : __data_(_VSTD::move(__a)) {}
+ : __data_(_VSTD::move(__a), __value_init_tag()) {}
+
+#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_INLINE_VISIBILITY
- __shared_ptr_emplace(_Alloc __a)
- : __data_(__a) {}
-
template <class _A0>
_LIBCPP_INLINE_VISIBILITY
__shared_ptr_emplace(_Alloc __a, _A0& __a0)
diff --git a/libcxx/include/mutex b/libcxx/include/mutex
index 8fc3c61221b5..62780bd07344 100644
--- a/libcxx/include/mutex
+++ b/libcxx/include/mutex
@@ -650,7 +650,7 @@ public:
#endif
template <class _Fp>
-void
+void _LIBCPP_INLINE_VISIBILITY
__call_once_proxy(void* __vp)
{
__call_once_param<_Fp>* __p = static_cast<__call_once_param<_Fp>*>(__vp);
diff --git a/libcxx/include/numeric b/libcxx/include/numeric
index 854bbfad65ac..5ceadc17755e 100644
--- a/libcxx/include/numeric
+++ b/libcxx/include/numeric
@@ -532,17 +532,14 @@ 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;
- int __sign = 1;
- _Up __m = __a;
- _Up __M = __b;
- if (__a > __b)
- {
- __sign = -1;
- __m = __b;
- __M = __a;
- }
- return __a + __sign * _Tp(_Up(__M-__m) >> 1);
+ _Up __diff = _Up(__b) - _Up(__a);
+ _Up __sign_bit = __b < __a;
+
+ _Up __half_diff = (__diff / 2) + (__sign_bit << __bitshift) + (__sign_bit & __diff);
+
+ return __a + __half_diff;
}
@@ -576,7 +573,7 @@ midpoint(_Fp __a, _Fp __b) noexcept
return __fp_abs(__a) <= __hi && __fp_abs(__b) <= __hi ? // typical case: overflow is impossible
(__a + __b)/2 : // always correctly rounded
__fp_abs(__a) < __lo ? __a + __b/2 : // not safe to halve a
- __fp_abs(__a) < __lo ? __a/2 + __b : // not safe to halve b
+ __fp_abs(__b) < __lo ? __a/2 + __b : // not safe to halve b
__a/2 + __b/2; // otherwise correctly rounded
}
diff --git a/libcxx/include/queue b/libcxx/include/queue
index 97ec6f633c51..33c25e0dfc13 100644
--- a/libcxx/include/queue
+++ b/libcxx/include/queue
@@ -562,7 +562,7 @@ priority_queue(_Compare, _Container)
template<class _InputIterator,
class _Compare = less<typename iterator_traits<_InputIterator>::value_type>,
class _Container = vector<typename iterator_traits<_InputIterator>::value_type>,
- class = typename enable_if< __is_input_iterator<_InputIterator>::value, nullptr_t>::type,
+ class = typename enable_if< __is_cpp17_input_iterator<_InputIterator>::value, nullptr_t>::type,
class = typename enable_if<!__is_allocator<_Compare>::value, nullptr_t>::type,
class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type
>
diff --git a/libcxx/include/random b/libcxx/include/random
index afa60b4af048..7c4054f7eea8 100644
--- a/libcxx/include/random
+++ b/libcxx/include/random
@@ -4592,7 +4592,10 @@ public:
template<class _IntType>
poisson_distribution<_IntType>::param_type::param_type(double __mean)
- : __mean_(__mean)
+ // According to the standard `inf` is a valid input, but it causes the
+ // distribution to hang, so we replace it with the maximum representable
+ // mean.
+ : __mean_(isinf(__mean) ? numeric_limits<double>::max() : __mean)
{
if (__mean_ < 10)
{
@@ -4610,7 +4613,7 @@ poisson_distribution<_IntType>::param_type::param_type(double __mean)
{
__s_ = _VSTD::sqrt(__mean_);
__d_ = 6 * __mean_ * __mean_;
- __l_ = static_cast<result_type>(__mean_ - 1.1484);
+ __l_ = std::trunc(__mean_ - 1.1484);
__omega_ = .3989423 / __s_;
double __b1_ = .4166667E-1 / __mean_;
double __b2_ = .3 * __b1_ * __b1_;
@@ -4627,12 +4630,12 @@ template<class _URNG>
_IntType
poisson_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr)
{
- result_type __x;
+ double __tx;
uniform_real_distribution<double> __urd;
if (__pr.__mean_ < 10)
{
- __x = 0;
- for (double __p = __urd(__urng); __p > __pr.__l_; ++__x)
+ __tx = 0;
+ for (double __p = __urd(__urng); __p > __pr.__l_; ++__tx)
__p *= __urd(__urng);
}
else
@@ -4642,19 +4645,19 @@ poisson_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr
double __u;
if (__g > 0)
{
- __x = static_cast<result_type>(__g);
- if (__x >= __pr.__l_)
- return __x;
- __difmuk = __pr.__mean_ - __x;
+ __tx = std::trunc(__g);
+ if (__tx >= __pr.__l_)
+ return std::__clamp_to_integral<result_type>(__tx);
+ __difmuk = __pr.__mean_ - __tx;
__u = __urd(__urng);
if (__pr.__d_ * __u >= __difmuk * __difmuk * __difmuk)
- return __x;
+ return std::__clamp_to_integral<result_type>(__tx);
}
exponential_distribution<double> __edist;
for (bool __using_exp_dist = false; true; __using_exp_dist = true)
{
double __e;
- if (__using_exp_dist || __g < 0)
+ if (__using_exp_dist || __g <= 0)
{
double __t;
do
@@ -4664,31 +4667,31 @@ poisson_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr
__u += __u - 1;
__t = 1.8 + (__u < 0 ? -__e : __e);
} while (__t <= -.6744);
- __x = __pr.__mean_ + __pr.__s_ * __t;
- __difmuk = __pr.__mean_ - __x;
+ __tx = std::trunc(__pr.__mean_ + __pr.__s_ * __t);
+ __difmuk = __pr.__mean_ - __tx;
__using_exp_dist = true;
}
double __px;
double __py;
- if (__x < 10)
+ if (__tx < 10 && __tx >= 0)
{
const double __fac[] = {1, 1, 2, 6, 24, 120, 720, 5040,
40320, 362880};
__px = -__pr.__mean_;
- __py = _VSTD::pow(__pr.__mean_, (double)__x) / __fac[__x];
+ __py = _VSTD::pow(__pr.__mean_, (double)__tx) / __fac[static_cast<int>(__tx)];
}
else
{
- double __del = .8333333E-1 / __x;
+ double __del = .8333333E-1 / __tx;
__del -= 4.8 * __del * __del * __del;
- double __v = __difmuk / __x;
+ double __v = __difmuk / __tx;
if (_VSTD::abs(__v) > 0.25)
- __px = __x * _VSTD::log(1 + __v) - __difmuk - __del;
+ __px = __tx * _VSTD::log(1 + __v) - __difmuk - __del;
else
- __px = __x * __v * __v * (((((((.1250060 * __v + -.1384794) *
+ __px = __tx * __v * __v * (((((((.1250060 * __v + -.1384794) *
__v + .1421878) * __v + -.1661269) * __v + .2000118) *
__v + -.2500068) * __v + .3333333) * __v + -.5) - __del;
- __py = .3989423 / _VSTD::sqrt(__x);
+ __py = .3989423 / _VSTD::sqrt(__tx);
}
double __r = (0.5 - __difmuk) / __pr.__s_;
double __r2 = __r * __r;
@@ -4708,7 +4711,7 @@ poisson_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr
}
}
}
- return __x;
+ return std::__clamp_to_integral<result_type>(__tx);
}
template <class _CharT, class _Traits, class _IntType>
@@ -6102,6 +6105,7 @@ public:
template<class _UnaryOperation>
param_type(size_t __nw, result_type __xmin, result_type __xmax,
_UnaryOperation __fw);
+ param_type(param_type const&) = default;
param_type & operator=(const param_type& __rhs);
_LIBCPP_INLINE_VISIBILITY
@@ -6425,6 +6429,7 @@ public:
template<class _UnaryOperation>
param_type(size_t __nw, result_type __xmin, result_type __xmax,
_UnaryOperation __fw);
+ param_type(param_type const&) = default;
param_type & operator=(const param_type& __rhs);
_LIBCPP_INLINE_VISIBILITY
diff --git a/libcxx/include/regex b/libcxx/include/regex
index d13f9addb70a..5ac9e325e136 100644
--- a/libcxx/include/regex
+++ b/libcxx/include/regex
@@ -965,7 +965,8 @@ enum error_type
error_stack,
__re_err_grammar,
__re_err_empty,
- __re_err_unknown
+ __re_err_unknown,
+ __re_err_parse
};
} // regex_constants
@@ -2539,8 +2540,7 @@ public:
: __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
__end_(0)
{
- if (__get_grammar(__flags_) == 0) __flags_ |= regex_constants::ECMAScript;
- __parse(__p, __p + __traits_.length(__p));
+ __init(__p, __p + __traits_.length(__p));
}
_LIBCPP_INLINE_VISIBILITY
@@ -2548,8 +2548,7 @@ public:
: __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
__end_(0)
{
- if (__get_grammar(__flags_) == 0) __flags_ |= regex_constants::ECMAScript;
- __parse(__p, __p + __len);
+ __init(__p, __p + __len);
}
// basic_regex(const basic_regex&) = default;
@@ -2561,8 +2560,7 @@ public:
: __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
__end_(0)
{
- if (__get_grammar(__flags_) == 0) __flags_ |= regex_constants::ECMAScript;
- __parse(__p.begin(), __p.end());
+ __init(__p.begin(), __p.end());
}
template <class _ForwardIterator>
@@ -2572,8 +2570,7 @@ public:
: __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
__end_(0)
{
- if (__get_grammar(__flags_) == 0) __flags_ |= regex_constants::ECMAScript;
- __parse(__first, __last);
+ __init(__first, __last);
}
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
@@ -2582,8 +2579,7 @@ public:
: __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
__end_(0)
{
- if (__get_grammar(__flags_) == 0) __flags_ |= regex_constants::ECMAScript;
- __parse(__il.begin(), __il.end());
+ __init(__il.begin(), __il.end());
}
#endif // _LIBCPP_CXX03_LANG
@@ -2629,8 +2625,8 @@ public:
_LIBCPP_INLINE_VISIBILITY
typename enable_if
<
- __is_input_iterator <_InputIterator>::value &&
- !__is_forward_iterator<_InputIterator>::value,
+ __is_cpp17_input_iterator <_InputIterator>::value &&
+ !__is_cpp17_forward_iterator<_InputIterator>::value,
basic_regex&
>::type
assign(_InputIterator __first, _InputIterator __last,
@@ -2656,7 +2652,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
typename enable_if
<
- __is_forward_iterator<_ForwardIterator>::value,
+ __is_cpp17_forward_iterator<_ForwardIterator>::value,
basic_regex&
>::type
assign(_ForwardIterator __first, _ForwardIterator __last,
@@ -2699,6 +2695,9 @@ private:
unsigned __loop_count() const {return __loop_count_;}
template <class _ForwardIterator>
+ void
+ __init(_ForwardIterator __first, _ForwardIterator __last);
+ template <class _ForwardIterator>
_ForwardIterator
__parse(_ForwardIterator __first, _ForwardIterator __last);
template <class _ForwardIterator>
@@ -2953,7 +2952,7 @@ private:
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
template <class _ForwardIterator,
- class = typename enable_if<__is_forward_iterator<_ForwardIterator>::value, nullptr_t>::type
+ class = typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value, nullptr_t>::type
>
basic_regex(_ForwardIterator, _ForwardIterator,
regex_constants::syntax_option_type = regex_constants::ECMAScript)
@@ -3056,6 +3055,17 @@ __lookahead<_CharT, _Traits>::__exec(__state& __s) const
template <class _CharT, class _Traits>
template <class _ForwardIterator>
+void
+basic_regex<_CharT, _Traits>::__init(_ForwardIterator __first, _ForwardIterator __last)
+{
+ if (__get_grammar(__flags_) == 0) __flags_ |= regex_constants::ECMAScript;
+ _ForwardIterator __temp = __parse(__first, __last);
+ if ( __temp != __last)
+ __throw_regex_error<regex_constants::__re_err_parse>();
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
_ForwardIterator
basic_regex<_CharT, _Traits>::__parse(_ForwardIterator __first,
_ForwardIterator __last)
diff --git a/libcxx/include/span b/libcxx/include/span
index 0694f5115df0..3421ca0f5a8e 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -39,7 +39,7 @@ public:
// constants and types
using element_type = ElementType;
using value_type = remove_cv_t<ElementType>;
- using index_type = size_t;
+ using size_type = size_t;
using difference_type = ptrdiff_t;
using pointer = element_type*;
using const_pointer = const element_type*;
@@ -49,11 +49,11 @@ public:
using const_iterator = implementation-defined;
using reverse_iterator = std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
- static constexpr index_type extent = Extent;
+ static constexpr size_type extent = Extent;
// [span.cons], span constructors, copy, assignment, and destructor
constexpr span() noexcept;
- constexpr span(pointer ptr, index_type count);
+ constexpr span(pointer ptr, size_type count);
constexpr span(pointer firstElem, pointer lastElem);
template <size_t N>
constexpr span(element_type (&arr)[N]) noexcept;
@@ -79,17 +79,17 @@ public:
template <size_t Offset, size_t Count = dynamic_extent>
constexpr span<element_type, see below> subspan() const;
- constexpr span<element_type, dynamic_extent> first(index_type count) const;
- constexpr span<element_type, dynamic_extent> last(index_type count) const;
- constexpr span<element_type, dynamic_extent> subspan(index_type offset, index_type count = dynamic_extent) const;
+ constexpr span<element_type, dynamic_extent> first(size_type count) const;
+ constexpr span<element_type, dynamic_extent> last(size_type count) const;
+ constexpr span<element_type, dynamic_extent> subspan(size_type offset, size_type count = dynamic_extent) const;
// [span.obs], span observers
- constexpr index_type size() const noexcept;
- constexpr index_type size_bytes() const noexcept;
+ constexpr size_type size() const noexcept;
+ constexpr size_type size_bytes() const noexcept;
constexpr bool empty() const noexcept;
// [span.elem], span element access
- constexpr reference operator[](index_type idx) const;
+ constexpr reference operator[](size_type idx) const;
constexpr reference front() const;
constexpr reference back() const;
constexpr pointer data() const noexcept;
@@ -105,8 +105,8 @@ public:
constexpr const_reverse_iterator crend() const noexcept;
private:
- pointer data_; // exposition only
- index_type size_; // exposition only
+ pointer data_; // exposition only
+ size_type size_; // exposition only
};
template<class T, size_t N>
@@ -195,7 +195,7 @@ public:
// constants and types
using element_type = _Tp;
using value_type = remove_cv_t<_Tp>;
- using index_type = size_t;
+ using size_type = size_t;
using difference_type = ptrdiff_t;
using pointer = _Tp *;
using const_pointer = const _Tp *;
@@ -206,7 +206,7 @@ public:
using reverse_iterator = _VSTD::reverse_iterator<iterator>;
using const_reverse_iterator = _VSTD::reverse_iterator<const_iterator>;
- static constexpr index_type extent = _Extent;
+ static constexpr size_type extent = _Extent;
// [span.cons], span constructors, copy, assignment, and destructor
_LIBCPP_INLINE_VISIBILITY constexpr span() noexcept : __data{nullptr}
@@ -215,7 +215,7 @@ public:
constexpr span (const span&) noexcept = default;
constexpr span& operator=(const span&) noexcept = default;
- _LIBCPP_INLINE_VISIBILITY constexpr span(pointer __ptr, index_type __count) : __data{__ptr}
+ _LIBCPP_INLINE_VISIBILITY constexpr span(pointer __ptr, size_type __count) : __data{__ptr}
{ (void)__count; _LIBCPP_ASSERT(_Extent == __count, "size mismatch in span's constructor (ptr, len)"); }
_LIBCPP_INLINE_VISIBILITY constexpr span(pointer __f, pointer __l) : __data{__f}
{ (void)__l; _LIBCPP_ASSERT(_Extent == distance(__f, __l), "size mismatch in span's constructor (ptr, ptr)"); }
@@ -260,14 +260,14 @@ public:
}
_LIBCPP_INLINE_VISIBILITY
- constexpr span<element_type, dynamic_extent> first(index_type __count) const noexcept
+ constexpr span<element_type, dynamic_extent> first(size_type __count) const noexcept
{
_LIBCPP_ASSERT(__count <= size(), "Count out of range in span::first(count)");
return {data(), __count};
}
_LIBCPP_INLINE_VISIBILITY
- constexpr span<element_type, dynamic_extent> last(index_type __count) const noexcept
+ constexpr span<element_type, dynamic_extent> last(size_type __count) const noexcept
{
_LIBCPP_ASSERT(__count <= size(), "Count out of range in span::last(count)");
return {data() + size() - __count, __count};
@@ -285,7 +285,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
constexpr span<element_type, dynamic_extent>
- subspan(index_type __offset, index_type __count = dynamic_extent) const noexcept
+ subspan(size_type __offset, size_type __count = dynamic_extent) const noexcept
{
_LIBCPP_ASSERT(__offset <= size(), "Offset out of range in span::subspan(offset, count)");
_LIBCPP_ASSERT(__count <= size() || __count == dynamic_extent, "Count out of range in span::subspan(offset, count)");
@@ -295,11 +295,11 @@ public:
return {data() + __offset, __count};
}
- _LIBCPP_INLINE_VISIBILITY constexpr index_type size() const noexcept { return _Extent; }
- _LIBCPP_INLINE_VISIBILITY constexpr index_type size_bytes() const noexcept { return _Extent * sizeof(element_type); }
- _LIBCPP_INLINE_VISIBILITY constexpr bool empty() const noexcept { return _Extent == 0; }
+ _LIBCPP_INLINE_VISIBILITY constexpr size_type size() const noexcept { return _Extent; }
+ _LIBCPP_INLINE_VISIBILITY constexpr size_type size_bytes() const noexcept { return _Extent * sizeof(element_type); }
+ _LIBCPP_INLINE_VISIBILITY constexpr bool empty() const noexcept { return _Extent == 0; }
- _LIBCPP_INLINE_VISIBILITY constexpr reference operator[](index_type __idx) const noexcept
+ _LIBCPP_INLINE_VISIBILITY constexpr reference operator[](size_type __idx) const noexcept
{
_LIBCPP_ASSERT(__idx >= 0 && __idx < size(), "span<T,N>[] index out of bounds");
return __data[__idx];
@@ -356,7 +356,7 @@ public:
// constants and types
using element_type = _Tp;
using value_type = remove_cv_t<_Tp>;
- using index_type = size_t;
+ using size_type = size_t;
using difference_type = ptrdiff_t;
using pointer = _Tp *;
using const_pointer = const _Tp *;
@@ -367,7 +367,7 @@ public:
using reverse_iterator = _VSTD::reverse_iterator<iterator>;
using const_reverse_iterator = _VSTD::reverse_iterator<const_iterator>;
- static constexpr index_type extent = dynamic_extent;
+ static constexpr size_type extent = dynamic_extent;
// [span.cons], span constructors, copy, assignment, and destructor
_LIBCPP_INLINE_VISIBILITY constexpr span() noexcept : __data{nullptr}, __size{0} {}
@@ -375,7 +375,7 @@ public:
constexpr span (const span&) noexcept = default;
constexpr span& operator=(const span&) noexcept = default;
- _LIBCPP_INLINE_VISIBILITY constexpr span(pointer __ptr, index_type __count) : __data{__ptr}, __size{__count} {}
+ _LIBCPP_INLINE_VISIBILITY constexpr span(pointer __ptr, size_type __count) : __data{__ptr}, __size{__count} {}
_LIBCPP_INLINE_VISIBILITY constexpr span(pointer __f, pointer __l) : __data{__f}, __size{static_cast<size_t>(distance(__f, __l))} {}
template <size_t _Sz>
@@ -394,13 +394,13 @@ public:
_LIBCPP_INLINE_VISIBILITY
constexpr span( _Container& __c,
enable_if_t<__is_span_compatible_container<_Container, _Tp>::value, nullptr_t> = nullptr)
- : __data{_VSTD::data(__c)}, __size{(index_type) _VSTD::size(__c)} {}
+ : __data{_VSTD::data(__c)}, __size{(size_type) _VSTD::size(__c)} {}
template <class _Container>
_LIBCPP_INLINE_VISIBILITY
constexpr span(const _Container& __c,
enable_if_t<__is_span_compatible_container<const _Container, _Tp>::value, nullptr_t> = nullptr)
- : __data{_VSTD::data(__c)}, __size{(index_type) _VSTD::size(__c)} {}
+ : __data{_VSTD::data(__c)}, __size{(size_type) _VSTD::size(__c)} {}
template <class _OtherElementType, size_t _OtherExtent>
@@ -430,14 +430,14 @@ public:
}
_LIBCPP_INLINE_VISIBILITY
- constexpr span<element_type, dynamic_extent> first(index_type __count) const noexcept
+ constexpr span<element_type, dynamic_extent> first(size_type __count) const noexcept
{
_LIBCPP_ASSERT(__count <= size(), "Count out of range in span::first(count)");
return {data(), __count};
}
_LIBCPP_INLINE_VISIBILITY
- constexpr span<element_type, dynamic_extent> last (index_type __count) const noexcept
+ constexpr span<element_type, dynamic_extent> last (size_type __count) const noexcept
{
_LIBCPP_ASSERT(__count <= size(), "Count out of range in span::last(count)");
return {data() + size() - __count, __count};
@@ -454,7 +454,7 @@ public:
constexpr span<element_type, dynamic_extent>
_LIBCPP_INLINE_VISIBILITY
- subspan(index_type __offset, index_type __count = dynamic_extent) const noexcept
+ subspan(size_type __offset, size_type __count = dynamic_extent) const noexcept
{
_LIBCPP_ASSERT(__offset <= size(), "Offset out of range in span::subspan(offset, count)");
_LIBCPP_ASSERT(__count <= size() || __count == dynamic_extent, "count out of range in span::subspan(offset, count)");
@@ -464,11 +464,11 @@ public:
return {data() + __offset, __count};
}
- _LIBCPP_INLINE_VISIBILITY constexpr index_type size() const noexcept { return __size; }
- _LIBCPP_INLINE_VISIBILITY constexpr index_type size_bytes() const noexcept { return __size * sizeof(element_type); }
- _LIBCPP_INLINE_VISIBILITY constexpr bool empty() const noexcept { return __size == 0; }
+ _LIBCPP_INLINE_VISIBILITY constexpr size_type size() const noexcept { return __size; }
+ _LIBCPP_INLINE_VISIBILITY constexpr size_type size_bytes() const noexcept { return __size * sizeof(element_type); }
+ _LIBCPP_INLINE_VISIBILITY constexpr bool empty() const noexcept { return __size == 0; }
- _LIBCPP_INLINE_VISIBILITY constexpr reference operator[](index_type __idx) const noexcept
+ _LIBCPP_INLINE_VISIBILITY constexpr reference operator[](size_type __idx) const noexcept
{
_LIBCPP_ASSERT(__idx >= 0 && __idx < size(), "span<T>[] index out of bounds");
return __data[__idx];
@@ -505,7 +505,7 @@ public:
__data = __other.__data;
__other.__data = __p;
- index_type __sz = __size;
+ size_type __sz = __size;
__size = __other.__size;
__other.__size = __sz;
}
@@ -517,8 +517,8 @@ public:
{ return {reinterpret_cast<byte *>(data()), size_bytes()}; }
private:
- pointer __data;
- index_type __size;
+ pointer __data;
+ size_type __size;
};
// tuple interface
diff --git a/libcxx/include/string b/libcxx/include/string
index 3368fb8bfcd5..8a0ac844470c 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -625,7 +625,7 @@ struct __libcpp_string_gets_noexcept_iterator_impl : public true_type {};
template <class _Iter>
struct __libcpp_string_gets_noexcept_iterator_impl : public false_type {};
#else
-template <class _Iter, bool = __is_forward_iterator<_Iter>::value>
+template <class _Iter, bool = __is_cpp17_forward_iterator<_Iter>::value>
struct __libcpp_string_gets_noexcept_iterator_impl : public _LIBCPP_BOOL_CONSTANT((
noexcept(++(declval<_Iter&>())) &&
is_nothrow_assignable<_Iter&, _Iter>::value &&
@@ -814,7 +814,7 @@ public:
template <class = typename enable_if<__is_allocator<_Allocator>::value, nullptr_t>::type>
_LIBCPP_INLINE_VISIBILITY
- basic_string(const _CharT* __s) {
+ 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
@@ -856,10 +856,10 @@ public:
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
explicit basic_string(const _Tp& __t, const allocator_type& __a);
- template<class _InputIterator, class = typename enable_if<__is_input_iterator<_InputIterator>::value>::type>
+ template<class _InputIterator, class = typename enable_if<__is_cpp17_input_iterator<_InputIterator>::value>::type>
_LIBCPP_INLINE_VISIBILITY
basic_string(_InputIterator __first, _InputIterator __last);
- template<class _InputIterator, class = typename enable_if<__is_input_iterator<_InputIterator>::value>::type>
+ template<class _InputIterator, class = typename enable_if<__is_cpp17_input_iterator<_InputIterator>::value>::type>
_LIBCPP_INLINE_VISIBILITY
basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a);
#ifndef _LIBCPP_CXX03_LANG
@@ -1023,7 +1023,7 @@ public:
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
typename enable_if
<
- __is_exactly_input_iterator<_InputIterator>::value
+ __is_exactly_cpp17_input_iterator<_InputIterator>::value
|| !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value,
basic_string&
>::type
@@ -1037,7 +1037,7 @@ public:
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
typename enable_if
<
- __is_forward_iterator<_ForwardIterator>::value
+ __is_cpp17_forward_iterator<_ForwardIterator>::value
&& __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value,
basic_string&
>::type
@@ -1091,7 +1091,7 @@ public:
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
typename enable_if
<
- __is_exactly_input_iterator<_InputIterator>::value
+ __is_exactly_cpp17_input_iterator<_InputIterator>::value
|| !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value,
basic_string&
>::type
@@ -1100,7 +1100,7 @@ public:
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
typename enable_if
<
- __is_forward_iterator<_ForwardIterator>::value
+ __is_cpp17_forward_iterator<_ForwardIterator>::value
&& __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value,
basic_string&
>::type
@@ -1142,7 +1142,7 @@ public:
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
typename enable_if
<
- __is_exactly_input_iterator<_InputIterator>::value
+ __is_exactly_cpp17_input_iterator<_InputIterator>::value
|| !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value,
iterator
>::type
@@ -1151,7 +1151,7 @@ public:
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
typename enable_if
<
- __is_forward_iterator<_ForwardIterator>::value
+ __is_cpp17_forward_iterator<_ForwardIterator>::value
&& __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value,
iterator
>::type
@@ -1213,7 +1213,7 @@ public:
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
typename enable_if
<
- __is_input_iterator<_InputIterator>::value,
+ __is_cpp17_input_iterator<_InputIterator>::value,
basic_string&
>::type
replace(const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2);
@@ -1239,10 +1239,10 @@ public:
_LIBCPP_INLINE_VISIBILITY
const value_type* c_str() const _NOEXCEPT {return data();}
_LIBCPP_INLINE_VISIBILITY
- const value_type* data() const _NOEXCEPT {return _VSTD::__to_raw_pointer(__get_pointer());}
+ const value_type* data() const _NOEXCEPT {return _VSTD::__to_address(__get_pointer());}
#if _LIBCPP_STD_VER > 14 || defined(_LIBCPP_BUILDING_LIBRARY)
_LIBCPP_INLINE_VISIBILITY
- value_type* data() _NOEXCEPT {return _VSTD::__to_raw_pointer(__get_pointer());}
+ value_type* data() _NOEXCEPT {return _VSTD::__to_address(__get_pointer());}
#endif
_LIBCPP_INLINE_VISIBILITY
@@ -1547,7 +1547,7 @@ private:
inline
typename enable_if
<
- __is_exactly_input_iterator<_InputIterator>::value,
+ __is_exactly_cpp17_input_iterator<_InputIterator>::value,
void
>::type
__init(_InputIterator __first, _InputIterator __last);
@@ -1556,7 +1556,7 @@ private:
inline
typename enable_if
<
- __is_forward_iterator<_ForwardIterator>::value,
+ __is_cpp17_forward_iterator<_ForwardIterator>::value,
void
>::type
__init(_ForwardIterator __first, _ForwardIterator __last);
@@ -1652,7 +1652,7 @@ private:
template<class _InputIterator,
class _CharT = typename iterator_traits<_InputIterator>::value_type,
class _Allocator = allocator<_CharT>,
- class = typename enable_if<__is_input_iterator<_InputIterator>::value, void>::type,
+ class = typename enable_if<__is_cpp17_input_iterator<_InputIterator>::value, void>::type,
class = typename enable_if<__is_allocator<_Allocator>::value, void>::type
>
basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
@@ -1721,6 +1721,7 @@ template <class _CharT, class _Traits, class _Allocator>
inline
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
__get_db()->__insert_c(this);
@@ -1736,7 +1737,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __
#else
_NOEXCEPT
#endif
-: __r_(__second_tag(), __a)
+: __r_(__default_init_tag(), __a)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
@@ -1765,7 +1766,7 @@ void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s,
__set_long_cap(__cap+1);
__set_long_size(__sz);
}
- traits_type::copy(_VSTD::__to_raw_pointer(__p), __s, __sz);
+ traits_type::copy(_VSTD::__to_address(__p), __s, __sz);
traits_type::assign(__p[__sz], value_type());
}
@@ -1789,14 +1790,14 @@ basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_ty
__set_long_cap(__cap+1);
__set_long_size(__sz);
}
- traits_type::copy(_VSTD::__to_raw_pointer(__p), __s, __sz);
+ traits_type::copy(_VSTD::__to_address(__p), __s, __sz);
traits_type::assign(__p[__sz], value_type());
}
template <class _CharT, class _Traits, class _Allocator>
template <class>
basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const _Allocator& __a)
- : __r_(__second_tag(), __a)
+ : __r_(__default_init_tag(), __a)
{
_LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*, allocator) detected nullptr");
__init(__s, traits_type::length(__s));
@@ -1808,6 +1809,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const
template <class _CharT, class _Traits, class _Allocator>
inline
basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_type __n)
+ : __r_(__default_init_tag(), __default_init_tag())
{
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n) detected nullptr");
__init(__s, __n);
@@ -1819,7 +1821,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_
template <class _CharT, class _Traits, class _Allocator>
inline
basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_type __n, const _Allocator& __a)
- : __r_(__second_tag(), __a)
+ : __r_(__default_init_tag(), __a)
{
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr");
__init(__s, __n);
@@ -1830,12 +1832,12 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_
template <class _CharT, class _Traits, class _Allocator>
basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str)
- : __r_(__second_tag(), __alloc_traits::select_on_container_copy_construction(__str.__alloc()))
+ : __r_(__default_init_tag(), __alloc_traits::select_on_container_copy_construction(__str.__alloc()))
{
if (!__str.__is_long())
__r_.first().__r = __str.__r_.first().__r;
else
- __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size());
+ __init(_VSTD::__to_address(__str.__get_long_pointer()), __str.__get_long_size());
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
#endif
@@ -1844,12 +1846,12 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st
template <class _CharT, class _Traits, class _Allocator>
basic_string<_CharT, _Traits, _Allocator>::basic_string(
const basic_string& __str, const allocator_type& __a)
- : __r_(__second_tag(), __a)
+ : __r_(__default_init_tag(), __a)
{
if (!__str.__is_long())
__r_.first().__r = __str.__r_.first().__r;
else
- __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size());
+ __init(_VSTD::__to_address(__str.__get_long_pointer()), __str.__get_long_size());
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
#endif
@@ -1878,10 +1880,10 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str)
template <class _CharT, class _Traits, class _Allocator>
inline
basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, const allocator_type& __a)
- : __r_(__second_tag(), __a)
+ : __r_(__default_init_tag(), __a)
{
if (__str.__is_long() && __a != __str.__alloc()) // copy, not move
- __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size());
+ __init(_VSTD::__to_address(__str.__get_long_pointer()), __str.__get_long_size());
else
{
__r_.first().__r = __str.__r_.first().__r;
@@ -1916,13 +1918,14 @@ basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c)
__set_long_cap(__cap+1);
__set_long_size(__n);
}
- traits_type::assign(_VSTD::__to_raw_pointer(__p), __n, __c);
+ traits_type::assign(_VSTD::__to_address(__p), __n, __c);
traits_type::assign(__p[__n], value_type());
}
template <class _CharT, class _Traits, class _Allocator>
inline
basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c)
+ : __r_(__default_init_tag(), __default_init_tag())
{
__init(__n, __c);
#if _LIBCPP_DEBUG_LEVEL >= 2
@@ -1933,7 +1936,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __
template <class _CharT, class _Traits, class _Allocator>
template <class>
basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c, const _Allocator& __a)
- : __r_(__second_tag(), __a)
+ : __r_(__default_init_tag(), __a)
{
__init(__n, __c);
#if _LIBCPP_DEBUG_LEVEL >= 2
@@ -1945,7 +1948,7 @@ template <class _CharT, class _Traits, class _Allocator>
basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str,
size_type __pos, size_type __n,
const _Allocator& __a)
- : __r_(__second_tag(), __a)
+ : __r_(__default_init_tag(), __a)
{
size_type __str_sz = __str.size();
if (__pos > __str_sz)
@@ -1960,7 +1963,7 @@ template <class _CharT, class _Traits, class _Allocator>
inline
basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str, size_type __pos,
const _Allocator& __a)
- : __r_(__second_tag(), __a)
+ : __r_(__default_init_tag(), __a)
{
size_type __str_sz = __str.size();
if (__pos > __str_sz)
@@ -1975,7 +1978,7 @@ template <class _CharT, class _Traits, class _Allocator>
template <class _Tp, class>
basic_string<_CharT, _Traits, _Allocator>::basic_string(
const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a)
- : __r_(__second_tag(), __a)
+ : __r_(__default_init_tag(), __a)
{
__self_view __sv0 = __t;
__self_view __sv = __sv0.substr(__pos, __n);
@@ -1988,6 +1991,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(
template <class _CharT, class _Traits, class _Allocator>
template <class _Tp, class>
basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t)
+ : __r_(__default_init_tag(), __default_init_tag())
{
__self_view __sv = __t;
__init(__sv.data(), __sv.size());
@@ -1999,7 +2003,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t)
template <class _CharT, class _Traits, class _Allocator>
template <class _Tp, class>
basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t, const _Allocator& __a)
- : __r_(__second_tag(), __a)
+ : __r_(__default_init_tag(), __a)
{
__self_view __sv = __t;
__init(__sv.data(), __sv.size());
@@ -2012,7 +2016,7 @@ template <class _CharT, class _Traits, class _Allocator>
template <class _InputIterator>
typename enable_if
<
- __is_exactly_input_iterator<_InputIterator>::value,
+ __is_exactly_cpp17_input_iterator<_InputIterator>::value,
void
>::type
basic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _InputIterator __last)
@@ -2039,7 +2043,7 @@ template <class _CharT, class _Traits, class _Allocator>
template <class _ForwardIterator>
typename enable_if
<
- __is_forward_iterator<_ForwardIterator>::value,
+ __is_cpp17_forward_iterator<_ForwardIterator>::value,
void
>::type
basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _ForwardIterator __last)
@@ -2070,6 +2074,7 @@ template <class _CharT, class _Traits, class _Allocator>
template<class _InputIterator, class>
inline
basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last)
+ : __r_(__default_init_tag(), __default_init_tag())
{
__init(__first, __last);
#if _LIBCPP_DEBUG_LEVEL >= 2
@@ -2082,7 +2087,7 @@ template<class _InputIterator, class>
inline
basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last,
const allocator_type& __a)
- : __r_(__second_tag(), __a)
+ : __r_(__default_init_tag(), __a)
{
__init(__first, __last);
#if _LIBCPP_DEBUG_LEVEL >= 2
@@ -2096,6 +2101,7 @@ template <class _CharT, class _Traits, class _Allocator>
inline
basic_string<_CharT, _Traits, _Allocator>::basic_string(
initializer_list<_CharT> __il)
+ : __r_(__default_init_tag(), __default_init_tag())
{
__init(__il.begin(), __il.end());
#if _LIBCPP_DEBUG_LEVEL >= 2
@@ -2108,7 +2114,7 @@ inline
basic_string<_CharT, _Traits, _Allocator>::basic_string(
initializer_list<_CharT> __il, const _Allocator& __a)
- : __r_(__second_tag(), __a)
+ : __r_(__default_init_tag(), __a)
{
__init(__il.begin(), __il.end());
#if _LIBCPP_DEBUG_LEVEL >= 2
@@ -2144,14 +2150,14 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace
pointer __p = __alloc_traits::allocate(__alloc(), __cap+1);
__invalidate_all_iterators();
if (__n_copy != 0)
- traits_type::copy(_VSTD::__to_raw_pointer(__p),
- _VSTD::__to_raw_pointer(__old_p), __n_copy);
+ traits_type::copy(_VSTD::__to_address(__p),
+ _VSTD::__to_address(__old_p), __n_copy);
if (__n_add != 0)
- traits_type::copy(_VSTD::__to_raw_pointer(__p) + __n_copy, __p_new_stuff, __n_add);
+ traits_type::copy(_VSTD::__to_address(__p) + __n_copy, __p_new_stuff, __n_add);
size_type __sec_cp_sz = __old_sz - __n_del - __n_copy;
if (__sec_cp_sz != 0)
- traits_type::copy(_VSTD::__to_raw_pointer(__p) + __n_copy + __n_add,
- _VSTD::__to_raw_pointer(__old_p) + __n_copy + __n_del, __sec_cp_sz);
+ traits_type::copy(_VSTD::__to_address(__p) + __n_copy + __n_add,
+ _VSTD::__to_address(__old_p) + __n_copy + __n_del, __sec_cp_sz);
if (__old_cap+1 != __min_cap)
__alloc_traits::deallocate(__alloc(), __old_p, __old_cap+1);
__set_long_pointer(__p);
@@ -2176,12 +2182,12 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_t
pointer __p = __alloc_traits::allocate(__alloc(), __cap+1);
__invalidate_all_iterators();
if (__n_copy != 0)
- traits_type::copy(_VSTD::__to_raw_pointer(__p),
- _VSTD::__to_raw_pointer(__old_p), __n_copy);
+ traits_type::copy(_VSTD::__to_address(__p),
+ _VSTD::__to_address(__old_p), __n_copy);
size_type __sec_cp_sz = __old_sz - __n_del - __n_copy;
if (__sec_cp_sz != 0)
- traits_type::copy(_VSTD::__to_raw_pointer(__p) + __n_copy + __n_add,
- _VSTD::__to_raw_pointer(__old_p) + __n_copy + __n_del,
+ traits_type::copy(_VSTD::__to_address(__p) + __n_copy + __n_add,
+ _VSTD::__to_address(__old_p) + __n_copy + __n_del,
__sec_cp_sz);
if (__old_cap+1 != __min_cap)
__alloc_traits::deallocate(__alloc(), __old_p, __old_cap+1);
@@ -2199,7 +2205,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_ty
size_type __cap = capacity();
if (__cap >= __n)
{
- value_type* __p = _VSTD::__to_raw_pointer(__get_pointer());
+ value_type* __p = _VSTD::__to_address(__get_pointer());
traits_type::move(__p, __s, __n);
traits_type::assign(__p[__n], value_type());
__set_size(__n);
@@ -2225,7 +2231,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c)
}
else
__invalidate_iterators_past(__n);
- value_type* __p = _VSTD::__to_raw_pointer(__get_pointer());
+ value_type* __p = _VSTD::__to_address(__get_pointer());
traits_type::assign(__p, __n, __c);
traits_type::assign(__p[__n], value_type());
__set_size(__n);
@@ -2289,10 +2295,20 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, tr
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
#endif
{
- __clear_and_shrink();
- __r_.first() = __str.__r_.first();
- __move_assign_alloc(__str);
- __str.__zero();
+ if (__is_long()) {
+ __alloc_traits::deallocate(__alloc(), __get_long_pointer(),
+ __get_long_cap());
+#if _LIBCPP_STD_VER <= 14
+ if (!is_nothrow_move_assignable<allocator_type>::value) {
+ __set_short_size(0);
+ traits_type::assign(__get_short_pointer()[0], value_type());
+ }
+#endif
+ }
+ __move_assign_alloc(__str);
+ __r_.first() = __str.__r_.first();
+ __str.__set_short_size(0);
+ traits_type::assign(__str.__get_short_pointer()[0], value_type());
}
template <class _CharT, class _Traits, class _Allocator>
@@ -2312,7 +2328,7 @@ template <class _CharT, class _Traits, class _Allocator>
template<class _InputIterator>
typename enable_if
<
- __is_exactly_input_iterator <_InputIterator>::value
+ __is_exactly_cpp17_input_iterator <_InputIterator>::value
|| !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value,
basic_string<_CharT, _Traits, _Allocator>&
>::type
@@ -2327,7 +2343,7 @@ template <class _CharT, class _Traits, class _Allocator>
template<class _ForwardIterator>
typename enable_if
<
- __is_forward_iterator<_ForwardIterator>::value
+ __is_cpp17_forward_iterator<_ForwardIterator>::value
&& __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value,
basic_string<_CharT, _Traits, _Allocator>&
>::type
@@ -2398,7 +2414,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_ty
{
if (__n)
{
- value_type* __p = _VSTD::__to_raw_pointer(__get_pointer());
+ value_type* __p = _VSTD::__to_address(__get_pointer());
traits_type::copy(__p + __sz, __s, __n);
__sz += __n;
__set_size(__sz);
@@ -2421,7 +2437,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c)
if (__cap - __sz < __n)
__grow_by(__cap, __sz + __n - __cap, __sz, __sz, 0);
pointer __p = __get_pointer();
- traits_type::assign(_VSTD::__to_raw_pointer(__p) + __sz, __n, __c);
+ traits_type::assign(_VSTD::__to_address(__p) + __sz, __n, __c);
__sz += __n;
__set_size(__sz);
traits_type::assign(__p[__sz], value_type());
@@ -2501,7 +2517,7 @@ basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::__append_forward_unsafe(
_ForwardIterator __first, _ForwardIterator __last)
{
- static_assert(__is_forward_iterator<_ForwardIterator>::value,
+ static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
"function requires a ForwardIterator");
size_type __sz = size();
size_type __cap = capacity();
@@ -2586,7 +2602,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_t
{
if (__n)
{
- value_type* __p = _VSTD::__to_raw_pointer(__get_pointer());
+ value_type* __p = _VSTD::__to_address(__get_pointer());
size_type __n_move = __sz - __pos;
if (__n_move != 0)
{
@@ -2618,7 +2634,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n
value_type* __p;
if (__cap - __sz >= __n)
{
- __p = _VSTD::__to_raw_pointer(__get_pointer());
+ __p = _VSTD::__to_address(__get_pointer());
size_type __n_move = __sz - __pos;
if (__n_move != 0)
traits_type::move(__p + __pos + __n, __p + __pos, __n_move);
@@ -2626,7 +2642,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n
else
{
__grow_by(__cap, __sz + __n - __cap, __sz, __pos, 0, __n);
- __p = _VSTD::__to_raw_pointer(__get_long_pointer());
+ __p = _VSTD::__to_address(__get_long_pointer());
}
traits_type::assign(__p + __pos, __n, __c);
__sz += __n;
@@ -2640,7 +2656,7 @@ template <class _CharT, class _Traits, class _Allocator>
template<class _InputIterator>
typename enable_if
<
- __is_exactly_input_iterator<_InputIterator>::value
+ __is_exactly_cpp17_input_iterator<_InputIterator>::value
|| !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value,
typename basic_string<_CharT, _Traits, _Allocator>::iterator
>::type
@@ -2659,7 +2675,7 @@ template <class _CharT, class _Traits, class _Allocator>
template<class _ForwardIterator>
typename enable_if
<
- __is_forward_iterator<_ForwardIterator>::value
+ __is_cpp17_forward_iterator<_ForwardIterator>::value
&& __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value,
typename basic_string<_CharT, _Traits, _Allocator>::iterator
>::type
@@ -2687,7 +2703,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _Forward
value_type* __p;
if (__cap - __sz >= __n)
{
- __p = _VSTD::__to_raw_pointer(__get_pointer());
+ __p = _VSTD::__to_address(__get_pointer());
size_type __n_move = __sz - __ip;
if (__n_move != 0)
traits_type::move(__p + __ip + __n, __p + __ip, __n_move);
@@ -2695,7 +2711,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _Forward
else
{
__grow_by(__cap, __sz + __n - __cap, __sz, __ip, 0, __n);
- __p = _VSTD::__to_raw_pointer(__get_long_pointer());
+ __p = _VSTD::__to_address(__get_long_pointer());
}
__sz += __n;
__set_size(__sz);
@@ -2761,11 +2777,11 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_ty
if (__cap == __sz)
{
__grow_by(__cap, 1, __sz, __ip, 0, 1);
- __p = _VSTD::__to_raw_pointer(__get_long_pointer());
+ __p = _VSTD::__to_address(__get_long_pointer());
}
else
{
- __p = _VSTD::__to_raw_pointer(__get_pointer());
+ __p = _VSTD::__to_address(__get_pointer());
size_type __n_move = __sz - __ip;
if (__n_move != 0)
traits_type::move(__p + __ip + 1, __p + __ip, __n_move);
@@ -2806,7 +2822,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __
size_type __cap = capacity();
if (__cap - __sz + __n1 >= __n2)
{
- value_type* __p = _VSTD::__to_raw_pointer(__get_pointer());
+ value_type* __p = _VSTD::__to_address(__get_pointer());
if (__n1 != __n2)
{
size_type __n_move = __sz - __pos - __n1;
@@ -2861,7 +2877,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __
value_type* __p;
if (__cap - __sz + __n1 >= __n2)
{
- __p = _VSTD::__to_raw_pointer(__get_pointer());
+ __p = _VSTD::__to_address(__get_pointer());
if (__n1 != __n2)
{
size_type __n_move = __sz - __pos - __n1;
@@ -2872,7 +2888,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __
else
{
__grow_by(__cap, __sz - __n1 + __n2 - __cap, __sz, __pos, __n1, __n2);
- __p = _VSTD::__to_raw_pointer(__get_long_pointer());
+ __p = _VSTD::__to_address(__get_long_pointer());
}
traits_type::assign(__p + __pos, __n2, __c);
__sz += __n2 - __n1;
@@ -2886,7 +2902,7 @@ template <class _CharT, class _Traits, class _Allocator>
template<class _InputIterator>
typename enable_if
<
- __is_input_iterator<_InputIterator>::value,
+ __is_cpp17_input_iterator<_InputIterator>::value,
basic_string<_CharT, _Traits, _Allocator>&
>::type
basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2,
@@ -2984,7 +3000,7 @@ basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos, size_type __n)
this->__throw_out_of_range();
if (__n)
{
- value_type* __p = _VSTD::__to_raw_pointer(__get_pointer());
+ value_type* __p = _VSTD::__to_address(__get_pointer());
__n = _VSTD::min(__n, __sz - __pos);
size_type __n_move = __sz - __pos - __n;
if (__n_move != 0)
@@ -3172,8 +3188,8 @@ basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __res_arg)
__was_long = __is_long();
__p = __get_pointer();
}
- traits_type::copy(_VSTD::__to_raw_pointer(__new_data),
- _VSTD::__to_raw_pointer(__p), size()+1);
+ 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)
@@ -4284,23 +4300,23 @@ template<class _CharT, class _Traits, class _Allocator>
bool
basic_string<_CharT, _Traits, _Allocator>::__dereferenceable(const const_iterator* __i) const
{
- return this->data() <= _VSTD::__to_raw_pointer(__i->base()) &&
- _VSTD::__to_raw_pointer(__i->base()) < this->data() + this->size();
+ return this->data() <= _VSTD::__to_address(__i->base()) &&
+ _VSTD::__to_address(__i->base()) < this->data() + this->size();
}
template<class _CharT, class _Traits, class _Allocator>
bool
basic_string<_CharT, _Traits, _Allocator>::__decrementable(const const_iterator* __i) const
{
- return this->data() < _VSTD::__to_raw_pointer(__i->base()) &&
- _VSTD::__to_raw_pointer(__i->base()) <= this->data() + this->size();
+ return this->data() < _VSTD::__to_address(__i->base()) &&
+ _VSTD::__to_address(__i->base()) <= this->data() + this->size();
}
template<class _CharT, class _Traits, class _Allocator>
bool
basic_string<_CharT, _Traits, _Allocator>::__addable(const const_iterator* __i, ptrdiff_t __n) const
{
- const value_type* __p = _VSTD::__to_raw_pointer(__i->base()) + __n;
+ const value_type* __p = _VSTD::__to_address(__i->base()) + __n;
return this->data() <= __p && __p <= this->data() + this->size();
}
@@ -4308,7 +4324,7 @@ template<class _CharT, class _Traits, class _Allocator>
bool
basic_string<_CharT, _Traits, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __n) const
{
- const value_type* __p = _VSTD::__to_raw_pointer(__i->base()) + __n;
+ const value_type* __p = _VSTD::__to_address(__i->base()) + __n;
return this->data() <= __p && __p < this->data() + this->size();
}
diff --git a/libcxx/include/thread b/libcxx/include/thread
index 02da703c3ccf..3b55342288d1 100644
--- a/libcxx/include/thread
+++ b/libcxx/include/thread
@@ -274,6 +274,7 @@ __thread_execute(tuple<_TSp, _Fp, _Args...>& __t, __tuple_indices<_Indices...>)
}
template <class _Fp>
+_LIBCPP_INLINE_VISIBILITY
void* __thread_proxy(void* __vp)
{
// _Fp = std::tuple< unique_ptr<__thread_struct>, Functor, Args...>
diff --git a/libcxx/include/tuple b/libcxx/include/tuple
index e93824f0aa7f..1f80b70759c7 100644
--- a/libcxx/include/tuple
+++ b/libcxx/include/tuple
@@ -1349,8 +1349,9 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J
typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
operator()(tuple<_Types...> __t, _Tuple0&& __t0)
{
- return forward_as_tuple(_VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
- _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
+ return _VSTD::forward_as_tuple(
+ _VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
+ _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
}
template <class _Tuple0, class _Tuple1, class ..._Tuples>
@@ -1361,15 +1362,16 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J
typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tuple0>::type _T0;
typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tuple1>::type _T1;
return __tuple_cat<
- tuple<_Types..., typename __apply_cv<_Tuple0, typename tuple_element<_J0, _T0>::type>::type&&...>,
- typename __make_tuple_indices<sizeof ...(_Types) + tuple_size<_T0>::value>::type,
- typename __make_tuple_indices<tuple_size<_T1>::value>::type>()
- (forward_as_tuple(
- _VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
- _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...
- ),
- _VSTD::forward<_Tuple1>(__t1),
- _VSTD::forward<_Tuples>(__tpls)...);
+ tuple<_Types...,
+ typename __apply_cv<_Tuple0, typename tuple_element<
+ _J0, _T0>::type>::type&&...>,
+ typename __make_tuple_indices<sizeof...(_Types) +
+ tuple_size<_T0>::value>::type,
+ typename __make_tuple_indices<tuple_size<_T1>::value>::type>()(
+ _VSTD::forward_as_tuple(
+ _VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
+ _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...),
+ _VSTD::forward<_Tuple1>(__t1), _VSTD::forward<_Tuples>(__tpls)...);
}
};
diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits
index 77b57a41e418..c0c3934afccc 100644
--- a/libcxx/include/type_traits
+++ b/libcxx/include/type_traits
@@ -427,7 +427,6 @@ template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS pair;
template <class _Tp> class _LIBCPP_TEMPLATE_VIS reference_wrapper;
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
-
template <class _Tp, _Tp __v>
struct _LIBCPP_TEMPLATE_VIS integral_constant
{
@@ -526,6 +525,7 @@ struct __identity { typedef _Tp type; };
template <class _Tp, bool>
struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {};
+
template <bool _Bp, class _If, class _Then>
struct _LIBCPP_TEMPLATE_VIS conditional {typedef _If type;};
template <class _If, class _Then>
@@ -570,6 +570,17 @@ using _IsNotSame = _BoolConstant<
!_VSTD::is_same<_Tp, _Up>::value
#endif
>;
+
+
+template <class _Tp>
+using __test_for_primary_template = _EnableIf<
+ _IsSame<_Tp, typename _Tp::__primary_template>::value
+ >;
+template <class _Tp>
+using __is_primary_template = _IsValidExpansion<
+ __test_for_primary_template, _Tp
+ >;
+
// addressof
#ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
@@ -720,7 +731,7 @@ template <class _Tp>
_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_null_pointer_v
= is_null_pointer<_Tp>::value;
#endif
-#endif
+#endif // _LIBCPP_STD_VER > 11
// is_integral
@@ -1418,8 +1429,7 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_base_of_v
#if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
- : public integral_constant<bool, __is_convertible_to(_T1, _T2) &&
- !is_abstract<_T2>::value> {};
+ : public integral_constant<bool, __is_convertible_to(_T1, _T2)> {};
#else // __has_feature(is_convertible_to)
diff --git a/libcxx/include/valarray b/libcxx/include/valarray
index 8f6221ab3f39..c048a6d7e498 100644
--- a/libcxx/include/valarray
+++ b/libcxx/include/valarray
@@ -1256,6 +1256,8 @@ public:
_LIBCPP_INLINE_VISIBILITY
operator>>=(const _Expr& __v) const;
+ slice_array(slice_array const&) = default;
+
_LIBCPP_INLINE_VISIBILITY
const slice_array& operator=(const slice_array& __sa) const;
@@ -1505,11 +1507,6 @@ public:
#endif // _LIBCPP_CXX03_LANG
-// gslice(const gslice&) = default;
-// gslice(gslice&&) = default;
-// gslice& operator=(const gslice&) = default;
-// gslice& operator=(gslice&&) = default;
-
_LIBCPP_INLINE_VISIBILITY
size_t start() const {return __1d_.size() ? __1d_[0] : 0;}
@@ -1645,10 +1642,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
void operator=(const value_type& __x) const;
-// gslice_array(const gslice_array&) = default;
-// gslice_array(gslice_array&&) = default;
-// gslice_array& operator=(const gslice_array&) = default;
-// gslice_array& operator=(gslice_array&&) = default;
+ gslice_array(const gslice_array&) = default;
private:
gslice_array(const gslice& __gs, const valarray<value_type>& __v)
@@ -1977,17 +1971,14 @@ public:
_LIBCPP_INLINE_VISIBILITY
operator>>=(const _Expr& __v) const;
+ mask_array(const mask_array&) = default;
+
_LIBCPP_INLINE_VISIBILITY
const mask_array& operator=(const mask_array& __ma) const;
_LIBCPP_INLINE_VISIBILITY
void operator=(const value_type& __x) const;
-// mask_array(const mask_array&) = default;
-// mask_array(mask_array&&) = default;
-// mask_array& operator=(const mask_array&) = default;
-// mask_array& operator=(mask_array&&) = default;
-
private:
_LIBCPP_INLINE_VISIBILITY
mask_array(const valarray<bool>& __vb, const valarray<value_type>& __v)
@@ -2336,17 +2327,14 @@ public:
_LIBCPP_INLINE_VISIBILITY
operator>>=(const _Expr& __v) const;
+ indirect_array(const indirect_array&) = default;
+
_LIBCPP_INLINE_VISIBILITY
const indirect_array& operator=(const indirect_array& __ia) const;
_LIBCPP_INLINE_VISIBILITY
void operator=(const value_type& __x) const;
-// indirect_array(const indirect_array&) = default;
-// indirect_array(indirect_array&&) = default;
-// indirect_array& operator=(const indirect_array&) = default;
-// indirect_array& operator=(indirect_array&&) = default;
-
private:
_LIBCPP_INLINE_VISIBILITY
indirect_array(const valarray<size_t>& __ia, const valarray<value_type>& __v)
diff --git a/libcxx/include/vector b/libcxx/include/vector
index be4894a89e2f..8366bb5d11e8 100644
--- a/libcxx/include/vector
+++ b/libcxx/include/vector
@@ -423,7 +423,7 @@ __vector_base<_Tp, _Allocator>::__destruct_at_end(pointer __new_last) _NOEXCEPT
{
pointer __soon_to_be_end = __end_;
while (__new_last != __soon_to_be_end)
- __alloc_traits::destroy(__alloc(), _VSTD::__to_raw_pointer(--__soon_to_be_end));
+ __alloc_traits::destroy(__alloc(), _VSTD::__to_address(--__soon_to_be_end));
__end_ = __new_last;
}
@@ -433,7 +433,7 @@ __vector_base<_Tp, _Allocator>::__vector_base()
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
: __begin_(nullptr),
__end_(nullptr),
- __end_cap_(nullptr)
+ __end_cap_(nullptr, __default_init_tag())
{
}
@@ -518,29 +518,29 @@ public:
vector(size_type __n, const value_type& __x, const allocator_type& __a);
template <class _InputIterator>
vector(_InputIterator __first,
- typename enable_if<__is_input_iterator <_InputIterator>::value &&
- !__is_forward_iterator<_InputIterator>::value &&
+ typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value &&
+ !__is_cpp17_forward_iterator<_InputIterator>::value &&
is_constructible<
value_type,
typename iterator_traits<_InputIterator>::reference>::value,
_InputIterator>::type __last);
template <class _InputIterator>
vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
- typename enable_if<__is_input_iterator <_InputIterator>::value &&
- !__is_forward_iterator<_InputIterator>::value &&
+ typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value &&
+ !__is_cpp17_forward_iterator<_InputIterator>::value &&
is_constructible<
value_type,
typename iterator_traits<_InputIterator>::reference>::value>::type* = 0);
template <class _ForwardIterator>
vector(_ForwardIterator __first,
- typename enable_if<__is_forward_iterator<_ForwardIterator>::value &&
+ typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
is_constructible<
value_type,
typename iterator_traits<_ForwardIterator>::reference>::value,
_ForwardIterator>::type __last);
template <class _ForwardIterator>
vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
- typename enable_if<__is_forward_iterator<_ForwardIterator>::value &&
+ typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
is_constructible<
value_type,
typename iterator_traits<_ForwardIterator>::reference>::value>::type* = 0);
@@ -589,8 +589,8 @@ public:
template <class _InputIterator>
typename enable_if
<
- __is_input_iterator <_InputIterator>::value &&
- !__is_forward_iterator<_InputIterator>::value &&
+ __is_cpp17_input_iterator <_InputIterator>::value &&
+ !__is_cpp17_forward_iterator<_InputIterator>::value &&
is_constructible<
value_type,
typename iterator_traits<_InputIterator>::reference>::value,
@@ -600,7 +600,7 @@ public:
template <class _ForwardIterator>
typename enable_if
<
- __is_forward_iterator<_ForwardIterator>::value &&
+ __is_cpp17_forward_iterator<_ForwardIterator>::value &&
is_constructible<
value_type,
typename iterator_traits<_ForwardIterator>::reference>::value,
@@ -692,10 +692,10 @@ public:
_LIBCPP_INLINE_VISIBILITY
value_type* data() _NOEXCEPT
- {return _VSTD::__to_raw_pointer(this->__begin_);}
+ {return _VSTD::__to_address(this->__begin_);}
_LIBCPP_INLINE_VISIBILITY
const value_type* data() const _NOEXCEPT
- {return _VSTD::__to_raw_pointer(this->__begin_);}
+ {return _VSTD::__to_address(this->__begin_);}
#ifdef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
@@ -737,8 +737,8 @@ public:
template <class _InputIterator>
typename enable_if
<
- __is_input_iterator <_InputIterator>::value &&
- !__is_forward_iterator<_InputIterator>::value &&
+ __is_cpp17_input_iterator <_InputIterator>::value &&
+ !__is_cpp17_forward_iterator<_InputIterator>::value &&
is_constructible<
value_type,
typename iterator_traits<_InputIterator>::reference>::value,
@@ -748,7 +748,7 @@ public:
template <class _ForwardIterator>
typename enable_if
<
- __is_forward_iterator<_ForwardIterator>::value &&
+ __is_cpp17_forward_iterator<_ForwardIterator>::value &&
is_constructible<
value_type,
typename iterator_traits<_ForwardIterator>::reference>::value,
@@ -808,7 +808,7 @@ private:
template <class _ForwardIterator>
typename enable_if
<
- __is_forward_iterator<_ForwardIterator>::value,
+ __is_cpp17_forward_iterator<_ForwardIterator>::value,
void
>::type
__construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n);
@@ -921,7 +921,7 @@ private:
_LIBCPP_INLINE_VISIBILITY
void __construct_one_at_end(_Args&& ...__args) {
_ConstructTransaction __tx(*this, 1);
- __alloc_traits::construct(this->__alloc(), _VSTD::__to_raw_pointer(__tx.__pos_),
+ __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__tx.__pos_),
_VSTD::forward<_Args>(__args)...);
++__tx.__pos_;
}
@@ -1042,7 +1042,7 @@ vector<_Tp, _Allocator>::__construct_at_end(size_type __n)
{
_ConstructTransaction __tx(*this, __n);
for (; __tx.__pos_ != __tx.__new_end_; ++__tx.__pos_) {
- __alloc_traits::construct(this->__alloc(), _VSTD::__to_raw_pointer(__tx.__pos_));
+ __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__tx.__pos_));
}
}
@@ -1059,7 +1059,7 @@ vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
{
_ConstructTransaction __tx(*this, __n);
for (; __tx.__pos_ != __tx.__new_end_; ++__tx.__pos_) {
- __alloc_traits::construct(this->__alloc(), _VSTD::__to_raw_pointer(__tx.__pos_), __x);
+ __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__tx.__pos_), __x);
}
}
@@ -1067,7 +1067,7 @@ template <class _Tp, class _Allocator>
template <class _ForwardIterator>
typename enable_if
<
- __is_forward_iterator<_ForwardIterator>::value,
+ __is_cpp17_forward_iterator<_ForwardIterator>::value,
void
>::type
vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n)
@@ -1173,8 +1173,8 @@ vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x, const allo
template <class _Tp, class _Allocator>
template <class _InputIterator>
vector<_Tp, _Allocator>::vector(_InputIterator __first,
- typename enable_if<__is_input_iterator <_InputIterator>::value &&
- !__is_forward_iterator<_InputIterator>::value &&
+ typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value &&
+ !__is_cpp17_forward_iterator<_InputIterator>::value &&
is_constructible<
value_type,
typename iterator_traits<_InputIterator>::reference>::value,
@@ -1190,8 +1190,8 @@ vector<_Tp, _Allocator>::vector(_InputIterator __first,
template <class _Tp, class _Allocator>
template <class _InputIterator>
vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
- typename enable_if<__is_input_iterator <_InputIterator>::value &&
- !__is_forward_iterator<_InputIterator>::value &&
+ typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value &&
+ !__is_cpp17_forward_iterator<_InputIterator>::value &&
is_constructible<
value_type,
typename iterator_traits<_InputIterator>::reference>::value>::type*)
@@ -1207,7 +1207,7 @@ vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, c
template <class _Tp, class _Allocator>
template <class _ForwardIterator>
vector<_Tp, _Allocator>::vector(_ForwardIterator __first,
- typename enable_if<__is_forward_iterator<_ForwardIterator>::value &&
+ typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
is_constructible<
value_type,
typename iterator_traits<_ForwardIterator>::reference>::value,
@@ -1227,7 +1227,7 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first,
template <class _Tp, class _Allocator>
template <class _ForwardIterator>
vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
- typename enable_if<__is_forward_iterator<_ForwardIterator>::value &&
+ typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
is_constructible<
value_type,
typename iterator_traits<_ForwardIterator>::reference>::value>::type*)
@@ -1410,8 +1410,8 @@ template <class _Tp, class _Allocator>
template <class _InputIterator>
typename enable_if
<
- __is_input_iterator <_InputIterator>::value &&
- !__is_forward_iterator<_InputIterator>::value &&
+ __is_cpp17_input_iterator <_InputIterator>::value &&
+ !__is_cpp17_forward_iterator<_InputIterator>::value &&
is_constructible<
_Tp,
typename iterator_traits<_InputIterator>::reference>::value,
@@ -1428,7 +1428,7 @@ template <class _Tp, class _Allocator>
template <class _ForwardIterator>
typename enable_if
<
- __is_forward_iterator<_ForwardIterator>::value &&
+ __is_cpp17_forward_iterator<_ForwardIterator>::value &&
is_constructible<
_Tp,
typename iterator_traits<_ForwardIterator>::reference>::value,
@@ -1622,7 +1622,7 @@ vector<_Tp, _Allocator>::__push_back_slow_path(_Up& __x)
allocator_type& __a = this->__alloc();
__split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a);
// __v.push_back(_VSTD::forward<_Up>(__x));
- __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(__v.__end_), _VSTD::forward<_Up>(__x));
+ __alloc_traits::construct(__a, _VSTD::__to_address(__v.__end_), _VSTD::forward<_Up>(__x));
__v.__end_++;
__swap_out_circular_buffer(__v);
}
@@ -1663,7 +1663,7 @@ vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args)
allocator_type& __a = this->__alloc();
__split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a);
// __v.emplace_back(_VSTD::forward<_Args>(__args)...);
- __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(__v.__end_), _VSTD::forward<_Args>(__args)...);
+ __alloc_traits::construct(__a, _VSTD::__to_address(__v.__end_), _VSTD::forward<_Args>(__args)...);
__v.__end_++;
__swap_out_circular_buffer(__v);
}
@@ -1753,7 +1753,7 @@ vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointe
_ConstructTransaction __tx(*this, __from_e - __i);
for (; __i < __from_e; ++__i, ++__tx.__pos_) {
__alloc_traits::construct(this->__alloc(),
- _VSTD::__to_raw_pointer(__tx.__pos_),
+ _VSTD::__to_address(__tx.__pos_),
_VSTD::move(*__i));
}
}
@@ -1911,8 +1911,8 @@ template <class _Tp, class _Allocator>
template <class _InputIterator>
typename enable_if
<
- __is_input_iterator <_InputIterator>::value &&
- !__is_forward_iterator<_InputIterator>::value &&
+ __is_cpp17_input_iterator <_InputIterator>::value &&
+ !__is_cpp17_forward_iterator<_InputIterator>::value &&
is_constructible<
_Tp,
typename iterator_traits<_InputIterator>::reference>::value,
@@ -1965,7 +1965,7 @@ template <class _Tp, class _Allocator>
template <class _ForwardIterator>
typename enable_if
<
- __is_forward_iterator<_ForwardIterator>::value &&
+ __is_cpp17_forward_iterator<_ForwardIterator>::value &&
is_constructible<
_Tp,
typename iterator_traits<_ForwardIterator>::reference>::value,
@@ -2231,18 +2231,18 @@ public:
vector(size_type __n, const value_type& __v, const allocator_type& __a);
template <class _InputIterator>
vector(_InputIterator __first, _InputIterator __last,
- typename enable_if<__is_input_iterator <_InputIterator>::value &&
- !__is_forward_iterator<_InputIterator>::value>::type* = 0);
+ typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value &&
+ !__is_cpp17_forward_iterator<_InputIterator>::value>::type* = 0);
template <class _InputIterator>
vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
- typename enable_if<__is_input_iterator <_InputIterator>::value &&
- !__is_forward_iterator<_InputIterator>::value>::type* = 0);
+ typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value &&
+ !__is_cpp17_forward_iterator<_InputIterator>::value>::type* = 0);
template <class _ForwardIterator>
vector(_ForwardIterator __first, _ForwardIterator __last,
- typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type* = 0);
+ typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type* = 0);
template <class _ForwardIterator>
vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
- typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type* = 0);
+ typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type* = 0);
vector(const vector& __v);
vector(const vector& __v, const allocator_type& __a);
@@ -2273,15 +2273,15 @@ public:
template <class _InputIterator>
typename enable_if
<
- __is_input_iterator<_InputIterator>::value &&
- !__is_forward_iterator<_InputIterator>::value,
+ __is_cpp17_input_iterator<_InputIterator>::value &&
+ !__is_cpp17_forward_iterator<_InputIterator>::value,
void
>::type
assign(_InputIterator __first, _InputIterator __last);
template <class _ForwardIterator>
typename enable_if
<
- __is_forward_iterator<_ForwardIterator>::value,
+ __is_cpp17_forward_iterator<_ForwardIterator>::value,
void
>::type
assign(_ForwardIterator __first, _ForwardIterator __last);
@@ -2389,15 +2389,15 @@ public:
template <class _InputIterator>
typename enable_if
<
- __is_input_iterator <_InputIterator>::value &&
- !__is_forward_iterator<_InputIterator>::value,
+ __is_cpp17_input_iterator <_InputIterator>::value &&
+ !__is_cpp17_forward_iterator<_InputIterator>::value,
iterator
>::type
insert(const_iterator __position, _InputIterator __first, _InputIterator __last);
template <class _ForwardIterator>
typename enable_if
<
- __is_forward_iterator<_ForwardIterator>::value,
+ __is_cpp17_forward_iterator<_ForwardIterator>::value,
iterator
>::type
insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);
@@ -2440,7 +2440,7 @@ private:
template <class _ForwardIterator>
typename enable_if
<
- __is_forward_iterator<_ForwardIterator>::value,
+ __is_cpp17_forward_iterator<_ForwardIterator>::value,
void
>::type
__construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
@@ -2599,7 +2599,7 @@ template <class _Allocator>
template <class _ForwardIterator>
typename enable_if
<
- __is_forward_iterator<_ForwardIterator>::value,
+ __is_cpp17_forward_iterator<_ForwardIterator>::value,
void
>::type
vector<bool, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last)
@@ -2622,7 +2622,7 @@ vector<bool, _Allocator>::vector()
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
: __begin_(nullptr),
__size_(0),
- __cap_alloc_(0)
+ __cap_alloc_(0, __default_init_tag())
{
}
@@ -2644,7 +2644,7 @@ template <class _Allocator>
vector<bool, _Allocator>::vector(size_type __n)
: __begin_(nullptr),
__size_(0),
- __cap_alloc_(0)
+ __cap_alloc_(0, __default_init_tag())
{
if (__n > 0)
{
@@ -2672,7 +2672,7 @@ template <class _Allocator>
vector<bool, _Allocator>::vector(size_type __n, const value_type& __x)
: __begin_(nullptr),
__size_(0),
- __cap_alloc_(0)
+ __cap_alloc_(0, __default_init_tag())
{
if (__n > 0)
{
@@ -2697,11 +2697,11 @@ vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const all
template <class _Allocator>
template <class _InputIterator>
vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
- typename enable_if<__is_input_iterator <_InputIterator>::value &&
- !__is_forward_iterator<_InputIterator>::value>::type*)
+ typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value &&
+ !__is_cpp17_forward_iterator<_InputIterator>::value>::type*)
: __begin_(nullptr),
__size_(0),
- __cap_alloc_(0)
+ __cap_alloc_(0, __default_init_tag())
{
#ifndef _LIBCPP_NO_EXCEPTIONS
try
@@ -2724,8 +2724,8 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
template <class _Allocator>
template <class _InputIterator>
vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
- typename enable_if<__is_input_iterator <_InputIterator>::value &&
- !__is_forward_iterator<_InputIterator>::value>::type*)
+ typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value &&
+ !__is_cpp17_forward_iterator<_InputIterator>::value>::type*)
: __begin_(nullptr),
__size_(0),
__cap_alloc_(0, static_cast<__storage_allocator>(__a))
@@ -2751,10 +2751,10 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
template <class _Allocator>
template <class _ForwardIterator>
vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last,
- typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type*)
+ typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type*)
: __begin_(nullptr),
__size_(0),
- __cap_alloc_(0)
+ __cap_alloc_(0, __default_init_tag())
{
size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
if (__n > 0)
@@ -2767,7 +2767,7 @@ vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __la
template <class _Allocator>
template <class _ForwardIterator>
vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
- typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type*)
+ typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type*)
: __begin_(nullptr),
__size_(0),
__cap_alloc_(0, static_cast<__storage_allocator>(__a))
@@ -2786,7 +2786,7 @@ template <class _Allocator>
vector<bool, _Allocator>::vector(initializer_list<value_type> __il)
: __begin_(nullptr),
__size_(0),
- __cap_alloc_(0)
+ __cap_alloc_(0, __default_init_tag())
{
size_type __n = static_cast<size_type>(__il.size());
if (__n > 0)
@@ -2968,8 +2968,8 @@ template <class _Allocator>
template <class _InputIterator>
typename enable_if
<
- __is_input_iterator<_InputIterator>::value &&
- !__is_forward_iterator<_InputIterator>::value,
+ __is_cpp17_input_iterator<_InputIterator>::value &&
+ !__is_cpp17_forward_iterator<_InputIterator>::value,
void
>::type
vector<bool, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
@@ -2983,7 +2983,7 @@ template <class _Allocator>
template <class _ForwardIterator>
typename enable_if
<
- __is_forward_iterator<_ForwardIterator>::value,
+ __is_cpp17_forward_iterator<_ForwardIterator>::value,
void
>::type
vector<bool, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last)
@@ -3120,8 +3120,8 @@ template <class _Allocator>
template <class _InputIterator>
typename enable_if
<
- __is_input_iterator <_InputIterator>::value &&
- !__is_forward_iterator<_InputIterator>::value,
+ __is_cpp17_input_iterator <_InputIterator>::value &&
+ !__is_cpp17_forward_iterator<_InputIterator>::value,
typename vector<bool, _Allocator>::iterator
>::type
vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last)
@@ -3165,7 +3165,7 @@ template <class _Allocator>
template <class _ForwardIterator>
typename enable_if
<
- __is_forward_iterator<_ForwardIterator>::value,
+ __is_cpp17_forward_iterator<_ForwardIterator>::value,
typename vector<bool, _Allocator>::iterator
>::type
vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last)
diff --git a/libcxx/include/version b/libcxx/include/version
index fe9cfed876b0..2abc71e0f382 100644
--- a/libcxx/include/version
+++ b/libcxx/include/version
@@ -43,6 +43,7 @@ __cpp_lib_constexpr_misc 201811L <array> <functio
__cpp_lib_constexpr_swap_algorithms 201806L <algorithm>
__cpp_lib_destroying_delete 201806L <new>
__cpp_lib_enable_shared_from_this 201603L <memory>
+__cpp_lib_endian 201907L <bit>
__cpp_lib_erase_if 201811L <string> <deque> <forward_list>
<list> <vector> <map>
<set> <unordered_map> <unordered_set>
@@ -223,6 +224,7 @@ __cpp_lib_void_t 201411L <type_traits>
# 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 201811L
// # define __cpp_lib_generic_unordered_lookup 201811L
# define __cpp_lib_interpolate 201902L
diff --git a/libcxx/src/algorithm.cpp b/libcxx/src/algorithm.cpp
index ffdcb5fccde7..40669fb9e756 100644
--- a/libcxx/src/algorithm.cpp
+++ b/libcxx/src/algorithm.cpp
@@ -10,7 +10,7 @@
#include "random"
#ifndef _LIBCPP_HAS_NO_THREADS
#include "mutex"
-#if defined(__unix__) && !defined(__ANDROID__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA)
+#if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
#pragma comment(lib, "pthread")
#endif
#endif
diff --git a/libcxx/src/chrono.cpp b/libcxx/src/chrono.cpp
index c461d19ddb1f..9d448b6a985b 100644
--- a/libcxx/src/chrono.cpp
+++ b/libcxx/src/chrono.cpp
@@ -37,7 +37,7 @@
#endif
#endif
-#if defined(__unix__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA)
+#if defined(__ELF__) && defined(_LIBCPP_LINK_RT_LIB)
#pragma comment(lib, "rt")
#endif
@@ -183,7 +183,7 @@ steady_clock::now() _NOEXCEPT
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms644905(v=vs.85).aspx says:
// If the function fails, the return value is zero. <snip>
-// On systems that run Windows XP or later, the function will always succeed
+// On systems that run Windows XP or later, the function will always succeed
// and will thus never return zero.
static LARGE_INTEGER
diff --git a/libcxx/src/condition_variable.cpp b/libcxx/src/condition_variable.cpp
index bf89d255dd82..d133b010d71f 100644
--- a/libcxx/src/condition_variable.cpp
+++ b/libcxx/src/condition_variable.cpp
@@ -15,7 +15,7 @@
#include "system_error"
#include "__undef_macros"
-#if defined(__unix__) && !defined(__ANDROID__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA)
+#if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
#pragma comment(lib, "pthread")
#endif
diff --git a/libcxx/src/debug.cpp b/libcxx/src/debug.cpp
index 1f5ce1052f87..20055fcf7590 100644
--- a/libcxx/src/debug.cpp
+++ b/libcxx/src/debug.cpp
@@ -15,7 +15,7 @@
#include "__hash_table"
#ifndef _LIBCPP_HAS_NO_THREADS
#include "mutex"
-#if defined(__unix__) && !defined(__ANDROID__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA)
+#if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
#pragma comment(lib, "pthread")
#endif
#endif
diff --git a/libcxx/src/experimental/memory_resource.cpp b/libcxx/src/experimental/memory_resource.cpp
index e98726283173..68c5bc99cc72 100644
--- a/libcxx/src/experimental/memory_resource.cpp
+++ b/libcxx/src/experimental/memory_resource.cpp
@@ -12,7 +12,7 @@
#include "atomic"
#elif !defined(_LIBCPP_HAS_NO_THREADS)
#include "mutex"
-#if defined(__unix__) && !defined(__ANDROID__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA)
+#if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
#pragma comment(lib, "pthread")
#endif
#endif
diff --git a/libcxx/src/filesystem/operations.cpp b/libcxx/src/filesystem/operations.cpp
index 4e6cb1427a11..876399fb4d4e 100644
--- a/libcxx/src/filesystem/operations.cpp
+++ b/libcxx/src/filesystem/operations.cpp
@@ -44,7 +44,7 @@
#include <sys/time.h> // for gettimeofday and timeval
#endif // !defined(CLOCK_REALTIME)
-#if defined(__unix__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA)
+#if defined(__ELF__) && defined(_LIBCPP_LINK_RT_LIB)
#pragma comment(lib, "rt")
#endif
@@ -1592,7 +1592,7 @@ static int CompareRootDir(PathParser *LHS, PathParser *RHS) {
static int CompareRelative(PathParser *LHSPtr, PathParser *RHSPtr) {
auto &LHS = *LHSPtr;
auto &RHS = *RHSPtr;
-
+
int res;
while (LHS && RHS) {
if ((res = (*LHS).compare(*RHS)) != 0)
diff --git a/libcxx/src/locale.cpp b/libcxx/src/locale.cpp
index 5b29ee448685..2757eaa5acda 100644
--- a/libcxx/src/locale.cpp
+++ b/libcxx/src/locale.cpp
@@ -39,7 +39,7 @@
#include "__undef_macros"
// On Linux, wint_t and wchar_t have different signed-ness, and this causes
-// lots of noise in the build log, but no bugs that I know of.
+// lots of noise in the build log, but no bugs that I know of.
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wsign-conversion"
#endif
@@ -770,7 +770,7 @@ const ctype_base::mask ctype_base::xdigit;
const ctype_base::mask ctype_base::blank;
const ctype_base::mask ctype_base::alnum;
const ctype_base::mask ctype_base::graph;
-
+
locale::id ctype<wchar_t>::id;
ctype<wchar_t>::~ctype()
diff --git a/libcxx/src/memory.cpp b/libcxx/src/memory.cpp
index e89d94f27e4c..633c9a6f5658 100644
--- a/libcxx/src/memory.cpp
+++ b/libcxx/src/memory.cpp
@@ -10,7 +10,7 @@
#ifndef _LIBCPP_HAS_NO_THREADS
#include "mutex"
#include "thread"
-#if defined(__unix__) && !defined(__ANDROID__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA)
+#if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
#pragma comment(lib, "pthread")
#endif
#endif
diff --git a/libcxx/src/mutex.cpp b/libcxx/src/mutex.cpp
index 7e979cd89041..27a4fd892778 100644
--- a/libcxx/src/mutex.cpp
+++ b/libcxx/src/mutex.cpp
@@ -13,7 +13,7 @@
#include "__undef_macros"
#ifndef _LIBCPP_HAS_NO_THREADS
-#if defined(__unix__) && !defined(__ANDROID__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA)
+#if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
#pragma comment(lib, "pthread")
#endif
#endif
diff --git a/libcxx/src/mutex_destructor.cpp b/libcxx/src/mutex_destructor.cpp
index 3a6b6b55eeb7..2038d2bbe21a 100644
--- a/libcxx/src/mutex_destructor.cpp
+++ b/libcxx/src/mutex_destructor.cpp
@@ -48,4 +48,3 @@ mutex::~mutex() _NOEXCEPT
#endif // !_LIBCPP_HAS_NO_THREADS
_LIBCPP_END_NAMESPACE_STD
-
diff --git a/libcxx/src/regex.cpp b/libcxx/src/regex.cpp
index a971f646459b..d31e49487432 100644
--- a/libcxx/src/regex.cpp
+++ b/libcxx/src/regex.cpp
@@ -53,6 +53,8 @@ make_error_type_string(regex_constants::error_type ecode)
return "An invalid regex grammar has been requested.";
case regex_constants::__re_err_empty:
return "An empty regex is not allowed in the POSIX grammar.";
+ case regex_constants::__re_err_parse:
+ return "The parser did not consume the entire regular expression.";
default:
break;
}
diff --git a/libcxx/src/shared_mutex.cpp b/libcxx/src/shared_mutex.cpp
index 9e6d5202aafa..5feef9f4889f 100644
--- a/libcxx/src/shared_mutex.cpp
+++ b/libcxx/src/shared_mutex.cpp
@@ -10,7 +10,7 @@
#ifndef _LIBCPP_HAS_NO_THREADS
#include "shared_mutex"
-#if defined(__unix__) && !defined(__ANDROID__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA)
+#if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
#pragma comment(lib, "pthread")
#endif
diff --git a/libcxx/src/thread.cpp b/libcxx/src/thread.cpp
index cee778f6ee85..c0bc1cbbbbc3 100644
--- a/libcxx/src/thread.cpp
+++ b/libcxx/src/thread.cpp
@@ -35,7 +35,7 @@
#include <windows.h>
#endif
-#if defined(__unix__) && !defined(__ANDROID__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA)
+#if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
#pragma comment(lib, "pthread")
#endif
@@ -139,7 +139,7 @@ class _LIBCPP_HIDDEN __hidden_allocator
{
public:
typedef T value_type;
-
+
T* allocate(size_t __n)
{return static_cast<T*>(::operator new(__n * sizeof(T)));}
void deallocate(T* __p, size_t) {::operator delete(static_cast<void*>(__p));}